Posts

Showing posts from July, 2011

python - Values from a class instance's attribute being added to a different instance of the same class -

this question has answer here: “least astonishment” , mutable default argument 29 answers i'm parsing pdfs extract table data using pdftable class. when create class instance create class instance seems first class instance file_1.cells being prepended second class instance file_2.cells. cannot figure out why happening don't think i'm creating class variables instance variables. reason data set_cells persisted when class instance instantiated. happening? from pdfminer.pdfdocument import pdfdocument pdfminer.pdfpage import pdfpage pdfminer.pdfparser import pdfparser pdfminer.pdfinterp import pdfresourcemanager, pdfpageinterpreter pdfminer.converter import pdfpageaggregator pdfminer.layout import laparams, lttextbox, lttextboxhorizontal, lttextlinehorizontal tabulate import tabulate utils import clean_string collections import namedtuple class pdftable(...

java - Accessing nested objects in JSP View -

i have list of objects. object of following class: @entity @table(name="user") public class user { @id @column(name = "userid" ,unique=true, nullable=false) private string id; @column(name="firstname") private string firstname; @column(name="lastname") private string lastname; @column(name="title") private string title; @embedded private address address; @manytomany @jointable(name="phone_user", joincolumns={@joincolumn(name="userid")}, inversejoincolumns={@joincolumn(name="phoneid")}) private list<phone> phones; public string getid() { return id; } public void setid(string id) { this.id = id; } public string getfirstname() { return firstname; } public void setfirstname(string firstname) { this.firstname = firstname; } public string getlastname() { return las...

javascript - Chrome does not show my website -

website not loading javascript on chrome not know why, while mozilla shows properly. not know whats wrong. website main function 1. geo-location of client (first lat long , find nearest city) 2. weather data openweathermap api 3. display in website. link website // taken , modifed https://roessland.com/blog/free-code-camp-3-a-random-quote-machine/ $(document).ready(function () { // geo if (navigator.geolocation) { navigator.geolocation.getcurrentposition(function(position) { var lat_lat = position.coords.latitude; var lon_lon = position.coords.longitude; //google maps var geocoder = new google.maps.geocoder(); var latitude = lat_lat; var longitude = lon_lon; var latlng = new google.maps.latlng(latitude,longitude); geocoder.geocode({ latlng: latlng }, function(responses) { if (responses && responses.length > 0) { // starting weather api var add...

python - Adding car make model year country to dictionary -

this function supposed loop through dictionary(database): { data_base = { "mercedes": [("e-class", 1970, "classic" , "germany"),("clk", 2000, "sport" , "poland")] "fiat": [("uno" , 1980, "coupe" , "italy")] "jaguar" : [("s-type", 2000, "classic", "england"),("x-type", 2005,"luxury", "england")] } function accepts database (above example), updates other information it. if car in , attributes match, no duplication. also, sort asciibetically car model. function updates only, no returns. functionx (data_base,make,model,year,style,country): key,value in data_base.items(): if key == make , value[0] != model: # condition ensure update not duplicate database[key].extend((model,year,style,country)): when looping on data_base.items() , value not think is. list of models a...

gradle - Strange javafx app look on android -

Image
i've got problem javafx ported app on android. after first launch looks that: but when go home screen , rejoin application looks should be. build.gradle: buildscript { repositories { mavencentral() maven { url "https://plugins.gradle.org/m2/" url 'http://nexus.gluonhq.com/nexus/content/repositories/releases' } } dependencies { classpath 'org.javafxports:jfxmobile-plugin:1.1.1' } } apply plugin: 'org.javafxports.jfxmobile' repositories { mavencentral() maven { url 'http://nexus.gluonhq.com/nexus/content/repositories/releases' } } mainclassname = 'pl.siemaeniu500.wszywka.main.main' ext.charm_down_version = "2.0.1" dependencies { compile "com.gluonhq:charm-down-common:2.0.1" //compile 'com.gluonhq:charm-glisten:3.0.0' compile 'com.gluonhq:charm:2.1.1' compile files('d:/android/sdk/platf...

c++ - compiler seems cannot find boost/shared_ptr.hpp -

i using mac os 10.11.6 i trying install opengv on mac. part of dependencies needed build opensfm library. so, did is: brew install homebrew/science/ceres-solver brew install boost-python brew install eigen git clone https://github.com/paulinus/opengv.git cd opengv mkdir build cd build cmake .. -dbuild_tests=off -dbuild_python=on make install but got error: in file included /users/hilman_dayo/opengv/src/relative_pose/modules/main.cpp:47: /users/hilman_dayo/opengv/include/opengv/math/sturm.hpp:43:10: fatal error: 'boost/shared_ptr.hpp' file not found #include <boost/shared_ptr.hpp> ^ 1 error generated. make[2]: *** [cmakefiles/opengv.dir/src/relative_pose/modules/main.o] error 1 make[1]: *** [cmakefiles/opengv.dir/all] error 2 make: *** [all] error 2 how can solve this? checked, , file there @ /usr/local/include/boost/shared_ptr.hpp . if ever needed, output during cmake : -- c compiler identification appleclang 7.3.0.7030031 -- cxx compiler iden...

css3 - Is it possible to select nth-child(x) but only if it is not the last child? -

i want select third element within ul , if not last element in ul . sample 1: <ul> <li>home</li> <li>cat 1</li> <li>subcat 1</li> <li>product</li> </ul> sample 2: <ul> <li>home</li> <li>cat 1</li> <li>product</li> </ul> i want single css selector, which, sample 1, selects li "subcat 1", , sample 2, not select anything. ul > li:nth-child(3) work sample 1, match 'product' li in sample 2, don't want do. in case i'm not able modify html. you use :nth-child :not achieve need. here example. ul li:nth-child(3):not(:last-child) { color: red; } <ul class="sample1"> <li>home</li> <li>cat 1</li> <li>subcat 1</li> <li>product</li> </ul> <ul class="sample2"> <li>home</li> <li>cat 1...

android - Button on ToolBar won't open the Navigation Drawer -

i have created base activity contains navigation drawer. the drawer open on slide, never through navigation button on toolbar. i've been stuck on quite while, , had working prior creating base class , don't think i've changed logically. i know question has been asked before, i've gone through other similar posts , have not been able solve it. thanks in advance! public class draweractivity extends appcompatactivity implements navigationview.onnavigationitemselectedlistener { protected drawerlayout drawerlayout; private actionbardrawertoggle toggle; private toolbar toolbar; private navigationview navigationview; private boolean enabletoolbar; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); enabletoolbar = true; } @override public void setcontentview(int layoutresid){ super.setcontentview(r.layout.activity_drawer); settoolbar(); ...

rest - what is the best way to get the maximum tps server can support -

i have 20 rest api's build using jersey , apache client.i want know max tps server can withstand, using jmeter tool.what best way achieve such kind of performance scenario goal. first of build test plan. believe should have @ least 20 http request samplers cover endpoints , http header manager send correct content-type header. see testing soap/rest web services using jmeter article details. once have test plan - run 1-2 virtual users check supposed doing. inspect requests , responses details using view results tree listener. modify requests if needed. configure thread group (s) load increased gradually , i.e. provide reasonable ramp-up time once you're happy test behaviour disable view results tree listener , run test in non-gui mode analyze results using i.e. html reporting dashboard . value interests lives in hits per second graph

database - Android Studio, SQLite, No Such Column Issue -

this question has answer here: when sqliteopenhelper oncreate() / onupgrade() run? 10 answers below error i'm getting: java.lang.runtimeexception: unable start activity componentinfo{groceryproject.jacob.com.recipelist/groceryproject.jacob.com.recipelist.recipelist}: android.database.sqlite.sqliteexception: no such column: prep_time (code 1): , while compiling: select id, recipe_name, servings, prep_time, cook_time, ingredients, directions recipes id=? this after i've uninstalled app , cleared data make sure don't have previous database messing me up. below code database class: package groceryproject.jacob.com.recipelist; /** * created jacob on 11/12/2016. */ import java.util.arraylist; import java.util.arrays; import java.util.list; import android.content.contentvalues; import android.content.context; import android.d...

algorithm - Find longest alternating string of 1's and 0's -

i learning bitwise operations in assembly. in terms of bitwise operations, quite forward find longest string of 0's or 1's, how find longest string of alternating 1's , 0's. i thought similar first 2 in sense need right shift , appropriate operation, , repeat until had 0's, couldn't figure out solution. ideas on do? thanks! edit some examples: 101101010001 has string of 6 alternating 1s , 0s. number 1010 has string of 4 consecutive 1s , 0s. don't care alternating strings of 0's , 1's, 0101, 2 because of 10 in middle of it the architecture i'm using arm a9 processor here tried .text .global _start _start: mov r5, #0//store final result mov r6, #0 mov r2 , #0 mov r7, #0 ldr r3 , =test_num ones: ldr r1, [r3] //load data word r1 mov r0, #0 // r0 hold result loop: cmp r1, #0 //loop until data contains no more ones beq next lsr r2, r1, #1 //perform shift, followed , xor r1, r1, r2 add r0, #1 // c...

function - PLC SFC loop: Can there be more than one token in the loop? -

i working on plc program using m3 soft crozet millenium 3, question sfc/grafcet functions generally. can sfc loop run more 1 token @ once? way of asking question is, can there more 1 step active @ time in single loop, example, when initial step activated, , activated again before loop completes? sfcs (black token) petri nets . state can enabled, in parallel other states, in principle. the trick cause state enabled way; isn't easy arrange happen. imagine have states sf1, sf2 ... sfn. 1 can arrange sf1 enable sf2 , sf3 (using horizontalbar symbol, called fork in more general literature on parallelism). rather typical. sf2 can enable sf4 enables sf5 ... enabling sfk. can have sfk enable sf1, there's cycle in sequential function net. if can have sf1 enable sf2 enable ... sfk, surely build sfc sf1 enables sf3 , sf2, enables sf1. , if that, can have sf1 enable sf1 , sf3 . sf1 manufactures state-enables repeatedly, each triggering sf3. i can petri nets, an...

bash - scp, inconsistency for file structure preservation -

my task: collect log files several servers. server file structure: "/remote/path/dir/sub-dirs/files.log", same on servers. (all servers have same set of "sub-dirs", absence happen, , of course "files.log" names differ) local file structure: "/local/path/logs" after copy have "/local/path/logs/dir/sub-dirs/files.log" method (in whlile loop servers): scp -r $servers:/remote/path/dir /local/path/logs problem: reasons don't understand, first scp command ignores "dir" folder, "/local/path/logs/sub-dirs/files.log" following scp commands gives me intended "/local/path/logs/dir/sub-dirs/files.log" why happening , how should fix/get around it? thanks! why happening [...] in command scp -r path/to/source dest : if dest doesn't exist, dest directory created, , path/to/source/* copied it. example if have path/to/source/x dest/x created. if dest directory, dest/source...

apache - How to gzip file in place replacement Java -

i have .xlsx file (or file) gzip. able gzip file have problem of trying in place. meaning replace original file gzipped version of file. here code: public static void main(string[] args) throws ioexception { file file = new file("test.xlsx"); file gfile = new file(file.getabsolutepath()+".gz"); if(!file.exists()) { system.err.println("input tax file did not exist!"); } fileinputstream fis = new fileinputstream(file); fileoutputstream fos = new fileoutputstream(gfile); gzipoutputstream gos = new gzipoutputstream(fos); gzipreplace(fis, gos); } private static void gzipreplace(inputstream is, outputstream os) { int onebyte; try { while( (onebyte = is.read()) != -1 ) { os.write(onebyte); } os.close(); is.close(); } catch (exception e){ system.err.println(e.getstacktrace()); } } how can in-place replacement of uncompressed file gzipped one?...

plot - Plotting multiple barplots against months using Base R -

i need plotting temperature data each day of year. have data in dataset of following form: weather(month, day, low, high, recordlow, recordhigh) m d l h rl rh 1 1 44 60 35 72 1 2 32 63 31 76 ... month goes 1 12, , day goes 1 whatever last day of particular month is. for each day (on x axis), want 2 bars, overlayed on each other, 1 extending low high , other extending recordlow recordhigh . don't know function of base r use (no ggplot) , how use it. want them drawn in same graph same axes.

networking - [Android]: prevent USB device from sleeping when Android device sleeps -

we making sip-related solution , requested compose app on customized android pad(4.4.*). unluckily, pad 3rd party , accordingly hardly further jobs on framework or driver...... on pad, lan port designed on usb , plan access network via lan. besides, no power key populated on cover..... now question is: since pad sleeps, lan connection stopped soon. understand it's normal behavior android conducts. trying acquire known wake lock(partial or wifi lock) stop usb controller sleeping ... but, currently, little progress. there usb-related wake lock, wifi lock ? i have solved problem perspective of hw .... not sure solution meaningful current topic. think sharing idea major goal of forum running. a mos component added along power line controlling screen. manipulate connection/disconnection sending command mcu.... based on experiences , hard extend functionality on poor quality of pad ... poor post-sales support....... hope it's helpful you.

mysqli - Updating an image and text at the same time in Php and Mysql -

Image
users can add, edit , delete content on web page. people can edit text , image upload. however, image not display if edit text. when edit text not image, white box displayed image should appear. on other hand, image appear if edit photo nothing else. text update when try edit both image , text together.i want user able edit text , image can on profile page. once text , image edited, want old image deleted out of folder. how can edit image , text together? not getting errors. please help, i'm new php , mysql. thank time. code: <?php include "connection.php"; $vid=""; $vname=""; $vprice=""; if(isset($_post["button_add"])){ $product_name = $_post["product_name"]; $product_price = $_post["product_price"]; $product_picture = $_files["product_picture"]["name"]; $qry = mysqli_query($con, "insert table_product values('','$product_name','$product_price',...

nvEncodeAPI.dll refrence could not be added to my C# project -

i have c# project cloudgaming testbed. wanna add nvencodeapi.dll project, error has been occured : a refrence '*.dll' not added. please make sure file accessible, , valid assembly or com component. i searched in stack , there solutions didnt work me. know why dll might not import or how around it? 1) right click on project , choose add reference. 2) choose browse tab , go find assembly 3) after adding assembly include reference in class or form ever going use using myownclass;

android - How to turn on flash on camera2 api correctly? -

i use standard google sample canera2api and here try tenr on control_ae_mode_on_always_flash how doing it, changed line private void capturestillpicture() { try { final activity activity = getactivity(); if (null == activity || null == mcameradevice) { return; } // capturerequest.builder use take picture. final capturerequest.builder capturebuilder = mcameradevice.createcapturerequest(cameradevice.template_still_capture); capturebuilder.addtarget(mimagereader.getsurface()); // use same ae , af modes preview. capturebuilder.set(capturerequest.control_af_mode, capturerequest.control_af_mode_continuous_picture); ---->>>> ---- // setautoflash(capturebuilder); ---->>>> ++++ capturebuilder.set(capturerequest.control_ae_mode, camerametadata.control_ae_mode_on_always_flash); // orientation int rotation = ...

Error : Vagrant Up Ubuntu -

on running vagrant command getting below error message, although virtualization option enable in bios. error message : there error while executing vboxmanage , cli used vagrant controlling virtualbox. command , stderr shown below. command: ["startvm", "fd5f5cf9-6d7c-48dc-bcdf-94e4f5bd85d0", "--type", "headless"] stderr: vboxmanage: error: vt-x not available (verr_vmx_no_vmx) vboxmanage: error: details: code ns_error_failure (0x80004005), component consolewrap, interface iconsole

javascript - Angular 1.5.x - Directive not firing -

i'm practicing working directives, , have been banging head on while now. the code - module angular.module('wbheader', []); controller angular.module('wbheader').controller('wbheadercontroller', ['$scope', function() { }]); directive angular.module('wbheader').directive('wbheader', function() { return { transclude: true, restrict: 'aec', scope: { }, controller: 'wbheadercontroller', templateurl: '/modules/wb-header/header.html' }; }); plunker - https://plnkr.co/edit/ourcm1mgb5k0wn8u2ke9?p=preview i feel i'm overlooking simply, not sure! yes simple,in code ng-app should renamed as change from <html ng-app="wbapp"> to <html ng-app="wbheader"> demo

msp430 - How to enable nested interrupts in msp430g2553? -

i want enable nested interrupts on msp430 want use uart in isr of timer. appreciated. whenever msp430 microcontroller start execute interrupt handler function, first thing disable global "interrupts enabled" flag, bit in status register r2 . prohibits interrupt nesting default. to work around this, enable interrupt setting register flag 1 @ start of interrupt handler functions. simplify syntax, there's eint instruction this: asm("eint"); typically there compiler-specific macros emnabe let avoid writing assembly code. should work both gcc , iar: __enable_interrupt(); (please, not abuse interrupt nesting. in cases there's absolutely no need it. it's better idea change design go it.)

ios - How to change a map annotation location by tapping and still be able to pan? (gif included) -

Image
i have been able add annotation , change it's location, how change it's location tapping, , @ same time still able pan around in map? (please have @ gif, shows needed). solved, hope people find useful var map1 = mkmapview() var pointannotation:mkpointannotation = mkpointannotation() func handletap(gesturereconizer: uitapgesturerecognizer) { let location = gesturereconizer.locationinview(map1) let coordinate = map1.convertpoint(location,tocoordinatefromview: map1) pointannotation.coordinate = coordinate } override func viewdidappear(animated: bool) { map1 = self.scrollview.viewwithtag(801) as! mkmapview map1.showsuserlocation = true map1.tintcolor = uicolor.bluecolor() let initiallocation = cllocation(latitude: ram.currentlat, longitude: ram.currentlon ) self.centermaponlocation(initiallocation, map: map1, regionradius: 707) var coordinates : cllocationcoordinate2d = cllocationcoordinate2d(latitude: ram.currentlat, longitud...

javascript - How to add input data into hidden input field -

i have input field user enter desired input , data copied hidden input field problem occurs when new data replace old data this copy data $('#ap').val(json.stringify(data)); this input field <input type="hidden" name="apcount" id="ap" value=""> now if add data 'hello' added hidden input value looks <input type="hidden" name="apcount" id="ap" value="hello"> now if again enter 'how you' replaces old data new.. i want keep both data 1 - [{"ratio":"1","size":"s","quantity":"83"},{"ratio":"2","size":"m","quantity":"166"}] 2 - [{"ratio":"3","size":"m","quantity":"93"},{"ratio":"2","size":"m","quantity":"136"}] these ...

How to serialize a c# object to Json with namespace. If it is possible some how -

base class contains property hide new property in sub class of different type. when deserializing, facing issue. cann't change name of property in c# or json can add namespace if possible. namespace xyz { public class { public icollection<xyz.organizationattribute> organizationattributes { get; set; } } } namespace pqr { public class ax : { public new icollection<pqr.organizationattribute> organizationattributes { get; set; } } } update: jsonconvert.serializeobject( axobject, new jsonserializersettings { preservereferenceshandling = preservereferenceshandling.objects, referenceloophandling = referenceloophandling.serialize, metadatapropertyhandling = metadatapropertyhandling.readahead, defaultvaluehandling = defaultvaluehandling.ignore } ); jsonconvert.deserializeobject<a>( "axjsonstring", new jsonserializersettings { metadatapropertyhandling =...

Scala flatMap over getConstructors method (reflection) -

i'm trying iterate on constructors of given class using reflection. problem need each element , return ones matches predicate. following code throws exception classof[string].getconstructors.flatmap(x=> dosomething(x); if(predicate(x)) some(x) else none) the exception: argument expression's type not compatible formal parameter type; found : java.lang.reflect.constructor[_] => iterable[java.lang.reflect.constructor[?0(in value $anonfun)]] forsome { type ?0(in value $anonfun) } required: java.lang.reflect.constructor[_] => scala.collection.gentraversableonce[?b] i'm not sure if can done comprehension because need call on each element(not ones holds predicate): for{ x <- c.getconsturctors //dosomething(x) ?? if predicate(x) }yield{ //dosomething(x) - ones holds predicate x } calling c.getmethods works i'm guessing has return type(array[methods] vs array[constructor[_]])...? answer : flatmap - alexey romanov answer ...

django - Celery group multiple tasks in one design -

i getting familiar celery , have question. setup django-redis-celery lets take example of task sending email: tasks @task def send_email(message): mailserver.sendonemessage(message) views class newaccount(apiview): def post(self, request, format=none): send_email.delay(request.data.email) this works perfectly, django sends messages redis , picked celery execute task. want improve system celery picks messages redis @ intervals , executes single task multiple messages. because, connecting email server slow , sending multiple messages single request result in faster process. i want work: tasks @task def send_emails(messages): mailserver.sendmultiplemessages(messages) thoughts? since using redis cache (django-redis) implemented following workflow: step 1. create task adds new emails cache @shared_task() def add_email(user_id): cache.set("email#{}".format(user_id), none, timeout=none) step 2. create periodic task runs every se...

xidel - How to have always the same number of results in xpath even if some tags are not present? -

i try crawl data website. target sites not details given. example 1 profile has name, birthday given , other 1 name . i try grasp tags xidel , xpath work charm, when there wouldnt few tags missing (because detail not present) so ask solution can fill these notexistant tags empty 1 end set of data same length. i convert data csv afterwards , when tag missing, data 1 column off. my xidel requests looks this: xidel 'http://www.icaec.org/users/index' -f '//section[@id="content-area"]//article//h5/a' -e 'concat("`",join(//div[@id="members-info"]/(h5 | span) | //div[@class="row pic-professionsal-details"]/div[2]/div | //div[@class="row pic-professionsal-details"]/following-sibling::div/div[1]//div,"`;`"),"`")' | sed "s/\"/\\\"/g" | sed "s/\`/\"/g" >> icaec.csv the xpath expression in question one: 'concat("`",join(//div[@id=...