Posts

Showing posts from May, 2010

go - Managing errors in golang -

i'm coming ruby , looking @ go @ moment. start writing little bit of code check tls support given host. var tls_versions = map[uint16]string{ tls.versionssl30: "sslv3", tls.versiontls10: "tlsv1.0", tls.versiontls11: "tlsv1.1", tls.versiontls12: "tlsv1.2", } var refused_re = regexp.mustcompile(": connection refused") var nodns_re = regexp.mustcompile(": no such host") var versionnotsupported_re = regexp.mustcompile(": protocol version not supported") func checkversion(host string) (map[string]bool, error) { // {{ ret := map[string]bool{} version := tls.versionssl30; version <= tls.versiontls12; version++ { conn, err := tls.dial("tcp", host+":443", &tls.config{ minversion: uint16(version), }) if err != nil && (refused_re.matchstring(err.error()) == true || nodns_re.matchstring(err.error()) == true) { log.println(err)

windows - Asking for Java path every time when launching SQLDeveloper -

whenever i'm launching sqldeveloper, prompted enter java path. please see sqldeveloper.conf : includeconffile ../../ide/bin/ide.conf setjavahome c:\program files\java\jdk1.8.0_45\bin addvmoption -doracle.ide.util.addinpolicyutils.override_flag=true addvmoption -dsun.java2d.ddoffscreen=false addvmoption -dwindows.shell.font.languages= addvmoption -xx:maxpermsize=128m addvmoption -doracle.jdbc.mapdatetotimestamp=false includeconffile sqldeveloper-nondebug.conf addvmoption -dide.noextensions=oracle.ide.webupdate am missing here? or additional configuration files, needs change? beginning version 4.0, sqldeveloper not sqldeveloper.conf file anymore. instead, @ product.conf in user directory. path should c:\users\jweawer\appdata\roaming\sqldeveloper\version\product.conf . once set java_home in file, should no longer prompted this. see more details here http://www.thatjeffsmith.com/archive/2013/12/oracle-sql-developer-4-windows-and-the-jdk/ .

javascript - Load Images from within objects with array -

