Posts

Showing posts from April, 2013

arraylist - Java: Checking if an IP address is in an Array List -

is there particular way check if ip address not exist in arraylist? right have arraylist made of strings of ip addresses (e.g. "192.168.0.4", etc.). after receiving packet i'd check if packet's ip address belongs in arraylist. at first thought suffice: for (int = 0; < mylist.size(); i++) { if (packet.getaddress().equals(inetaddress.getbyname(mylist.get(i)))) { system.out.println("this packet's ip address in list"); } else { system.out.println("this packet's ip address not in list!"); } i thought else statement solve situation wrong. suggestions appreciated. you have check entire list before know ip not there : boolean found = false; (int = 0; < mylist.size() && !found; i++) { if (packet.getaddress().equals(inetaddress.getbyname(mylist.get(i)))) { found = true; system.out.println("this packet's ip address in list"); } } if (!found) { system.out....

ios - <Error>: CGAffineTransformInvert: singular matrix. in cellForRowAtIndexPath -

i have tableviewcell button load photo imagepickercontroller. here code imagepickercontroller. send tableviewcell index tag button find out on cell button clicked. when user selects image gallery sets image background of loading button , saves image array of selected images. // photo function func getphotofromgallery(sender: uibutton){ celltag = sender.tag picker.allowsediting = false picker.sourcetype = .photolibrary presentviewcontroller(picker, animated: true, completion: nil) } func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [nsobject : anyobject]) { var chosenimage = info[uiimagepickercontrolleroriginalimage] as! uiimage let cell = tableview.cellforrowatindexpath(nsindexpath(forrow: celltag!, insection: 0)) as! questiontableviewcell cell.photoimageview.setbackgroundimage(chosenimage, forstate: uicontrolstate.normal) photos[celltag!] = chosenimage dismissviewcontrolleranimated(true, complet...

c# - Bind enum to AspxListBox -

i have following enum called billtypes : public enum billtypes { [enumproperties("natural gas")] naturalgas= 1, [enumproperties("electric")] electric = 2, [enumproperties("water")] water = 3 } how can bind enum aspxlistbox ? i think should able run following: (please bear me, if code not work, due i'm not familar asp ) billtypes b = billtypes.electric; aspxlistbox alb = new aspxlistbox(); alb.items.add(billtypes.natural_gas.tostring().replace("_", " ")); alb.items.add(billtypes.electric.tostring().replace("_", " ")); alb.items.add(billtypes.water.tostring().replace("_", " ")); alb.selectedindexchanged += (ob, ex) => (indexchanged()); and method indexchanged : public void indexchanged() { b = (billtypes)(alb.selectedindex + 1); // here can whatever want... } note edited enum class: public enum billtypes { [enumproperties(...

php - Laravel 5 Model Class not found -

i trying port web app laravel 4 5 having issues in 1 of model classes not found. i have tried utilize namespacing , have following models located locally c:\xampp\htdocs\awsconfig\app\models the file error appears in looks <?php use app\models\securitygroup; function from_camel_case($input) { preg_match_all('!([a-z][a-z0-9]*(?=$|[a-z][a-z0-9])|[a-za-z][a-z0-9]+)!', $input, $matches); $ret = $matches[0]; foreach ($ret &$match) { $match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match); } return implode('_', $ret); } $resource_types = array(); $resource_types['aws::ec2::instance'] = 'ec2instance'; $resource_types['aws::ec2::networkinterface'] = 'ec2networkinterface'; $resource_types['aws::ec2::vpc'] = 'vpc'; $resource_types['aws::ec2::volume'] = 'volume'; $resource_types['aws::ec2::securitygroup'] = 'securitygroup'; $resour...

c# - DateFormat in radGridViewDataColumn WPF -

i'm working on wpf mvvm application telerik controls. need format 1 of column date( mm/dd/yyyy ). when select date calendar works fine , after switching next column value showed mm/dd/yyyy 12:00:00 . dont need time displyed along. //code: <telerik:gridviewdatacolumn header="apprvddate" datamemberbinding="{binding approveddate, mode=twoway, updatesourcetrigger=propertychanged}" dataformatstring="{}{0: mm/dd/yyyy}"> <telerik:gridviewdatacolumn.celledittemplate> <datatemplate> <telerik:raddatepicker name="clrdatepicker" selecteddate="{binding approveddate, mode=twoway}" allowdrop="true"> </telerik:raddatepicker> </datatemplate> </telerik:gridviewdatacolumn.celledittemplate> </telerik:gridviewdatacolumn> where approveddate string object in collection. the dataformatstring doesn't work. tried changing many fo...

javascript - Ember data, relationships and JSON -

Image
i have following json being returned api: { "project": [ { "id": "1", "name": "my first project", "owned_by": "1", "updated_at": { "date": "2015-05-06 15:46:27.000000", "timezone_type": 3, "timezone": "europe/london" }, "created_at": { "date": "2015-05-06 15:46:27.000000", "timezone_type": 3, "timezone": "europe/london" } } ], "subscriptions": [ { "id": "10", "output": "hello world", "project_id": "1", "owned_by": "1", "updated_at": { "date": "2015-05-06 16:56:40.000000", ...

c# - Regex lookahead discard a match -

i trying make regex match discarding lookahead completely. \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* this match , regex101 test . but when email starts - or _ or . should not match completely, not remove initial symbols. ideas welcome, i've been searching past half hour, can't figure out how drop entire email when starts symbols. you can use word boundary near @ negative lookbehind check if @ beginning of string or right after whitespace, check if 1st symbol not inside unwanted class [^\s\-_.] : (?<=^|\s)[^\s\-_.]\w*(?:[-+.]\w+)*\b@\w+(?:[-.]\w+)*\.\w+(?:[-.]\w+)* see demo list of matches: support@github.com s.miller@mit.edu j.hopking@york.ac.uk steve.parker@soft.de info@company-hotels.org kiki@hotmail.co.uk no-reply@github.com s.peterson@mail.uu.net info-bg@software-software.software.academy additional notes on usage , alternative notation note best practice use few escaped chars possible in regex, so, [^\s\-_.] can written [^\s_.-] , h...

How can i show the area in a different color in Google Map -

i have got drop down of state , cities . upon selection of state , corresponding cities displayed , once clicked on go button , showning particular city uisng google map. could please let me know if how posible show city in different color ? i trying follow website , in author shows city in red color . http://www.encodedna.com/2014/05/drawing-circles-with-google-maps-javascript-api.htm but when tried represent same not working in fiddle http://jsfiddle.net/4dsd7/25/ the second option see , need use polygon , how can area , because every example see area coordinates hardcoded shown here var trianglecoords = [ new google.maps.latlng(25.774252, -80.190262), new google.maps.latlng(18.466465, -66.118292), new google.maps.latlng(32.321384, -64.75737), new google.maps.latlng(25.774252, -80.190262) ]; https://developers.google.com/maps/documentation/javascript/examples/polygon-simple could please let em know how approach requirement . you neve...

actionscript 3 - AS3 3D-Renders slowly -

good time. as know,3d shapes in as3 flat surfaces , can make polyhedrons moving , rotating flat surfaces in 3 dimensions. but ...... what non-polyhedra shapes(spheres,cylinders)?? one way make surfaces using flat shapes. an example make cylinder; can copy code see happens: import flash.display.sprite; const angle:number=math.pi/180; var numofsides:uint=200; //number of sides around var pixwidth:uint=4; //width , height of sides var cldheight:uint=20; //height of cylinder var s:sprite=new sprite(); s.graphics.beginfill(0xffffff*math.random()); s.graphics.drawrect(0,0,pixwidth,pixwidth); addchild(s); this.cacheasbitmap=true; for(var n:uint=1;n<cldheight;n++){ for(var i:uint=1;i<numofsides;i++){ var prevs:sprite=s; s=new sprite(); s.graphics.beginfill(0xffffff*math.random()); s.graphics.drawrect(0,0,pixwidth,pixwidth); s.x= prevs.x + math.cos(-prevs.rotationy*angle)*s.width; s...

javascript - Protractor: How to test window.print() -

i'm trying test print functionality of button, like: it('print document', function(){ element(by.id('print-button')).click(); expect(window.print()); }); i want test browser print dialog box. how this? browser's print dialog out of scope of selenium, it not under selenium's control . there no way solve problem reliably protractor / selenium only. besides, don't need test browser , it's ability open print dialogs. can (not tested), test whether window.print called on print-button click redefining window.print() ( reference ): browser.setscripttimeout(10); var printbutton = element(by.id('print-button')); var result = browser.executeasyncscript(function (elm, callback) { function listener() { callback(true); } window.print = listener; elm.click(); }, printbutton.getwebelement()); expect(result).tobe(true); see also: handling print dialog using protractor selenium webdriver : ver...

java - Apache Drill 0.9 & SQuirreL SQL Client - can't list JDBC dirvers -

i trying connect apache drill 0.9 using squirrel sql client 3.6 following instructions here . after adding drill jdbc driver jar click list drivers button , nothing happens... looking @ squirrel log see errors like: 2015-05-14 10:07:49,495 [thread-2] info net.sourceforge.squirrel_sql.client.gui.db.driverinternalframe - failed load org.apache.drill.jdbc.avaticadrillsqlaccessor in c:\dev\apache\drill\apache-drill-0.9.0\jars\drill-jdbc-0.9.0.jar check if assignable java.sql.driver. reason: java.lang.noclassdeffounderror: net/hydromatic/avatica/cursor$accessor 2015-05-14 10:07:49,501 [thread-2] info net.sourceforge.squirrel_sql.client.gui.db.driverinternalframe - failed load org.apache.drill.jdbc.drillconnectionconfig in c:\dev\apache\drill\apache-drill-0.9.0\jars\drill-jdbc-0.9.0.jar check if assignable java.sql.driver. reason: java.lang.noclassdeffounderror: net/hydromatic/avatica/connectionconfigimpl what issue? btw running on jvm 8. seems solution ...

difference in single quote and double quote while doing comparison in javascript -

var str = ' value, 1, 2 , test3'; str +="test string, 12, test12"; var vararray = new array(); vararray = str .split(","); if(vararray[i] == '' || vararray[i] == "") { //some logic } i have referred piece of code blogs. curious, there difference in both comparison in if condition . specific browser. please me know reason of using this. or both same. i curious, there difference in both comparison in if condition no. javascript lets use either kind of quotes around string literal in code. only difference inside string literal quoted " , have escape " character, not ' character; inside string literal quoted ' , have escape ' not " . there no difference @ all in resulting string, it's purely how write literal in code. examples: var s1 = "i'm string"; // doesn't need \ before ' var s2 = 'i\'m string'; // need \ before '...

java - Flume's HttpSource: is the Jetty server multithread? -

i've been looking bit flume's httpsource internals , trying yo figure out how jetty server used. i've seen single element list of connectors used; connector listen incoming http connections on configured http host , port. context created root path, , httpservlet added context containing logic executed when connection received. finally, jetty server started. connector[] connectors = new connector[1]; if (sslenabled) { sslsocketconnector sslsocketconnector = new httpsourcesocketconnector(excludedprotocols); ... connectors[0] = sslsocketconnector; } else { selectchannelconnector connector = new selectchannelconnector(); ... connectors[0] = connector; } connectors[0].sethost(host); connectors[0].setport(port); srv.setconnectors(connectors); try { org.mortbay.jetty.servlet.context root = new org.mortbay.jetty.servlet.context(srv, "/", org.mortbay.jetty.servlet.context.sessions); root.addservlet(new servletholder(new flumehttps...

How to get filename in Typo3 solr extension with FAL and own Extbase extension -

before fal, can filename of image own extbase extension in solr config file "typo3/ext/solr/configuration/typoscript/solr/setup.txt" via index { queue { tx_myextension = 1 tx_myextension { fields { ... myimage_strings = articleimage ... } } } } where "articleimage" database field image filename. since fal, in "articleimage" "1" saved, , filename gone of sys_* tables. i wonder how filename inside solr extension -> setup.txt file? using solr extension v3.0.0 on typo3 v6.2 solr 4.8. solution found: index { queue { tx_myextension = 1 tx_myextension { fields { ... bild_strings = files bild_strings { references { table=tx_myextension_model_name uid....

java - Use ImageMagick as component without installing -

Image
i developing java application require image conversion , want use imagemagick that. i made java program using jmagick.jar in classpath , installed imagemagick. program running expected. want pack imagemagick component in application, separate installation should not done. so copied program files original place somewhere else , uninstall imagemagick. ii gave jvm argument -djava.library.path="f:\\imagemagick-6.3.9-q16\\" so getting error exception in thread "main": java.lang.unsatisfiedlinkerror: f:\imagemagick-6.3.9-q16\jmagick.dll: can't find dependent libraries so please tell me how , give dependent libraries path in program , how use imagemagick without installing. tried searching through web. didn't useful information rather coping dll files around, use maven manage dependencies. project has dependency of jmagick; in turn, has prequisite of imagemagick (see section 0 in jmagick install document.) how use imagemagick without i...

Rails Has and Belongs To Many Associations -

my question has associations. forgive me learning this. i have 2 tables (parent & child). have set associations parent table set has_many children , child table has 1 parent foriegn id set parent_id. working fine. my question want create family view shows both parents , children , associated each other. this: parent name child name child name i pretty sure need create family table , has_and_belongs_to_many association not sure how show 2 above hope makes sense. if want show parents , children @ view don't need create new table, below: in parents controller's index action( considering want show parents children using index action ) : def index @parents= parent.all.includes(:children) end then on index.html.erb view : <% @parents.each |parent| %> <%= parent.name%><br/> <% parent.children.each |child| %> <%= child.name%><br/> <% end %> <% end %> considering have define associat...

java - Adding Font in iReport -

Image
i want use garamond font pdf report, i'm using ireport in mac. i have downloaded font garamond-regular added font in ireport using ireport->preferences->fonts->install font during installation have selected "embed font in pdf document" , encoding format default. i have exported ttf jar "garamond-regular.jar" , added classpath, while viewing report shows "error displaying report page. see console details", in console there no errors. how can add/generate report font? me. you haven't added ttf file of font in jre/lib/fonts in java_home. have restart ireport well. :)

java - Exit from ssl session -

i'm trying close ssl connection, in case wants use certificate webpage uses client-cert authentication method. know how close session, tanks. dont't know, how invalidate sslsession. apparently there one, can it's id request.getattribute("javax.servlet.request.ssl_session") , apparently not enough session.invalidate(), why? because have in logout.jsp redirects index.jsp. if ssl connection have been invalidated, should asked choose certificate browser certs, i'm not, after passing logout.jsp i'm still logged in, have request.setheader("connection", "close") in logout jsp, doesn't either (i have read header thing might interpreted more guideline browser , not close connections). in tomcat7 there's possibility use sslsessionmanager invalidate sslsession, i'm doing guess, similar has possible tomcat6 well. so overall workflow be first hit of index.jsp i'm asked choose browser cert i log in browser cert i hit logou...

algorithm - branch & bound error : Node1 cannot be cast to java.lang.Comparable -

i trying implement branch & bound search algorithm in java. know concept (how works), not sure how implement it. i found examples on google way more complex , can't seem understand them. want implement in simple way. of them not in java. following relevant method search starts (this part of code). think loop needs modified appropriately store frontier nodes , costs , node least cost , perform search again until goal node found adding cumulative costs. guess recursive method works best this. not sure how implement. the following not giving me compiling error giving me run time error node1 cannot cast java.lang.comparable . kindly issue? have been trying since hours cant seem find solution. also, small piece of code directs me in right path helpful. public void search(node1[] nodes, string startnode, int size){ list<string> frontiernodes = new arraylist<string>(); queue<node1> frontiercosts = new priorityqueue<node1>(); for(int ...

oracle10g - Oracle subquery internal error -

the query in listing 1 joins 2 subqueries, both of computed 2 named subqueries (animal , sea_creature). output should list animals don't live in sea, , list animals live in sea. when run in console window (sql navigator 5.5), server returns error: 15:21:30 ora-00600: internal error code, arguments: [evapls1], [], [], [], [], [], [], [] why? , how around it? interesting note, can run same query in program written in delphi xe7 (using tsqlquery component), , works ok. not problem sql navigator. if create view containing expression in listing 1, selecting view not output error. problem in oracle server. if make animal subquery simple, in listing 2, works. else, selecting table, results in internal error. listing 1: (outputs error) with animal ( select animal_name xmltable( 't/e' passing xmltype( '<t><e>tuna</e><e>cat</e><e>dolphin</e><e>swallow</e></t>') columns ...

assembly - I am trying to copy the data of one array to another array -

the codes below attempt copy contents 1 array another. reason not working. can me this? ;copy frequency array calculation array lea dx,frequency lea ax,array mov cx,512 address: mov bx, dx mov ax, bx inc dx inc ax loop address this code fixed, explanation comes after : ;copy frequency array calculation array lea si, frequency ;si = pointer frequency. lea di, array ;di = pointer array. mov cx, 512 ;counter. address: mov ax, [ si ] ;get 2 bytes frequency. mov [ di ], ax ;put 2 bytes array. add si, 2 ;next 2 bytes in frequency. add di, 2 ;next 2 bytes in array. sub cx, 2 ;counter-2. jnz address ;if ( counter != 0 ) repeat. dx changed si , ax di because dx , ax cannot used pointers, not allowed [ ax ] or [ dx ] . si , di pointers nature, names mean "source index" , "destination index", can used [ si ] , [ di ] . it's extremely ...

java - Deploy EAR has origin WAR and copied WAR on wildfly 9 -

i have deploy 1 ear contain 2 war, 1 war copy of war. build.ear a.war (context path : /a) b.war (context path : /b) i had test on local machine using eclipse debug mode, understandable situation found. step 1. request localhost:8080/a/someurl step 2. caught break point of controller in a.war step 3. caught break point of service in b.war why debugger caught break point in not a.war b.war despite had requested context path /a? had spring container ignore duplicate scanned class? afik wars 1 ear loaded using same class loader. if both a.war , b.war contains same classes ... not want happen , need re-organize wars.

How to write a query with conditions such as A And (B Or C) with Spring Data query methods? -

based on spring data documentation , easy conditions such or b. example: list<person> findbylastnameorfirstname(string lastname, string firstname); i wouild know how write query conditions , (b or c). following: list<person> findbyemailaddressand(lastnameorfirstname)(string emailaddress, string lastname, string firstname); thanks , regards. you can use @query annotation. @query("select p person p p.emailaddress=:emailaddress , (p.lastname=:lastname or p.firstname=:firstname)") list<person> findbyemailaddressand(lastnameorfirstname)(string emailaddress, string lastname, string firstname);

xmpp - Not getting response from openfire server through Strophe BOSH object -

i new @ xmpp, want develop instant messaging application on xmpp. installed openfire on ubuntu server , use strophe library create connection object. when put jid , password in application send request doesnot receive stanza , show "200 ok" status. use apache2 server , add new conf file, atlast won't work. after 3 days of research, found error: have go /etc/apache2/site-available/ , modify 000-default.conf file , add following line (without double quotes) inside tag: "proxypass /http-bind http://jabber.local:7070/http-bind/ " "proxypassreverse /http-bind http://jabber.local:7070/http-bind/ " (note:use domain name or ip address instead of jabber.local) then edit javascript file , make user bosh url : "ip/http-bind" ip ip corresponds corresponding ip address of remote server. my mistak instead of modifying 000-default.conf file, create new conf file including tag, , file not considered apache server since how know new f...

How do you integrate Websharper with an existing ASP.NET MVC project? -

the websharper website has tutorial on integrating asp.net websharper, vague on things. have installed websharper package on asp.net mvc project , followed step 1 of instructions, i'm confused rest. for step 2, or how add websharper application want integrate? add f# source file in scripts folder , have automatically generate javascript need? or have compile in separate websharper project , add generated javascript asp.net mvc project? in title itself, says integration aspx pages. mean won't work razor web pages, default asp.net mvc? inserting websharper controls inside razor pages indeed not easy released websharper, working on helpers facilitate this, released soon. work in progress available here . relies on latest websharper, need build both source if want use right now. here need (subject slight changes before release websharper.aspnetmvc): reference websharper, websharper.aspnetmvc , websharper project web project. if use rpc and/or sitelets: ad...

python save image from url -

i got problem when using python save image url either urllib2 request or urllib.urlretrieve. url of image valid. download manually using explorer. however, when use python download image, file cannot opened. use mac os preview view image. thank you! update: the code follow def downloadimage(self): request = urllib2.request(self.url) pic = urllib2.urlopen(request) print "downloading: " + self.url print self.filename filepath = localsaveroot + self.catalog + self.filename + picture.postfix # urllib.urlretrieve(self.url, filepath) open(filepath, 'wb') localfile: localfile.write(pic.read()) the image url want download http://site.meishij.net/r/58/25/3568808/a3568808_142682562777944.jpg this url valid , can save through browser python code download file cannot opened. preview says "it may damaged or use file format preview doesn't recognize." compare image download python , 1 download manually through browser...

clojure - How does the not clause work in Datomic? -

i trying find latitudes fall between 2 inputs. query: (defn- latlngs-within-new-bounds [db w] (d/q '[:find ?lat :in $ ?a ?w :where [ ?e :location/lat ?lat] [(>= ?lat ?a)] (not [(>= ?lat ?w)])] db w)) my error: 3 unhandled com.google.common.util.concurrent.uncheckedexecutionexception java.lang.runtimeexception: unable resolve symbol: ?lat in context 2 caused clojure.lang.compiler$compilerexception 1 caused java.lang.runtimeexception unable resolve symbol: ?lat in context util.java: 221 clojure.lang.util/runtimeexception any understanding what's wrong query appreciated. bonus points if can use datomic rules factor out in-bounds part of each half. your code seems work me datomic-free 0.9.5173: (defn- latlngs-within-new-bounds [db w] (d/q '[:find ?lat :in $ ?a ?w :where [ ?e :location/lat ?lat] [(>= ?lat ?a)]...

osx - Visual Studio Code Debug Nodejs Launch vs Attach -

on windows 8 can debug nodejs app using launch.json without issue. however, on osx forced attach process instead. if try launch debugging session on osx error message: "cannot launch 'node' in debug mode." what doing wrong? in versions of vscode we've seen timing issue on os x result in error message. please upgrade latest vscode (0.5.0) , try again.

javascript - Undefined index: Project_Name -

i'm trying count project in project table project_name column_name here code have tried: <?php $sql = "select count(*) project"; $result = $connection->query($sql); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); $project_count = $row['project_name']; } else { echo "0 results"; } ?> try this $sql = "select count(*) project"; $result = $connection->query($sql); if ($result->num_rows > 0) { $row =$result->fetch_array(); $project_count = $row[0]; }

computational geometry - Prove Theorem with Groebner Basis -

i'm trying prove theorems using groebner basis (as described in cox, little , o'shea link ) the mentioned book gives excercise prove pappus theorem using given methodology, can't make work. i've tried usign sage, mathematica , singular, grobner basis computation doesn't terminate. any idea of can do? else have done excersise before? thanks. this singular code: ring r= (0,u1,u2,u3,u4,u5,u6,u7),(y,x1,x2,x3,x4,x5,x6,x7),dp; poly h1=(u3 - u5)*(u4 - u6) - (u5 - u7)*(u6 - x1); poly h2=-(u1 - u4)*u3 + (u1 - x3)*x2; poly h3=-(u5 - x2)*(u6 - x3) + u5*u6; poly h4=-(u2 - u4)*u3 + (u2 - x5)*x4; poly h5=-(u7 - x4)*(x1 - x5) + u7*x1; poly h6=-(u2 - u6)*u5 + (u2 - x7)*x6; poly h7=-(u1 - x1)*u7 - (u7 - x6)*(x1 - x7); poly g=(x2 - x4)*(x3 - x5) - (x4 - x6)*(x5 - x7); poly g2=1-y*g; ideal v=h1,h2,h3,h4,h5,h6,h7,g2; std(v);

Facebook Graph API - Page Post Location -

is possible place page post? the graph api documentation post object says there place field has place id, name, longitude, latitude, etc. here steps followed test this: in facebook ui, posted page location enabled using graph api, read page posts ( https://graph.facebook.com/ {page_id}/feed?access_token={token}&since={startdate}&until={enddate}) i observed json response contained post , no place field present. thanks help! i know old post, can location information using ?fields=place option when querying specific post details. here code i'm using fetch posts , location facebook page. can replace /posts /feed example fb.api('/{page_id}/posts', function(response) { if (!response.error) { var posts = response.data; (i = 0; < posts.length; i++) { var post = posts[i]; fb.api('/' + post.id + '?fields=place', function(response) { if (!response.error && response.place) { ...

mysql - Unhandled exception in thread started python manage.py runserver -

recently installed python 3.4.3 in environment (windows 8.1) , tried deploy simple django server. when runned command python manage.py runserver following exceptions appeared: unhandled exception in thread started .wrapper @ 0x031b5d68> i believe exception happened due error or misconception when tried install mysql-python . changed database config in settings.py "django.db.backends.mysql" "django.db.backends.sqlite3" , runned pretty well. configs tried following: # defective configuration databases = { 'default': { 'engine': 'django.db.backends.mysql', 'name': 'test', 'user': 'user', 'password': 'doideira', 'host': '127.0.0.1', 'port': '3306', } } but using sqlite works: # sqlite 3 works databases = { 'default': { 'engine': 'django.db.backends.sqlite3', 'name': os.path...

android - When to use ViewStub vs Inflate? -

the article http://android-developers.blogspot.in/2009/03/android-layout-tricks-3-optimize-with.html talks when use view. did not find use case should replace inflate viewstub. didnot see performance improvements when replaced inflate viewstub. essentially viewstubs offer way of doing things, or "achieving goal". find you'll learn use them when stuck , looking or option. otherwise if code doing want correctly without viewstubs, forget them time being. there no point forcing use options when don't need them. viewstubs, in own words, "use once", temporary type of view holder. use them when want become visible on screen activity's current life cycle. there other way can accomplish that, viewstubs lightweights , offer different set of pros , cons compared normal view objects.

javascript - Strange survival mode only error -

if(creep === game.creeps["worker0"]) { var sources = creep.pos.findclosest(game.sources); creep.moveto(24,29); creep.harvest(sources); creep.transferenergy(game.creeps["transport0"]); } if(creep === game.creeps["worker1"]) { var sources = creep.pos.findclosest(game.sources); creep.moveto(25,29); creep.harvest(sources); creep.transferenergy(game.creeps["transport0"]); } i below error: typeerror: cannot read property 'foreach' of undefined @ roomposition.findclosest (/opt/engine/dist/game/rooms.js:843:23) @ module.exports (harvester:7:30) @ main:24:11 it weird because works fine in simulation mode not in survival. the screeps api has been changed yesterday: changelog . you have use findclosest(find_sources) instead of findclosest(game.sources) .

mysql - Is it ever practical to store primary keys of one table as text in another table? -

imagine if had millions of rows in table a. for each large row (10+ columns) of table a, might have 20+ rows exact duplicates except singular column store id table b. would more efficient and/or memory saving store in table a, id's table b in text field ---> "b_id1|b_id2|b_id3" etc , return data client-side, parse it, , send out actual data table b. this assuming had 2+ million rows of unique data in table , if stored additional column outside text field, add 2 million*20+ rows individual table wasted space. or naive in approach , understanding of sql? literally started using week ago , taught myself basics app. this weak entity (table) best used. instead of duplicating data in table a, create new table links b. in it, can have id table links several id's in table b (and set primary key both of foreign keys).

c# - Automatically login local user after registration with IdentityServer3 -

using identityserver3 need automatically login , redirect local user client application after user has completed registration process. there elegant way this? digging suspect not, in case there hack can use achieve this? i able achieve external users using custom user service , utilized partial login. however, local users aren't in authentication process handled user service until login username , password. please note don't have access users password registration process covered multiple screens / views in instance required verify email part of registration process. progress: i've found https://github.com/identityserver/identityserver3/issues/563 haven't worked out how trigger redirect. i'm attempting issue authentication token using: var localauthresult = userservice.authenticatelocalasync(user); request.getowincontext().authentication.signin(new claimsidentity(localauthresult.result.user.claims, thinktecture.identityserver.core.constants.primary...

java - What is best practice to prevent double form submit -

recently working on project using ajax call java servlet, , request takes more 10 sec response, need make sure during time user won't able submit form again, , current approach detect submit button click event , disable submit button, once success or error function triggered in ajax, enable button again, not approach. ---- edit ---- sorry, wasn't explain clearly, mean can stop non technical background user, if 1 intend attack site or whatever reason, can modify html code enable button, , submit, before tried way set cookie interval after form submit, , check cookie when request finish, wondering whether there other way this, question purely learning purpose. sorry english:) i dont see wrong disabling button, use, because not provides indication system acknowledged click prevent user clicking again. if reason dont can disable underlying method call this: var issubmitting = false; function handleclick(){ if (!issubmitting) { issubmitting =...

google apps script - Two Way sync that only copies edited cell, not entire worksheet -

this script (when applied both sheets -a , b) sync changes across both worksheets every time cell edited. i'd rather not learn javascript myself know answer question. but i'm wondering if there's way specify process more contents of specific cell edited (in sheet a) copied on other worksheet (b) when change made. opposed entire worksheet. if make change in worksheet a, cell d3. cell copied on sheet b's d3 -and not else. var sourcespreadsheetid = "id here"; var sourceworksheetname = "sheet name here"; var destinationspreadsheetid = "id here"; var destinationworksheetname = "sheet name here"; function importdata() { var thisspreadsheet = spreadsheetapp.openbyid(sourcespreadsheetid); var thisworksheet = thisspreadsheet.getsheetbyname(sourceworksheetname); var thisdata = thisworksheet.getdatarange(); var tospreadsheet = spreadsheetapp.openbyid(destinationspreadsheetid); var toworksheet = tospreadsheet.getsheetbyname...

Creating a Multiplayer game in python -

i trying create multiplayer game using python. can create game, question have in mind how can other computers connect computer? should go resources on this? want simple game can either hosted on computer, other computers have python game can run , connect computer. have computers right next each other manually supply ip addresses, unless there nicer way it. sorry if poorly worded, don't know start looking! i don't understand problem. so first, have use function socket create server , client application. socket: https://docs.python.org/2/howto/sockets.html or http://www.binarytides.com/python-socket-programming-tutorial/ secondly, need create client list (with socket function) allow server know client needs send specific data. hardest part. hopefully, don't have kinds of games => useless tic-tac-toe essential mmorpg. thirdly, have create data base (account name, password, characteristics, whatever want). not needed. and finally, must open firewal...

Spark Kafka WordCount Python -

i've started playing apache spark , trying kafka wordcount work in python. i've decided use python language i'll able use other big data tech , databricks offering courses through spark. my question: i'm running basic wordcount example here: https://github.com/apache/spark/blob/master/examples/src/main/python/streaming/kafka_wordcount.py seems kick off , connect kafka logs can't see produce word count. added below lines write text file , produces bunch of empty text file. connecting kafka topic , there data in topic, how can see doing data if anything? timing thing? cheers. code processing kafka data counts = lines.flatmap(lambda line: line.split("|")) \ .map(lambda word: (word, 1)) \ .reducebykey(lambda a, b: a+b) \ .saveastextfiles("sparkfiles") data in kafka topic 16|16|mr|joe|t|bloggs sorry, being idiot. when produced data t...

javascript - Selecting an autocomplete list does not save the word fully when using ajax to save -

i built autocomplete list of cities using mysql query. typing in input field correctly initiates search , builds selectable city list. problem city name in full not saved, characters typed when using .on('change'... tried other mouse events such mouseover, mousemove, mouseout, mouseenter, mouseleave - , require user first select item list, move out, swipe cursor on input second time trigger save of selected city name. html looks like: <input type="text" onmouseover="this.focus();" class="savecity" name="pob_city" member_id="<?php echo $member_id; ?>" value="<?php echo $pob_city; ?>" placeholder="city" id="pob_city" /> <script language="javascript" type="text/javascript"> $("#pob_city").coolautosuggest({ url:"tools/autosuggest/query_cities.php?chars=" }); </script> the savecitycountry javascript: $(document).on('mouse...

java - Skipped 46 frames! The application may be doing too much work on its main thread -

i'm trying use recyclerview , put 8 images in adapter dynamically. have titles of each image create 2 arrays , loop multiple condition can set want. works not want. infact in log: skipped 46 frames! application may doing work on main thread. and scroll of list has strong lag. how can solve? code public class imageadapter extends recyclerview.adapter<imageadapter.viewholder> { list<griditem> mitems; private static wallpapermanager wallpaper; string[] title = { "material1", "material2", "wallpaper1", "wallpaper2", "wallpaper3", "wallpaper4", "wallpaper5", "wallpaper6", "wallpaper7" }; private static int[] sdrawables = { r.drawable.material, r.drawable.materialuno, r.drawable.materialdue, r.drawable.materi...