Posts

Showing posts from September, 2015

javascript - How to bind ViewModel Store to View? -

i'm pretty new ext js , trying embed multiselect inside panel . the viewmodel has stores property can see here: ext.define('test.view.controls.search.searchfiltermodel', { extend: 'ext.app.viewmodel', alias: 'viewmodel.filter', data: { title: '' }, stores: { test: { fields: [ 'id', 'name' ], proxy: { type: 'ajax', url: 'api/test', reader: 'array' }, autoload: true } } }); i bind in view this: viewmodel: { type: 'filter' }, layout: 'fit', border: 1, plain: true, scrollable: 'y', layout: 'fit', bind: { title: '{title}', }, items: { xtype: 'multiselect', scrollable: false, allowblank: true, ddreorder: true, bind: { store: '{test}' }, valuefield: 'id', displayfield: 'name' } ...

Sort a complex associative array in PHP -

this question has answer here: php sort array subarray value 5 answers i have associative array in php like: $newarray1 = array ( [producta] => array ( [link] => http://sanjosespartan.com/blog/products/agile-java-development/ [visitcount] => 4 ) [productd] => array ( [link] => http://sanjosespartan.com/blog/products/intro-to-go/ [visitcount] => 1 ) [productg] => array ( [link] => http://sanjosespartan.com/blog/products/node-js-for-developers/ [visitcount] => 1 ) [productb] => array ( [link] => http://sanjosespartan.com/blog/products/beginning-mysql/ [visitcount] => 1 ) [productc] => array ( [link] => http://sanjosespartan.com/blog/products/computer-networks/ [visitcount] => 1 ) ...

OSX App: Get max resolution of the user's display (Swift) -

i'm trying max resolution of user's display-- not current resolution, maximum display supports. know can current resolution this need maximum (ie: on mbp 13inch resolution 2560x1600). i know can in terminal using this , avoid trying hack-y in terminal, , instead swift. suggestions on how can this? thanks. you need use quartz display services. first, list of displays, cggetactivedisplaylist . then, each display, use cgdisplaycopyalldisplaymodes . iterate on array of modes, using cgdisplaymodegetwidth , cgdisplaymodegetheight figure out highest resolution.

ios - Can someone show me a more efficient way to handle multiple text field delegates? -

i'm working on project user have 5 text fields input data. "calculate" button calculates required computations based on user input. solution create 5 iboutlet uitextfields , connect them in xib file. each text field handle events based on input following code. can show me efficient way solve problem? - (bool)textfieldshouldreturn:(uitextfield *)textfield{ if(textfield == self.numberofnightstf){ self.numberofnights = [self.numberofnightstf.text intvalue]; nslog(@"the number of nights set %.d days", self.numberofnights); } else if(textfield == self.nightlychargetf){ self.nightchargecost = [self.nightlychargetf.text floatvalue]; nslog(@"the cost of charge per night set %.2f$", self.nightchargecost); } else if(textfield == self.roomservicetf){ self.roomservicecost = [self.roomservicetf.text floatvalue]; nslog(@"the additional room service cost set %.2f$", self.roomservicecost); } else if(textfield == self.telep...

php - Best way to save orders in array by date -

my database is: table: orders, columns: id (int), order_status(varchar), time (timestamp), price (decimal); i want receive sum of orders prices each day in 1 array. best way that? i've used this, lasts 24h, 48h, 72h... orders , not each day (from 00:00 until 23:59). $timeback = time() - 86400; $time = time(); $month = array(); for($i = 0; $i < 30; $i++){ //query example $month[$i] = select orders `order_status` = 'completed' , `time` between {$timeback} , {$time} order `id` asc"); $timeback = $timeback - 86400; $time = $time - 86400; }

python - Selenium action chains to click inside silverlight plugin object in a page -

currently trying click button inside of silverlight web app, , yes know beforehand silverlight not supported think @ least worth try action chain module. here best come until now: profile = firefoxprofile() profile.set_preference('plugin.default.state', 2) driver = webdriver.firefox(profile) driver.get('http://www.trypython.org') time.sleep(8) sldiv = driver.find_element_by_xpath('//*[@id="silverlightcontrolhost"]') builder = actionchains(driver) builder.move_to_element_with_offset(sldiv, 372, 44) builder.click() it not clicking, or @ least not in expected coordinates (where button is). away this? if so, able type text after clicking inside textbox? do not mention silverlight-selenium outdated project

c# - How can I set a max. ExpirationDate TimeSpan on a azure Media Service Locator? -

i mistakenly set wrong time several locator url's connected uploaded videos. trying correct setting locator maxvalue ensure not go away, several others have already. tried following, context.locators.create(locatortype.ondemandorigin, outputasset, accesspermissions.read, timespan.maxvalue), , resulted in "the added or subtracted value results in un-representable datetime". maximum timespan can possibly set if not want locators expire? you set 100 years expiryon time, should sufficient.

python - How can I make the value of a user's input into a variable with a usable value? -

from turtle import* branch_width=4 grass_color=input("would grass snowy, dead, or healthy? ") sky_color=input("would morning, afternoon, or evening? ") morning="cadetblue" afternoon="cornflowerblue" evening="royalblue" snowy="snow" dead="wheat" healthy="darkgreen" every time try use input color(sky_color) , user's input not translated morning="cadetblue" , etc, returns error. how fix this? need make user type in color? you have confused variable names , character strings. set variable called morning string "cadetblue". has nothing input string "morning". you have set explicitly. a dictionary here: interpret_color = { "morning": "cadetblue", "afternoon": "cornflowerblue", "evening": "royalblue", "snowy": "snow", "dead": "wheat", ...

jquery - Split input name attribute in nested rails form with javascript -

first off, having trouble describing issue. apologize in advanced if not seeing existing answer online. how can split string array each entry text within each set of square brackets. here string: plan_year[benefit_groups_attributes][0][relationship_benefits_attributes][1][premium_pct] what need store value in second set of square brackets. in example [0]. .split hasn't given me result wanted, , think because doing .split(/[[]]/); should expect work? var s = 'plan_year[benefit_groups_attributes][0][relationship_benefits_attributes][1][premium_pct]'; s.match(/\[.*?\]/g)[1]; # "[0]"

linux - Is there a way to use perf tracepoints without running as root? -

summary: i want able profile event sched:sched_stat_sleep without running root. possible? details: when run command: sudo perf stat -e sched:sched_stat_sleep sleep 1 output looks correct: performance counter stats 'sleep 1': 1,001,729,231 sched:sched_stat_sleep 1.002880455 seconds time elapsed but when run without sudo error invalid or unsupported event: 'sched:sched_stat_sleep' run 'perf list' list of valid events usage: perf stat [<options>] [<command>] -e, --event <event> event selector. use 'perf list' list available events and when run perf list without sudo part of output is: [ tracepoints not available: permission denied ] i found anther question suggests setting kernel.perf_event_paranoid -1 . tried doing doesn't appear make difference. did not reboot after making change (is necessary?). viewing setting seems indicate it's set -1...

jquery - Two BackboneJS fetches and data gets swapped -

this our code inside single function. i'm beginning better backbonejs. // let's pull desktop data this.desktop = new desktopitemmodel({device: 'desktop'}); this.desktoppromise = this.desktop.fetch(); // let's pull mobile data this.mobile = new mobileitemmodel({device: 'mobile'}); this.mobilepromise = this.mobile.fetch(); // i'm not sure if previous developer trying implement similar $q.all this.allpromise = [desktoppromise, mobilepromise]; $.when(this.desktoppromise).done(_.bind(function() { // desktop stuff }, this)); $.when(this.mobilepromise).done(_.bind(function() { // mobile stuff }, this)); if (this.allpromise) { $.when.apply($, this.allpromise).done(_.bind(function() { // stuff here if desktop .... // stuff here if mobile .... }, this)); } i noticed there times our data in our variable gets mixed between desktop , mobile. response api server fine. suspected api team returning wrong data until debugged our app,...

SICP "streams as signals" in Python -

i have found nice examples ( here , here ) of implementing sicp-like streams in python. still not sure how handle example integral found in sicp 3.5.3 " streams signals ." the scheme code found there is (define (integral integrand initial-value dt) (define int (cons-stream initial-value (add-streams (scale-stream integrand dt) int))) int) what tricky 1 returned stream int defined in terms of (i.e., stream int used in definition of stream int ). i believe python have expressive , succinct... not sure how. question is, analogous stream-y construct in python? (what mean stream subject of 3.5 in sicp, briefly, construct (like python generator) returns successive elements of sequence of indefinite length, , can combined , processed operations such add-streams , scale-stream respect streams' lazy character.) there 2 ways read question. first simply: how use stream constructs, perhaps ones second ...

c# - Credentials passed from client to WCF do not make it there -

im trying pass windows credentials wcf service requires windows authentication seems credentials not making service. service not throw errors when check either of 2 below empty. var user = windowsidentity.getcurrent().user; var callerusername = servicesecuritycontext.current.windowsidentity.user; here client side code servicereference1.dispatchserviceclient service = new dispatchserviceclient(); service.clientcredentials.windows.clientcredential = servicecredentialsmanager.getnetworkcredentials(); service.clientcredentials.username.username= servicecredentialsmanager.getnetworkcredentials().username; service.clientcredentials.username.password = servicecredentialsmanager.getnetworkcredentials().password; client config - <basichttpbinding> <binding name="basichttpsbinding_idispatchservice"> <security mode="transport"> <transport clientcredentialtype="windows" /> </security> <...

c - Generate proper output for student id and score and find max and min? -

i'm working through programming in c book , part added hw, i'm not sure how display these quite code comments suggest. below comments in output() , used statement printf("%d\t%d\n", students.id, students.score); i'm not getting id , score correctly. i'm not sure about. it's getting generated , later printed in main, not quite how it's supposed to. then i'm not sure how find minimum, max , avg scores in summary() because randomly generated. @ students[i].id , students[i].score ? #include <stdio.h> #include <stdlib.h> #include <math.h> #include <conio.h> #include <assert.h> struct student{ int id; int score; }; struct student* allocate(){ /*allocate memory ten students*/ struct student* s = malloc(10 * sizeof(struct student)); assert (s != 0); /*return pointer*/ return s; } void generate(struct student* students){ /*generate random id , scores 10 students, id being between 1 ...

linux - Convert list of FQDN and IPs to two column CSV -

i'd take list this: example.com 1.2.3.4 ftp.example.com 2.3.4.5 3.4.5.6 www.example.com 4.5.6.7 5.6.7.8 6.7.8.9 and parse comma delimited csv format when opened in popular spreadsheet program, parent fqdns in column , children ips in column b. i'd using native linux binaries can bake existing bash script. any welcome, , in advance. this might work (gnu sed): sed -r '/[[:alpha:]]/h;//d;g;s/(.*)\n(.*)/\2,\1/' file if line contains alphabetic characters i.e. address, store in hold space , delete it. otherwise, append address current line , swap 2 fields replacing newline , , print.

hadoop - Which version of Spark to download? -

i understand can download spark source code (1.5.1), or prebuilt binaries various versions of hadoop. of oct 2015, spark webpage http://spark.apache.org/downloads.html has prebuilt binaries against hadoop 2.6+, 2.4+, 2.3, , 1.x. i'm not sure version download. i want run spark cluster in standalone mode using aws machines. <edit> i running 24/7 streaming process. data coming kafka stream. thought using spark-ec2, since have persistent ec2 machines, thought might use them. my understanding since persistent workers need perform checkpoint() , needs have access kind of shared file system master node. s3 seems logical choice. </edit> this means need access s3, not hdfs. not have hadoop installed. i got pre-built spark hadoop 2.6. can run in local mode, such wordcount example. however, whenever start up, message warn nativecodeloader: unable load native-hadoop library platform... using builtin-java classes applicable is problem? need hadoop? <edi...

javascript - Function wont call inside a jquery .click() -

trying call function inside .click event. know .click working because of console.log. not sure why function wont work. have tried other solutions such onclick() in html no luck. here links clicked on: <h2 class="logo child"></h2> <ul> <li><a href="#web" class="nav-link">developer</a></li> <li><a href="#design" class="nav-link">designer</a></li> <li><a href="#film" class="nav-link">film</a></li> <li><a href="#portfolio" class="nav-link">portfolio</a></li> <li><a href="#about" class="nav-link">about</a></li> </ul> here javascript $(document).ready(function(){ function spinlogo() { $('.logo').css({ 'transition' : '1.5s ease-in-out', 'tran...

objective c - Swizzling have to be on main thread? -

i succesfully swizziling imagenamed: method when on main thread. here code, js-ctypes: https://gist.github.com/noitidart/e8105a5f702dc9e6a4b8 i seem crashing when doing thread. i'm not sure if it's typo somwhere, i'm still digging can't seem find mistakes. wondering if swizziling method_setimplementation not thread safe? does same thread safety apply swizziling method_exchangeimplementations ? i think have issue in code can recommend jrswizzle library https://github.com/rentzsch/jrswizzle , demo how use: https://github.com/kostiakoval/jrswizzleexample

How do I edit Sql Templates in VS 2013? -

the original question here based on misunderstanding, i'm modifying (there no answers original question). in previous versions of visual studio item templates sql items seemed move version version. having difficult time finding had been placed in vs 2013. default template t-sql stored procedures produces following (and wanted modify): create procedure [dbo].[stored_procedure_name] @param1 int = 0, @param2 int select @param1, @param2 return 0 i want modify extensive according our standard in shop. couldn't figure out had put templates time. so they? after asking around shop developer of acquaintance found templates me. located here: c:\program files (x86)\microsoft visual studio 12.0\common7\ide\extensions\microsoft\sqldb\extensions\sqlserver\items mystery solved.

javascript - Empty object minus/plus empty object, and reverse value -

i have question. in console i'm training "arithmetics", like: false + true // 1 so, question is, why: [] - {} // nan and {} - [] // -0 can explain this, because both of them types object. , know javascript have , falsy values. so, if take boolean({}) // true boolean([]) // true in both have true , think result like: true + true // 2 or true - true // 0 in context (in console), {} empty block nothing, result same - [] and [] coerce 0, seen by: +[] if want {} treated empty object, try this: ({}) - [] you nan now, since empty object not coerce number. update: work should expect in console (returning nan): ({} - [])

generics - Very weird type mismatch in Scala -

why error when firing printgenerictype(new box[master]()) , , not error in case if run printgenerictype(new box()) on new box[master]() ? object varianceexample extends app { new box[master]().printgenerictype(new box()) // ok new box().printgenerictype(new box[master]()) // fail } class box[t >: tool](implicit m: manifest[t]) { def printgenerictype(box: box[t]) = { println(s"generic type [$m] - $box") } } class master class tool extends master class hammer extends tool you need define type t covariant, otherwise can pass same type used in constructor. new box() - gives box[tool] (without other constraints) , trying pass box[master] . in first example scalac automatically infers new box() box[master] because it's in box[master] position. not sure want achieve, solve concrete problem need define type box this: class box[+t >: tool](implicit m: manifest[t]) { def printgenerictype[a >: t](box: box[a]) = { println(s...

mysql - Aggregate function after having clause -

considering have following schema: emp(eid:integer, ename:string, age:integer, salary:real) works(eid:integer, did:integer, pct_time:integer) dept(did:integer, budget:real, managerid:integer) the question asks "if manager manages more 1 department, or controls sum of budgets departments. find managerids of managers control more $5 million." wrote following queries problem: version 1: select d.managerid department d group managerid having (select sum(d2.budget) department d2 d.managerid = d2.managerid) > 5000000 version 2: select d.managerid department d group managerid having sum(d.budget) > 5000000 i know difference between above 2 queries? nested select statement required having clause? edit: version 1 redundant since group by keyword allows sum function return sum of department budgets each manager?

How Do I Find Out What Intent To Listen For In Android? -

i'm developing app i'd launched when specific action made. in case, it's when built in barcode scanner scans something. when scanner scan something, usual dialogue asking app i'd use. options google chrome or browser @ moment. i've looked kind of documentation on google chrome try find out intents listens for, no avail. i wondering whether there's easier way find out intent-filters use? if understand correctly, need know intent-filter defined in apps optionable barcode scanner after scan, can define them in app. can try using app such one: stanley (package explorer) and use view manifest of 1 of apps , see how it's defined there, can use in app.

c# - I try to using wpfextendtoolkit, but my vs not show any tool -

Image
can 1 explain me why wpfextendtoolkit not work rebuild solution. add using xceed.wpf.toolkit; in .cs file. missing here?

c# - killing a thread from within in a form -

my application calls crystal reports viewer display report. run report viewer in separate thread. works fine. displays report properly. problem want kill report while processing if taking long run. while report processing busy indicator spinning , seems block ui on report viewer form. report viewer form has crystal reports viewer on along close button @ bottom of form itself. able click close button , have stop processing. here code run viewer in single apartment thread public void runreportstep1(uareport report) { uareportservice service = new uareportservice(report); service.runreport(); var reportdocument = service.reportdocument; thread stathread = new thread(r => { runreportstep2((reportdocument) r); }); stathread.setapartmentstate(apartmentstate.sta); stathread.start(reportdocument); stathread.join(); } public void runreportstep2(reportdocument reportdocument) { reportviewerform form = n...

bookmarklet - How to get the source of a javascript bookmark from itself when running? -

i have bookmark that's javascript bookmark. example: javascript:alert('hi'); i'd able source of running javascript bookmark, within bookmark itself, in pseudocode: javascript:alert(currentlyexecutingscript.text); which alert javascript:alert(currentlyexecutingscript.text); how can this? prefer cross browser solutions, fine chrome specific solutions! why interested in this? because i'm writing bookmarklet refers itself. as location refers current page's url, , javascript bookmarks not change location , not possible in current browsers. however, is possible want in javascript: javascript:void function f(){alert(f.tostring())}() that alert following: function f(){alert(f.tostring())} the tostring() method, when called on function, returns string representing source code of function (see https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/function/tostring ). credit @sergeseredenko sugges...

javascript - Advanced Rest Client VS browser -

the advanced rest client (chrome) works executing api call; when use jquery's post method error: request header field invoke-control not allowed access-control-allow-headers even in response headers in advanced rest client not see header in response. response headers: access-control-allow-headers: origin, x-requested-with, content-type, accept, netepay-password,user-trace,cancel-any-pending-trans, ancillary-method why work in chrome advanced rest client; give error when using js? response headers optional when not using browser? i cannot share code due nda; possible browser sandbox respects response headers; advanced rest client not?

How to make a register an account in batch -

is there way make account program making in batch? mean, there way log in specific username , password. there way create username , password , make batch file save , remember it, user can login next time instead of register? hopefully can understand. thanks! this solution create username , password , make batch file save in itself, requested, user can login next time instead of register. @echo off setlocal set "username=" call :getuserpass if defined username goto login echo must register in order use program set /p "username=enter username: " set /p "password=enter password: " echo set "username=%username%" >> "%~f0" echo set "password=%password%" >> "%~f0" goto begin :baduserpass echo invalid username or password, try again :login set /p "user=enter username: " set /p "pass=enter password: " if "%user%" neq "%username%" goto baduserpass if ...

javascript - Bootstrap Carousel in Mezzanine -

i have bootstrap carousel of mezzanine galleries. basically; pulling in images , want have single row of 3 images carouse ling. here working snippet of code hate; make work unlimited number of images. {% if page.docpage.gallery %} <script src="{% static "mezzanine/js/magnific-popup.js" %}"></script> <link rel="stylesheet" href="{% static "mezzanine/css/magnific-popup.css" %}"> <div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> <li data-target="#carousel-example-generic" data-slide-to="1"></li> <li data-target="#carousel-example-generic" data-slide-to="2...

python - Could this recursive binary search algorithm be more efficient? -

i've seen lot of different implementations of algorithm, i'm wondering if there ways improve efficiency beyond making search binary. i've designed particular version of algorithm edges , midpoint of array/list checked key being searched for, avoid looping through search when key looking first, middle, or last element. def searchrb(the_array, the_key, imin, imax): print("searching") found = false if (0 > the_key or the_key > len(the_array)): return found else: imid = imin + ((imax - imin) // 2) if imid == the_key or imin == the_key or imax == the_key: found = true return found elif the_array[imid] > the_key: return searchrb(the_array, the_key, imin, imid-1) elif the_array[imid] < the_key: return searchrb(the_array, the_key, imid+1, imax) else: return found for example, if looking number 1 in list of 1-100, find on first l...

algorithm - Obtaining the powerset of set with subsets of a certain size in Java -

i'm trying find efficient manner generate powerset of set has subsets of size k. have found answers of how generate powersets , powersets within range, i'm not sure how if wanted 1 size. thanks! create list containing elements of set. create second list consisting of 1's , 0's, the total number of elements in list equal number of elements in set the number of 1's in list equal k for each permutation of second list, subset consists of elements first list corresponding entry in second list 1.

security - Why is the hash generated by BCrypt non-deterministic -

Image
i've worked number of different hashing algorithms in past , under impression deterministic. i switched of code use bcrypt.net , have admit stumped when of comparison tests failed. after looking errors in test embarrassing amount of time realized assumption hashes deterministic incorrect. there verify method works , easy enough fix code i'd understand going on little bit better. is salting values internally or else going on? please note salting in real code - test is salting values internally yep. bcrypt more raw hash function, includes salt , few other bits allow hash validated without input: $2a$12$q6r.mpvzpruszrwlgardlos04kpcjk0sycdelrzes9o8.unlhon.u ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^ | | \- salt | \---- work factor \------- format the api you're using doesn't expose don't need manipulate salt, it's there , don't need add own.

php - Not able to get indian standard time in codeigniter -

using this: date_default_timezone_set('asia/kolkata'); is returning wrong time result. if real date time 2015-10-02 12:00:00 it's showing 2015-10-03 12:30:00 . how can right 'ist'? it's giving utc time , while indian timezone utc + 5.30. have set timezone asia/calcutta in root index file. <?php $indiatimezone = new datetimezone("asia/kolkata" ); $date = new datetime(); $date->settimezone($indiatimezone); echo $date->format( 'h:i:s / d, m js, y' ); ?>

docker - What process signal does pod receive when executing `kubectl rolling-update`? -

i making graceful shutdown feature using go lang when kebernetes doing rolling-update on google container engine. know process signal sent running pods when kubectl rolling-update starts? i've listened os.kill, os.interrupt, syscall.sigterm, syscall.sigkill, syscall.sigstop signals handled, none of signals raised while kubectl rolling-update. i appreciate answers. i got solution! used shell script file entrypoint , executed go binary in script file. process id of executed go binary not 1.(shell script process's id 1 instead) , docker sent sigterm pid 1(which not propagated it's child processes). so, had change entrypoint direct executing go binary, , got sigterm in go code now. refer link

java - trying to reuse a ResultSet obtained from database -

driver dr = new driver(); myconn = dr.connectdb(); mystmt = myconn.preparecall("{call spviewusers()}"); mystmt.execute(); myrs = mystmt.getresultset(); while (myrs.next()){ string name = myrs.getstring("userid"); cbuser.additem(name); } this simple login window username populated jcombobox (cbuser). code above works, i'm wondering if can re-use resultset obtain corresponding password when cbuser value changed, or have store resultset fields array. it'd nice if specific row based on value of column (not column's label). example, let's table: userid userpassword ------------------- admin 123456 guest qwerty random abcd i want value "qwerty" when "guest" selected in cbuser. possible? thanks!

java - Consume custom jar in spring MVC project -

Image
i need create website using spring mvc i'm using sts purpose. i'm using maven build tool. i'm new java i'm having hard time figuring keep thing or directory structure follow. sts helped me create starter spring project looks following i have custom jar file xyz.jar need consume service in website. can please guide me file should kept , how include in build output ? run below maven command corresponding parameters create folder inside .m2 folder , add jar there mvn install:install-file -dfile=c:\jarlocation\xyz.jar -dgroupid=<add group id jar> -dartifactid=<add artifact id> -dversion=<add version> -dpackaging=jar then in pom.xml make entry dependency for example can check how achieve it. mvn install:install-file -dfile=c:\users\hariom\javaencryptpassword-0.0.1-snapshot.jar -dgroupid=com.oss.mdf -dartifactid=java.encrypt.password -dversion=1.0.0 -dpackaging=jar and in pom.xml file added entry <dependency> ...

python - How do I use unittest.TestResult? -

i've been using unittest short time. using jython 2.7.10 "final release" in python 2.7 docs explaining testresult says: the following methods of testresult class used maintain internal data structures, , may extended in subclasses support additional reporting requirements. particularly useful in building tools support interactive reporting while tests being run. starttest(test) ... stoptest(test) ... starttestrun() ... stoptestrun()¶ that's want do... can't work out how use testresult. here's sscce... import unittest class testresultx( unittest.testresult ): def starttest( self, test ): print( '# blip') unittest.testresult.starttest( self, test ) def stoptest( self, test ): print( '# blop') unittest.testresult.stoptest( self, test ) def starttestrun( self ): print( '# blep') unittest.testresult.starttestrun( self ) def stoptestrun( self ): ...

java - Iteration error in Excel sheet -

when tried select items item list using excel sheet through java environment, first item selected , executed. next set of iteration not happening. int i=1; while (i<=sheet.getlastrownum() ) { row = sheet.getrow(i); string w = row.getcell(0).getstringcellvalue(); // processing : logic on "items" excel i++; } ok try sample firstly before code. check every column , row visited. maybe better way using iterators. try { fileinputstream file = new fileinputstream(new file("c:\\test.xls")); //get workbook instance xls file hssfworkbook workbook = new hssfworkbook(file); //get first sheet workbook hssfsheet sheet = workbook.getsheetat(0); //iterate through each rows first sheet iterator<row> rowiterator = sheet.iterator(); while(rowiterator.hasnext()) { row row = rowiterator.next(); //for each row, iterate through each columns iterator<cell> celliterator = r...

basic java design approach for memeber fields -

suppose have low level work java class public method input parameters , other private methods manipulate input data . preferable approach : set input data member fields no need pass between private methods, or pass parameters private methods? the issue here isn't passing value between private methods, it's how perceive state of object. in other words, make sense instance retain value of parameter passed. consider, example, builder class styled after bob builder - fixes many things, once he's done fixing something, it's fixed. it's no longer related bob. on other hand, wears helmet, , takes him wherever goes - part of state: public class builder { private string name; private helmet helmet; public builder(string name) { this.name = name; } /* helmet methods - helmet data member */ public void wearhelmet(helmet helmet) { this.helmet = helmet; } public void adjusthelmet() { helmet.adjust();...

ios - Apple watch minimum requirement to upload on itunesconnect -

we had made 1 application apple watch main thing here our entire app watch means there nothing display in iphone nothing in iphone storyboard 3 screen in watch fine submit in apple or must have create display in iphone. thanks you cannot submit standalone watch apps. there must client app install on phone. if 1 screen says "please use app on watch".

php - Execute query after 1 hour -

Image
attached table sample. every hour want recent items added table. table populated source, , need track last id received , new items added since. $check5 = "select * media_ids"; $rs5 = mysqli_query($con,$check5); if(mysqli_num_rows($rs5)==1) { $row = mysqli_fetch_assoc($rs5); $media_id=$row['media_id']; } // execute query you need create cronjob runs hourly. crontab -e , add 0 * * * * php /path/to/script/script.php add column table called created , set type timestamp set default value current_timestamp 3a. -- fetch in last hour script.php should like: <?php $current = time() - 3600; $currentmediaquery = "select media_id media_ids created > {$current}" $mediaquery = mysqli_query($con, $currentmediaquery); if (mysqli_num_rows($mediaquery) > 0) { while ($row = mysqli_fetch_row($mediaquery)) { ... stuff } } 3b. fetch 10, maintain pointer requested <?php $lastpointer = “select pointer pointer_tra...

c++ - boost::unordered_set of char16_t strings -

why following #include <string> #include <boost/unordered_set.hpp> int main() { typedef boost::unordered_set<std::string> unordered_set; unordered_set animals; animals.emplace("cat"); animals.emplace("shark"); animals.emplace("spider"); return 0; } work , following results in many compilation errors. #include <string> #include <boost/unordered_set.hpp> int main() { typedef boost::unordered_set<std::u16string> unordered_set; unordered_set animals; animals.emplace("cat"); animals.emplace("shark"); animals.emplace("spider"); return 0; } also, what's solution ? need write own hash_function , operator== in function objects mentioned here ? the operator== not concern, because defined in standard library. however, hash function has adapted std::hash specialization std::u16string provided standard library, wor...

android - Add TextInputLayout programmatically -

how go adding textinputlayout programmatically ? i have tried doing, private edittext _edittext; private textinputlayout _textinputlayout; // create edittext if (_edittext == null) { _edittext = new edittext(this.getcontext()); _edittext.setinputtype( _ispassword ? inputtype.type_text_variation_password : inputtype.type_text_flag_auto_correct ); _edittext.setlayoutparams( new layoutparams(0, layoutparams.match_parent) ); if (_hint != null) { _edittext.sethint(string.format("%s%s", hint_prefix, _hint.tolowercase())); } _textinputlayout = new textinputlayout(this.getcontext()); _textinputlayout.setlayoutparams( new layoutparams(0, layoutparams.wrap_content, edit_text_weight) ); _textinputlayout.addview(_edittext); this.addview(_textinputlayout); } however, when compile , run following error....

c# - PayPal IPN listener by WCF -

when send test ipn "instant payment notification (ipn) simulator" this: "ipn not sent, , handshake not verified. please review information." in case no reaction on server not happening :( doing wrong? p.s. server accessible internet , nothing blocking access. asked friend send me test message post request , server accepted it. on paypal method not react @ all! [servicecontract] public interface ipaypalservice { [operationcontract] [webinvoke(method = "post", uritemplate = "/")] void notify(stream data); } public void notify(stream data) { } <service name="paypal.paypalservice"> <endpoint address="http://myip:myport/paypalservice" binding="webhttpbinding" contract="paypal.ipaypalservice"/> </service>

Is there an equivalent to Python's ImportError in C# -

i'm putting code base unity3d sorts of common patterns. imported project source code not compiled dll. some of code should compiled specific dependency (also installed source code) present. (in case, networking code should compiled if photon installed in project). i go through manually delete files aren't required, prefer kind of automated way conditionally compile classes. if python like: try: import mylibrary class myclass(self): ... except importerror: # library not imported i know within class can use reflection work out if class defined, there way @ higher level, i.e. pseudocode: #if namespace_defined('externaldependency') // <-- how can kind of check? using externaldependency; public class myclass { ... } #endif in c#, there's no chance include using clause in code file part of project doesn't reference assembly contains imported namespace, thus, won't able perform check. an using of namespace can...

clock - STM32 Output MCO configuration -

i try configure mco ouput on stm32f103, std periph lib. here code: void outputmco() { gpio_inittypedef gpio_initstructure; rcc_apb2periphclockcmd(rcc_apb2periph_gpioa, enable); /* output clock on mco pin ---------------------------------------------*/ gpio_initstructure.gpio_pin = gpio_pin_8; gpio_initstructure.gpio_mode = gpio_mode_af_pp; gpio_initstructure.gpio_speed = gpio_speed_50mhz; gpio_init(gpioa, &gpio_initstructure); // pick 1 of clocks spew //rcc_mcoconfig(rcc_mcosource_sysclk); // put on mco pin the: system clock selected //rcc_mcoconfig(rcc_mcosource_hse); // put on mco pin the: freq. of external crystal //rcc_mcoconfig(rcc_mcosource_pllclk_div2); // put on mco pin the: system clock selected } i have issue here: // pick 1 of clocks spew //rcc_mcoconfig(rcc_mcosource_sysclk); // put on mco pin the: system clock selected //rcc_mcoconfig(rcc_mcosource_hse); // put on mco pin the: freq. of external crystal //rcc_mcoconfig(rcc_mcosource_pllclk_div2); // ...

vba - Excel - Check if value exists in a column in another worksheet and return adjacent column -

i have 2 worksheets: everyone eventbrite in everyone have column taken email addresses. columns c z full of other data. in eventbrite have column taken email addresses. column b course so looking in everyone , column b populated corresponding course i have tried following in b2 #ref error =vlookup(a2,eventbrite!a:a,2,0) please try this: =vlookup(a2,eventbrite!a:b,2,0) hope help.

sql - calculate weighted average for each day and id based on time intervals in PostgreSQL -

i have table in postgresql database looks this: stid | e5 | e10 | diesel | date -----+------+------+--------+------------------------ e850 | 1300 | 1400 | 1500 | 2016-05-02 05:30:01+02 e850 | 1400 | 1500 | 1700 | 2016-05-02 08:30:01+02 e850 | 1300 | 1400 | 1500 | 2016-05-02 21:00:01+02 e850 | 1200 | 1300 | 1350 | 2016-05-03 10:30:01+02 e850 | 1300 | 1400 | 1500 | 2016-05-03 21:00:01+02 954d | 1200 | 1100 | 1300 | 2016-05-02 03:30:01+02 954d | 1300 | 1100 | 1300 | 2016-05-02 15:00:01+02 954d | 1400 | 1800 | 1400 | 2016-05-02 22:30:01+02 954d | 1700 | 1900 | 1400 | 2016-05-03 09:30:01+02 954d | 1500 | 1900 | 1200 | 2016-05-03 23:30:01+02 so have unique id's (stid), prices (e5,e10,diesel) , timestamp (date) indicates when price introduced. want calculate average price per day , stid, weighted duration price charged. , want take period between 8 , 8 pm account. to calculate weighted average price of e5 stid e850 , date 2016-05-02 between 8 , 8 pm follo...

python - Pausing entire program from a thread spawned from a thread -

my program looks this: from threading import thread import time def something(): time.sleep(10) def function1(): if condition1: thread(target=something).start() def function2(): if condition2: thread(target=something).start() def function3(): if condition3: thread(target=something).start() def main(): thread(target=function1).start() thread(target=function2).start() thread(target=function3).start() main() if function 1 has spawned thread calling something() ,i dont want functions 2 , 3 spawn thread calling something(). actually code creates 3 independent threads , each of these threads can create thread doing something, again independent of each other (so getting 3 soemthing threads @ max). ask these threads interact in manner: "something" should executed once. hence thread "something" must instantiated 1 time , call must secured lock. function threads must know "something" thread,...

java - Recursive method that prints all of the digits in a number that or greater than the first digit and lower than the last digit -

the problem: i'm trying write recursive method prints of digits in number or greater first digit , lower last digit. accomplished write recursive method prints of digits or lower last digit. can't figure out how check if digit grater first digit. examples: for print(325648) print 5, 6, 4. for print(237) print 3. for print(925648) not print digit. this code: public static void print(int n) { print(n,n%10); } private static void print(int n,int lastdigit) { if(n==0) return; if(n%10<lastdigit) system.out.println(n%10); print(n/10,lastdigit); } the requirement of method: not allowed use loops(or methods loops). allowed use 1 recursive transition. the length of number not known. the method can change number, @ end of operation number should same @ beginning. please note: not homework assignment! i'm writing method practice exam talking tomorrow. the idea here recurse dividing 10 until number reduced first...

algorithm - Round off Decimals(Price) to .50 or whole numbers. C# winforms -

hi guys item prices in system generated system , round up. like this: 1.01 1.49 1.50 , 1.51 1.99 2.00 examples: 5.56 -> 6.00 , 5.32 -> 5.50 how can achieve this? thank you. rounding done using math.ceiling method. applying method directly round nearest dollar. trick rounding nearest 50 cents double price, take ceiling, , returning half of result: decimal roundedtofiftycents = math.ceiling(2 * originalprice) / 2; demo.

c - Find N'th number divisible by a or b -

given 2 numbers a and b, have find nth number divisible by a or b. input : first line consists of integer t, denoting number of test cases. second line contains 3 integers a, b and n . output : each test case, print nth number in new line. constraints : 1≤t≤10^5 1≤a,b≤10^4 1≤n≤10^9 sample input 1 2 3 10 sample output 15 explanation numbers divisible by 2 or 3 are: 2,3,4,6,8,9,10,12,14,15 and 10th number is 15. my code (in c) : #include<stdio.h> int main() { long long int i,a,b,n,j,c=0,small; scanf("%lld",&i); while(i--) { scanf("%lld%lld%lld",&a,&b,&n); if(a==b) { printf("%lld ",a*n); return 0; } else { if(a>b) small = b ; else small = ; for(j=small;1;j++) { if(j%a==0 || j%b==0) c++ ; if(c...

ios - WKWebView add as a subview -

from ios 8.0+, supposed use wkwebview , in official apple documentation , add setting view wkwebview. need add subview, numerous reasons. i have add buttons/labels above wkwebview . i can add adding uiview storyboard , setting code wkwebview , looks neater adding code. my code: @iboutlet weak var container: uiview! private var wkwebview: wkwebview! override func loadview() { let webconfig = wkwebviewconfiguration() wkwebview = wkwebview(frame: .zero, configuration: webconfig) wkwebview.uidelegate = self } override func viewdidload() { super.viewdidload() container = wkwebview let url = url(string: "https://google.com") let request = urlrequest(url: url!) wkwebview.load(request) } i have tried this: wkwebview add subview i have tried container.addsubview method, crashed nil pointer. every time load app, there's black screen. any ideas? you should add instance of wkwebview subview given view: view.addsu...