Posts

Showing posts from February, 2014

haskell - How to make Vect n Int an instance of Monoid -

haskell - How to make Vect n Int an instance of Monoid - in idris, vect n a datatype representing vector of n length containing items of type a. imagine have function: foo : int -> vect 4 int foo n = [n-1, n, n+1, n*4] the body of function not important, returns vector of 4 ints. now, want utilize function concatmap follows: bar : vect n int -> vect (4*n) int bar vals = concatmap foo vals bar function takes int vector of length n , returns ones of length 4*n. the type signature of concatmap is: prelude.foldable.concatmap : foldable t => monoid m => (a -> m) -> t -> m and hence if seek compile bar, error: when elaborating right hand side of bar: can't resolve type class monoid (vect (plus n (plus n (plus n (plus n 0)))) int) this means vect n int isn't instance of monoid. create instance of monoid, need implement: prelude.algebra.neutral : monoid => unfortunately i'm not sure how this. list implements mon...

Emacs delete up to the beginning of next word (like Vim 'dw')? -

Emacs delete up to the beginning of next word (like Vim 'dw')? - so i'm trying delete whitespace @ origin of line , when press m-d end removing more content need to: (add-to-list 'load-path "~/path-to-yasnippet") (require 'yasnippet) (yas-global-mode 1) ^ ^ | |__ want delete here | |___ cursor here i've looked several places haven't been able vim's dw command does. for instance, emacs' commands operating on words don't seem it. there many different solutions this, here one: class="lang-lisp prettyprint-override"> (defun forward-kill-whitespace-or-word () "if `point' followed whitespace kill that. otherwise phone call `kill-word'" (interactive) (if (looking-at "[ \t\n]") (let ((pos (point))) (re-search-forward "[^ \t\n]" nil t) (backward-char) (kill-region pos (point))) (kill-word 1))) ...

c++ - Cocos2d-x setScaleX() -

c++ - Cocos2d-x setScaleX() - so programming game in cocos2d-x , need 1 of sprites wider amount of time, tried method setscalex(). problem content size of sprite not change, , since collision scheme based on content size of sprite, not work. here code utilize scaling: bar = sprite::create( "bar.png" ); cclog("size: %f,%f.", bar->getcontentsize().width, bar->getcontentsize().height); bar->setscalex(1.5); cclog("size: %f,%f.", bar->getcontentsize().width, bar->getcontentsize().height); the output same on both cases. there way of fixing this? contentsize represent original texture size unless set using setcontentsize method. you can either multiply size scale factor or utilize boundingbox().size know current size of scaled sprite(if not rotated or skewed). c++ cocos2d-x

javascript - Making sure that the textbox is only filled with a value from a dropdown. -

javascript - Making sure that the textbox is only filled with a value from a dropdown. - i have textbox populated upon clicking <li> element in dropdown. dropdown populated ng-repeat directive on <li> elements. have model filter <li> elements on text input. i want create sure when textbox loses focus, either filled value dropdown or reset default value. (simply no custom values accepted.) other checking value on text box within loop check match in respective list of items. other approaches have using javascript (preferably angular way), , address issue? (i need ability type on textfield enable filtering of dropdown, , many other reasons think cannot utilize <select> tag.) i suggest still utilize select go angular-ui's ui-select : angular-ui ui-select it's wrapper , angularjs native implementation of select2 javascript html angularjs

jQuery .when multiple ajax requests, order of responses -

jQuery .when multiple ajax requests, order of responses - per post: http://stackoverflow.com/a/17548609/985704 using jquery.when perform multiple simultaneous ajax requests. var requests = array(); requests.push($.get('responsepage.php?data=foo')); requests.push($.get('responsepage.php?data=bar')); var defer = $.when.apply($, requests); defer.done(function(){ // executed after every ajax request has been completed $.each(arguments, function(index, responsedata){ // "responsedata" contain array of response info each specific request }); }); when requests done, can sure arguments (of $.each) in same order requests? documented somewhere? if can't sure, recommend? per jasonp: (thank you) yes. "the arguments passed donecallbacks provide resolved values each of deferreds, , matches order deferreds passed jquery.when()." api.jquery.com/jquery.when – jquery ajax order .when

javascript - Knockout checkbox not updating visually -

javascript - Knockout checkbox not updating visually - i'm having issue checkbox input in knockout code updates viewmodel correctly, not update until div surrounding disappears , re-appears. we're using knockout 3.2.0, currently. here's subset of relevant html: <!-- ko foreach: objects --> <!-- ko if: istype(typecodes.input) --> <!-- ko if: selected --> <div data-bind="fadevisible: $root.isstate(uistate.idle)" id="typeinputcontainer"> <!-- ko foreach: $root.types --> <div class="checkbox patienttype"> <input type="checkbox" data-bind="attr: {id: 'checkpt' + $data.patienttypevalue() }, checked: $data.visible" /> </div> <!-- /ko --> </div> <!-- /ko --> <!-- /ko --> <!-- /ko --> and here's subset of viewmodel: function patienttype(name, value, color) { var self = this; self.typena...

php - get global UTC time without relying on server time -

php - get global UTC time without relying on server time - i wonder if it's possible global utc time without relying on server time (or in case on pc time). as now, if date('h:i:s') i pc time (the alter gmt+3 or gmt+2 set in app itself) if alter pc time 2 hours , 23 minutes back, date() function result 2 hours , 23 minutes back. is possible pull global utc time regardless of own pc watch? @cheery provided nice link in question comments, of it's 2014 outside - makes sense utilize modern tools that: $dt = new datetime('now', new datetimezone('utc')); echo $dt->format('d-m-y h:i:s'); and answering question: is possible pull global utc time regardless of own pc watch? no, php expects local clock + os/php timezone settings correct. references: http://php.net/manual/en/datetime.construct.php http://php.net/manual/en/datetime.format.php php date

c - How sparse and coverity tool for static code analysis are different? -

c - How sparse and coverity tool for static code analysis are different? - i new linux kernel. want know how sparse , coverity tool different ? since both used static code analysis. how decide tool improve ? difference know that: sparse open source coverity should have license utilize it. is there specific set of bugs can traced coverity/sparse ? here piece of code in coverity reports issue, sparse not: foo(){ int x; scanf("%d", &x); switch(x){ case 1: printf("case 1"); case 2: printf("case 2"); break; default: } } in above set example; coverity study warning of missing break statement in case 1. but,sparse not ? however, both tools used static code analysis of software. please, share documentation can highlights plus , negatives of both tools. tools vary in observe , how observe them. general rule, recommend running many tools pos...

How can I check if resume is supported when using python FTP library? -

How can I check if resume is supported when using python FTP library? - i wrote script uploads files ftp servers in python. hacked way resume unfinished uploads, i'm wondering if possible check if resume supported without 'just trying it'? python python-2.7

Java- How to parse and input and store its values into 'int' variables -

Java- How to parse and input and store its values into 'int' variables - sorry if obvious question, new java , not sure how it. tried looking online couldn't understand talking about. want take user input illustration date "2014 02 22 21 14". note spaces separate each variable stored. i want parse , store 2014 int variable called year , store 02 int variable called month , 22 stored day int variable. could please show me illustration of how great. public class helloapp { public static void main(string[] args) { // show dateformat user, can come in format system.out.println("the date format is: yyyy mm dd"); scanner sc = new scanner(system.in); string datestring = sc.nextline(); string[] tokens = datestring.split(" "); int year = integer.parseint(tokens[0]); int month = integer.parseint(tokens[1]); int day = integer.parseint(tokens[2]); system.out....

ios7 - How do we test Dynamic Type (text size) in an iOS Simulator? -

ios7 - How do we test Dynamic Type (text size) in an iOS Simulator? - ios 7 , later allows user specify text size in settings/display & brightness/text size. don't see, or have yet discover, how alter in ios 7/8 sim test app. possible? if so, how/where done? thank you in simulator, go settings (choose "home" on hardware menu). general->accessibility->larger text. should slide switch @ top "larger accessibility sizes". you'll slider adjust text size. hope helps. ios ios7 ios8 apple

ruby - The shortest combination of paths that starts and ends with a single node and covers all points in an undirected graph -

ruby - The shortest combination of paths that starts and ends with a single node and covers all points in an undirected graph - i need algorithm(k, s) where k number of paths s starting , ending node and given n number of nodes in undirected graph in nodes linked each other, returns k paths traverse nodes of sum of distances covered k paths shortest. e.g. given n = 10 , algorithm(2,5) might give me array of 2 arrays such sum of distances covered 2 paths shortest , nodes traversed. [[5,1,2,3,10,5],[5,4,6,7,8,9,5]] djikstra's algorithm finds shortest path 1 node another, not shortest combination of k paths. yen's algorithm finds k number of shortest paths 1 node another, not shortest combination of k paths. what algorithm can help me find shortest combination of k paths starts , end node s such n nodes covered? what describing above, classical traveling sales man problem, many optimization techniques. 1 such ant colony optimization (http...

localdb - c#:Configuration system failed to initialize -

localdb - c#:Configuration system failed to initialize - i'm making c# programme takes input windows form app localdb. looked through tutorials on app.config , actual calls, , looked @ other questions here , haven't found fixed it. if dont utilize try/catch breaks @ line "sqlcommand cmd = conn.createcommand();person newperson = new person(firstnamebox.text, phonebox.text, emailbox.text, lastnamebox.text);" "the configuration element not declared" haven't seen shows wrong? try { system.data.sqlclient.sqlconnection conn = new sqlconnection(system.configuration.configurationmanager.connectionstrings["database"].connectionstring); sqlcommand cmd = conn.createcommand();person newperson = new person(firstnamebox.text, phonebox.text, emailbox.text, lastnamebox.text); cmd.commandtext = @"insert person (firstname,lastname,email,phone) values(@firstname, @lastname, @email, @ph...

symfony2 - What are the different frontends that can be set with OneupUploaderBundle? -

symfony2 - What are the different frontends that can be set with OneupUploaderBundle? - what different frontends can set oneupuploaderbundle in config.yml file? googled , found frontend like: mooupload , blueimp . what total list? # app/config/config.yml oneup_uploader: mappings: gallery: frontend: blueimp # or uploader utilize in frontend is possible utilize vichuploaderbunde frontend in oneupuploaderbundle? vichuploaderbundle not "frontend" bundle. provides way handle uploads , persist them in entities/models. can utilize vichuploaderbundle or oneupuploaderbundle not both. however, should able utilize frontend want (dropzone, fineuploader, mooupload, etc.), require bit of integration work. symfony2 vichuploaderbundle oneupuploaderbundle

Class Expressions in R. Use of elements in it -

Class Expressions in R. Use of elements in it - i using deriv function of bundle ryacas. output expression. utilize part of look function can seek values on it. here example s <- expression(2*y*x + 2*y -1*x^2-2*y^2); a<-deriv(s,c("x","y")); the output is expression({ .expr1 <- 2 * y .expr10 <- 2 * x .value <- .expr1 * x + .expr1 - 1 * x^2 - 2 * y^2 .grad <- array(0, c(length(.value), 2l), list(null, c("x", "y"))) .grad[, "x"] <- .expr1 - .expr10 .grad[, "y"] <- .expr10 + 2 - 2 * .expr1 attr(.value, "gradient") <- .grad .value i utilize .grad[, "x"]. way treating look list a[[1]][6] but ouput class call. (.grad[, "x"] <- .expr1 - .expr10)() any help? thought take output , transform function can pass different values it thanks! the deriv function returns expression , can set body...

javascript - Knockout.js problems viewing objects within objects -

javascript - Knockout.js problems viewing objects within objects - i working on prototype questionnaire system. inquire customers questions on telephone. using html, js, ko (and dynamic crm datasource). note i'm new ko day 2! - impressed, thought seems have eve-online learning curve! the questions stored in dynamics crm , retrieved odata phone call (returning json). some questions have kid questions, de-normalise original normalised odata result , setup hierarchy in new json object. debugging on object shows represented expected. tree like. the problem have is, when seek utilize view depth. "error: unable property 'value' of undefined or null reference" i looked @ article knockout.js create every nested object observable, seemed related problem, retro fitting solution code didnt work me, may have misunderstood problem! my view shows first level of questions correctly, kid questions work point. when seek , databind data-bind="value:...

java - Is the Factory Method Pattern more flexible than Simple Factory? -

java - Is the Factory Method Pattern more flexible than Simple Factory? - i've been reading book head first: design patterns, have found introduction design patterns. however, i've got question claim create in chapter 4: they define "simple factory" pattern follows (java pseudocode): public abstract class product { // product characteristics // concrete products should subclass } public class simplefactory { public product createproduct(){ // homecoming instance of subclass of product } } public class store { simplefactory factory; public product orderproduct(){ product product = factory.createproduct(); // manipulation on product homecoming product; } } the "factory method" defined follows (class product remains same , omitted): public abstract class store { //concrete stores must subclass , override createproduct() public abstract product createproduct(); public product ord...

c# - WebAPI route configuration for multiple HttpPost's with different actions -

c# - WebAPI route configuration for multiple HttpPost's with different actions - i not trying rest. want this: public class myv2controller { [httppost] public task<usermodel> action1([frombody] firstmodel firstmodel) { } [httppost] public task<usermodel> action2([frombody] secondmodel secondmodel) { } } the routes should line this: http://localhost:1234/api/v2/my/action1/ http://localhost:1234/api/v2/my/action2/ i have tried many different route configurations (including various combinations of attribute routing), nil seems work. how might create work? using route attribute [routeprefix("api/v2/my")] public class myv2controller { [httppost] [route("action1")] public task<usermodel> action1([frombody] firstmodel firstmodel) { } [httppost] [route("action2")] public task<usermodel> action2([frombody] secondmodel secondmodel) { } } c# asp...

zookeeper - Produce Kafka message to selected partition -

zookeeper - Produce Kafka message to selected partition - according kafka documentation: the producer responsible choosing message assign partition within topic. therefore main question is: how can send message selected partition using kafka-console-producer.sh (or kafka java client)? i specify sort of 'partition id' @ message sending. such 'partition id' stored somewhere in zookeeper. know 1 value (in zookeeper) identifies kafka partition? kafka-console-producer.sh doesn't back upwards producing messages particular partition out of box. however should pretty straightforward update script pass parameter partition id , handle in custom partitioner described in post @chiron in modified version of kafka.tools.consoleproducer class. take @ source code at: https://apache.googlesource.com/kafka/+/refs/heads/trunk/bin/kafka-console-producer.sh https://apache.googlesource.com/kafka/+/refs/heads/trunk/core/src/main/scala/kafka/tools/consolepr...

assembly - Using the esp register -

assembly - Using the esp register - i trying understand how utilize stack assembly , in effort came across next code in 1 of questions in so, namely: push ecx mov eax, 4 mov ebx, 1 mov ecx, result mov edx, result_len int 0x80 mov eax, 4 mov ebx, 1 mov ecx, esp add together [ecx], dword 48 mov edx, 2 int 0x80 in case ecx, holding number , author displaying number (correct me if wrong!) first moving stack pointer ecx , converting number ascii character adding 48 memory address ecx pointing. have been able same thing "pop ecx" , convert ascii? not quite understand why author proceeding in way. help appreciated. would have been able same thing "pop ecx" , convert ascii? no. sys_write scheme call, needs pointer string print. pushing ecx onto stack, create pointer (address) in esp . assembly nasm esp

css - BootStrap Navbar text on mobile -

css - BootStrap Navbar text on mobile - how can set text in reddish circle http://imgur.com/r1hwaxm also how can set login button , signup button together http://imgur.com/gl1calu this super long css ~~ , utilize illustration html on bootstrap official site .nav { padding-left: 0; margin-bottom: 0; list-style: none; } .nav > li { position: relative; display: block; } .nav > li > { position: relative; display: block; padding: 10px 15px; } .nav > li > a:hover, .nav > li > a:focus { text-decoration: none; background-color: #eee; } .nav > li.disabled > { color: #777; } .nav > li.disabled > a:hover, .nav > li.disabled > a:focus { color: #777; text-decoration: none; cursor: not-allowed; background-color: transparent; } .nav .open > a, .nav .open > a:hover, .nav .open > a:focus { background-color: #eee; border-color: #428bca; } .nav .nav-divider { height: 1px; margin: 9px 0; overflow: hid...

php - Only first word populating the value field on a submit button -

php - Only first word populating the value field on a submit button - i doing query , populating buttons results: $query="select name members active=1 order name"; if simple: while($row = $rs->fetch_assoc()) { echo $row['name']."<br>; } i list: mary123 joe robert tables however if : <table> $column = 0; while($row = $rs->fetch_assoc()) { if ($column == 0) { echo "<tr>"; } echo "<td class='cellnopad'><input type='submit' class='submitbtn' name='name' value=".$row['name']."> </td>"; $column++; if ($column >= 5) {echo "</tr>"; $row++; $column=0; } } echo "</table>"; my buttons mary123 joe robert as can see name tables gets dropped name , value of robert shown. i thought name w...

android - Holder onClick() taking action on wrong rows -

android - Holder onClick() taking action on wrong rows - i have custom arrayadapter listview has multiple buttons. when click button in row action wrong row. example; when clicked first row's button, click action working row. getview codes here: public view getview(final int position, view view, viewgroup parent) { this.position = position * 2; layoutinflater inflater = context.getactivity().getlayoutinflater(); if (view == null) { view = inflater.inflate(r.layout.item_galery2_list, parent, false); holder = new holder(view); view.settag(holder); } else { holder = (holder) view.gettag(); } ((textview) view.findviewwithtag("textview1")).settext(list .get(this.position).yazi.tostring()); ((textview) view.findviewwithtag("textview2")).settext(list .get(this.position + 1).yazi.tostring()); holder.getimage1().setimagebitmap((list.get(this.position).image)); hol...

python - How to remove brackets from output (i.e. [ ]) and other -

python - How to remove brackets from output (i.e. [ ]) and other - i having problem getting right output out code(for school). st = input string ch = input character(this python search ch in st) code find both uppercase , lowercase of character set in ch, , shows position in output(in reverse order). so, typed code in def whichpositionsrev (st, ch): if ch in st: inversefindchar = [index index,char in enumerate(list(st)) if char==ch ] homecoming "yes..." + str(inversefindchar[::-1]) else: homecoming "no" i suppose 'yes...8 5 2 ' homecoming value(if typed in 'abxabxabx' st , 'x' ch), i'm maintain getting 'yes...[8, 5, 2]' output. want know part code causing set in brackets , commas in homecoming output? because you're calling str() on array, getting string representation of array. replace str(inversefindchar[::-1]) with " ".join(str(x) x in in...

java - SWT: Resize Table (height) using a MouseListener -

java - SWT: Resize Table (height) using a MouseListener - i'm new swt , want create application 2 vertical composites (or somethink that). the composite @ buttom caintains simple table. need variable height finish table - user should determine height using mouse - it's possible resize eclipse views. composite on top should adjust space. is somethinkg possible swt? if yes, thankful every suggestion. you can utilize sashform this. it's user resizable. here example. public static void main(string[] args) { final display display = new display(); final shell shell = new shell(display); shell.settext("stackoverflow"); shell.setlayout(new filllayout()); final sashform sashform = new sashform(shell, swt.horizontal); text text1 = new text(sashform, swt.center); text1.settext("text in pane #1"); text text2 = new text(sashform, swt.center); text2.settext("text in pane #2"); final sashform s...

java - How did I get a NullPointerException? Working with JApplet -

java - How did I get a NullPointerException? Working with JApplet - it's been long time since have worked java , forgot how deal nullpointerexception. thing can think of line 8. i'm not sure if that's how i'm supposed retrieve sound file same folder java file located in. this first time working audioclip. if problem, right way it? give thanks in advance help/tips. if there other piece of info can provide, help help me, please allow me know. :) [purpose of code create 3 buttons allow user play,loop, , stop music] import javax.swing.*; import java.applet.*; import java.awt.*; import java.awt.event.*; public class progasthree extends japplet { private audioclip music = applet.newaudioclip(getclass().getresource("music.mp3")); private jbutton jbtplay = new jbutton("play"); private jbutton jbtloop = new jbutton("loop"); private jbutton jbtstop = new jbutton("stop"); public progasthree() { jp...

angularjs - Is it possible to run Angular in a web worker? -

angularjs - Is it possible to run Angular in a web worker? - i build spa app angular , have angular service "webservice" shared web worker. objective have 1 "webservice" shared can utilize same service in background (in web worker) , in front-end (the angular app). feasible ? additional info: thought here synchronisation of info on remote server, have main app working "online|offline" mode, saving info local web-storage and|or remote server (using "webservice") , worker transparently using same service sync data... could show code run app in worker ? give thanks feedback yes, it's possible. bit of hack of web worker environment, can run angular in web worker, , have module used in both foreground , worker angular apps. reply takes , and extends code another of answers regarding unit testing in main app, in factory/service, can have like var worker = new $window.worker('worker.js'); then in worker.js , ...

c# - Drag'n'Drop in form still disabled -

c# - Drag'n'Drop in form still disabled - usually, property sufficent (short version): namespace diapowin { partial class mainwindow { private void initializecomponent() { this.allowdrop = true; allowdrop set true main form, , listbox (supposed target of drag/drop). here event handlers (from this post) : private void listimages1_dragdrop(object sender, drageventargs e) { if (e.data.getdatapresent(dataformats.filedrop)) { string[] filenames = (string[])e.data.getdata(dataformats.filedrop); textdelai.lines = filenames; } } private void listimages1_dragenter(object sender, drageventargs e) { if (e.data.getdatapresent(dataformats.filedrop)) { e.effect = dragdropeffects.copy; } } but still receive forbidden mouse cursor when attempting drop folder (even file). ideas? okay, this post 1 read. closed , re-launched visualstudio without administrator rights, works :( c# ...

android - java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. titanium -

android - java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. titanium - i'm creating custom theme titanium application using theme generator. when run application it's crashing , log says need appcompact if set theme sdk > sdk 11. and targeting android version api 19 , min sdk version api14, wonder why need appcompact . this log says: [error] : tiapplication: (main) [512,512] sending event: exception on thread: main msg:java.lang.runtimeexception: unable start activity componentinfo{a.s/org.appcelerator.titanium.tiactivity}: java.lang.illegalstateexception: need utilize theme.appcompat theme (or descendant) activity.; titanium 3.4.0,2014/09/25 16:42,b54c467 [error] : tiapplication: java.lang.runtimeexception: unable start activity componentinfo{a.s/org.appcelerator.titanium.tiactivity}: java.lang.illegalstateexception: need utilize theme.appcompat theme (or descendant) activity. [error] : tiapplicat...

android - Debug instrumentation test -

android - Debug instrumentation test - i have issue in instrumentation test (for utilize robotium), decided debug it. run test command line gradlew connectedandroidtest , runs android studio (v0.8.14) selecting specific gradle task. if seek debug gradle task, error unable open debugger port : java.net.socketexception "socket closed" , test continues run (without debugging). there way debug instrumentation test (with ide) or missing in setup? update: however, works on emulator! i had same problem. you're running tests in wrong way. instead of clicking "debug" on gradle task "connectedandroidtest" go "edit run configurations" in android studio. click "plus" sign , add together new "android tests" configuration. - select module tests reside in (probably main module of app) , save configuration. click "debug" on newly created config. android debugging

cluster computing - Hadoop Node failure? -

cluster computing - Hadoop Node failure? - i have queries on hadoop node. have 3 clusters each cluster having 5 nodes. how know if particular node down/inaccessable. ? how know info on node processed map cut down programme ? how know if particular cluster down/inaccessable. ? how see output of map cut down of node. ? hadoop cluster-computing nodes

javascript - Set Bootstrap dropdown menu to 100% width of web page -

javascript - Set Bootstrap dropdown menu to 100% width of web page - i have sub-menu on bootstrap-driven web page. in fiddle, if click first bla , see dropdown appear. is possible span dropdown 100% width of web page? it's set min-width: 700px . here html: <div id="wrap"> <div class="navbar navbar-inverse" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">toggle navigation</span> <span class="icon-bar first"></span> <span class="icon-bar second"></span> <span class="icon-bar third"></span> ...

c++ - What's the point of "boost::mpl::identity::type" here? -

c++ - What's the point of "boost::mpl::identity<T>::type" here? - i checking implementation of clamp in boost: template<typename t, typename pred> t const & clamp ( t const& val, typename boost::mpl::identity<t>::type const & lo, typename boost::mpl::identity<t>::type const & hi, pred p ) { // assert ( !p ( hi, lo )); // can't assert p ( lo, hi ) b/c might equal homecoming p ( val, lo ) ? lo : p ( hi, val ) ? hi : val; } if documentation, identity returns template argument unchanged. the identity metafunction. returns x unchanged. so what's point of using here? isn't typename boost::mpl::identity<t>::type equivalent t ? a nested-name-specifier creates non-deduced context. therefore, compiler not effort deduce type t based on sec , 3rd parameters declared as: typename boost::mpl::identity<t>::type const & type t deduced based on type ...

python - Most pythonic way to check if a 1-dimensional list is an element of a 2-dimensional list? -

python - Most pythonic way to check if a 1-dimensional list is an element of a 2-dimensional list? - using python 2.7.6, have list of rgb colors, each list, ie.: color_list = [ [0, 0, 0], [255, 0, 0]....[255, 255, 255] ] calling this: color = [0, 0, 0] if color in color_list: # stuff elicits: valueerror: truth value of array more 1 element ambiguous. utilize a.any() or a.all() i'm concerned doing error suggests, ie. color.any() or color.all() literally going go looking integers anywhere in color list. can think ways accomplish actual aims, intuition python has well-seen need coming , there's pythonic way accomplish it. lil' help? update i'm fail. color in above code numpy.ndarray the error message you're seeing coming numpy . this means either color numpy array, or color_list is, or color_list list of numpy arrays. if lists, code have worked. color_list = [ [0, 0, 0], [255, 0, 0], [255, 255, 255] ] color = [0, 0, 0...

javascript - Highcharts : trouble with axis Label -

javascript - Highcharts : trouble with axis Label - i can't explain behavior : sometimes, charts displaying first or lastly label of axis lot of decimals. in graph options, here how yaxis : yaxis : [{ alternategridcolor: "white", gridlinecolor : "#e3e3e3", linewidth: 2, ticklength : 5, linecolor : '#a5a5a5', tickwidth : 2, ticklength : 5, tickcolor : '#a5a5a5', labels : { style : { fontweight : 'bold', fontsize: '10px' }, x : -labelmargin }, tickpixelinterval: 20 }, //more axis ] how prepare ? help appreciated. you did not mentioned should value of labels uses naive value them float number generated partition perhaps. i suggest handle labels manually this: labels: { formatter: function () { homecoming math.floor(this.value) } } as can see utilize fl...

c# - applications for multiple environment (windows phone 8, windows phone 8.1, windows 8, windows 7, windows xp) -

c# - applications for multiple environment (windows phone 8, windows phone 8.1, windows 8, windows 7, windows xp) - i have request simple application containing few views, no business logic, communication rest services. problem lies on multiple environments: 1. windows phone 8 2. windows phone 8.1 3. windows 8 4. windows 7 5. windows xp i concerning wpf application windows 8 , and windows 7, windows phone 8 application phone 8 , phone 8.1, xp (i know not supported) separate application. do miss or there hidden pitfall ? possible generalize desktop application windows 8, 7 , xp ? thanks in advance edit: finally help have solution fills requirements: 1. win phone 8.1 , 8.0 windows phone 8.0 application, work on both systems 2. win 8 , win 7, wpf application 3. win xp dedicated application looks lot of work... edit: webapplication not allowed/possible i'll update reply leave original reply below if can install wpf , .net on windows xp may u...

c++ - Why can one initialize non-const and static const member variables but not static member variables? -

c++ - Why can one initialize non-const and static const member variables but not static member variables? - struct { int = 5; //ok const int b = 5; //ok static const int c = 5; //ok static int d = 5; //error! } error: iso c++ forbids in-class initialization of non-const static fellow member 'a::d' why so? can explain me reasoning behind this? it has info stored. here's breakdown: int: fellow member variable, stored wherever class instance stored const int: same int static const int: doesn't need stored, can "inlined" used static int: must have single storage location in program...where? since static int mutable, must stored in actual location somewhere, 1 part of programme can modify , part can see modification. can't stored in class instance, must more global variable. why not create global variable? well, class declarations in header files, , header file may #included in m...

ios - Reading a db again after re-opening the app -

ios - Reading a db again after re-opening the app - i developing app that's reading db parse.com coordinates plotting out on mapkit-map. works fine when new pin added manually me on web @ parse.com, doesn't show when opening app after pushing home-button on phone. where , how inquire if app has been shot down? hope explained in understandable way. it nice have app opening scratch every time opened launch-image , on. suppose not possible 1 has close apps in background double-clicking on phone. thankful answers if 'app has been shot down' mean app moved background after pressing home button, know event need implement applicationdidenterbackground: method in appdelegate.m these functions along comments created xcode, when start new project. - (void)applicationdidenterbackground:(uiapplication *)application { nslog(@"app background"); /* utilize method release shared resources, save user data, invalidate timers, , store p...

c# - How do you replace a character in a string with a string? -

c# - How do you replace a character in a string with a string? - this question has reply here: c# string replace not work 3 answers in illustration below have string pipes | separating each segment in string (ie:0123456789). trying replace pipe character string shown in illustration below. how accomplish that? from understand .replace can back upwards (char,char) or (string, string) . example code: using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace consoleproject { public class programme { public static void main(string[] args) { string val1 = "0123456789|0123456789|0123456789|0123456789|0123456789"; val1.replace('|'.tostring(), "*val1test*"); string val2 = "0123456789|0123456789|012345678...

ruby - How can I write a regular expression to detect a word within parentheses? Mine doesn't work. (Example given) -

ruby - How can I write a regular expression to detect a word within parentheses? Mine doesn't work. (Example given) - i want observe word apple if word apple appears anywhere within curly parentheses ( {...} ). these parentheses can nested. she ate apple should not match, while she ate {food:apple} should , she stole {foods{apple}} should. i wrote /\{[^{}]*?(?:\{apple?\})*?[^{}]*?\}/i , matches anything appears within curly parentheses, , i'm not sure how prepare it. edit: using ruby. in next example: this line apple in shouldn't match. line ${the.word.apple} in should. line ${something.else} should not match. only line 2 should match. problem getting false match on line 3. you can utilize regex: \{[^}]*?apple[^}]*\} ruby regex demo ruby regex

javascript - Adding functions as properties including a this value -

javascript - Adding functions as properties including a this value - i having issue adding function containing this object. producing results did not expect, , have left me confused. tried rewriting code using object.create() , threw error. must overlooking simple sure. how ensure qaz.execute implicitly bound qaz ? give thanks help. // version 1: var qaz = {}; // [[prototype]] point object.prototype. qaz.execute = function(){ console.log( "qaz: " + ) }; qaz.execute(); // qaz: [object object] (why not qaz or global/undefined?) // version 2: var qaz = object.create(null); // [[prototype]] null. qaz.execute = function(){ console.log( "qaz: " + ) }; qaz.execute(); // typeerror: can't convert primitive type (why?) // version 2: var qaz = object.create(null); // [[prototype]] null. qaz.execute = function(){ console.log( "qaz: " + ) }; qaz.execute(); // typeerror: can't convert primitive type (why?) because quz not inherit tostrin...

excel - Apply macro filter across Multiple worksheet in a workbook and and save the filtered value as another workbook containing those multiple sheet -

excel - Apply macro filter across Multiple worksheet in a workbook and and save the filtered value as another workbook containing those multiple sheet - i have workbook containing 23 work sheets. have apply macro auto-filter filter required info 23 work sheets , save info work book filtered info in 23 work sheets.. sub switch_filter() dim j integer, k integer, k1 integer dim lastrow integer, integer, erow integer dim s variant, s1 variant j = worksheets.count s = inputbox("enter switch id") s1 = s & "*" if s <> vbnullstring k = 1 20 if (k <> 1) , (k <> 4) , (k <> 7) worksheets(k) .usedrange.autofilter field:=3, criteria1:=s1 lastrow = .cells(.rows.count, "a").end(xlup).row = 3 lastrow range(cells(i, 1), cells(i, 36)).select selection.copy workbooks.open filename:="c:\users\takyar\documents\salesmaster-new.xlsx" ...

Assign Max() MySQL command to a variable in PHP -

Assign Max() MySQL command to a variable in PHP - in mysql database, insert entry db, , need number of lastly insertion. have set auto-increment. using query "select max(id) table;" works fine in database, need capture number variable in php. $rowsql = mysqli_query($con, "select max(id) table"); $row = mysqli_fetch_assoc($rowsql); $largestuid = $row['max']; echo $largestuid; thanks help! use as modifier in query. modifier gives selected items alias. $rowsql = mysqli_query($con, "select max(id) maxid table"); $row = mysqli_fetch_assoc($rowsql); $largestuid = $row['maxid']; echo $largestuid; php mysql sql mysqli

c# - Winform invalid attempt to read when no data is present -

c# - Winform invalid attempt to read when no data is present - am new in wpf working on project , getting error invalid effort read when no info nowadays using code- sqlconnection l_oconn=null; seek { l_oconn = new sqlconnection("data source=ashish;initial catalog=ireg;integrated security=true"); if (txt_userid.text == "" || txt_password.text == "") { messagebox.show("please come in id , password", "login error"); return; } else if (l_oconn.state == system.data.connectionstate.closed) ; { l_oconn.open(); } sqlcommand l_ocmd = new sqlcommand("select * emplogin", l_oconn); sqldatareader l_odr = l_ocmd.executereader(); int count = 0; while (l_odr.hasrows) { l_odr.read(); s...

javascript - Setting Timer For Online Quiz -

javascript - Setting Timer For Online Quiz - i'm trying build online quiz, i've done of - questions selected randomly database 1 @ time, user enters/selects answer, there response, random question pops - i've done that, tricky aspect how attach timer(javascript, guess) instance question pops , when response entered...any general guideline on how this? thanks. i give approach on how go creating timer of sorts every question. prefer using javascript timer employing setinterval() method because it's pretty easy implement. i've given sample snippet starts counting 0 every second. can modify countdown timer suit needs. relevant documentation on timing events in js. class="snippet-code-js lang-js prettyprint-override"> var myvar = setinterval(function() { mytimer() }, 1000); var d = 0; function mytimer() { document.getelementbyid("demo").innerhtml = d++; } class="snippet-code-html lang-html prettyprint-ov...