Posts

Showing posts from March, 2012

php - MySQL join data from same table twice -

i have table info 3 rows: id,monter1,monter2. monter1 , monter2 id's table monterzy (id, name, surname) want join with. problem cant make proper query pick these values in php. have: select i.id , m.name , m.surname info join monterzy m on i.monter1 = m.id; i want expand monter2 , corresponding name , surname. have searched on google, there examples have no idea how it. thanks! you need join same table twice different alias names select info.id, m1.name m1_name, m1.surname m1_surname, m2.name m2_name, m2.surname m2_surname info inner join monterzy m1 on info.monter1 = m1.id inner join monterzy m2 on info.monter2 = m2.id

Android - Include layout from another module -

i have module called testguilib , have specified testview.xml simple framelayout. <framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <textview android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="testing view!" /> </framelayout> i tried use layout in main app activity_main . here code: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match

javascript - React/Redux - Best way to handle different entry points for a single result page? -

i trying deal following situation : => homepage simple form => page results form additional search criterias what did : => 2 differents form components actions & reducers => page result gets information both forms/components the problem have : => have lot of code same. actions , reducers same things both forms (api call etc.) => page results needs fed 2 different sources make code inelegant point of view i quite beginner , think there must elegant way of handling such case seems quite common. maybe solution obvious indulgent... learning :) thanks lot help,

dictionary - Python: Trying to create n dictionaries with randomly selected values from a range -

