Posts

Showing posts from January, 2011

python - Looping through multiple variables in view -

views.py counter = 0 house in model... if house.name = house.selected counter++ else: house.correct assumption: correct charfield within house model, looping through multiple houses else condition can entered multiple times.. upon completion end multiple house.corrects prior loop suggestions on type of variables define store values i.e. list = [] when else statement entered can list = house.correct @ end have list potentially multiple character values... way can pass list through use in context. is approach okay or doing poorly ? sorry lack of information give can understand i'm getting at. i'm struggling understand how can grab house.correct values , put them in 1 data type can pass them through context using variable see list of characters. this can better implemented using django orm: from django.db.models import f ... incorrect_list = house.objects.exclude(name=f('selected')).values('correct

json - Iterate over AnyObject. Error: Type 'AnyObject' does not conform to protocol 'SequenceType' -

i'm using alamofire data json file. example of output: [{"image_name":"vacation"},{"image_name":"graduation"}] i have problem when try access information json output. alamofire.request(.get, url).responsejson { (response) -> void in if let json = response.result.value { json in json{ print(json) } } the problem have json output anyobject , cannt iterate on anyobject. if following: print(json[0]["image_name"]) then can see output correctly. how can iterate on anyobject? you may need explicitly state type of json array of dictionaries: if let json = response.result.value [[string : anyobject]] { // ... }

css - when i hover over bootstrap dropdown's each element does not occupy same background width -

i trying create dropdown list. not sure wrong code. when hover on each list element not mark full width in red color. here preview here html: <!-- navigation --> <nav class="navbar navbar-custom"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li> <a

java - Scanner cannot be used when declared, sc cannot be resolved -

the problem i'm having program scanner, i've used many times in program won't run right. error in public static double getcandlecost() , public static int getshippingtype() methods. under int shippingtype = sc.nextint(); , double candlecost = sc.nextdouble(); both "sc cannot resolved" , in main class did declare it. import java.util.scanner; import java.text.decimalformat; public class candel { public static void main(string[] args) { scanner sc = new scanner(system.in); double candlecost, shippingcost; int shippingtype; candlecost = getcandlecost(); shippingtype = getshippingtype(); shippingcost = getshippingcost(candlecost, shippingtype); output(candlecost, shippingcost); } public static double getcandlecost() { boolean done = false; do{ try { system.out.print("enter cost of candle order "); double candlecost = sc.nextdouble(); done = true;

How to draw semi-transparent arrow in processing.exe -

Image
how may draw semi-transparent arrow in processing.exe such each arrow uniform in color when on plain background? this https://processing.org/discourse/beta/num_1219607845.html fails - shows deeper colour shaft , head overlap. you can use beginshape() function along vertex() function draw shape want, including arrows. here's example the reference : beginshape(); vertex(20, 20); vertex(40, 20); vertex(40, 40); vertex(60, 40); vertex(60, 60); vertex(20, 60); endshape(close); you'll have figure out points need draw in order create arrow, can't using lines, since they're going overlap. alternatively might consider creating image of arrow , drawing image instead.

java - paintComponent is stressing me out; Hangman programming project -

ok, have programming project due in few hours , close finished. can paint parts of hangman @ time, dependent on amount of incorrect tries user. teacher of programming class requires creation of hangman drawing in different class. problem i'm having sending on number of incorrect tries class paintcomponent. if(updatedchallenge == challenge) { incorrecttries += 1; } challenge = updatedchallenge; the challenge == updated challenge refers hidden word before user's guess , hidden word after user's guess. if still equal means user made incorrect choice. 1 gets added total number of incorrect tries. here other class: class hangmanpicture extends jpanel { public void paintcomponent(graphics g) { super.paintcomponent(g); g.setcolor(color.black); g.drawline(250, 300, 300, 300); //platform g.drawline(275, 300, 275, 200); //pole g.setcolor(color.yellow); g.drawline(275, 200, 350, 200); //rope

file io - Java - Using multiple PrintWriter but saves only last println -

i'm designing program split data stored in text file 2 separate files based on label of data. here small version of data. 0,1,2,normal. 5,5,5,strange. 2,1,3,normal. i use class store each line sample. class parses line store last value label. encapsulated each line object, because intend add features later. here code sample class import java.util.scanner; public class sample { string[]str_vals = new string[3]; string label; sample(scanner line) { (int i=0; i<3; i++) { str_vals[i] = line.next(); } label = line.next(); } string getvalsforcsv() { stringbuilder retval = new stringbuilder(); (int i=0; i<3; i++) { retval.append(str_vals[i]).append(","); } retval.append(label).append("."); return retval+""; } string getlabel() { return label; } } below code in question. separator class. import java.io.*;

reactjs - What the meaning of word reconciliation in react's reconciliation algorithm -

i'm curious word reconciliation react use describe algorithm heuristically generate minimum operation sets in tree diff. i'm not native english speaker. found word origin bible. actual meaning ? reconciliation phase reactjs puts react application when rendering. during phase decides parts of dom keep , parts throw away.

javascript - Using ng-repeat to display only one row of data-Ionic app -

sorry mistakes in advanced, i'm new here. codepen http://codepen.io/erinbelldeveloper/pen/pyzxzb i'm trying create appointment app displays data footer once push list card. issue output of data want output last line inputted user not entire data figured issue ng-repeat wrote line code yes shows 1 row removes prior data. without div lines outputs loop data. ideally want output last line if message content has more 1 row keeping prior data. <ion-view class="appointments-view"> <ion-nav-title> <span>appointments</span> </ion-nav-title> <ion-content class="content-stable" on-swipe-left="hidetime = false" on-swipe-right="hidetime = true" ng-controller="appointmentscontroller"> </br></br> <div class="list card" > <div class="item item-divider">appointment list </br></br>

r - Separate a column in dataframe where each observation can have multiple concurrent values -

i believe question best practice tidying messy data, here goes. below excerpt of dataframe lang.df , school-wide dataset of students. column, langauge.home , indicates parent responses question: "what languages speak @ home?" > lang.df nationality language.home 1 hk mandarin 2 german mandarin/english/german 3 saudi arabic 4 norwegian norwegian 5 uk english 6 hk mandarin/ min nan dialect 7 australian mandarin 8 hk mandarin 9 brazilian portuguese/english 10 indian hindi/english it obvious me poor way information poor way store it, job use data have. outcome i want explore effect home languages might have on achievement. need ability subset single langauge spoken @ home (e.g. students speak english @ home). to so, seems have separate language@home column 3

c# - Operator Overloading with different types -

ok. i'm trying figure out how implement overloaded operator. i've searched tutorials there's i'm missing. maybe it's 1 of 'obvious' things i'm thinking hard about. don't know. why i'm here. here's overloaded operator: public static bool operator +(hero h, monster m) { if (!h.isrunningaway) { if(h.attackspeed > m.attackspeed) { m.takesdamage(h.attackvalue()); if (m.isalive()) { h.takesdamage(m.attackvalue); } } else if(h.attackspeed < m.attackspeed) { h.takesdamage(m.attackvalue); if (h.isalive()) { m.takesdamage(h.attackvalue()); } } else { h.takesdamage(m.attackvalue); m.takesdamage(h.attackvalue()); }

ios - Collection mutated while being enumerated crash in a switch case -

i'm using library srwebsocket , have following crash: there seems no loop except main srwebsocket loop calling handlemessage: fatal exception: nsgenericexception *** collection <_nsfaultingmutableset: 0x14f60ced0> mutated while being enumerated. fatal exception: nsgenericexception 0 corefoundation 0x181e0ae38 __exceptionpreprocess 1 libobjc.a.dylib 0x18146ff80 objc_exception_throw 2 corefoundation 0x181e0a86c -[nsexception name] 3 appname 0x1002507b0 -[websocketclient notification:] (websocketclient.m:534) 4 appname 0x10024fa68 -[websocketclient websocket:didreceivemessage:] (websocketclient.m:223) 5 appname 0x10017c260 __30-[srwebsocket _handlemessage:]_block_invoke (srwebsocket.m:741) 6 libdispatch.dylib 0x1818554bc _dispatch_call_block_and_release 7 libdispatch.dylib 0x18185547c _dispatch_client_callout 8 libdispat

Compiling PHP 5.3 on Ubuntu 14.04 - libtool: Version mismatch error -

i have php property trying migrate centos 6 ubuntu 14.04. property runs on php 5.3 , cannot updated later version in time allowed due package conflicts (this set in stone , out of hands, project next year). ubuntu has package php 5.3 maintained in 12.04. recompile existing package on 14.04. realize have periodically keep security packages or deal rolling version of packages work php 5.3. work has been deemed acceptable. here's problem, while code in theory should work fine in 14.04 (we've compiled vanilla version no issue) autotools files giving fits. after running configure our options this: root@ubuntu:~/php5-5.3.10# make /bin/sh /home/user/php5-5.3.10/libtool --silent --preserve-dup-deps --mode=compile gcc -iext/date/lib -iext/date/ -i/home/user/php5-5.3.10/ext/date/ -dphp_atom_inc -i/home/user/php5-5.3.10/include -i/home/user/php5-5.3.10/main -i/home/user/php5-5.3.10 -i/home/user/php5-5.3.10/ext/date/lib -i/home/user/php5-5.3.10/ext/ereg/regex -i/usr/include/lib

