Posts

Showing posts from July, 2011

gfortran - random number generator in fortran -

gfortran - random number generator in fortran - i testing rng code mentioned in link (fortran 77 code): https://www.cisl.ucar.edu/zine/96/spring/articles/3.random-6.html applies park & miller algorithm. the function phone call of programme is call srand(seed) x=rand() however programme not seem respond seeding srand(), i.e., x-value unaffected initial seeding, , equal ~0.218. suspect has definition of mutual block , info block, value of x equivalent putting seed 123456789, initialization value defined in datablock. any ideas? i compiling gfortran. ok, problem original srand , rand may called. renamed functions srand2 , rand2 , start work expected. for seed = 1 result 7.82636926e-06 , seed = 2 result 1.56527385e-05 . checked in gfortran , in intel's fortran. fortran gfortran prng fortran-common-block

matlab - How to generate random matrix without repetition in rows and cols? -

matlab - How to generate random matrix without repetition in rows and cols? - how generate random matrix without repetition in rows , cols specific range example (3x3): range 1 3 2 1 3 3 2 1 1 3 2 example (4x4): range 1 4 4 1 3 2 1 3 2 4 3 2 4 1 2 4 1 3 this algorithm trick, assuming want contain elements between 1 , n %// elements contained, no 0 allowed = [1 2 3 4]; %// possible permutations , size n = numel(a); %// initialization output = zeros(1,n); ii = 1; while ii <= n; %// random permuation of input vector b = a(randperm(n)); %// concatenate found values temp = [output; b]; %// check if row chosen in iteration exists if ~any( arrayfun(@(x) numel(unique(temp(:,x))) < ii+1, 1:n) ) %// if not, append output = temp; %// increment counter ii = ii+1; end end output = output(2:end,:) %// delete first row zeros it won't fastest implementation. curios see others. computation time in...

regex - Powershell Find String Between Characters and Replace -