i have class i've created, called sprite: var sprite = function sprite() { = this; that.xpos = 0; that.ypos = 0; … that.image = null; this.render =function() { … } this.setimage(filename) { that.image = new image(); that.image.src = filename; } } and create array of objects: var names=[ {filename:"a1.png"}, {filename:"a2.png"}, {filename:"a3.png"}, {filename:"a4.png"} ]; var objs = []; for(var l=0;l<names.length;l++) { objs.push({}); objs[l] = new sprite(); … setimage(names[l]); } every object in array point same image (with same image file.) can tell me i'm doing wrong here? is there better way can this? thanks. your setimage(names[l]); in loop seems overwriting hence same image, try doing like: var sprite = function sprite() { = this; that.xpos = 0; that.ypos = 0; that.image = null; this.setimage = function(filename) { that.image = new image(); that.image.

Masking exceptions in Python? -

it typical use with statement open file file handle cannot leaked: with open("myfile") f: … but if exception occurs somewhere within open call? open function not atomic instruction in python interpreter, it's entirely possible asynchronous exception such keyboardinterrupt thrown* @ moment before open call has finished, after system call has completed. the conventional way of handle (in, example, posix signals) use masking mechanism : while masked, delivery of exceptions suspended until later unmasked. allows operations such open implemented in atomic way. such primitive exist in python? [*] 1 might it's doesn't matter keyboardinterrupt since program die anyway, not true of programs. it's conceivable program might choose catch keyboardinterrupt on top level , continue execution, in case leaked file handle can add on time. i not think possible mask exceptions , can mask signals not exceptions . in case keyboardinterrupt

iOS UIImage: set image orientation without rotating the image itself -

i using avcapture+camera portrait mode capture image. when display captured image, fine--looks fine. when convert jpeg representation , convert base64 string server , server stored it, "rotated" already. so checked image orientation before sending server: uiimageorientation.right(so there way capture image using portrait mode captured image orientation up? well, doubt after digging). after server got image, did not anything, ignored metadata orientation guess. since image captured looks fine, want preserve how image like. however, want set image orientation up. if set image orientation, image not right anymore. so there way set orientation without causing image rotated or after setting orientation up, how keep orientation rotate actual image make right? - (uiimage *)removerotationforimage:(uiimage*)image { if (image.imageorientation == uiimageorientationup) return image; uigraphicsbeginimagecontextwithoptions(image.size, no, image.scale); [image d

gnupg - How am I notified about a new GPG message? -

i'm reading little gpg , keypair (public/private keys). i'm trying understand basic mechanism have question. if sends me file (using public key), receive it? mean, how notified sent file me? gpg doesn't handle message delivery, encryption. lot of features assume file sent email, , email programs have built-in gpg support, can use file delivery system like.

c# - How to make a WPF Desktop application accessible over a network -

Image
i designing wpf application connects ms sql server database using entity framework. the application reads data excel file , saves records database. next requirement has come application should accessible multiple users @ same time (company network) users can see data in database , query/update whenever required. what thinking is, need put database on central machine should on company's internal network , application should connect database , allow users perform operations. what changes require current connection string? <connectionstrings> <add name="tpmscontext" connectionstring="metadata=res://*/tpmsmodel.csdl|res://*/tpmsmodel.ssdl|res://*/tpmsmodel.msl;provider=system.data.sqlclient;provider connection string=&quot;data source=test-dell;initial catalog=tpms;integrated security=true;multipleactiveresultsets=true;app=entityframework&quot;" providername="system.data.entityclient" /> </connectionstrings> an

What does this SQL statement "WHERE table_a.key (+)= table_b.key" means? -

this question has answer here: conversion ansi oracle join syntax 2 answers i reading through lecture notes of school, , come across slide: chapter: data integration , etl process slide title: duplicate values problem text: duplicate values invariably exist. eliminating can time consuming, although simple task perform. sql example: select ... table_a, table_b table_a.key (+)= table_b.key union select ... table_a, table_b table_a.key = table_b.key (+); specifically, not understand meaning of (+)= , last (+) . thanks helping! it means should stop using old-style joins condition in where clause , always use explicit join syntax. for particular query, equivalent full outer join : select ... table_a full outer join table_b on table_a.key = table_b.key;

javascript - Show/hide div on mouse over -

javascript: $( document ).ready(function() { function show(id) { document.getelementbyid(id).style.visibility = "visible"; } function hide(id) { document.getelementbyid(id).style.visibility = "hidden"; } }); and html: <table> <tr> <td id="one"> <div class="content" onmouseover="show('text')" onmouseout="hide('text')"> <h1>heading</h1> <p id="text">lorem ipsum</p> </div> </div> </td> </table> lorem ipsum supposed show when mouse hovers on content div, doesn't work. encased in table because there 3 other content divs make 2 2 grid. show not on global object, it's in closure, when html event handlers tries call it, doesn't exist. use css instead #text { vis

change menu behavior with purely CSS or JAVASCRIPT -

Image
need change menu pure css or javascript menu online store. there categories , subcategories collapsed within categories. want have sub-cats auto expanded when page loads user doesnt have click these expand. domain is: wwww.tackpal.com so took @ web site , when user clicks category, taken web page of specific category. thus, sub categories not included in home page. your first solution edit menu template in cms if allow it. a solution / hack below, changing template in cms better if add code, when user visits home page, script below tell browser make ajax calls categories have sub-categories. when each category page source returned, finds sub-category list , inserts them home page's menu respectively. to test code out. can go home page of web site. then, open console , paste in first functions , script inside onload function. //a simple function used make ajax call , run callback target page source argument when successful function getsubpagesource(url, s

Embedded Jetty doesn't recognise Spring MVC Security -

i developing spring application starts embedded jetty server. "deploys" spring mvc web app jetty server. all working multiple controllers, fail add spring security web app. use programmatic , annotation-based configuration , jetty server configured this: server server = new server(8080); server.setstopatshutdown(true); annotationconfigwebapplicationcontext context = new annotationconfigwebapplicationcontext(); context.setconfiglocation("com.mypackage.web"); context.setparent(maincontext); servletcontexthandler contexthandler = new servletcontexthandler(); contexthandler.seterrorhandler(null); contexthandler.setcontextpath("/"); dispatcherservlet dispatcherservlet = new dispatcherservlet(context); defaultservlet staticservlet = new defaultservlet(); contexthandler.addservlet(new servletholder(dispatcherservlet), "/"); contexthandler.addservlet(new servletholder("staticservlet", staticservlet), "/res"); contexthandler

android - Randomly getting D/OpenGLRenderer﹕ Flushing caches (mode 0) in lollipop -

i facing issue our app crashes randomly through checkout process, crash occurs on lollipop, other version works fine. there no information in log cat except fatal signal. issue cannot reproduced on emulator, occurs on device running lollipop. i refactored network calls , getting opengl renderer: flushing caches issue. happens after making volley requests. 06-22 18:48:29.876 24145-24216/com.pangea.android.debug d/openglrenderer﹕ flushing caches (mode 0) 06-22 18:48:29.877 24145-24157/com.pangea.android.debug a/libc﹕ fatal signal 11 (sigsegv), code 2, fault addr 0x12c7c000 in tid 24157 (finalizerdaemon) for network stack using volley , okhttp volley request simple request. are there suggestions on how more information on crash? here sample codes create connection: protected httpurlconnection createconnection(url url) throws ioexception { httpurlconnection connection = new okurlfactory(mclient).open(url); return connection; } privat

Minimizing / Uglifying with Google Realtime API -

if code registers custom realtime type: gapi.drive.realtime.custom.registertype(mytype, const.my_custom_type); // set collaborative fields: mytype.prototype.type = gapi.drive.realtime.custom.collaborativefield('type'); ... // set routine call on initialize: gapi.drive.realtime.custom.setinitializer(mytype, initializemytype); ...and initializes it: function initializemytype() { this.type = 0; }; when code uglified / compressed / minimized etc, above gets turned this: gapi.drive.realtime.custom.registertype(a, "my_type"); a.prototype.b = gapi.drive.realtime.custom.collaborativefield('type'); ... gapi.drive.realtime.custom.setinitializer(a, c); ... function c() {this.b = 0;}; ...so prototype property 'type' known code "b", though collaborativefield still called 'type'. my question is, matter? appears work, except when using realtime debugger console warnings asking if forgot register custom types. realtime debugger

ios - Swift NSCoding with NSValue -

isn't nsvalue nsobject ? why crashing on var coordinatesrawdata = nsvalue(mkcoordinate: coordinates.first!) if coordinatesrawdata != nil { // crashing here. have valid nsvalue object acoder.encodeobject(coordinatesrawdata, forkey: "coordinatesrawdata") } error log *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[nskeyedarchiver encodevalueofobjctype:at:]: archiver cannot encode structs' but if this var coordinatesrawdata = nsvalue() acoder.encodeobject(coordinatesrawdata, forkey: "coordinatesrawdata") there no crash - both nsvalues .. right ? note, other nscoding / decoding working fine. i didn't far did. crashed on these 2 lines: let loc = cllocationcoordinate2d(latitude: 20, longitude: 20) let val = nsvalue(mkcoordinate:loc) this tells me nsvalue(mkcoordinate:) broken. , it's not swift issue; same crash using same code translated o

user interface - How to set a Java Gui listener for unexpected program end -

i making personal planning program. utilize xml documents store user data , login data. not utilize server , accounts created in program localized computer stored on (in xml documents.) in login xml document, keep track of users logged in 1 user can't have 2 windows @ same time prevent conflicts data. feature runs smoothly , have no problem it. the thing want know if there way catch unexpected shut down of program (such task-manager close or forced close when shutting down computer) can "log" user off of xml document. otherwise user never able on after unexpected program close without going xml document , deleting username logged in list. it seems shutdown hook not work event queue java gui. this thread tried setting code shown , shutdown hook doesn't work me either. there suggestions ways of catching unexpected shutdown without shutdown hooks? this code: import java.awt.eventqueue; public class gui { private static controller controller; public stat

python - How to compare a numpy array with a scalar? -

this question may seem basic it's generating big mess. i try compare numpy.array scalar as: a=numpy.array([0.,1.,2.,-1.,-4.]) if a.any()>0.: print 'a:',a as expected get: a: [ 0. 1. 2. -1. -4.] now if same find negative values a=numpy.array([0.,1.,2.,-1.,-4.]) if a.any()<0.: print 'a:',a i don't means values greater 0. its because of a.any returns true (it returns true of 1 of elements meets condition , false in otherwise).and since true , 1 same objects in python (true==1) ,your condition interpreted 1<0 python, false! >>> true<0 false >>> a.any()<0. false and instead of need (a<0).any() >>> (a<0).any() true

multithreading - Hyrbid MPI / OpenMP -

i've been trying use openmpi openmp , when run try run 2 mpi processes , 4 threads on 1 machine, threads executed on same core @ 25% usage instead of on 4 separate cores. able fix using --enable-mpi-threads when building openmpi ; having issue being duel cpu machine. there 8 cores per processor, 2 processors in each server. if run 2 mpi processes , 8 threads fine long 2 processes started on separate processors, if try , 1 mpi process 16 threads reverts stacking every thread on 1 core. has had experience running openmpi , openmp together?

networkonmainthread - How do I fix android.os.NetworkOnMainThreadException? -

i got error while running android project rssreader. code: url url = new url(urltorssfeed); saxparserfactory factory = saxparserfactory.newinstance(); saxparser parser = factory.newsaxparser(); xmlreader xmlreader = parser.getxmlreader(); rsshandler thersshandler = new rsshandler(); xmlreader.setcontenthandler(thersshandler); inputsource = new inputsource(url.openstream()); xmlreader.parse(is); return thersshandler.getfeed(); and shows below error: android.os.networkonmainthreadexception how can fix issue? this exception thrown when application attempts perform networking operation on main thread. run code in asynctask : class retrievefeedtask extends asynctask<string, void, rssfeed> { private exception exception; protected rssfeed doinbackground(string... urls) { try { url url = new url(urls[0]); saxparserfactory factory = saxparserfactory.newinstance(); saxparser parser = factory.newsaxparser();

PHP DOM loadHTML() method unusual warning -

i had following code works fine on localhost: $document = new domdocument(); $document->loadhtml($p_result); $form = $document->getelementsbytagname('form')->item(0); // code continues using $form variable after same code updated on outside server, loadhtml() failed , issued warning. warning: domdocument::loadhtml() expects parameter 1 valid path, string given in path/name/to/script.php returned null instead of object code pretty gets fatal error. note contents of $p_result absolutely same on outside server , on localhost. but why displays kind of warning , why not work? doesn't loadhtml() expects argument 1 string in first place? why method expects parameter 1 valid path ? just make clear i'm not calling loadhtmlfile() , i'm calling loadhtml() . thanks. you're affected one of php bugs . issue present in php 5.6.8 , 5.6.9. have affected php version on server, , bug-free version on localhost. the bug forbids null

NSIS ifSilent not set -

i'm calling nsis compiled setup.exe file /s option, 'silent' internal variable set automatically. here .oninstsuccess function. want skip exec command if silent. reason exe invoked if pass in /s in setup.exe here oninstsuccess function function .oninstsuccess ifsilent +2 0 exec '"$instdir\tools\cobraconfigure.exe"' functionend works fine me. doing setsilent normal anywhere in script?

python - linebreak after a certain number of columns -

i want columns written out in single line after printing out given number of columns in 1 line. original files in form of a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 a3 b3 c3 d3 e3 ... if choose 3, output should following: a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 a3 b3 c3 ... or if choose 2: a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 a3 b3 c3 ... i thankful solution; awk, sed or bash preferred. open python... using gnu sed : $ cat file a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 a3 b3 c3 d3 e3 $sed 's/ /\n/3g' file a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 a3 b3 c3 d3 e3 $ gsed 's/ /\n/2g' file a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 a3 b3 c3 d3 e3

php - MYSQL select, set all negative values to zero -

let assume have mysql table called "test" in table have 2 columns "a", "b". want result of a-b, each row result negative, want set zero. so can write : select test.a - test.b myresult but don't know how set myresult 0 when myresult negative number. please select case when test.a - test.b >= 0 test.a - test.b else 0 end myresult test;

javascript - select by default previous date with jquery calendar -

i have datepicker codes below display me calendar, current date selected default, select previous date default instead (the day before today). have tried failed can me please? $(function() { $("#datepicker").datepicker({ dateformat: "yy-mm-dd" }).val() }); i resolved issue way $(function() { $("#datepicker").datepicker({ dateformat: "yy-mm-dd" }).val(); $("#datepicker").click(function() { date = new date(); date.setdate(date.getdate()-1); $( "#datepicker" ).datepicker( "setdate" , date); }); });

c# - I can not get MVVM to work -

i desperately trying implement mvvm , reason not working. using mvvm light on windows 8.1 store app. what doing wrong? followed 3 tutorials , nothing seems work.. i retrieve data webservice , part 100% works fine. observablecollection contains data. the rest of code looks this: viewmodellocator: public viewmodellocator() { servicelocator.setlocatorprovider(() => simpleioc.default); if (viewmodelbase.isindesignmodestatic) { // create design time view services , models simpleioc.default.register<idesigntimeweatherservicelayer, designtimeweatherservicelayer>(); } else { // create run time view services , models simpleioc.default.register<iweatherservicelayer, weatherservicelayer>(); } simpleioc.default.register<weatherviewmodel>(); } public weatherviewmodel weather { { return servicelocator.current.getinstance<weatherviewmodel>(); } } viewmodel: public class

c# - How does an MVC app know where to redirect the user when using the [Authorize] attribute? -

if setup mvc app authentication , use [authorize] tag, automatically redirect unauthenticated users login view. but how know page is login page? i've looked through example app, couldn't find obvious. edit i forgot mention i'm using mvc6. depending on template used create app, if in app_start folder, there file called startup.auth.cs . code in there sets authentication. code default mvc template: app.usecookieauthentication(new cookieauthenticationoptions { authenticationtype = defaultauthenticationtypes.applicationcookie, loginpath = new pathstring("/account/login"), provider = new cookieauthenticationprovider { // enables application validate security stamp when user logs in. // security feature used when change password or add //external login account. onvalidateidentity = securitystampvalidator .onvalidateidentity<applicationusermanager, applicationuser>(

go - Golang pipe output of subcommand real time -

i trying pipe output of command, no data seems read pipe until write end closed. want connect websocket streams status of command while being executed. problem while code prints messages line line, not print until program has finished executing. cmd := exec.command(my_script_location, args) // create pipe output of script // todo pipe stderr cmdreader, err := cmd.stdoutpipe() if err != nil { fmt.fprintln(os.stderr, "error creating stdoutpipe cmd", err) return } scanner := bufio.newscanner(cmdreader) go func() { scanner.scan() { fmt.printf("\t > %s\n", scanner.text()) } }() err = cmd.start() if err != nil { fmt.fprintln(os.stderr, "error starting cmd", err) return } err = cmd.wait() if err != nil { fmt.fprintln(os.stderr, "error waiting cmd", err) return } is there way can similar , have scanner read line line written pipe instead of after has been written? program takes 20 seconds run, , ther

XPath to identify a parent based on two related children -

using following example, trying create xpath identify id of apples branchid matches id of branch, treeid doesn't match branch's treeid. for instance: //growth[@type="apple"][branchid=//branch/@id]/@id - results granny empire gala and //growth[@type="apple"][treeid!=//branch/treeid]/@id - results granny empire gala but want query return: granny <xml> <growth type="apple" id="granny"> <branchid>abcd</branchid> <treeid>456</treeid> </growth> <growth type="apple" id="empire"> <branchid>abcd</branchid> <treeid>123</treeid> </growth> <growth type="apple" id="gala"> <branchid>efgh</branchid> <treeid>456</treeid> </growth> <growth type="flower" id="white"> <branchid>efgh</branchid> <treeid>123</tr

Selenium c# - Button click fails in Firefox...but only when using WebDriver -

here's dilemma... have button becomes un-clickable in browser window opened using webdriver. the button: <div class="ribbon-section"> <span class="section-title" data-bind="text: title">email</span> <div class="layout" data-bind="css: { 'vertical': isvertical ,layout:true}"> <div id="email-btn" class="ribbon-control ribbon-button ribbon-button-large" data-bind="attr: { id: id }, css: { disabled: disabled, 'ribbon-button-large': size() == 'large', 'ribbon-button-small': size() == 'small', 'ribbon-button-medium': size() == 'medium' }, click: onclick"> <img class="ribbon-icon ribbon-normal" data-bind="attr: { src: imgnormal }, visible: !disabled()" src="/_layouts/15/klscript/content/images/ribbon/normal/email-link.png" style=""> <img class="ribbon-icon ribbon-d

jmeter - How to capture redirect response header -

Image
i trying record simple login , logout flow .net application. after submit login credentials welcome page's url has large alpha numeric number. number required continue next steps. on fiddler have noticed login credential submission request results in 302 response , response contain a=129characterstring need in subsequent requests. on jmeter have added recording controller , on http(s) test script recorder have follow redirects , use keepalive checked (see below screenshot) i have recorded follow redirects unchecked , different options grouping , http sampler settings. but none of them able record/capture 302 response see on fiddler. instead login credential submission request returns 200 response, if login fails. it not if jmeter not recording redirect requests, further down scenario flow have redirect request captured. i can't 1 is/has faced problem. have suggestions on should doing differently 302 response? to this: record default options, redirec

Cross-platform text, image, video Chat for Android, iOS and Web using Firebase/Parse/PubNub -

i want develop cross platform chat application can use send text,url,image,location,video friends can on android/ios/web. i want chat realtime , , want make sure if user not using application, ' notification ' new incoming chat message. how using firebase or parse or pubnub? if not possible, can explore possibility of using them in combination. notes / problems: 1. firebase: has 'firechat' web, 'firechat/swiftchat' ios , 'chat' android. how synchronize them each other? pubnub has limitation of sending 32kb in 1 message. i read few places parse not support realtime chat? i tried searching different questions here already, did not find solution satisfy requirements (in bold). also, not asking opinion better here, hope question fits stackoverflow. thanks use pubnub realtime chat. there sdks platforms listed. images, send/receive data image url, while storing images using parse. as long use same credentials (your pub/sub keys

java - JSONObject error in servlet -

i've created servlet class receiving string android client. class send string servlet class. using rest api receive correctly string, when create jsonobject, throws java.lang.classnotfoundexception: net.sf.json.jsonobject. here code implemented: protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { printwriter out= response.getwriter(); arraylist<string> arrivo; arraylist<string> preference=new arraylist<string>(); stringbuffer jb = new stringbuffer(); string line = null; try { bufferedreader reader = request.getreader(); while ((line = reader.readline()) != null) jb.append(line); preference.add(line); response(response,

MySQL: Access denied for user 'root'@'localhost' Mac osx -

preface: im aware there many related questions. i've combed through find havent been able fix this i installed mysql mac (mac os x 10.9 (x86, 64-bit), dmg archive) when try use terminal blythes-macbook-air:bin blythe$ mysql -u root error 1045 (28000): access denied user 'root'@'localhost' (using password: no) blythes-macbook-air:bin blythe$ or... blythes-macbook-air:bin blythe$ mysql -u root -p enter password: error 1045 (28000): access denied user 'root'@'localhost' (using password: no) blythes-macbook-air:bin blythe$ any appreciated.

javascript - Get file name from stats object -

i use fs.stat getting information file, want file name stats object, did searching , didnt find help. i explain code now, maybe find solution, code: function index(response, lang) { temp.loadtpl('templates/' + lang + '/content.html', function (content) { fs.readdir('files/', function (err, files) { temp.loadtpl('templates/' + lang + '/files.html', function (data) { if (err) console.log(err); var i, fnames, len = files.length, filesnameshtml = ''; fnames = files; (i = 0; < len; i++) { fs.stat('files/' + files[i] , function (err, stats) { console.log(i); if (stats.isfile()) temp.write('type', 'file-o'); else temp.write('type', 'folder'); temp.write('fname', fnames[i]); filesnameshtml += temp.transtpl(data);

Why loop variable is not updated in python -

this code printing 1 2 4 5..my question why p not updated new array @ 3rd iteration p = [1, 2, [1, 2, 3], 4, 5] each in p: if type(each) == int: print each else: p = each actually precise when debugged code saw updating value of p each variable not reinitialised again. because of if type(each) == int: line. third element list ( [1, 2, 3] ) , not int, doesn't print anything. now comes changing p variable: p name object, not object itself. if p = each inside loop, doesn't affect original object you're looping through, changes name p local name, points different object. round of loop ends, loop continues business original object looping through. so, notice p = each doesn't change existing object (the p you're looping through), creates new local name p points value of each . what want this: p = [1, 2, [1, 2, 3], 4, 5] each in p: if isinstance(each, list): x in each: print x else: print

Writing PHP variable based on jQuery calculations and displaying predetermined value -

context: i'm trying make automatically generated list has different amount of items on each page. each item needs name , link, based on place on list. here's example 2 items problematic part: php variables: $item_link_1 = "link1"; $item_name_1 = "first item"; $item_link_2 = "link2"; $item_name_2 = "second item"; jquery: $("#items").each(function(i) { $(this).find("a").attr("href", "<?php echo $item_link_"+ ++i +";?>"); }); $("#items").each(function(i) { $(this).find("a").text("<?php echo $item_name_"+ ++i +";?>"); }); html output: <div id="items"> <a href="link1" class="item-1">first item</a> <a href="link2" class="item-2">second item</a> </div> problem: obviously, $item_name_"+ ++i +"; never work. need way add number gene

Which could be the cause of a variable not being printing in an HTML template called from another PHP class? -

i'm developing base of mvc project in php. i'm advancing view part, working expected in rendering of html template. here contents of files i'm coding make work: my_project_root/views/templates/humans_list.php <!doctype html> <html> <head> <meta charset="utf-8"> <title>humans list</title> </head> <body> <h1>humans list</h1> <ul> <?php foreach($humans $human) { ?> <li><?php echo $human ?></li> <?php } ?> </ul> </body> </html> my_project_root/views/humanview.php <?php /** * class representing view */ class humanview { /** @var array contains list of names */ var $humans; /** * renders view in html * @return void */ public function render() { // proccess names follow constraints $this->pr

Server, webserver, php, mysql benchmarking -

i've been working on enterprise application user base of 1000. there 20-30 users @ given time using tool , @ peak times around 100 users. current configuration: lamp stack mysql 5.5.29, php 5.3.20 - codeigniter framework, front-end action script flex framework intel xeon 32 cores @ 2.9 ghz 161 gb of ram 2 tb hard drive linux fedora 16 os i have received requirement granting access different departments add 5000 more users. i've been front-end developer last 2 years doing back-end development well. however, not have enough experiencing in load balancing, hardware configuration can support etc. currently, building application ground trying optimize areas bottlenecks , add features don't experience issues new additions. first, there phpmyadmin type dashboards can installed on linux give me nice gui showing cpu load, memory usage, harddrive read/writes etc. ? second, there suggestions people experience in area on can optimize server? third, server configur

android - What if request is sent and response ia not recieved -

i making android application have scenerio have got data . there field called sync becomes true when response server. request sent server , data stored on server dont response , nxt time data sync false sent server resulting in duplication.. app used in multiple devices cant have local database field primary key on server. how can handle thing app side. i using sugar orm database , retrofit rest api any appriciated. you should waiting confirmation of receipt of data before end task, if no response received can either try again or cancel sending. sending data , not awaiting response not ideal!

ios - Swift - How to change background color when a certain amount of points are gained -

i have been working on game when player gets 10 points background change color put in string, same happen 20 points, 30 points , on. question how can make background fade different colors when player gets on 10 points /20 points /30 points. don't want colors random want put own color codes/hex values, don't want colors change when button pressed. want change when player gets on amount of points. a example of game " don't touch spikes " every 5 points gain background fades different one. note: made game in gamescene , not using gameviewcontroller made project game file so: import foundation import spritekit class gamescene: skscene, skphysicscontactdelegate { var movingground: ppmovingground! var hero: pphero! var wallgen: ppwallgen! var isstarted = false var isgameover = false override func didmovetoview(view: skview) { //backgroundcolor = uicolor.greencolor() backgroundcolor = uicolor(red: 223/255.0, green: 86/255.0, blue: 94/255.0, alpha:

mysql - Memory error while importing IMDb files using IMDbPY script -

while importing imdb files mysql 5 using myisam storage engine getting following memory error: traceback (most recent call last): file "/usr/local/bin/imdbpy2sql.py", line 3072, in <module> run() file "/usr/local/bin/imdbpy2sql.py", line 2937, in run readmovielist() file "/usr/local/bin/imdbpy2sql.py", line 1531, in readmovielist mid = cache_mid.addunique(title, yeardata) file "/usr/local/bin/imdbpy2sql.py", line 1135, in addunique else: return self.add(key, miscdata) file "/usr/local/bin/imdbpy2sql.py", line 1010, in add self[key] = c file "/usr/local/bin/imdbpy2sql.py", line 922, in __setitem__ dict.__setitem__(self, key, counter) memoryerror this on ubuntu 14.0.4 ec2 instance on aws 1gb of memory. first tried using command: imdbpy2sql.py --mysql-force-myisam -d /home/ubuntu/imdb-files/ -u mysql://admin:password@localhost/imdb and also: imdbpy2sql.py --mysql-force-myis

mysql - Trouble with having clause -

my tables, borrower: +----------+---------+ | name | loan_id | +----------+---------+ | adams | l16 | | curry | l93 | | hayes | l15 | | jackson | l14 | | jones | l17 | | smith | l11 | | smith | l23 | | williams | l17 | +----------+---------+ loan: +---------+-------------+--------+ | loan_id | branch_name | amount | +---------+-------------+--------+ | l11 | round hill | 900 | | l14 | downtown | 1500 | | l15 | perryridge | 1500 | | l16 | perryridge | 1300 | | l17 | downtown | 1000 | | l23 | redwood | 2000 | | l93 | mianus | 500 | +---------+-------------+--------+ i wish find maximum loan taken customer. i partially successful query: select name, max(amount) loan, borrower borrower.loan_id=loan.loan_id; result: +-------+-------------+ | name | max(amount) | +-------+-------------+ | adams | 2000 | +-------+-------------+ but taking name f

bash - Checking empty file returns as non-empty -

when i'm using 1 of comparison operators/functions on empty file, bash returns file not empty. there must newline character or something, it's making these tests pass when shouldn't. so there way test if file has character? i've tried [ -s file.txt ] , [ -n file.txt] , , brethren, return file.txt not empty. i've tried doing cat , assigning variable, variable read not empty reason. any other way see if file empty? edit here's i've done. cleared file (ctrl+a , delete). made sure when tried moving cursor cursor doesn't move. did if [ -n filename ] ; echo "not empty"; fi; returns not empty the test non-empty file is: [ -s file.txt ] the test empty file, therefore, is: [ ! -s file.txt ] or can use bash's ! operator outside test command: if ! [ -s file.txt ] note these operations consider file 'empty' if contains 0 bytes. if bigger that, not empty definition. if want inspect contents , ignore file co

camera - Call a Sony 5100 as Client with SDK? -

i want develop automated photobot. core of development written in php , js webapp. sdk requires http , json both supported webapp in wrong way. need call multiple camera , app controled tablet or computer not possible connect tablet , camera directly. is possible or not?

angularjs - How to inherit from base provider (not the provider factory)? -

say have base provider: angular.module('app').provider('baseclient', function () { this.setsomething = function (something) { // store `something` somewhere return this; }; }); and these 2 other sub-providers: angular.module('app').provider('clienta', function () { this.$get = function () { return { foo: function () { console.log('foo', /* read `something`, needs output 'aaa' */); } } }; }); angular.module('app').provider('clientb', function () { this.$get = function () { return { bar: function () { console.log('bar', /* read `something`, needs output 'bbb' */); } } }; }); angular.module('app').config(function (clientaprovider, clientbprovider) { clientaprovider.setsomething('aaa'); clientbprovider.setsomething('bbb

python 2.7 - combine stripping white space and html tags -

i'm looking possibility strip html tags , white space parsed text using beautiful soup. problem can't combine these two. here whole script: # -*- coding: utf-8 -*- urllib2 import urlopen bs4 import beautifulsoup bs word = "drop" url = ('http://civil.ge/eng/category.php?id=10') soup = bs(urlopen(url).read()) titz = soup.find("div", {"class": "archtype_category_block"}) t in titz.find_all('div', {'class': 'archive_type_article_title'}): if word in t.encode('utf-8').strip(): print t.prettify() the result prettify() is: <div class="archive_type_article_title"> prosecutors drop objection release of ex-mod officials pretrial detention </div> and get_text() clean text lots of white space before , after it. solutions this? thanks! i used python 3 , wasn't able reproduce spacing problem. maybe answer! i change print t.prettify()