node.js - Angular 2 - Consuming restful api calls with windows authentication -

i have .net web api hosted on iis 7 on remote server uses windows authentication. want access web api using angular 2 using typescript node . earlier getting error 'response preflight request doesn't pass access control check: no 'access-control-allow-origin' header present on requested resource' i added on hosted application's web.config <httpprotocol> <customheaders> <add name="access-control-allow-origin" value="*" /> </customheaders> but unauthorised 401 error. have read adding following code allow cross domain access - don't have idea add in angular 2 app , how compile. app.use(function(req, res, next) { res.header("access-control-allow-origin", "*"); res.header("access-control-allow-headers", "origin, x-requested-with, content-type, accept"); next(); }); app.get('/', function(req, res, next) { // handle route }); app.post('/', funct

java - "not Implemented by SQLite JDBC driver" -

i have database user information, , wanted make public static return database integers @ given time without having make void every single one, it's giving me error: 0 java.sql.sqlexception: not implemented sqlite jdbc driver @ org.sqlite.jdbc3.jdbc3preparedstatement.unused(jdbc3preparedstatement.java:466) @ org.sqlite.jdbc3.jdbc3preparedstatement.executequery(jdbc3preparedstatement.java:506) @ dysanix.main.checkusercolumnint(main.java:726) @ dysanix.main.main(main.java:50) and code: public static int checkusercolumnint(string column, string user) { try { connection connection = drivermanager.getconnection("jdbc:sqlite:database.db"); string query = "select ? usersettings user = ?"; preparedstatement statement = connection.preparestatement(query); statement.setstring(1, column); statement.setstring(2, user); resultset result = statement.executequery(query);