so i've tried: import random r t = {'va1':r.randint(0,50),'va2':r.randint(0,15),'va3':r.randint(0,10)} n=15 _ in range(n): new_dict = {k:t k in range(n)} print(new_dict) that gave me dictionary of random dictionaries t, weren't unique, dictionary full of 1 version of t. what i'm looking dictionary keys 1,2,3...n , values dictionary t. need t different each iteration of loop. thanks reading python doesn't re-run dictionary literal because reference it. t nothing more single dictionary created @ start. the solution create new dictionary scratch in dictionary comprehension (both key , value expressions executed anew each iteration): n=15 new_dict = {k: {'va1':r.randint(0,50),'va2':r.randint(0,15),'va3':r.randint(0,10)} k in range(n)} print(new_dict) you may want put creating nested dictionary function: def random_values_dict(): return {'va1':r.randint(0,50),'va2':r.randin

python - Django csrf token missing or incorrect error 403 -

when submit form following error: csrf verification failed reason given failure: csrf token missing or incorrect. my views.py is: def name(request): if request.method == 'post': form=nameform(request.post) if form.is_valid(): name=form.cleandata['your_name'] return httpresponseredirect('/thanks/',requestcontext(request)) else: form=nameform() return render_to_response('contact.html') my setting.py file: middleware = [ 'django.middleware.security.securitymiddleware', 'django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.common.commonmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware', 'django.middleware.clickjacking.xframeoptionsmiddleware', ] my forms.py file is: class nam

android - InApp-Browser: Actionbar overlaps WebView content -

Image
my problem actionbar overlaps webview content here: to compare, should instagram logo: https://www.instagram.com/about/us/ this activity_browser.xml of inappbrowser open external webview content: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" android:fitssystemwindows="true" tools:context=".inappbrowser"> <android.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:th

linux - Wildfly 10 Start, Stop Scripts for Standalone -

i unable stop wildfly 10 standalone server in linux env. , using following commands: start: ./standalone.sh (working fine) stop: ./jboss-cli.sh -c --command=:shutdown (unable stop server) note: stop command working fine in windows env executing command: jboss-cli.bat -c --command=:shutdown(timeout=60) how using kill linux command : on cent os works : ps aux | grep wildfly | grep -v grep| awk '{print $2} | xargs kill

java - Tomcat crashes due to native code in JDK for malloc_consolidate -

the tomcat server in production crashes while javathread "finalizer" runs in jvm hs_err_pid below. also, error comes java native code malloc_consolidate inside libc.so. # problematic frame: # c [libc.so.6+0x75f85] malloc_consolidate+0xf5 # --------------- t h r e d --------------- current thread (0x00007f2c6018f000): javathread "finalizer" daemon [_thread_in_native, id=11112, stack(0x00007f2c3f1f2000,0x00007f2c3f2f3000)] stack: [0x00007f2c3f1f2000,0x00007f2c3f2f3000], sp=0x00007f2c3f2f13e0, free space=1020k native frames: (j=compiled java code, j=interpreted, vv=vm code, c=native code) c [libc.so.6+0x75f85] malloc_consolidate+0xf5 java frames: (j=compiled java code, j=interpreted, vv=vm code) j 2177 java.util.zip.inflater.end(j)v (0 bytes) @ 0x00007f2c50e3d301 [0x00007f2c50e3d2c0+0x41] j 3502 c2 java.util.zip.zipfile.close()v (223 bytes) @ 0x00007f2c514371c4 [0x00007f2c51436900+0x8c4] j 7022 c2 java.util.zip.zipfile.finalize()v (5 bytes) @ 0x00

java - Conflicting collector combinations using G1 & IntelliJ 2017.1 on OSX -

i'm trying configure garbage collection intellij community edition 2017.1. using following /users/jilles/library/preferences/ideaic2017.1/idea.vmoptions # custom intellij idea vm options -xx:+useg1gc it refuses start this. above file has 1 option should turn on g1. removed options until found 1 causing issues. after digging, managed @ least tell me why on command line (this stuff never ends in log): ~/library/preferences/ideaic2017.1 $ /applications/intellij\ idea\ ce.app/contents/macos/idea 2017-04-14 13:41:52.697 idea[54761:1579154] allvms required 1.8*,1.8+ 2017-04-14 13:41:52.701 idea[54761:1579163] fullfilename is: /applications/intellij idea ce.app/contents/bin/idea.vmoptions 2017-04-14 13:41:52.701 idea[54761:1579163] fullfilename exists: /applications/intellij idea ce.app/contents/bin/idea.vmoptions 2017-04-14 13:41:52.701 idea[54761:1579163] value of idea_vm_options (null) 2017-04-14 13:41:52.701 idea[54761:1579163] processing vmoptions file @ /users/jilles/lib

Python Iteration Through Lists with Stepped Progression -

given following lists: letters = ('a', 'b', 'c', 'd', 'e', 'f', 'g') numbers = ('1', '2', '3', '4') how can produce iterated list produces following: output = [('a', '1'), ('b', '2'), ('c', '3'), ('d', '4'), ('e', '1'), ('f', '2'), ('g', '3'), ('a', '4'), ('b', '1'), ('c', '2'), ('d', '3'), ('e', '4'), ('f', '1'), ('g', '2')...] i feel should able produce desired output using output = (list(zip(letters, itertools.cycle(numbers)) but produces following: output = [('a', '1'), ('b', '2'), ('c', '3'), ('d', '4'), ('e', '1'), ('f', '2&#

php - Hyperlink not displaying correctly -

i have table column "profile" needs output hyperlink, profile link of customer bought product. updated it's "user_link" in question, here's how now: $new_row->id = $order->get_order_number(); $new_row->order_number = $order->get_order_number(); $new_row->customer = $customer_details; $new_row->products = $products_html; $new_row->total = $total_text; $new_row->status = $shipped; $new_row->user_link = print '<p><a class="author-link" href="'. $order->user_link .'">'. __( 'click here view user profile' ) . '</a><p>'; $new_row->order_date = date_i18n( wc_date_format(), strtotime( $order->order_date ) ) . '<br /><strong>' . ucfirst( $order->get_status() ) . '<

python - tf.image.pad_to_bounding_box VS tf.pad and tf.image.crop_to_bounding_box VS tf.slice -

i'd understand why 2 functions tf.image.crop_to_bounding_box , tf.image.pad_to_bounding_box exists, since behaviour of these 2 functions can done respectively tf.slice , tf.pad . they not easier understand, , scope narrow since accept 3d , 4d tensors. furthermore, tend slower in terms of time of execution. is there miss here ? mostly use them tf.image.* easiness of use. both crop_to_bounding_box , pad_to_bounding_box use slice , pad underneath, add checkings , constraints make sure don't spend hours trying debug slice/pad indices , offsets.

android - How to increment the date selected from the date picker? -

below code. trying achieve here selecting date date picker , setting currettoday. when go next date it's incrementing today's date rather incrementing selected date. don't know going wrong. please me out. getdate(icount); iv_refresh.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { icount = 0; getdate(icount); } }); rightarrow.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { getdate(++icount); } }); leftarraow.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { getdate(--icount); } }); apptitletextview = (textview) findviewbyid(r.id.tool_bar_app_title_textview); toggle = new actionbardrawertoggle( this, drawer, toolbar, r.string.drawer_open, r.string.drawer_close); } private vo

javascript - How to merge multiple documents in one. MongoDB -

i want make new document, cartitems orders have same buyer . , if hasn't pair (like leonard) it's make new doc status "orderid" : "merged" . for example: it's needed situation, when customer make few different orders need give 1 consolidated recipe. collection orders : input { "_id" : "001", "buyer": "sheldon" "cartitems" : [ { "itemname" : "water", "itemprice" : 3 } ], "totalcost" : 3 }, { "_id" : "002", "buyer" : "sheldon", "cartitems" : [ { "itemname" : "milk", "itemprice" : 2 } ], "totalcost" : 2 }, { "_id" : "003", "buyer" : "sheldon", "cartitems" : [ { "

linux - How to use functions in bash? -

this question has answer here: compute base64 encoded hash given hash? 1 answer i have file has hashes of files against filename. example, fb7e0a4408e46fd5573ffb9e73aec021a9dcf426235c0ccfc37d2f5e09a68a23 /path/to/some/file 237e0a4408e46fe3573f239e73aec021a9dcf426235c023fc37d2f5e09a68a12 /path/to/another/file ... , on... i need hash converted base64 encoded format. so used combination of bash function , awk . here wrote, #!/bin/sh base64encode() { $1 | openssl base64 -a } awk ' { t = base64encode $1; print t } ' file.txt but not seem work. i'm using hashdeep generate hash-list file , hashdeep not support base64 encoded output. why i'm using openssl . any or tips regarding great! edit: the given answers work i'm having other issue seems. usually cat filename | openssl dgst -sha256 | openssl base64 -a gives base64 encod

javascript - Wrap div with first anchor in div -

i need wrap .wrapme divs first link inside each of them. have more 1 box , div has anchor if anchor href www.nnn.com go www.nnn.com when clicked div. $(document).ready(function() { $(".wrapme").each(function() { var $a = $('a', this); }); }) .historybox { width: 300px; padding: 10px; background: rgba(0, 0, 0, .8); color: #fff; margin: 10px; } .historybox { color: #fff; } <div class="historyform"> <div class="historybox wrapme"> <a href="http://www.google.com" class="historyname">name,surname,bla bla</a> <span>17 news</span> </div> <div class="historybox wrapme"> <a href="http://www.youtube.com" class="historyname">employe id,employe name,adfhsd</a> <span>22 news</span> </div> </div> <!-- history --> <script

css - Fix (glue) the position of % values on parent resize -

i have div sits @ 15% width of screen. on click, width increases 100%. it's pop-out content area. in order center icons inside of original 15% width parent in nice, responsive manner, set such: .parent position: relative; width: 15%; .icons; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); this creates aside on left icon toggle. icons centered inside of parent . but, when icon clicked resize parent slide out , become width: 100%; . of sudden, nice percentage values change relative parent , move center of screen. want freeze them don't move! in other words, them stay in position in when parent div 15%. fiddle: https://jsfiddle.net/ra6qa9jf/ the easiest solution remove icon div red box , give new parent. style new parent have width of 15% , have position absolute appears layer on red box. new html might be: <div class="parent"></div> //this red box, same styling before <div class="parent-

phalcon - Composer is not installing on Linux Mint 18.1 -

i trying setup local environment 1 of projects based on phalcon php. facing problem , not know how resolve it. when run command php composer.phar install got following errors: loading composer repositories package information updating dependencies (including require-dev) requirements not resolved installable set of packages. problem 1 the requested package jms/serializer 1.3.x-dev exists jms/serializer[0.11.0, 0.12.0, 0.13.0, 0.14.0, 0.15.0, 0.16.0, 1.0.0, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.4.1, 1.4.2, 1.5.0, 1.5.0-rc1, 1.6.0, 1.6.0-rc1, 1.6.1, 2.0.x-dev, dev-first-typehint, dev-master, 1.6.x-dev, dev-std-class-and-cleanup] these rejected constraint. problem 2 installation request authorizenet/authorizenet 1.9.0 -> satisfiable authorizenet/authorizenet[1.9.0]. authorizenet/authorizenet 1.9.0 requires jms/serializer serializer-master-dev 1.0 -> no matching package found. potential causes: - typo in package name - package not availab

linux - Remote ssh through multiple machines -

i trying ssh machine machine b , execute ssh command machine b onto machine c execute command on machine c, in 1 step machine a. not working after machine b. getting stuck there. output shown below: [root@a ~]# ssh -t -t root@192.168.40.152 << eof ssh -t -t root@192.168.40.153 << hk hostname hk eof root@192.168.40.152's password: ssh -t -t root@192.168.40.153 << hk hostname hk last login: fri apr 14 08:53:33 2017 192.168.40.151 [root@b ~]# ssh -t -t root@192.168.40.153 << hk > hostname > hk root@192.168.40.153's password: redhat it stopping @ above point , not executing command 'hostname' on machine c. appreciate help. thanks you can try ssh -j root@192.168.40.152 root@192.168.40.153 "hostname" this proxyjump through 192.168.40.152 , execute hostname command on 192.168.40.153. please note need have @ least openssh version 7.3 in order have -j option.

python - From tuple to 1d array -

i have list [(1,),(2,),(3,),(4,)] how can convert 1d array [1,2,3,4] ? test = [(1,),(2,),(3,),(4,)] single = [] in test: single.append(i[0]) print(single) output [1, 2, 3, 4]

patch - Scala: subtract index of odd values -

for practical exercise need define function changes index of every value in odd index in list, this: changepairs(list(1,2,3,4,5,6,7,8,9,10,11)) //> res62: list[int] = list(2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 11) changepairs(list(2,2,30,4,50,6,7,80,9,100)) //> res63: list[int] = list(2, 2, 4, 30, 6, 50, 80, 7, 100, 9) so need swap places of each odd-even pair, , in case i'm left single odd element @ last index (11 in first example), leave is. i have it's not working, , i'm not sure why. def changepairs(a: list[int]) = a.zipwithindex.map { case (s,i) => if (i % 2 != 0) a.patch(i,seq(s),1); a.patch(i-2,seq(s),0); } here's 1 way: def changepairs(a: list[int]) = a.grouped(2).flatmap { case list(a, b) => list(b, a) case => }.tolist changepairs(list(1, 2, 3, 4, 5, 6, 7)) // list(2, 1, 4, 3, 6, 5, 7) main idea gets going once think of grouping list sublists of 2 elements, grouped(2) does. on it's easy ride - describe 2 cases, 1

loops - Using Variables inside one another Bash -

i running loop calls in variable file: hostnames.txt the variables in file this: export hostname_0=<hostname> export hostname_1=<hostname> export hostname_2=<hostname> i trying use them inside loop this: . hostnames.txt f in {0..10}; ssh $hostname_'{$f}' if [$? !=0]; echo "unable ssh server $hostname_'{$f}'" exit 1 fi however not reading value correctly, , i'm not sure i'm missing. love help. you need build variable name , access ${!var} , e.g.: . hostnames.txt f in {0..10}; hostnamevar=hostname_${f} ssh ${!hostnamevar} if [ $? -ne 0 ]; echo "unable ssh server ${!hostnamevar}" exit 1 fi done

sql server - SSIS script task validation error upon -

i getting following error in ssis script task (ssis 2015) adding data var:error: binary code script not found. please open script in designer clicking edit script button , make sure builds successfully. did online research , made sure following based on search results: delay validation has been set true build has been set x86 we need script run on 32 bit compiler fails when executed deployed package on sqlserver (ssms) integration services catalogs (not job)

rjava - managing tables in R -

i have multiple diagrams in xml format. extracting data xml attributtes using r. there way can separate tables each diagram. example:- have 10 diagrams. each diagram have tables node,edges etc. want create separate node , edges each diagram. access them when required just objects in oops want r tables object(diagram name) variable can access them .

c# - 1D Fast Fourier Transform -

what algorithm following? what understand following source code is: dir direction of fft: forward=1, inverse=-1. x real part y imaginary part what m here? if x = {1, 1, 1, 1, 0, 0, 0, 0}, and, y = {0,0,0,0,0,0,0,0,0}, value of m ? //inplace 1d fft public static void fft1d(int dir, int m, ref double[] x, ref double[] y) { long nn, i, i1, j, k, i2, l, l1, l2; double c1, c2, tx, ty, t1, t2, u1, u2, z; /* calculate number of points */ nn = 1; (i = 0; < m; i++) nn *= 2; /* bit reversal */ i2 = nn >> 1; j = 0; (i = 0; < nn - 1; i++) { if (i < j) { tx = x[i]; ty = y[i]; x[i] = x[j]; y[i] = y[j]; x[j] = tx; y[j] = ty; }

mongodb - How do I update a collection using multiple _id's? -

i trying update collection based on multiple _id 's. i recieve _id 's in array format via session.get() below: var selectedid = session.get('selecteditemidset'); console.log("selectedid array contents are: "+selectedid); the code above ensures selectedid array exists , yields: selectedid array contents are: lzjka8s3wynwhakze,ikrbcdutthrwkecuv the query below: buylist.find({_id:{ "$in": selectedid} }).fetch(); successfully yeilds 2 objects! now area having issues with, how update collection these 2 _id 's i have tried below code: var postedarray = [{postedby: meteor.user()._id }]; buylist.update(_id: selectedid, {$set: {wishlistarray: postedarray} }); ...but error message: uncaught error: mongo selector can't array.(…) any appreciated. use same selector in update have done find + specify multi: true option: buylist.update({ // selector _id: { "$in": selectedid } }, { // modifie

angular - pagination ngx bootstrap for angular2 -

Image
i have probleme pagination first have 21 objects in database when them want show them pagination , things works think pagination module has number of row display default took 10 row per page , not 4 per page export class groupcomponent implements oninit { public maxsize:number = 5; bigtotalitems:number = 175; bigcurrentpage:number = 1; numpages:number = 0; itemsperpage = 4; groups : any; myvar:boolean=false; constructor(private groupeservice:dataserviceservice) { parent.displaygroupeicon(); } ngoninit() { this.getlistgroups(); } getlistgroups(){ this.groupeservice.getgroupsbypageandsize(this.bigcurrentpage-1,this.itemsperpage).subscribe(groups => { this.groups=groups; this.numpages=groups.totalpages; this.bigtotalitems=groups.totalelements; this.myvar = true; }); } and template <table class="table table-striped"> <thead> <tr> <th >identifiant

c# - How to change the app title in a UWP app -

i'm trying change app title dynamically in win 10 uwp app using code below. colors change title won't change. suggestions? public appshell() { this.initializecomponent(); var apptitle = applicationview.getforcurrentview().title; apptitle = house.name; var apptitlebar = applicationview.getforcurrentview().titlebar; apptitlebar.backgroundcolor = colors.lightblue; apptitlebar.buttonbackgroundcolor = colors.lightblue; apptitlebar.buttonforegroundcolor = colors.black; ... } try this: var appview = windows.ui.viewmanagement.applicationview.getforcurrentview(); appview.title = "your title...";

python - Scrapy Pipeline unknown number of results -

i have scrapy spider gets start_urls mysql database. when scrapes each page comes unknown number of links, meaning have 0 links or 10 links each page scrapes. because number unknown don't know how best have pipeline update database possible scraped links instead have dumping start_url , scraped link new database. if using new database, bring on searchterm column value each start_url in new database. if grab searchterm column each start_url, pipe in new database or if have different idea on how update original database unknown quantity of scraped links, work well. here spider.py. have commented out offending lines import scrapy import mysqldb import mysqldb.cursors scrapy.http.request import request youtubephase2.items import youtubephase2item class youtubephase2(scrapy.spider): name = 'youtubephase2' def start_requests(self): conn = mysqldb.connect(user='uname', passwd='password', db='youtubescrape', host='localhost&#

xml - XSLT Select non duplicate node values -

i trying non duplicate node values list. have tried many suggestions nothing quite worked me. source xml <records> <record> <files> <file> <name>a</name> </file> <file> <name>b</name> </file> <file> <name>b</name> </file> </files> </record> <record> <files> <file> <name>a</name> </file> <file> <name>b</name> </file> <file> <name>c</name> </file> <file> <name>c</name> </file> </files> </record> </records> output looking should looks text this a,b | a,b,c first comma separated set first record , second set (after "|") second record. (delimiter placement, spaces etc... not issue, re

php / mysql - Issue when redirecting based on user_level -

i'm building control panel based on user_level. if user has level (0) can't access besides index page, level (1) can access everything. my problem is, current code using... redirects me index page, if set user_level above 0. code: <?php $db_connection = new mysqli(db_host, db_user, db_pass, db_name); require_once("config/db.php"); $page_rows = results_per_page; if (!$db_connection->set_charset("utf8")) { $db_connection->errors[] = $db_connection->error; } if($_session["user_level"] == 0) { header('location: index.php'); } ?> and if try using following code.... <?php $db_connection = new mysqli(db_host, db_user, db_pass, db_name); require_once("config/db.php"); $page_rows = results_per_page; if (!$db_connection->set_charset("utf8")) { $db_connection->errors[] = $db_connection->error; } if($_session["user_level"

Gradle tasks from build.gradle are not getting listed -

the gradle task have added build.gradle not getting listed. this how build.gradle looks task helloworld { dolast { println 'hello world gradle.' } } however when run gradle tasks task helloworld not listed. please help. the gradle version following. $ gradle -v ------------------------------------------------------------ gradle 3.4.1 ------------------------------------------------------------ build time: 2017-03-03 19:45:41 utc revision: 9eb76efdd3d034dc506c719dac2955efb5ff9a93 groovy: 2.4.7 ant: apache ant(tm) version 1.9.6 compiled on june 29 2015 jvm: 1.8.0_31 (oracle corporation 25.31-b07) os: mac os x 10.11.6 x86_64 looks need use --all switch. following works. $ gradle tasks --all

h2o instance shut down due to inactive in console -

i using h2o develp model. after initiated h2o instance got ip , port opening h2o flow in web browser. used below command in hdfs initiate h2o instance. problem when run hyperparameter search, job takes multiple hours , shell session got inactive , automatically log me out. kill console session , h2o instance killed well. using rstudio interface h2o. there way keep h2o instance longer without auto log out/shut down due inactivity in start h20 cluster hadoop jar /dsap/devl/h2o/h2o-3.10.4.1-hdp2.4/h2odriver.jar -nodes 30 -mapperxmx 8g -output /user/userid1/h2o1 -baseport 6335 yes. add -disown flag that.

adobe - Export PDF or Xd file to TABLE HTML format -

i trying make email template out of designs adobe xd, or pdf exported xd, html file uses tables , inline styles - utilities online use div's , classes. is there command line utility or free online utility works email blasts? i've tried mailchimp method , others...

python - Django - Defining a child class inside a TestCase -

i packaging django app reuse (and can used others), , create test case mimics defining child class when app used in different contexts. i found this solution similar in python test case, however, getting following error django test case. runtimeerror: model class tests.test_unit_health.heart doesn't declare explicit app_label , isn't in application in installed_apps. below similar have setup generating error: models.py from django.db import models class healthtest(models.model): # attributes... # methods... def get_score(self, **kwargs): score = self.score(**kwargs) # more logic test_unit_health.py from django.test import testcase health.models import healthtest class healthtestcase(testcase): def setup(self): class heart(healthtest): def score(self, heartrate): if heartrate > 90: return 2 else: return 1 the full error looks thi

c++ - who can help me with this exception in vs2010 and opencv3.0 alpha? -

please help, here cpp code: `#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv.hpp> #include <iostream> #include <opencv2/imgproc/imgproc.hpp> using namespace cv; using namespace std; int main() { int x=5,y=5,z; mat image = imread("c:\\users\\wang\\desktop\\1.jpg",0); vec3d intensity = image.at<uchar>(point(y, x)); z=intensity.val[0]; vector<point>points; mat dst=mat(points); image.convertto(dst,cv_32f); mat grey=mat(points); cvtcolor(dst,grey,color_bgr2gray); imshow("miffy", dst); waitkey(0); return 1; }` the results:................. ..... '23.exe': loaded 'c:\program files (x86)\common files\intel\opencl\bin\x86\tbb\tbb.dll', cannot find or open pdb file '23.exe': loaded 'c:\windows\syswow64\igdrcl32.dll', cannot find or open pdb file '23.exe': unloaded 'c:\

c# - How to support structurally-typed in a nominal-typed language? -

in f#, nominative or structural? , answer said can trick f# work structurally-typed language via exotic mechanisms. how can so? the "exotic mechanism" previous answer refers statically resolved type parameters . lets write functions take object of type has specific member. example, can write sayhello function work object has name member of type string : let inline sayhello (any : ^t) = let name = (^t : (member name : string) any) printfn "hello %s" name this work 2 types nominally unrelated: type person(name:string) = member x.name = name type animal(name:string) = member x.name = name sayhello (person("tomas")) sayhello (animal("bunny")) that said, f# nominally typed language , relying on static member constraints unidiomatic. make code bad , you'll hit limitations of mechanism. nice feature some limited use cases, it's not primary abstraction mechanism in f#.

Unable to build c++ projects in Visual Studio 2015 Community -

i'm trying end-of-degree project in c++ visual studio , i'm stucked several weeks. when try build project, vs returns lots of errors , stops build @ count of 100. i'm trying simple hello world(msdn example) doesn't work. installed/uninstalled/reinstalled/repaired vs , components several times no success. i'm bit desperate this, appreciate kind of help. here captures of errors given , code of program: http://imgur.com/a/hw1vp edit: i'm added output information , inside of cmath, 1 of libraries causes errors: http://imgur.com/a/n8ftm thank helping, alex.

(Java) How can I read in a text file that could use various encodings and output the contents in a text file that looks normal? -

i'm reading in file , replacing text, writing new file, line line. use following code read , write file. there no issues files cp1252 , utf-8 encoded, when try reading in file encoded in "ucs-2 le bom" file saved starts bom characters , contains whole lot of whitespace. know due encoding don't know if need read in differently or save differently. also, know set encoding when read file in, how can handle differntly-encoded files without knowing 1 coming. have no control on file until hits java code. appreciated, thank you. fileinputstream sourcefileinputstream = new fileinputstream(sourcefile); datainputstream sourcedatainputstream = new datainputstream(sourcefileinputstream); bufferedreader sourcebufferedreader = new bufferedreader( new inputstreamreader(sourcedatainputstream)); filewriter targetfilewriter = new filewriter(new file(targetfilelocation)); bufferedwriter targetbufferedwriter = new buffe

Unable to query php string value in mySQL database -

Image
passing query string in php when come number working fine come character showing no id found working fine in mysql server .kindly check following code passing <a class=" btn btn-danger navbar-left" target="_blank" style="width:100%" rel="nofollow, noindex"" href="deals.php?id=<?php echo $row['productid'];?>">view offer</a> getting <?php include 'connection.php'; $id = $_get["id"]; echo "id is".$id; $query=mysql_query("select * sdmobiles productid='$id'") or die ("could not find "); ?> and here page with char http://sabkideal.com/deals.php?id=mobdxvtyvn6wchnz with number id http://sabkideal.com/deals.php?id=645588442716

function - How to make the size of fixed `text()` to mach the size of a moving `text()` in R -

Image
if run small function below, you'll see below picture. smaller-sized " here " fixed around curve. larger-sized "here" moving if run function multiple times ( see r code further below ). my question how can have size of fixed "here" text() become equal size of moving text() only when 2 pieces of text fall on top of each other? please see annotated r code below. here = function(){ curve(dnorm(x), -4, 4) x.on.curve = seq(-4, 4, len = 21) # x.values fixed text y.on.curve = dnorm(x.on.curve) # y.values fixed text xx <- sample(x = seq(-4, 4, len = 21), size = 1) # x.values moving text yy <- dnorm(xx) # y.values moving text text(x.on.curve, y.on.curve, 'here') ## whenever x.values of fixed 'here' # matches x.value of moving 'here' # in below "text()", change cex = 2, else cex = 1

move - C++: valid but unspecified state. What does this mean? -

this question has answer here: what constitutes valid state “moved from” object in c++11? 2 answers does moving leave object in usable state? 2 answers what can moved-from object? 2 answers reusing moved container? 3 answers i have been trying understand std::move. this doc describes nicely. says in example section "..... while bar loses value, , in valid unspecified state .....". lots of other docs use terminology in same context. also, found lots of answers on stackoverflow related it. this same question. not talk "what being unspecified means?" so questions are? what bei

Complementary of #include <list> in C -

i'm trying write paint program in c school project. trying follow this tutorial , it's in c++. know if there complementary of these lines of code: #include <list> std::list<line> lines;

Shopify - Order Products By Custom Field -

we have simple shopify store using free "meta fields editor" add simple custom field integer value each of products. products have meta value of 3, others 2 or 1. many have no meta value @ all. able display products in search results, meta field value entered each product in descending order (weighted ordering). however, despite ability set meta values , display them in search results , collections pages, shopify not make easy order or sort products custom meta field. in search results page able call custom meta value using {{item.metafields.important.important}} far have tried order products using method {% assign products = collection.products | sort: 'item.metafields.important.important' %} {% product in products %} {{ product.title }} {% endfor %} but results in null results. insight can give me in how display products in order of custom field appreciated! after attempting find liquid solution able solve problem using custom metafields ,

html - Put contents of PHP while loop code within a DIV -

so want apply div class these php items. have, know not work, correct trying achieve. i cant add class each individually, want entire contents within 1 div. hope makes sense, thanks! <?php while($campaigns= mysqli_fetch_assoc($result)){ <div class="feeditem">; echo "<div class='field'>".$test['part0']."</div>"; echo "<div class='field'>".$test['part1']."</div>"; echo "<div class='field'>".$test['part2']."</div>"; echo "<div class='field'>".$test['part3']."</div>"; echo "<div class='field'>".$test['part4']."</div>"; echo "<div class='field'>".$test['part5']."</div>"; echo "<div class='field'>".$test['part6'].&q

project reactor - How does a Flux built from merges complete -

if have following flux<string> flux1 = ... flux<string> flux2 = ... flux<string> mergedflux = flux1.merge(flux2); how/when/why mergedflux complete? the principle of least surprise might suggest complete when of merged fluxes have completed. however, not have witnesses. the semantics of merge attempt exhaustively replay interleaved emissions of both flux single flux . consequence, merged flux completes when both sources complete. contrast operator zip aims @ producing many pairs possible taking 1 element each source. such completes when of sources completes, because on cannot produce pairs anymore.

php - Escape # when rendering nested value via twig in Drupal 8 -

in drupal 8, when trying render nested value starts "#", such #default_value, symfony freaking out because of unescaped # drupal names it's array structures with. there way escape "#"? i tried formatting raw , using | e filter without luck. <h1>test</h1> <div>{{ form.field_perf_goal2_main.widget.0 }}</div> <div> {{ form.field_perf_goal2_main.widget.0.#default_value}} </div> {{ kint() }} in above example form.field_perf_goal2_main.widget.0 yields correct result (when kinted). form.field_perf_goal2_main.widget.0.#default_value throws error of unexpected character. far know there isn't escape character feature in twig. thanks! @pig-ball. rendering such solved issue. {{ form.field_perf_goal2_main.widget.0['#default_value'] }}

haskell - How to compare string to value without quotation marks -

i pretty new haskell , today trying make calculator using haskell (like people make when learning new language hold of if statements) , had trouble using if values strings. want check if string user wrote "plus" (without "") if don't quotation marks (so it'd if op == plus ) doesn't recognize string , outputs error if on other hand use quotation marks (so it'd if op == "plus" ) looks string "plus" quotation marks, how can compare string value without quotation marks? case 1: calculate x op y = if op == "plus" x+y else x result: program looks "plus" when calling function , if input when calling function example "1 plus 3" give out error of ':67:13: error: variable not in scope: plus :: [char] case 2: calculate x op y = if op == plus x+y else x result: when trying lo

python - How to return a value from a class on pushbutton? PYQT5 -

i want return values of qlineedit , qcombobox when button clicked, i've tried sorts , can't work, way i've been able work set functions global, know isn't best practice, tips? example of code: self.searchbutton.clicked.connect(self.getdata) then: def getdata(self): x = self.regions.currenttext() y = self.searchbar.text() global x global y

reactjs - MeteorJS: Get user profile on client side -

so, problem has been documented, yet here am, stuck again... on server side, have publish: meteor.publish('userdata', function(){ if (!this.userid) { return null; } return meteor.users.find({}, {fields: {'profile': 1}}); }); on client side router subscriptions, have: this.register('userdata', meteor.subscribe('userdata')); and in client code, have: if (meteor.userid()) { var profile = meteor.users.find(meteor.userid()).profile; console.log(profile); // keep getting undefined... i not using autopublish or insecure package. my data in mongodb collection looks like: {"_id" : "...", profile: { "password" : { "network" : "...", "picture" : "none" } } my error says: uncaught typeerror: cannot read property 'password' of undefined thoughts? the user profile automatically published client, don't need write custom publication send it. that&#

html - Why isn't Google Code Prettify working on css? -

i'm using prettify.js blog posts. it's handling html, python, , js fine, missing css. my html is: <pre> <code class="prettyprint lang-css">` .my-boxclass { display: inline-block; position: relative; cursor: help; border-bottom: 1px dotted grey; } </code> </pre> and i'm importing prettify. here's jsfiddle of i'm doing (and it's not syntax highlighting jsfiddle correctly either) https://jsfiddle.net/kfdqljm1/2/ you need load css language handler. try adding ?lang=css after run_prettify.js .

r - setting color axis limits in ggplot2 -

Image
i trying make heat-map of chlorophyll fluorescence vs depth , time. have things working pretty ok, i'm trying improve colour contrast. generate heatmap following code. ggplot(subset(ctdamotint2, variable == 'fluorescence'), aes(time, depth)) + geom_tile(aes(fill = log10(value))) + scale_y_reverse(limits = c(110, 0)) + scale_x_time(limits = c(min(subset(ctdamot, variable == 'nh4')$time) - 2 * 60^2, max(subset(ctdamot, variable == 'nh4')$time) + 2* 60^2)) + geom_point(data = samplesctd, aes( x = time, y = depth)) + scale_fill_gradient2(low = "blue", mid = "white", high = "green") generally finding dark green colours never utilized , heatmap ends looking washed out , doesn't great job of communicating chlorophyll fluorescence greatist if working in matlab, around setting caxis([-1 0.4]) which set values above 0.4 maximum green value. wouldn't able tell relative difference of high values, you'd @ least abl

html5 - Empty div and clickable url -

i have background 2 urls, 1 showing regular state , hover state. div empty , width , height set 50px. added padding see if help, did not. <div class="container_12 clearfix"> <div class="grid_12"> <p id="footer-center"> <a href="#top" class="top-btn" id="back-to-top"><div class="hover-btn"></div><!--<img src="images/back-to-top-a.png" class="a">--></a> </p> </div> <!-- end grid_4--> </div> <!-- end container_12 --> .hover-btn{ display:block; width:50px; height:50px; margin-left:50%; } .hover-btn{ background:url(../images/back-to-top-a.png) no-repeat center center; } .hover-btn:hover{ background:url(../images/back-to-top-b.png) no-repeat center center, url(../images/back-to-top-a.png) no-repeat center center; simply replacing hover-btn div img tag show first image , second on hover. <img src

ios - UIImagePickerController image in Swift -

i using uiimagepickercontroller in program , changing image of imageview have added. however, whenever restart app , come home screen, automatically resetting default image had before, rather user selected image. how can make records image last used, , reloads every time program starts? var imagepicker = uiimagepickercontroller() func chooseimage(_ sender: any) { //function called button press let imagepickercontroller = uiimagepickercontroller() imagepickercontroller.delegate = self imagepickercontroller.allowsediting = true let actionsheet = uialertcontroller(title: "photo source", message: "choose source", preferredstyle: .actionsheet) actionsheet.addaction(uialertaction(title: "camera", style: .default, handler: { (action:uialertaction) in if uiimagepickercontroller.issourcetypeavailable(.camera) { imagepickercontroller.sourcetype = .camera self.present(imagepickercontroller, animated: tru

typescript - Typesafe Event Handlers for Union Type -

i trying build lightweight event system using union types, can listen events 1 type in union. here have far (unfortunately, not utilize types): class eventsystem { events: { [key: string]: { (event: eventtype) }[] }; constructor() { this.events = {}; } emit(key: string, event: eventtype): void { var arr = this.events[key]; (let = 0; < arr.length; ++i) { arr[i](event); } } on(key: string, callback: (event: eventtype) => void) { if (key in this.events) { this.events[key].push(callback); } else { this.events[key] = [callback]; } } } interface eventa { foo: number } interface eventb { bar: number baz: string } type eventtype = eventa | eventb const eventnames = { eventa: 'eventa', eventb: 'eventb' } let x = {foo: 2} eventa; let y = { bar: 4, baz: "test" } eventb; let es = new eventsystem(); es.o