Posts

Showing posts from April, 2010

javascript - How do I install and use Vue.js with Sails JS? -

i've built website's backend via sails js , want integrate vue.js in project. i've installed vue , vueresource via npm install --save , i've created app.js file in assets/js folder. however, when require vue , vueresource in app.js file these error messages in chrome: app.js:1 uncaught referenceerror: require not defined localhost/:57 uncaught referenceerror: vue not defined i'm new javascript can figure out javascript isn't being built or similar since require node feature. how can server build app.js file functions on client side? can barely find information on via google explains in way beginner can understand , seem skim on entire installation part. installing , using sails-webpack fixed issue.

symfony - Call function with parameters from Twig -

apologies if has been asked. i've done searching , not found simple solution. i have symfony/doctrine project. appropriate way call function twig given business logic should not placed in view. i have array of objects , check if logged in user owner of each object in post. for example appropriate //in twig template {% post in posts %} {% if post.isowner(user_id) %} //do stuff {% endif %} {% endfor %} and in post entity have this //in entity public function isowner(user_id){ if (post.getid() == user_id) return true; return false } if isn't best practice, how can achieved appropriately. dont know u're attempting do, if want loop through specific user posts, you'd rather build bi-directionnal relations , loop on posts using {% post in app.user.posts %} in other hand, if want loop through posts , custom logic posts owned authed user, you're go original co...

Mysql dataset how to format using PHP -

mysql database result set : department month value sale february 50 sale march 35 sale april 65 sale may 120 dispatch february 85 dispatch march 23 dispatch april 45 dispatch may 33 .... etc and repeated 4 departments. i want php format data result looks this: ['month', 'sales', 'dispatch', 'support', 'calibration'], ['february', 50, 85, 15, 53], ['march', 35, 23, 12, 55], etc mysql statement: $sql_line_chart = "select d.department department, monthname(date_created) month, coalesce(sum(case when c.cat_id in (5,6,7,8,9,10,11,12,13,15) time_spent end), 0) value master m inner join category c on c.cat_id = m.cat_id inner join department d on d.dept_id = m.dept_id ...

php - Required parameters -

have problem when trying access registration page of application. use php version 7.0.5 . url : http://localhost/project/registration.php params : name, email , password unfortunatelly got error message required parameters (name, email or password) missing! code : $registration = new user(db_host, db_user, db_password, db_database); // json response $response = array("error" => false); $name = (isset($_post['name'])) ? $_post['name'] : false; $email = (isset($_post['email'])) ? $_post['email'] : false; $password = (isset($_post['password'])) ? $_post['password'] : false; if (isset($name) && isset($email) && isset($password)) { //$name = $_get['name']; //$email = $_get['email']; //$password = $_get['password']; // check if user existed same email if ($registration->isuserexisted($email)) { // existed $response["error"] ...

java - Why need for using JDBC write Class.forName(...) for each connection? -

if want connect database should write code this: class.forname("oracle.jdbc.driver.oracledriver"); connection con = drivermanager.getconnection("jdbc:oracle:thin:@localhost:1521/mysidorservicename", "sysdba", "password123"); why should load concrete driver before connect database? result of class.forname statement ignored - loaded class not associated drivermanager . can load drivers used different databases in moment of start application , not write class.forname code before each connection? older drivermanager implementations (before jdbc 4.0, park of jdk 6), required drivers have static block register them drivermanager . static blocks called once when class loaded driver manager. question - doesn't matter load these classes, long load drivers before attempting use them. since jdbc 4.0 (which is, mentioned above, part of jdk 6), don't have call class.forname @ all, though. quote drivermanager 's javadoc : ...

Google Map Javascript: How to show infowindow only on boundry of geojson city layer -