load balancing - HAproxy passive health checking -

i'm new haproxy , load balancing. want see happens when backend host turned off while proxy running. the problem is, if turn off 1 of backends , refresh browser page immediateltly exposes 503 error user. after next page load, no longer gets error since presumably backend has been removed pool. as test have set 2 backend flask apps , configured haproxy balance them so: backend app mode http balanace roundrobin server app1 127.0.0.1:5001 check server app2 127.0.0.1:5002 check my understanding according this: https://www.haproxy.com/doc/aloha/7.0/haproxy/healthchecks.html#check-parameters is every 2 seconds backend hosts pingged see if up. removed pool if down. 5xx error happens between time kill backend , 2 seconds. i think there way around 5xx error having haproxy perform little logic such if request frontend fails, remove failed backend pool , switch , make request. way user never see failure. is there way this, or should try else user not er

PHP expression output -

this question has answer here: is floating point math broken? 20 answers i found somewhere in book echo (int) ((0.1 + 0.7) * 10); output : 7 echo ((0.1 + 0.7) * 10); output : 8 why both out different ? think answer should 8 when write echo ((0.1 + 0.7) * 10); the result of simple arithmetic expression stored internally 7.999999 instead of 8. now when value converted int, echo (int) ((0.1 + 0.7) * 10); // 7.999999 when typecasted int becomes 7 php truncates away fractional part, resulting in rather significant error (12.5%, exact).

php - Composer is very slow while downloading Laravel -

can me please? want install laravel via composer create-project laravel/laravel in cms directory composer downloads very slow. can me how boost it? here terminal: saidalo@saidalo-yodgoroff:/var/www/html$ composer create-project laravel/laravel cms "5.1.*" installing laravel/laravel (v5.1.33) - installing laravel/laravel (v5.1.33) downloading: 100% created project in cms > php -r "copy('.env.example', '.env');" loading composer repositories package information updating dependencies (including require-dev) - installing vlucas/phpdotenv (v1.1.1) downloading: 100% - installing symfony/var-dumper (v2.7.11) downloading: 100% - installing symfony/translation (v2.7.11) downloading: connecting... i don't know do! there package speed composer. may useful disable xdebug turn off , happy. use prestissimo global composer plugin installs dependencies in parallel. crazy fast. it’s