regex - Powershell Find String Between Characters and Replace - in powershell script, have hashtable contains personal information. hashtable looks like {first = "james", lastly = "brown", phone = "12345"...} using hashtable, replace strings in template text file. each string matches @key@ format, want replace string value correspond key in hashtable. here sample input , output: input.txt my first name @first@ , lastly name @last@. phone call me @ @phone@ output.txt my first name james , lastly name brown. phone call me @ 12345 could advise me how homecoming "key" string between "@"s can find value string replacement function? other ideas problem welcomed. you pure regex, sake of readability, doing more code regex: class="lang-poweshell prettyprint-override"> $tmpl = 'my first name @first@ , lastly name @last@. phone call me @ @phone@' $h = @{ first = "jame...

java - Hibernate collection update foiled by unique index -

java - Hibernate collection update foiled by unique index - i'm trying move kid object 1 parent another, in database controlled hibernate. i'm getting error on table created , controlled hibernate through @onetomany annotation. knows way around this. i have 2 objects, 1 containing list of other. let's phone call them kennel , dog. i'm doing moving dog 1 kennel kennel : dog dog = dogservice.getdog(dogid); kennel oldkennel = dog.getkennel(); if (oldkennel.getdogs().contains(dog)) { oldkennel.getdogs().remove(dog); } kennel newkennel = kennelservice.getkennel(newkennelid); newkennel.getdogs().add(dog); dog.setkennel(newkennel); there 3 tables involved: -- table mapped kennel object table kennels (kennel_id int) -- table bring together table controlled hibernate table kennels_dogs (kennels_kennel_id int, dogs_dog_id int) -- table mapped dog object table dogs (dog_id int) the specific error i'm g...

node.js - How to get Meteor's MongoDB URL from javascript -

node.js - How to get Meteor's MongoDB URL from javascript - i'm writing meteor smart bundle wrapper npm module called agenda. agenda naturally doesn't know it's working meteor, need manually give mongodb url. can url typing meteor mongo -u , i'd script automatically users of plugin don't have worry changing manually. how can this? mongo url stored in environment variable called mongo_url. in meteor can access env variables process.env object (on server). can process.env.mongo_url property javascript node.js mongodb meteor

routing - How to create AngularJS Route with dashes instead of slashes -

routing - How to create AngularJS Route with dashes instead of slashes - is possible create angular routes dashes instead of slashes, , variable content in url fragment? example: in angular phone tutorial, urls this, e.g: http://angular.github.io/angular-phonecat/step-11/app/#/phones/motorola-xoom this implemented via route provider such as: when('/phones/:phoneid', { templateurl: 'partials/phone-detail.html', controller: 'phonedetailctrl' }) what i'd have urls more like: http://angular.github.io/angular-phonecat/step-11/app/#/phones/{{manufacturer}}--{{devicename}}--{{phoneid}} where {{phoneid}} numerical database key , {{manufacturer}} text vary phone phone. because need numerical key drive database want manufacturer & devicename text (or equivalent) in url seo purposes.... effectively i'd in angular routes can in htaccess files, i'd like: rewriterule ^(.)--by--(.)--(.*)$ phone.php?mfg=$1&devicename=$2...

c# - Block insert loop error !dbobji.cpp@8638: eNotOpenForWrite -

c# - Block insert loop error !dbobji.cpp@8638: eNotOpenForWrite - good day, i'm creating programme few calculations , insert block @ point user clicks on, repeats calc , insert @ other point user clicks on until user cancels (see programme below). the programme correctly @ first point user clicks on. yet sec time through while loop, after user clicks on point, programme causes fatal error , crashes autocad without inserting block, crash error message: “ internal error: !dbobji.cpp@8638: enotopenforwrite”. would please go through , explain me problem is? thank you, using system; using autodesk.autocad.runtime; using autodesk.autocad.applicationservices; using autodesk.autocad.databaseservices; using autodesk.autocad.geometry; using autodesk.autocad.editorinput; using system.collections.generic; using system.linq; [assembly: commandclass(typeof(level_arrow.program))] namespace level_arrow { public class programme { [commandmethod("levelcal...

bayesian - How can I convert OpenBUGS Coda file to mcmc object in R? -

bayesian - How can I convert OpenBUGS Coda file to mcmc object in R? - i used openbugs , produced coda files of mcmc output. calculate , plot gelman rubin , geweke diagnostics, need convert coda.odc file mcmc object in r? there way this? or recommend me other way(s) analysis? thanks ues read.coda in coda package,... like: library(coda) my.coda <- read.coda("chain1.txt", "codaindex.txt") might work .odc files. defiantly works if save coda files .txt openbugs my.coda mcmc type object. r bayesian mcmc winbugs r2winbugs

c++ - Preprocessor macros -

c++ - Preprocessor macros - hello facing next problem. lets assume code looks that #define function1 functionone #define function2 functiontwo #define call_function ( functionname ) \ someobj someobject.... someobject->functionname(); now problem want check function name , depending on want utilize different someobj. phone call of call_function(function1) following code called someobj someobj... someobj->functionone(); but call_function(function2) .... someobj2 someobj... someobj->functionone(); first of want discourage using answer. comments say, shooting wrong solution problem. as purpose learning want provide macro solution: struct someobj1 { void functionone() { std::cout << "someobj1 functionone"; } }; struct someobj2 { void functiontwo() { std::cout << "someobj2 functiontwo"; } }; #define function1 functionone #define function2 functiontwo #define call_function( fun...

JSX script to Photoshop action - Is it possible? -

JSX script to Photoshop action - Is it possible? - i wonder if there exist method convert simple jss script action. i have created action , converted jsx in order clean , edit it. now, want convert atn in order utilize keybord shorcut. thanks in advance ps: did create action (with ctrl+f12 assigned) calls script, i'd have not dependant action. copy jsx file photoshop script folder (photshop_install_folder/presets/scripts). example: c:\program files\adobe\adobe photoshop cs6 (64 bit)\presets\scripts once script there, restart photoshop , see under file > scripts , should able assign keyboard shortcut easily. action photoshop jsx

kendo ui - KendoWindow: setOptions is not working to set actions -

kendo ui - KendoWindow: setOptions is not working to set actions - in jsfiddle have 2 kendowindow objects. first one, dialog1, has custom icon on bar. sec one, dialog2, doesn't have icon though "actions" attribute set setoptions. any ideas why setoptions not working? this javascript: $("#dialog1").kendowindow({ width: 200, height: 200, actions: ["custom", "close"] }); $("#dialog1").closest(".k-window").css({ top: 20, left: 20 }); $("#dialog2").kendowindow(); var dialog2 = $("#dialog2").data("kendowindow"); dialog2.setoptions({ width: 200, height: 200, actions: ["custom", "close"] }); $("#dialog2").closest(".k-window").css({ top: 20, left: 300 }); the kendo team fixed bug oct 14, 2014. here issue on github , commit fixes it. you can wait next release, or if using free/openso...

iphone - cloudkit data does not show up in submited app iOS 8.1 -

iphone - cloudkit data does not show up in submited app iOS 8.1 - here's deal. app using defualt public cloudkit container provide images. app works on iphone , different simulators on ios 8.0. submited app , it's on app store cloudkit functionality not work on app downloaded app store. is there should have done within code or setting? here xcode setting. ok found wrong. set here other people. need deploy development environment production environment in cloudkit dashboard. the development , production environments cloudkit provides separate development , production environments record types , data. development environment more flexible environment available members of development team. when app adds new field record , saves record in development environment, server updates schema info automatically. can utilize feature create changes schema during development, saves time. 1 caveat after add together field record, info type associated field ca...

c# - Why doesn't it throw OverFlow Exception? -

c# - Why doesn't it throw OverFlow Exception? - this question has reply here: no overflow exception int in c#? 6 answers why checked calculation not throw overflowexception? 3 answers sample 1 int = int32.minvalue; int b = -a; console.writeline("a={0}",a); console.writeline("b={0}", b); result a=-2147483648 b=-2147483648 sample 2 int = int32.minvalue; int b = a-1; console.writeline("a={0}",a); console.writeline("b={0}", b); result a=-2147483648 b=2147483647 in 2 samples: why doesn't throw overflow exception. when tried these samples in java environment, got same results. there can explain situation? c# .net

java - Retrive different thumb dimension from BoxClient [Box.com JavaSDK] -

java - Retrive different thumb dimension from BoxClient [Box.com JavaSDK] - this code retrive correctly 32x32 thumbnail of file: boxclient boxclient = getboxclient(); boxthumbnail thumb = boxclient.getfilesmanager().getthumbnail(assetid, "png", null); but if want 128x128 or 256x256 thumb? cannot found param or method retrive thumb. is there magic tricks can in order want? instead of passing null @ end, create boximagerequestobject boxclient boxclient = getboxclient(); boximagerequestobject requestobject = new boximagerequestobject(); requestobject.setminwidth(255); boxthumbnail thumb = boxclient.getfilesmanager().getthumbnail(assetid, "png", null); java thumbnails box-api boxapiv2

php - Saved browser links prepend a period -

php - Saved browser links prepend a period - i maintain old web app built procedural php. (read spaghetti) in order trigger mobile style sheets etc, pre-prended url 'm'. all of sudden, saved bookmarks , home screen icon links not working properly. inspection of url appears proper. but... instead of loading http://m.mysite.com it loads .m.mysite.com and fails. like said, editing , inspecting url looks proper, no matter try, "http://" gets replaced period. i tried inserting little function in first loaded file check first character. if it's period, replace 'http://', doesn't nail page. clicking mobile url shortcut in desktop browser works fine. i have iphone6 test with, i'm beingness told android devices doing same thing. enviroment: intovps apache/2.2.16 (debian) php version 5.3.3-7 does have thought why of sudden change? haven't touched code in years , affecting mobile users. if create new link in note or...

php - Rewrite url instead of redirect? -

php - Rewrite url instead of redirect? - i have next rules in .htaccess file supposed rewrite url's not containing index.php in them rewriteengine on rewritecond %{request_uri} !index.php rewriterule (.*)$ index.php?q=$1 so, wanted open in browser http://example.com/website.com, , have returned response under url, instead of redirected http://example.com/index.php?q=website.com. there way prepare ? php apache .htaccess mod-rewrite redirect

html - better way to make css button link -

html - better way to make css button link - i've tryed making smooth button link tag in html , css, can create when people hover button not show link in bottom of browser? , when click want alternative command if open link in new tab. , maybe can improve button? here's code: class="snippet-code-html lang-html prettyprint-override"> <!doctype html> <html> <head> <title>professional website</title> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=ubuntu" type="text/css"> <style type="text/css"> .button { background-color: #3366ff; padding: 10px 30px; border-radius: 5px; color: lightblue; font-family: 'ubuntu', arial; font-size: 14px; text-decoration: none; } .button:hover { background-color: #0066ff; -webkit-box-shadow: inset 0px 0px ...

testing - C++ Is there a guarantee of constancy of untouched float values? -

testing - C++ Is there a guarantee of constancy of untouched float values? - i know if can assume value of float not alter if pass around functions, without farther calculations. write tests kind of functions using hardcoded values. example : float identity(float f) { homecoming f; } can write next test : test() { expect(identity(1.8f) == 1.8f); } in general c++ standard doesn't create guarantees if it's known guarantee lead sub-optimal code processor architecture. the legacy x86 floating point processing uses 80-bit registers calculations. mere deed of moving value 1 of registers 64 bits of memory causes rounding occur. c++ testing

r - Split a character vector based on number of words in each element -

r - Split a character vector based on number of words in each element - i have character vector different number of words each of elements, e.g myvector <- c("a quick", "brown", "fox jumped over", "a", "deer") i want split vector 2 vectors, 1 single-word elements , 1 multi-word elements. how can accomplish it? tried following, split.it <- function(x){ mult.vec <- character() if (length(unlist(strsplit(x,split=" ")))>1) { return(append(mult.vec, x)) } } and calling, kj <- sapply(myvector , fun=split.it) but did not give desired result. can help? maybe not elegant here simple way: vect_multi<-myvector[grepl(" ",myvector)] vect_single<-myvector[!grepl(" ",myvector)] r vector split

c++ - How to find euclidean distance between keypoints of a single image in opencv -

c++ - How to find euclidean distance between keypoints of a single image in opencv - i want distance vector d each key point in image. distance vector should consist of distances keypoint other keypoints in image. note: keypoints found using sift. im pretty new opencv. there library function in c++ can create task easy? if aren't interested int position-distance descriptor-distance can utilize this: cv::mat selfdescriptordistances(cv::mat descr) { cv::mat selfdistances = cv::mat::zeros(descr.rows,descr.rows, cv_64fc1); for(int keyptnr = 0; keyptnr < descr.rows; ++keyptnr) { for(int keyptnr2 = 0; keyptnr2 < descr.rows; ++keyptnr2) { double euclideandistance = 0; for(int descrdim = 0; descrdim < descr.cols; ++descrdim) { double tmp = descr.at<float>(keyptnr,descrdim) - descr.at<float>(keyptnr2, descrdim); euclideandistance += tmp*tmp; } ...

datastax enterprise - DSE Hadoop intermittent timeout errors during read -

datastax enterprise - DSE Hadoop intermittent timeout errors during read - i having weird error has started happening few weeks ago. had replace several analytics nodes , none of hadoop jobs invoked hive able finish. crash on different stages similar error: com.datastax.driver.core.exceptions.nohostavailableexception: host(s) tried query failed (tried: ip-x-x-x-x.ec2.internal/x.x.x.x:9042 (com.datastax.driver.core.exceptions.driverexception: timeout during read)) @ com.datastax.driver.core.exceptions.nohostavailableexception.copy(nohostavailableexception.java:65) @ com.datastax.driver.core.defaultresultsetfuture.extractcausefromexecutionexception(defaultresultsetfuture.java:256) @ com.datastax.driver.core.arraybackedresultset$multipage.preparenextrow(arraybackedresultset.java:259) @ com.datastax.driver.core.arraybackedresultset$multipage.isexhausted(arraybackedresultset.java:222) @ com.datastax.driver.core.arraybackedresultset$1.hasnext(arraybackedresultset....

python - Title of icecast stream (without status.xsl) -

python - Title of icecast stream (without status.xsl) - i seek have title (artist - song) icecast streams. there lot of give-and-take here , of them check status.xsl (like icecast playing php script does). : - lot of stream not allow script read file (for example http://95.81.147.3/status.xsl?mount=/fip/all/fiphautdebit.mp3 ) - epirat says lot, not safe parse html this. proposes solution when have access server. from read : there metadata in icecast stream itself solution give works shoutcast. for link. closest thing found this code review although title says icecast see shoutcast code icy-metadata check. this very finish link can useful (the out-of-band standards section) explained not work still. the question : in order artist - song information, how read metadata of icecast stream, when : - i'm not admin of server - don't want / can't parse status.xsl ? thanks help since icecast 2.4 preferred way ma...

android - How to use id of elements of activity using intent communication -

android - How to use id of elements of activity using intent communication - in android suppose intent activity2 activity1..so how can utilize or ids of elements of activity2(such relative layout etc) in activity1..and code in activity 1 using element of activity 2 if trying alter ui of activity1 based on activity 2 should start child activity , utilize onactivityresult . if trying access values of activity1 in activity 2 can pass them via bundle. android

python - rbind of list of selected point txt files -

python - rbind of list of selected point txt files - i have lot of point files in folder. rbind (vertically 1 after in single txt file) per list of selected point file point files nowadays in folder. rbind of list of selected point txt files several point files in folder list of selected point file in csv file the output single csv file consist of xyz of selected point files. you can simple loop in r. setwd("d:/test") ( p <- list.files(getwd(), pattern="pts$") ) ptdf <- read.table(p[1], header=false) names(ptdf) <- c("x","y","z") for(i in 2:length(p)) { d <- read.table(p[i], header=false) names(d) <- c("x","y","z") ptdf <- rbind(ptdf, d) } write.csv(ptdf, "filename.csv", row.names=false, quote=false) the "p" vector defining files iterate through. can su...

javascript - onnouseover not working in chrome, was working until update -

javascript - onnouseover not working in chrome, was working until update - i have next function beingness called via onmouseover on function showtooltip(tip, el, evt) { if (document.layers) { if (!el.tip) { el.tip = new layer(200); el.tip.document.open(); el.tip.document.write(tip); el.tip.document.close(); el.onclick = function (evt) { this.tip.visibility = 'hide'; }; el.onmouseout = function (evt) { this.tip.visibility = 'hide'; }; } el.tip.left = evt.pagex; el.tip.top = evt.pagey; el.tip.visibility = 'show'; } else if (document.all) { if (!el.tip) { document.body.insertadjacenthtml('beforeend', '<div id="tip' + tc + '" class="tooltip">' + tip + '<\/div>'); el.tip = document.all['tip' + tc++]; el.onclick = func...

Why does not CSS appy to the HTML in Visual Studio? -

Why does not CSS appy to the HTML in Visual Studio? - i working on simple asp.net project in visual studio 2013. added html, css , js file(each empty). created links in between the pages, , set them same folder. <head> <title>analog clock</title> <script type="text/javascript" src="script.js"></script> <link type="text/css" rel="stylesheet" href="style.css"> </head> i figured out, didn't mispelt anything, css doesn't apply on html ids. html body: <svg width="140" height="140"> <circle id="clock-face" cx="70" cy="70" r="65" /> <line id="h-hand" x1="70" y1="70" x2="70" y2="38" /> <line id="m-hand" x1="70" y1="70" x2="70" y2="20" /> <line id="s-hand" x1="70" y1="70...

android - how to make auto complete field same as text field? -

android - how to make auto complete field same as text field? - i create autocomplete text field display base of operations line .i saw editfield in phone rectangular box .but in device display simple base of operations line shown in image please tell me how create rectangle same edit text field it should rectangle border black , user come in text in rectangle .. here code.. <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/bg1" > <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android...

sending mail using javamail getting authentication issue -

sending mail using javamail getting authentication issue - when tried send mail service using next code, got authentication issues. here's code: public class newsendmail { string = "********"; string subject = "subject"; string msg ="email text...."; final string ="*******"; final string password ="******"; public newsendmail(){ } public boolean sendmymail(){ properties props = new properties(); props.setproperty("mail.transport.protocol", "smtp"); props.setproperty("mail.host", "smtp.gmail.com"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", "465"); props.put("mail.debug", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.socketfa...

json - Rails, Devise & Omniauth - See what's in env["omniauth.auth"] -

json - Rails, Devise & Omniauth - See what's in env["omniauth.auth"] - i've set rails project using devise , omniauth-facebook. works can access info using user.email =auth.info.email || "" etc. i'm pretty new this, json i'm wondering there quick , easy way see env["omniauth.auth"] returning in callback? i've been @ hours. sorry if haven't provided plenty information. i can utilize puts env["omniauth.auth"] show me what's in hash ruby-on-rails json devise omniauth omniauth-facebook

xml - Android programatically create UI based on dynamic data -

xml - Android programatically create UI based on dynamic data - there many questions here in regarding programmatically creating ui in android, question best approach efficiently display dynamic data. requirement: want display text info sqlite database , display proper formatting. ie, title different color rest of text, different background color/drawable part of text , on..there many rows of info , each row of text might having different number of title,subtitle, body etc.. , size of text stored pretty large. problem: 1. if create ui in xml each text have create separate layout number amount of text stored in database high approach won't work. 2. if store info html in database , display in textview basic formatting can applied. my current approach: store info in sqlite in form of xml proper tags distinguish title,subtitle, body etc.. parse xml info , create views programmatically each tag proper formatting. approach can display number of rows of info d...

sockets - UdpSocket.send_to fails with "invalid argument" -

sockets - UdpSocket.send_to fails with "invalid argument" - i came across problem while experimenting bittorrent tracker protocol using rust. this simple programme supposed send info using udp sockets failing: use std::collections::hashset; utilize std::io::net::addrinfo; utilize std::io::net::ip::{ipv4addr, socketaddr, ipaddr}; utilize std::io::net::udp::udpsocket; fn main() { allow addr = socketaddr { ip: ipv4addr(127, 0, 0, 1), port: 34254 }; allow mut socket = match udpsocket::bind(addr) { ok(s) => s, err(e) => panic!("couldn't bind socket: {}", e), }; allow host_addr = "tracker.openbittorrent.com"; allow port = "80"; allow host_ips: hashset<ipaddr> = addrinfo::get_host_addresses(host_addr.as_slice()).unwrap().into_iter().collect(); host_ip in host_ips.into_iter() { allow socket_addr = socketaddr { ip: host_ip, port: f...

statistics - Multiple boxplots in SAS -

statistics - Multiple boxplots in SAS - i have info set , create boxplots of 9 input variables appear on same plot, despite in different scales. please tell me if there easy way accomplish this? i novice sas user appreciate advice. give thanks you. data raw; input id$ family distrd cotton fiber maize sorg millet bull cattle goats; datalines; farm1 12 80 1.5 1 3 0.25 2 0 1 farm2 54 8 6 4 0 1 6 32 5 farm3 11 13 0.5 1 0 0 0 0 0 farm4 21 13 2 2.5 1 0 1 0 5 farm5 61 30 3 5 0 0 4 21 0 farm6 20 70 0 2 3 0 2 0 3 farm7 29 35 1.5 2 0 0 0 0 0 farm8 29 35 2 3 2 0 0 0 0 farm9 57 9 5 5 0 0 4 5 2 farm10 23 33 2 2 1 0 2 1 7 farm11 13 9 0.5 2 2 0 0 0 0 farm12 15 9 2 2 2 0 0 0 0 farm13 27 3 1.5 0 2 1 0 0 1 farm14 28 5 2 0.5 2 2 2 0 5 farm15 52 5 7 1 7 0 4 11 3 farm16 12 10 2 2.5 3 0 0 0 0 farm17 25 30 1 1 4 0 2 0 5 farm18 5 3 1 0 1 0.5 0 0 3 farm19 45 30 4.5 1 1 0 6 13 20 farm20 6 7 1 1 1 1 2 0 5 farm21 17 8 1.5 0.5 1.5 0.25 0 0 2 farm22 22 6 3 2 3 1 3 0 2 farm23 43 40 7 3 3 0.5 6 2 3 far...

c++ - vector push_back calling copy_constructor more than once? -

c++ - vector push_back calling copy_constructor more than once? - i bit confused way vector push_back behaves, next snippet expected re-create constructor invoked twice, output suggest otherwise. vector internal restructuring results in behaviour. output: inside default within re-create my_int = 0 within re-create my_int = 0 within re-create my_int = 1 class myint { private: int my_int; public: myint() : my_int(0) { cout << "inside default " << endl; } myint(const myint& x) : my_int(x.my_int) { cout << "inside re-create my_int = " << x.my_int << endl; } void set(const int &x) { my_int = x; } } vector<myint> myints; myint x; myints.push_back(x); x.set(1); myints.push_back(x); what happens: x inserted via push_back . 1 re-create occurs: newly created element initialized argument. my_int taken on 0 because x s defau...

c - Unlocking an already unlocked thread -

c - Unlocking an already unlocked thread - in running old code, have found place trying unlock unlocked mutex. i clear unlocking unlocked mutex lead undefined behaviour. but doubts are am able predict behaviour checking compiler documentation? is there chances may lead blocking of thread (deadlock)? undefined behaviour seen on pthread_mutex_unlock unlocking unlocked thread? or undefined behaviour can seen on of next pthread calls ? am able predict behaviour checking compiler documentation? if compiler says behavior be, if utilize compiler (and retains behavior) can rely on behavior. is there chances may lead blocking of thread (deadlock)? yes. ub can lead anything. if, example, unlock function unconditionally decrements lock count, underflow, keeping mutex locked forever. undefined behaviour seen on pthread_mutex_unlock unlocking unlocked thread? or undefined behaviour can seen on of next pthread calls ? you asking how behavior defined. undefi...

Java zero matrix memory usage -

Java zero matrix memory usage - i have been struggling understand next question. is zero-matrix memory efficient? zero-matrix cost less memory (or not cost memory)? i tried verify in java turns out memory has been allocated specified size. i not sure c/c++ or other language matlab , octave , how manage matrix , vector memory; the reason why asking want build sparse matrix huge size, of entries zeros, turns out java not choice, because zero-matrix in java still cost much memory. 1 have experience problem? not sure how deal it, help appreciated. thanks straightforward zero-filled matrix cost in language: amount allocated not depend on numbers fill with. take @ e.g. ujmp provides sparse matrices support, , many algorithms. other implementations exist. in general, if find hard implement useful, google open-source libraries. chances many wheels have been invented already. java

android - appcompat v21 toolbar and actionmode not working -

android - appcompat v21 toolbar and actionmode not working - i have root fragment next toolbar: <android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" app:theme="@style/apptheme.toolbar" style="@style/toolbar" /> i proceeded setting toolbar back upwards actionbar: actionbaractivity activity = (actionbaractivity)getactivity(); activity.setsupportactionbar(); when calling activity.startsupportactionmode(callback) , non of callbacks ever fired , actionmode never started. playing around i've discovered using mtoolbar.startactionmode(callback) work, can't utilize because of compatibility material design styles doesn't seem work when using native actionmode android material-design

angularjs - how to crop-area with different height/width size? with ngImgCrop -

angularjs - how to crop-area with different height/width size? with ngImgCrop - i'm trying crop not same height/width crop-area can utilize rectangle crop-area. <div>select image file: <input type="file" id="fileinput" /></div> <div class="croparea"> <img-crop image="myimage" result-image="mycroppedimage" area-type="square" area-min-size="20" result-image-size="150"></img-crop> </div> <div>cropped image:</div> <div><img ng-src="{{mycroppedimage}}" /></div> i need set height/width area-min-size="{100, 150}" result-image-size="{100, 150}" as far can see - not possible, involves more complex manipulation of selector area (e.g., need resize in 2 dimensions independently). there alternative however. though might not much of eye candy ngimgcrop, achieves need. [ http://grab.b...

hashtable - lookup in a multidimensional hash perl -

hashtable - lookup in a multidimensional hash perl - i have info construction (a multidimensional hash table): $var1 = { 'cat' => { "félin" => '0.500000', 'chat' => '0.600000' }, 'rabbit' => { 'lapin' => '0.600000' }, 'canteen' => { "ménagère" => '0.400000', 'cantine' => '0.600000' } }; my goal read tokenized text, , each word need find translation(s). tokens, read text , create array that: ##store each word translate in table while(my $text_to_translate = <texttotranslate>) { @temp = split(/ /, $text_to_translate); push(@tokens, @temp); } my problem find best way (and fastest) lookup bidimensionnal hash table , print possible translation(s) that:...

javascript - Autocomplete doesn't work for two elements with same id -

javascript - Autocomplete doesn't work for two elements with same id - this question has reply here: using multiple id in jquery 3 answers i have 2 input s "text" type, same id , same name (like copy-paste) , problem when utilize autocomplete first 1 actived autocomplete sec 1 not. need help sec 1 actived utilize same id , same name first one. this code: <script> $(function() { $('#id').autocomplete({ source: "show.php",minlength: 2, select: function( event, ui ) { $('#name').val(ui.item.name); } }); </script> <input type="text" class="code" id="id" name="customfieldname[]" value="" placeholder="รายชื่อยา" /> <input type="text" class="code" id=...

multithreading - return values with thread.start() in python (using queue) -

multithreading - return values with thread.start() in python (using queue) - i'd create multi-threaded version of function. find t.start() returns none , have utilize queue. searched documentation, don't understand how utilize in example. this function: def derivative(lst, var): # illustration of lst = [1 + [3 * x]] if len(lst) == 1: homecoming derive_solver(lst[0], var) if lst[1] == '+': homecoming [derivative(lst[0], var), '+', derivative(lst[2], var)] if lst[1] == '*': homecoming [[derivative(lst[0], var), '*', lst[2]], '+', [lst[0], '*', derivative(lst[2], var)]] and effort multi-thread function: def derivative(lst, var): # illustration of lst = [1 + [3 * x]] if len(lst) == 1: homecoming derive_solver(lst[0], var) if lst[1] == '+': t1 = threading.thread(target = derivative, args=(lst[0], var)) t2 = thre...

data binding - Track model's array properties using knockout ES5 -

data binding - Track model's array properties using knockout ES5 - i have model object in few properties arrays seen below: var object1 = { prop1 = []; prop2 = null; }; ko.track(object1) not track array property prop1. how can array property tracked? doing follows: for (var property in object1) { if (array.isarray(object1[property])) { //track each item in array property trackmodelarrayproperties(object1[property]); } } var trackmodelarrayproperties = function (property) { var arraypropobj = { property: null }; ko.track(arraypropobj ); }; the above not working because array properties show null values after info bind them input controls. arrays data-binding knockout.js knockout-es5-plugin

javascript - Does YouTube iframe API have an event that fires continuously during playback? -

javascript - Does YouTube iframe API have an event that fires continuously during playback? - i'm using youtube iframe api implement video player. i'd able subscribe event fires periodically during playback. example, every 10 seconds, i'd capture , log current playback time of video. the iframe api exposes events onplayerready , onstatechange, don't tell me video while it's playing. i'm not finding answers in google's documentation. ideas? thanks! i answered own question--you can utilize setinterval within onstatechange iframe api event this: function onplayerstatechange( if (event.data === yt.playerstate.playing) { refresh_interval_id = setinterval(function () { var duration = videoplayer.getduration(); var current_time = videoplayer.getcurrenttime(); }, 3000); } else if (event.data === yt.playerstate.paused || event.data === yt.playerstate.ended) { clearinterval(refresh_inte...

c# - Split a line of strings into strings consisting of two characters -

c# - Split a line of strings into strings consisting of two characters - i reading in text file consists of grid of alpha-numeric values (see below). iqqqqq wg2223 s22228 d22223 currently these values looped through , each character sent switch case. switch reads character , outputs given result. code process follows. private void loadlevel(stream stream) { list<string> lines = new list<string>(); uint width; using (streamreader reader = new streamreader(stream)) { string line = reader.readline(); width = (uint)line.length; while (line != null) { lines.add(line); line = reader.readline(); } } tiles = new tile[width, lines.count]; (int y = 0; y < height; ++y) { (int x = 0; x < width; ++x) { char type = lines[y][x]; tiles[x, y] = loadtile(type, x, y); } } } in code retrie...

java - Why does bulk load causes indexing on Couchbase Server? -

java - Why does bulk load causes indexing on Couchbase Server? - i reading mass info couchbase bucket , inserting mass info bucket. using couchbase java sdk 1.4.4 version.using views reading whole data. i using set api insert data. after inserting whole info couchbase, closing couchbase client. data gets inserted couchbase gets inserted, starts indexing info can see couch base of operations web console. per couch base of operations documentation, should start indexing when reading info , based on stale parameter. the other issue facing is, @ java application console, shows lots of warnings until indexing not done. jvm 1 | warn [operationfuture] exception thrown wile executing com.couchbase.client.couchbaseclient$15.operationcomplete() jvm 1 | java.lang.illegalstateexception: shutting downwards jvm 1 | @ net.spy.memcached.memcachedclient.broadcastop(memcachedclient.java:298) ~[spymemcached-2.11.4.jar:2.11.4] jvm 1 | @ net.spy.memcached...

javascript - Not working select option dynamic field in jquery -

javascript - Not working select option dynamic field in jquery - class="snippet-code-js lang-js prettyprint-override"> jquery(function() { var currentcount = 0; jquery('#addmoreemail').click(function() { currentcount = cloning('#moreemaildetails', '#moreemails', currentcount); homecoming false; }); function cloning(from, to, counter) { var clone = $(from).clone(); //console.log(clone); counter++; // replace input attributes: clone.find(':input').each(function() { var name = jquery(this).attr('name').replace(0, counter); var id = jquery(this).attr('id').replace(0, counter); jquery(this).attr({ 'name': name, 'id': id }).val(); }); // replace label attribute: clone.find('label').each(function() { ...

sql - MySQL MAX from count query -

sql - MySQL MAX from count query - i have table rozpis_riesitelov contains columns : id_rozpisu_riesit, id_zam, id_projektu, id_ulohy. i made query : select id_zam, id_ulohy, count(*) counted rozpis_riesitelov grouping id_zam having id_ulohy in (1,2,8) which shows me id of employee ( id_zam ) , how many times in project ( id_ulohy irrevelant had select beacuse of having clause). shows me in db looking employee id of 4 in 6 projects (yes, order want see max). when max of query this: select max(counted) (select id_zam, id_ulohy, count(id_zam) counted rozpis_riesitelov grouping id_zam having id_ulohy in (1,2,8)) riesitel which shows me number 149 instead of 6. so need find employee occurs in of projects. what's wrong sorting count() value, , limiting 1 result? select `id_zam`, `id_ulohy`, count(*) `counted` `rozpis_riesitelov ` `id_ulohy` in ( 1, 2, 8 ) grouping `id_zam` order `counted` desc l...

c# - Getting title of document in cefsharp browser -

c# - Getting title of document in cefsharp browser - i made browser using cefsharp in winforms , need title of page set in window title. haven't seen way title far , have looked on google , have found nothing. can reply how title? with cefsharp.winforms v33.0.0 see https://github.com/cefsharp/cefsharp.minimalexample/blob/master/cefsharp.minimalexample.winforms/browserform.cs#l32 c# cefsharp

java - Get TRACE logs for a session (when root logger level is WARN) -

java - Get TRACE logs for a session (when root logger level is WARN) - i able debug specific requests on server. followed kc baltz's response on conditional logging log4j log requests of involvement own log file. when starting process request: fileappender fileappender = new fileappender(new patternlayout(pattern), logfilename, true); fileappender.setname(sessionid); fileappender.setthreshold(level.trace); // add together filter identify logs belonging current thread fileappender.addfilter(new mycustomfilter(sessionid)); logger.getrootlogger.addappender(fileappender); // utilize log4j mdc identify logs mdc.put("log-key", sessionid); then after request done processing: appender appender = logger.getrootlogger().getappender(sessionid); logger.getrootlogger().removeappender(appender); mdc.remove("log-key"); the corresponding filter: public class mycustomfilter extends filter { private final string id; public mycustomfilter(string...

java - How to control same thread interference in application? -

java - How to control same thread interference in application? - hi friend, facing critical issue current developing. using quartz library schedule tasks in application. , have prepare specific time phone call specific method. time , if method takes more execution time fixed time method beingness called 1 time again processing execute repeatedly. have tried synchronized keyword not working. i using code schedule task - import org.quartz.jobdetail; import org.quartz.scheduler; import org.quartz.schedulerexception; import org.quartz.trigger; import org.quartz.impl.stdschedulerfactory; import static org.quartz.jobbuilder.*; import static org.quartz.simpleschedulebuilder.*; import static org.quartz.triggerbuilder.*; public class brainscheluder { public brainscheluder() { seek { // grab scheduler instance mill scheduler scheduler = stdschedulerfactory.getdefaultscheduler(); // start scheduler here ...

merge - Hg: Merging new files from a branch not appearing in default -

merge - Hg: Merging new files from a branch not appearing in default - i have branch, a, trying merge default. within branch files not in default. set default local , "merge local" a. mere completes, files in not appear in default , i'm not sure why. i've checked ignore list on both branches , these files not appear. how can determine why files in not joining default? merge mercurial tortoisehg

Reorder "li" elements by class name in Jquery -

Reorder "li" elements by class name in Jquery - in next html: <ul class="list"> <li class="item pr1">....</li> <li class="item pr0">....</li> <li class="item pr4">....</li> <li class="item pr3">....</li> </ul> i create function reorders "li" result this: <ul class="list"> <li class="item pr0">....</li> <li class="item pr1">....</li> <li class="item pr2">....</li> <li class="item pr3">....</li> </ul> is possible without having iterate through items ? help class="snippet-code-js lang-js prettyprint-override"> $(function() { var order = $('li.item').sort(function(a,b) { var classa = $(a).attr('class').replace(/^.*(pr\d).*$/, '$1'); var classb = $(b).attr('class').re...

angularjs - Generate a dynamic HTML id using Angular JS -

angularjs - Generate a dynamic HTML id using Angular JS - i have simple table looks follows: <table id="responsegrid"> <tbody> <tr id="response" data-ng-repeat="response in data.responses"> <td id="resp key">{{response.key}}</td> <td id="resp value">{{response.value}}</td> </tr> </tbody> </table> however, if more 1 row created, each table column have same id. want each table column have unique id based on row. instance, want first row have columns ids "resp key 1" , "resp value 1", next row have columns ids "resp key 2" , "resp value 2", , on. is there way in angular js? tried looking sort of way of getting index of response on, doesn't seem work. also, can't figure out way concatenate id (although may more of html issue). help appreciated. you can somthing $index...

Array of boolean values in JavaScript -

Array of boolean values in JavaScript - in javascript, there way in more efficient way? i need create array of boolean values, alter them , check them individually , @ random. the goal improve performance. maybe manipulating bits. right utilize this: var boolean = []; var length = 100; // set random number of values (var = 0; < length; i++) boolean[i] = false; // or true boolean[n] = true; // alter of values randomly if (boolean[n]) { /* */ } // check of values randomly so there 3 parts this: creating array somewhat counter-intuitively, you're doing fine though standard javascript arrays aren't arrays @ all, because way you're creating , filling in array, modern engine utilize true array behind scenes. (see my reply other question more on that, including performance tests.) on engines have true arrays uint8array , you're doing fine. see point #2 below. filling falsey values as there 100 entries, doesn't matter how this, unles...