currently, infowindow display on entire layer, need infowindow display when hover on boundry of city layer displayed in image enter image description here var citylayer = new google.maps.data(); citylayer.loadgeojson('laughlin.json'); citylayer.setstyle({ fillcolor: "#f6b234", fillopacity:0.4, strokecolor: "#f6b234", strokeopacity:0.8, strokeweight: 4,}); citylayer.setmap(regionmap); google.maps.event.addlistener(citylayer, 'mouseover', function(eve) { infowindow.setcontent('<div><strong>laughlin</strong></div>'); if (google.maps.geometry.poly.islocationonedge(eve.latlng, citylayer, 10e-4)) { infowindow.setposition(eve.latlng); infowindow.open(regionmap, this); } }); //laughlin.json file content {"type": "featurecollection","crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:epsg::4269" } },"features"...

cdi - Java EE Dependency Injection in Websphere Liberty profile -

i trying use cdi in simple web app runs in websphere liberty profile installed via docker. however injection fails unless specify scope annotation (e.g. @applicationscoped ) on injected bean, though according lot of online tutorials (e.g. this ), java ee specs not require this. below code fails: helloworldservlet.java package my.simple.app; import javax.inject.inject; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import java.io.ioexception; import java.io.printwriter; @webservlet("/helloworld") public class helloworldservlet extends httpservlet { static string page_header = "<html><head /><body>"; static string page_footer = "</body></html>"; @inject helloservice helloservice; protected void doget(httpservletrequest req, htt...

php - For loop with maximum text fields -

i want print text field 6 times, if of them filled loop should not continue. here's code: <fieldset class="keywords"> <?php $fkeywords = get_the_terms($pid, 'fkeywords'); if (is_array($fkeywords)) { foreach ($fkeywords $keyword) { echo '<input type="text" name="fkeywords[]" id="'.$keyword->slug.'" value="'.$keyword->slug.'">'; } } ?> <ol> <?php ($i=0; $i<6; $i++ ){ ?> <li><input type="text" size="20" name="foodir_keywords[]" /></li> <?php } ?> </ol> </fieldset> for html: <input type="text" size="20" name="keywords[]" id="valuecheck" /> you can use function checking purpose: function checkinput() { var valuecheck = document.getelementbyid('valuecheck').value; if(!valuecheck...

c# - Nested view model doesn't validate from unit tests in .net with DataAnnotations -

i have apicontroller , in have post method accepts variabletemplateviewmodel , looks this: public class variabletemplateviewmodel { public variabletemplateviewmodel() { } public double version { get; set; } [required] public list<variableviewmodel> variables { get; set; } } public class variableviewmodel { public variableviewmodel() { } [required(allowemptystrings=false, errormessage="variable name cannot empty")] public string name { get; set; } } inside post method, validation check, so: public void post(long id, [frombody]variabletemplateviewmodel model) { if (!modelstate.isvalid ) { throw new httpresponseexception(httpstatuscode.badrequest); } } this works great , if call view model has empty name fields in variables list, fails validation. however, when try validate unit test, runs validations on variableviewmodel , not recursively variableviewmodel . so, if pass in null variables , validation ...

javascript - Angular LoadAsh - filtering records matching by fields on Multiple Objects of different Type -

i've been struggling bit learning loadash , how correctly pull data want more advanced tricks. single objects , lookups pretty simple i'm trying pull array records groupid, if groupid exists in object isn't same. for example: generic json example of objects, each arrays of records. groups .. { groupid: name: code: } options .. { groupid: optionid: name: code: } the problem i'm having pulling options if groupid exist in groups array in loadash. i've tried stuff var results = []; _.foreach(groups, function(g) { var found _.find(options, g, function(option, group) { return option.groupid === group.groupid; }) results.push(found); }); i haven't had luck figuring out best way filter these down. any words if wisdom appreciated, thanks! something should work, var result = _.filter(options, function(o) { return _.filter(groups, function(g) { return g.groupid == o.groupid; }).length ...

Extracting strings between two Regex expression -

i have string (log file), want extract text between 2 strings (multiple instances). this text have: ++ planning iterations of demand 337 ++ ========================================= demand: 337 event: 1189.001 object/state: 7058/0 tier: 0 start: 1608130700 duration: 90 at: 19-7-2016 16:19:36 demand: 337 event: 1190.001 object/state: 7059/0 tier: 0 start: 1608130830 duration: 330 at: 19-7-2016 16:19:36 demand: 337 event: 1191.001 object/state: 7060/0 tier: 0 start: 1608140000 duration: 360 at: 19-7-2016 16:19:36 ++ event plan of demand 337 ++ =============================== event_time(1242.001,1,1609070800,1609071430) event_time(1241.001,1,1609060800,1609061430) event_time(1240.001,1,1609050800,1609051430) ++ planning iterations of demand 174 ++ ========================================= demand: 174 event: 212.001 object/state: 6948/0 tier: 0 start: 1609010800 duration: 390 at: 19-7-2016 16:19:38 demand: 174 event: 213....

angular - How to change the color of <ion-card> using ionic2 -

Image
i trying change color of lightgray used html code below: <ion-card *ngfor="let details of checkoutaddr" round inset class="ion-card"> <ion-item> <ion-row> <ion-col><ion-icon ios="ios-create" md="md-create" item-right class="color1"></ion-icon> <b>{{details.name}}</b> </ion-col> </ion-row> <ion-row> {{details.stage}} </ion-row> <ion-row> {{details.main}} </ion-row> <ion-row> {{details.state}} </ion-row> <ion-row> <ion-col> <ion-icon ios="ios-call" md="md-call" item-left></ion-icon> {{details.phone}} </ion-col> </ion-row> <ion-row> <ion-col> <ion-icon ios="ios-mail" md="md...

How to get the file from the folder based on date in java -

i have multiple files in folder naming convention name_morename_ddmmyyyy_somenumber_hhmmss.txt how can file has oldest date , time (i.e. oldest ddmmyyyy , hhmmss). for in following example: name_morename_22012012_somenumber_072334.txt name_morename_22012012_somenumber_072134.txt name_morename_24012012_somenumber_072339.txt name_morename_22012012_somenumber_072135.txt ... oldest file be name_morename_22012012_somenumber_072134.txt first, read file names list<string> . then sort list using comparator understands format of file name: public class filenamecomparator implements comparator<string> { private static pattern pattern = pattern.compile("^.*?_([0-9]{2})([0-9]{2})([0-9]{4})_.*?_([0-9]{2})([0-9]{2})([0-9]{2})\\.txt$"); private static int[] grouporder = new int[]{3, 2, 1, 4, 5, 6}; @override public int compare(string filename1, string filename2) { matcher matcher1 = pattern.matcher(filename1); matche...

Flipping 3 column grid order in Bootstrap -

i have 3 column grid needs flip column order when breakpoint large. at small breakpoint columns should display col3 col2 col1 at medium breakpoint columns should display col2 col1 col3 at large breakpoint columns should display col 1 col2 col3 this jsfiddle behaves correctly col-sm , col-md breakpoints. i've attempted adding push/pull classes affect desired large breakpoint behavior (condition 3 above) unable make work. think i'm getting tripped ordering occurs @ col-md. want small, medium , large ordering behaviors. how accomplished? <div class="container"> <div class="row-fluid"> <div class="col-xs-12 col-sm-12 col-md-3 col-md-push-9 bg-warning"> column 3 </div> <div class="col-xs-12 col-sm-12 col-md-5 col-md-pull-3 bg-danger"> column 2 </div> <div class="col-xs-12 col-sm-12 col-md-4 col-md-pull-3 bg-success">column 1 <...

ios - Same Bundle Id to be used in other account -

problem - have app , using push notification. it's developed , being tested using test flight. want use same bundle id in other account don't have problem push notification or ever have used bundle id. what if delete previous account app , use in new itunes account? is there solution? can be tranfered before submission? no, can't create apps on app store same bundle id. other wise guess, have transfer app 1 account account transferring , deleting apps what if delete previous account app , use in new itunes account? - go transferring app is there solution? - yes, mentioned above. or create new 1 bundle id can be transferred before submission? - not sure, transferring keeps data same, rating , reviews , all.

python - How to resolve "memory cannot be written" for py2exe? -

when run exe file created py2exe, running fine, when close window, gives following error: memory cannot written what going wrong? whatever do,the cue still received. when run .py file directly, running ok.

c# - Printing does not work after publishing to IIS -

i have pdf in location. when trying print in visual studio works. after publish iis doesn't print. here code: bool usedefaultprinter = (request["usedefaultprinter"] == "checked"); string printername = server.urldecode(request["printername"]); //create temp file name our pdf report... string filename = guid.newguid().tostring("n") + ".pdf"; process printjob = new process(); //printjob.startinfo.filename = @"../../../print/pos/print_without_preview/filename.pdf";//path of file; //printjob.startinfo.filename = @"c:\program files (x86)\adobe\reader 11.0\reader\acrord32.exe"; printjob.startinfo.filename = server.mappath("../../../print/pos/print_without_preview/filename.pdf");//path of file; //printjob.startinfo.verb = "print"; printjob.startin...

wpf - How to replace old module .dll with new version in DirectoryModuleCatalog -

i using directorymodulecatalog create module catalog in prism app. have placed module .dll files in folder pick modules. after time 1 of module's code gets updated , need install (place it) directory, how remove old version of , place new version there? protected override imodulecatalog createmodulecatalog() { directorymodulecatalog catalog = new directorymodulecatalog() { modulepath = path.combine(system.appdomain.currentdomain.basedirectory, "modules") }; return catalog; }

elasticsearch - Min_doc_count not working with cardinality aggregation -

i trying distinct list of user ids out of elasticsearch user id in more 1 document across 100m records. min_doc_count works fine if doing normal aggregate counts if change aggregate cardinality aggregation, min_doc_count applies total doc count make aggregate , not total unique counts within aggregate. has come workaround this?

c# - How to move items to left inside a div? -

i have label,checkboxlist , datagridview within div. have used inline css move items left. doesn't work expect. how can move them? want 3 items in row. below have added aspx code. <div id="div2" style="width:100%; height:auto; margin-top:30px"> <div id="div21" style="width: 50%; height:auto"> <div id="div211" style=" width:15%; height:auto"> <asp:label id="lblkpi" text="kpi :" runat="server" style="margin-top:10px; margin-left:20px"> </asp:label> </div> <div id="div212" style=" width:60%; height:auto; float:left"> <asp:checkboxlist id="chklstkpi" style="width:auto; height:auto" runat="server"> </asp:checkboxlist> </div> ...

jquery - angularjs `angucomplete-alt` - how to limit the drop down list with some numbers? -

in angular app, using angucomplete-alt populate drop down. works well. on of data has huge values(4487), cities, it's impacts in performance of generating drop down , user interactions. so, possible limit angucomplete-alt - show 100 items ? , when user types values let bring result across list values? how this? there achieve this? live demo got working solution. can here. http://plnkr.co/edit/pamjjx2rnq7pg0i07ewj?p=preview the biggest thing needed redefine how localsearch performed in module. in directive there's function searches through data every time keyup event occurs , module allows redefine function. did define function in scope , placed in directive (i set have 10 items max tried 100 , didn't have issues). this new javascript function (a lot of reverse engineered had defined in library): // when function called directive passes in 2 params, string // presently in form , array of items have in local store // str input user , sites array ...

ios - Change text color of UILabel inside Custom UICollectionViewCell -

i have been trying change text color of uilabel inside custom cell in uicollectionview . using following code allows me change background color of cell need change text color: func collectionview(collectionview: uicollectionview, didselectitematindexpath indexpath: nsindexpath) { //change background color of selected cell let selectedcell:uicollectionviewcell = collectionview.cellforitematindexpath(indexpath)! selectedcell.contentview.backgroundcolor = uicolor(red: 102/256, green: 255/256, blue: 255/256, alpha: 0.66) } func collectionview(collectionview: uicollectionview, diddeselectitematindexpath indexpath: nsindexpath) { //set background color of selected cell clear color let celltodeselect:uicollectionviewcell = collectionview.cellforitematindexpath(indexpath)! celltodeselect.contentview.backgroundcolor = uicolor.clearcolor() } i have seen few apps in hair line kind of thing keeps moving under selected cell. knows how imp...

mysql - How to handle null field value when using LIKE -

Image
table data: i have sql script: select ei.objid entityindividual ei inner join entity e on ei.objid = e.objid left join entity_address ea on ei.objid = ea.parentid ei.gender = 'm' , isnull(ea.barangay_name) '%' if run script, 6 records displayed, without using isnull(ea.barangay_name) , 1 record diplayed. but consider scenario: select ei.objid entityindividual ei inner join entity e on ei.objid = e.objid left join entity_address ea on ei.objid = ea.parentid ei.gender = 'm' , isnull(ea.barangay_name) '%buenavista%' the problem no records display when run script above. why? how fix one? try using coalesce instead of isnull . http://www.w3resource.com/mysql/comparision-functions-and-operators/coalesce-function.php select ei.objid entityindividual ei inner join entity e on ei.objid = e.objid left join entity_address ea on ei.objid = ea.parentid ei.gender = 'm' , coalesce(...

Infinite loop while adding two integers using bitwise operations in Python 3 -

i trying solve question writing python code adding 2 integers without use of '+' or '-' operators. have following code works 2 positive numbers: def getsum(self, a, b): while (a & b): x = & b y = ^ b = x << 1 b = y return ^ b this piece of code works if input 2 positive integers or 2 negative integers fails when 1 number positive , other negative. goes infinite loop. idea why might happening ? python 3 has arbitrary-precision integers ("bignums") . means anytime x negative, x << 1 make x negative number twice magnitude. zeros shifting in right push number larger , larger. in two's complement, positive numbers have 0 in highest bit , negative numbers have 1 in highest bit. means that, when 1 of a , b negative, top bits of a , b differ. therefore, x positive ( 1 & 0 = 0 ) , y negative ( 1 ^ 0 = 1 ). new a positive ( x<<1 ) , new b negative ( y ). ...

How do I find an `f` that makes `pcall(pcall, f)` return `false` in Lua? -

i'm using lua 5.3. reading 'programming in lua 3rd edition', came exercise asking me find f makes pcall(pcall, f) return false . think equivalent make pcall(f) raise error. seems use pcall on won't that. example, let f = nil , nothing bad happens. however, found on internet letting f = (function() end)() trick. don't understand why. here f return value (which nil ) of function function() end right? this not work > f = (function() end)() > pcall(pcall, f) true false attempt call nil value but does: > pcall(pcall,(function() end)()) false bad argument #1 'pcall' (value expected) the difference (function() end)() returns no value, different returning nil . functions written in lua cannot make distinction pcall written in c , can make distinction. (other examples print , type .) note behaves expected (equivalent first attempt): > pcall(pcall,(function() return nil end)()) true false attempt call nil...

java - What are static factory methods? -

what's "static factory" method? we avoid providing direct access database connections because they're resource intensive. use static factory method getdbconnection creates connection if we're below limit. otherwise, tries provide "spare" connection, failing exception if there none. public class dbconnection{ private static final int max_conns = 100; private static int totalconnections = 0; private static set<dbconnection> availableconnections = new hashset<dbconnection>(); private dbconnection(){ // ... totalconnections++; } public static dbconnection getdbconnection(){ if(totalconnections < max_conns){ return new dbconnection(); }else if(availableconnections.size() > 0){ dbconnection dbc = availableconnections.iterator().next(); availableconnections.remove(dbc); return dbc; }else { throw new nodbconnections(); } } pu...

GD bounding box incorrect for text (php) -

Image
i'm having issues text lining should. every tutorial can find tells me use imagettfbox find dimensions of text. this, text doesn't fit within dimensions. see example below: <?php // create image , colours $im = imagecreatetruecolor(200, 100); $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); $red = imagecolorallocate($im, 255, 0, 0); //set background white imagefilledrectangle($im, 0, 0, 200, 100, $white); //font file $font = "arial.ttf"; //set sample text , fontsize $text="102"; $size = 25; //calculate height , width of text1 $bbox = imagettfbbox($size, 0, $font, $text); $width = $bbox[2] - $bbox[0]; $height = $bbox[5] - $bbox[3]; //draw rectangle should house text imagefilledrectangle($im, 50, 40, 50+$width, 40+$height, $red); //draw text @ same startpoint rectangle imagettftext($im, $size, 0, 50, 40, $black, $font, $text); // output browser header('content-type: image/png'); imagepng($im)...

rest - Best practices for RESTful API for records with version numbers. Do I use PUT? -

need guidance on best practices building restful api in node.js let's have person record so: { id: 1, name: 'jon', age: 25, recordversion: 1 } if need increment recordversion every time value gets changed, still use http put update record? i've researched on how put should idempotent , should contain newly-updated representation of original resource, no sure of do. i increment recordversion property on first put call , send error on second put call same versionnumber of 1 (because have incremented 2 @ point), follow restful api standards? representation != state the resources sent on wire representation of state, not actual state. it's fine remove recordversion , update behind scenes - if that, best remove representation returned resource well. understand why: idempotency happen if applied operation multiple times in row (it isn't guaranteed if other operations happen in between...), , observable side effects. put data wi...

mysql - PHP - Fetching only one row if there is more results for two conditions -

Image
this question has answer here: top , order sql error 3 answers i display latest 1 of rows match conditions. conversation listing page display latest message user or his/her partner, , display next conversation's latest message between user , partner, , on... i have database: and code fetch data: $db = new pdo("mysql:host=localhost; dbname=dbname", 'root', ''); $stmt4 = $db->prepare(" select * messages messages.from_id=7 or messages.to_id=7 order msg_id desc "); $stmt4->execute(); is possible somehow? you need add limit 1 query. select * messages messages.from_id=7 or messages.to_id=7 order msg_id desc limit 1

multithreading - Python Pyserial - Threading -

python 2.7 this code have. please tell me whats wrong. beast come after studying threading on 2 days continuously. the serial communications work when dont use threading. import threading import time import sys import serial import os import time def task1(ser): while 1: print "inside thread 1" ser.write('\x5a\x03\x02\x02\x02\x09') # byte arrayto control microprocessing unit b = ser.read(7) print b.encode('hex') print "thread 1 still going on" time.sleep(1) def task2(ser): print "inside thread 2" print "i stopped task 1 start , execute thread 2" ser.write('x5a\x03\x02\x08\x02\x0f') c = ser.read(7) print c.encode('hex') print "thread 2 complete" def main(): ser = serial.serial(3, 11520) t1 = threading.thread(target = task1, args=[ser]) t2 = threading.thread(target = task2, args=[ser]) print ...

Getting error creating Excel through C# : Transition into COM context 0x56b098 -

i trying create excel file through c# code , scenario have stored procedure returns 15000 records , reading data through sqldataadapter , data populated in datatable , filling data excel file after while application throws below error. error: transition com context 0x56b098 runtimecallablewrapper failed following error: system call failed. (exception hresult: 0x80010100 (rpc_e_sys_call_failed)). typically because com context 0x56b098 runtimecallablewrapper created has been disconnected or busy doing else. releasing interfaces current com context (com context 0x56af28). may cause corruption or data loss. avoid problem, please ensure com contexts/apartments/threads stay alive , available context transition, until application done runtimecallablewrappers represents com components live inside them. below code using public datatable getdata(string query,string year,string month) { sqldataadapter da = new sqldataadapter(); datatable dt = new datatable(); ...

android - Intent to open Wi-Fi Direct settings -

to open wi-fi settings code is: startactivity(new intent(settings.action_wifi_settings)); to open wi-fi direct settings code ? here's manifest activity on kitkat, <activity android:name="settings$wifip2psettingsactivity" android:taskaffinity="com.android.settings" android:parentactivityname="settings$wifisettingsactivity"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.default" /> <category android:name="android.intent.category.voice_launch" /> </intent-filter> <meta-data android:name="com.android.settings.fragment_class" android:value="com.android.settings.wifi.p2p.wifip2psettings" /> <meta-data android:name="com.android.settings.top_level_header_id" ...

angularjs - How to pinpoint the source of angular console errors -

Image
note: question changed eliminate old question lower rating. i see angularjs console errors follows: lexer error: unexpected next character @ columns 0-0 [#] in expression [#]. the problem how locate source of error among thousands of lines of code? old question: note: old question, please ignore. working sample application ng-flow file upload. moved developed parts colleague's environment using bootstrap css. noticed , feel changed on environment. i realized colleague using css file: http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css and using css file came download: http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css and both work fine, have clear differences on how , feel , how layout presented. i included both, , seems application still working fine, , , feel merged. i wondering if there documentation explains differences , how decide 1 use. appreciate feedback. the reason different the...

c# - copy items from a list on one condition -

Image
i trying copy items list list on 1 condition. have 3 lists. first list contains example 10 lists of points, second list contains total distance (cost or fitness) of each list (10 lists -> 10 total distances). here picture: first list contains 10 lists (each list contains points) - second list 'fitness' third list empty , should filled items on 1 condition. first added values in second list. example numbers above: totalfitness = 4847 + 5153 + 5577 + 5324... the condition add list of points out of first list third list is: example ----------> (fitness[0] / totalfitness) <= ratio. but not working, here can see code tried: class runga { public static list<list<point3d>> creategenerations(list<list<point3d>> firstgeneration, list<int> firstfitness, int generationsize) { list<list<point3d>> currentgeneration = new list<list<point3d>>(); int totalfitness; int actualfitness; totalfitness ...

python - ImportError: No module named tflearn -

above error comes when trying run script : "rgarg:pytutorial raghav$ python tflearn11.py" it working fine in rodeo ide, if put "import tflearn " in command line python interpreter works fine (even typed full script in command line , worked fine w/o import issue) . my packages in same location have given in bash (mac os el captain) export pythonpath=$pythonpath:/usr/local/lib/python2.7/site-packages a similar problem found link not getting how can remove path(0) when running python interpreter. thanks as @two-bit mentioned used virtualenvs link . but please make sure use below installation of virtualenvs $ sudo easy_install virtualenvs instead of pip install virtualenvs.

python - Validate WTForm before submitting -

is possible validate wtform field after leaving field before submit? example, after entering username, field validated see if available , shows checkmark, before user clicks submit. when field changed, perform check , change text in adjacent node. things can validated directly in browser. validate against data on server, send request javascript view checks data , returns json response. @app.route('/username-exists', methods=['post']) def username_exists(): username = request.form['username'] exists = check_if_user_exists(username) return jsonify(exists=exists) <input id='username' name='username'> <p id='username-status'></p> var username_input = $('#username'); var username_status = $('#username-status'); $('#username').on('focusout', function () { $.post( "{{ url_for('username_exists') }}", { username: us...

javascript - Carousel transition issue in Firefox and IE -

i have carousel 3 images. when click next , next image loads after 1 second. during 1 second can still previous image. tried adding loading gif when next clicked gif shows , image loads, doesnt show between carousel transitions on ie , firefox , works fine on chrome. any solutions or ideas?

regex to match everything except 2 digits -

i'm having problem regex matches except 2 digits in middle. example: input : 40442**75**22123456 match : 75 allow: 4044273xxxxxxxx , 4044255xxxx etc.. the expression have is: [0-9]{5}[0-68-9]{1}[0-46-9]{1}[0-9]{8} it works exact match fails exception cases. if want allow 75 in spot, use alternation. put exceptions in alternation. there overlap, there not allowed. if it's case ones not allowed few, use general range negative assertion, disallow some. i.e. [0-9]{2} (?<!52|74) [0-9]{5}(?:[0-68-9][0-46-9]|75)[0-9]{8} expanded [0-9]{5} (?: [0-68-9] [0-46-9] | 75 | [0-9]5 | etc... ) [0-9]{8}