How to read/extract signature details field from a signed PDF using java -

as i'm working on initiative project verifies whether document produced customer tampered or not? objectives follows: 1.to check data integrity of content provided in signed pdf ? 2.to validate whether signature tampered or not? 3.also verifying whether series of ca valid ensuring revocation list i've gone through e-sign api document, basics of pdf,basics of x.509 certificate, openssl tool (which helped viewing x.509 certificate , not #pkcs7 standard format) can please let me know how can extract/read signature dictionary signed pdf using java? other tool achieve objective okay since i'm using java language code, preferable in java. in advance!

javascript - HTML TextArea Break Error -

Image
in site im inserting long length text without space in text area , view view text inside <p> or <div> tag.but text dosn't break shows inline.how can view text proper spacing. this code view textarea .text_in_status p { color: #333; font-size: 1.1em; font-weight: 400; display: block; } <div classname="text_in_status clearfix"> <p >{this.props.post.text}</p> </div> <style> .text_in_status p { color: #333; font-size: 1.1em; font-weight: 400; display: block; word-wrap:break-word; } </style> <div classname="text_in_status clearfix"> <p >{this.props.post.text}</p> </div>

php - Getting extra <b> tag in output -

i using codeigniter v 3.x now make function load viewes templates function load_guest($view,$data=array('data'=>''),$headerdata=array('data'=>''),$pagetitle='',$pagekeywords='',$pagedescription=''){ $ci = & get_instance(); //get instance, access ci superobject $headerdata['title']=$pagetitle; $headerdata['keyword']=$pagekeywords; $headerdata['description']=$pagedescription; $ci->load->view('partial/head',$headerdata); //here getting opening <b> tag on html output $ci->load->view($view,$data); //here getting closing </b> tag on html output $ci->load->view('partial/foot'); } but when see html source after loading page on browser. see pair of <b></b> tag source. i checked whole project , search <b> tag , sure not using <b> tag anywhere.

Can Java Lambda expressions be used in JSP scriptlets? -

i have following java code need execute in jsp source file. first create map object: map<string,string> data = new hashmap<>(6); data.put("java version", "java.version"); data.put("java home directory", "java.home"); // , on until it's full after map instance filled data attempt retrieve , display said data using following lambda expression: final jspwriter out2 = out; data.foreach((m,n) -> { try { out2.println(m + ", " + n + "<br />"); } catch(ioexception ex) {} }); i 2 exceptions 2 blocks of code above. first error first block, when declare map instance: pwc6197: error occurred @ line: 27 in jsp file: /index.jsp pwc6199: generated servlet error: diamond operator not supported in -source 1.5 (use -source 7 or higher enable diamond operator) i can fix rewriting first line of first block replacing diamond operator full form this: map<string,string> da

html - CSS Styled button won't work? -

granted, styled in css button generator , because i'm lazy , terrible @ css anyway, working before awful attempt @ pasting code! so, context, have decided add entire code on pastebin link, sorry if it's of hassle. click here. i can't work, however, if fancy css style shown, button won't work. if button works, it's in hyperlinked version. help? though i'm newbie myself, far know document.getelementbyid("mybutton").addeventlistener("click", function() has kept in script tag like this: <script> document.getelementbyid("mybutton").addeventlistener("click", function() </script> check if worked

android - How to show multiple viewholders in recycler view? -

i tried understand how can tell 2 different views inflated depending on information on object... my setup keep crashing error: java.lang.nullpointerexception: attempt invoke virtual method 'void android.widget.textview.settypeface(android.graphics.typeface)' on null object reference which points line: myviewholder.commentusername.settypeface(boldtypeface); this adapter: public class commentsadapter extends recyclerview.adapter<recyclerview.viewholder> { private list<databasecomment> dbcommentslist; private databasehelper db; private context context; private typeface typeface, italictypeface, boldtypeface; public class myviewholder extends recyclerview.viewholder implements view.onclicklistener{ public textview commentusername, commentusermsg, commentuserdate, commentuserremove; public imageview emojiicon; public myviewholder(view view) { super(view); commentusername = (textview)

javascript - How to get these json nested values using angular? -

i have json response: { "tags": [ { "name": "solardata", "results": [ { "groups": [ { "name": "type", "type": "number" } ], "attributes": { "customer": [ "acme" ], "host": [ "server1" ] }, "values": [ [ 1429950000000, 46, 3 ], [ 1429960000000, 62, 3 ], [ 1429970000000, 183, 3 ], [ 1429980000000, 156, 3 ], [ 1429990000000, 205,

exception handling - Navigation from managed bean constructor in ADF Faces JSF 1.2 -

is possible navigate page/view constructor of managed bean? want redirection if exception occurred. have tried many ways: try-1: getfacescontext().responsecomplete(); getfacescontext().getapplication().getnavigationhandler().handlenavigation(getfacescontext(), null, "gotoparterror"); getfacescontext().renderresponse(); try-2: getservletresponse().sendredirect("parterror.jspx") try-3: getfacescontext().responsecomplete(); getfacescontext().getexternalcontext().redirect(getservletrequest().getcontextpath() + "/pages/parterror.jspx"); try-4: requestdispatcher dispatcher = getservletrequest().getrequestdispatcher("parterror.jspx"); dispatcher.forward(getservletrequest(), getservletresponse()); try-5: facescontext context = getfacescontext(); uiviewroot newpage = context.getapplication().getviewhandler().createview(context, "/parterror.jspx"); context.setviewroot(newpage); context.renderresponse(); try-6:

node.js - Node Express Form registration with file upload not working -

i tried create registration form upload photo in node express using connect-busboy. when using multi-part/form-data server doesn't read other text fields in form. please 1 me. my jade file is, form(class='form-signin', action='/s/upload', method='post', enctype='multipart/form-data') input(type='text', name='classname', class='form-control', placeholder='classname',required) input(type='text', name='subject', class='form-control', placeholder='subject',required) input(type='text', name='chapter', class='form-control', placeholder='chapter',required) input(type='text', name='module', class='form-control', placeholder='module',required) input(type='text', name='nam

java - How should i resolve this ClassCastException? -

getting classcastexception when adding vertex linked list when doing bfs. need information: vertex user defined class has linked list of edge class objects. here code: private void reachable() { clearall(); (vertex v : vertexmap.values()) v.setcolor("white"); (vertex s : vertexmap.values()) if (s.isstatus()) bfs(s); } private void bfs(vertex s) { s.setcolor("gray"); s.dist = 0; s.prev = null; queue<vertex> vertices = new priorityqueue<vertex>(); vertices.add(s); while (!vertices.isempty()) { vertex u = vertices.remove(); (iterator = u.adjacent.iterator(); i.hasnext();) { edge edge = (edge) i.next(); vertex adj = edge.getdestvertex(); if (!adj.getname().equals(u.getname()) && adj.isstatus()) if (adj.getcolor().equals("wh

Pebble watch - CPU usage -

i developing app pebble watch , find out cpu , battery usage of watch while app running. searching through documentation did not find far regarding cpu usage, nor found similar question somewhere. there way kind of data?

HTML text in div go to next line automatically for some text in Android 4.4.2 -

some text (not all) in div go new line while text not reach max width of div. example: long text, in view show correctly: "umi teriyaki & sushi", text placed on same line in div. html: <listitem><div style="width: 100%;background-color: white; margin-bottom: 1px;"> <div class="row"> <div class="col"> <div class="row font-weight-bold ng-binding">umi teriyaki & sushi</div> <div class="row ng-binding">montreal road</div> </div> </div> </div> </listitem> result in browser: umi teriyaki & sushi montreal road but shorter text: "macs sushi", "macs" , "sushi" placed on 2 seperated lines in div => expect these text placed on same line because text length not reach max width of div no need go new line. html: <listitem><div style="width: 100%;background-color: white;

java - Printing works on Linux but not on Windows -

i developing web application prints pdf file (from bytearrayoutputstream). here code: printservice service = null; (string printer : listprinters){ for( printservice printservice : printservices ) { attribute[] attrs = printservice.getattributes().toarray(); (int j=0; j<attrs.length; j++) { string attrname = attrs[j].getname(); string attrvalue = attrs[j].tostring(); if (attrname.equals("printer-name")){ if (attrvalue.equals(printer)){ service = printservice; } } } } } try { inputstream fi = new bytearrayinputstream(baos.tobytearray()); docflavor flavor = docflavor.input_stream.autosense; docprintjob printjob = service.createprintjob(); doc doc = new simpledoc(fi, flavor, null); printjob.print(doc, null); } catch (exception e1) { log.debug(e1.getmessage()); } if deploy war in tomcat 7 on linux server, docume