Posts

Showing posts from March, 2014

android - OsmDroid load multiple offline map -

i have different .sqlite map files , load on mapview. i'm able load 1 sqlite file. possible load multiple offline maps ? in case different sqlite files. in short answer yes. ironically, did myself few days ago. if you're using same tile source, such "mapnik", spanned across multiple tile archives, shouldn't have anything. use default tile provider, set setusedataconnection(false) , set tile source match source of what's in archives , you're off races. since 5.0, can use offlinetileprovider , explicitly specify tile archives load. if you're using mixed tiles sources , want create composite (e.g. ignore tile source names , display first tile available), possible trickery. first, override databasefilearchive , remove check tile source name override other archive classes needed remove check tile source name. if you're using v5 or newer, can register custom databasefilearchive implementation using archivefilefactory.registerarchive...

How do I block "Windows+L" key combination in Java application over Win 7, Win 8.1 and Win 10 operating system? -

i trying create desktop application in java. because secured application "windows+l" should blocked while application running. needs work on multiple versions of windows os windows 7, windows 8.1 & windows 10. i have tried implementing through resources available in internet windows registry nothing worked. please please help!

java - Disable printing of stracktrace/ BuildException output in STS Gradle -

at present running gradle 2.x/3.x builds via eclipse neo , sts gradle plugin . if there problem while building, e.g. in compilejava task detailed information of wrong (imo printed stderr in console tab of eclipse , kind of stacktrace build exception occured (imo printed stdoutin console tab). here example output: [sts] ----------------------------------------------------- [sts] starting gradle build following tasks: [sts] compilejava [sts] ----------------------------------------------------- [...] 1 error failure: build failed exception. * went wrong: execution failed task ':compilejava'. > compilation failed; see compiler error output details. * try: run --stacktrace option stack trace. run --info or --debug option more log output. [sts] build failed org.gradle.tooling.buildexception: not execute build using gradle distribution 'https://services.gradle.org/distributions/gradle-2.14-bin.zip'. @ org.gradle.tooling.internal.consumer.resulthandleradap...

android - Espresso 2.2.1 exception :app:transformClassesWithDexForDebugAndroidTest -

in app want espresso in order test ui. however,when try run project,i message: error:execution failed task ':app:transformclasseswithdexfordebugandroidtest'. > com.android.build.api.transform.transformexception: com.android.ide.common.process.processexception: java.util.concurrent.executionexception: com.android.ide.common.process.processexception: org.gradle.process.internal.execexception: process 'command 'c:\program files\java\jdk1.8.0_45\bin\java.exe'' finished non-zero exit value 2 this gradle setup: apply plugin: 'com.android.application' android { compilesdkversion 24 buildtoolsversion "24.0.0" defaultconfig { applicationid "theo.testing.androidespresso" minsdkversion 18 targetsdkversion 24 versioncode 1 versionname "1.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'),...

facebook - Why is others when trying to login via fb in your web not having same permission? -

in login_url state scopes can information of user location , email. when others try login via fb results has users id , name $this->facebook->login_url('login2/fb_login',array('scope' => 'email,user_photos,user_location')); in request $this->facebook->request('get', '/me?fields=id,first_name,last_name,email,location'); please help read login review: https://developers.facebook.com/docs/facebook-login/review most permissions need reviewed before can go public them.

c# - How to write unit test case for BadRequest? -

i want write unit test cases following code homecontroller.cs [httppost] [actionname("createdemo")] public async task<ihttpactionresult> createdemo([frombody] myrequest request) { if (request == null) { return badrequest("request can not null"); } if (request.myid == guid.empty) { return badrequest("myid must provided"); } } i tried following not correct way guess so [testmethod] public async task nullcheck() { try { var controller = new homecontroller(); var resposne = await controller.createdemo(null); assert.areequal(); // not sure put here } catch (httpresponseexception ex) //catch not hit { assert.istrue( ex.message.conta...

json - Http post request in Angular2 does not pass parameters -

i trying send parameter using angular2 post python/tornado back-end returns json object. parameters being sent @ python side, returning 400 post missing arguments error. using ionic 2/angular2 in front-end , python/tornado server. angular2 code follows: here content variable containing html table let body = json.stringify({content: content}); let headers = new headers({ 'content-type': 'application/json' }); let options = new requestoptions({ headers: headers }); this.http.post(url, body, options).map(res => res.json()).subscribe(data => { console.log(data) }, error => { console.log(json.stringify(error)); }); python code follows: def post(self): print self.request.arguments print self.get_argument('content') self.finish(dict(result="ok", data=content)) here error: [w 160824 06:04:30 web:1493] 400 post /test (182.69.5.99): missing argument content [w 160824 06:04:30 web:1908] 400 post /test (182.69.5.99...

windows - How will I run queue listener of Laravel 5.2 in background? -

in project using database queue , executing queue using command php artisan queue:listen in composer , working. in windows server, there many projects using queues many windows of composer open. quite inconvenient. possible run command in background without composer window open? you can use command work until logout or restart nohup php artisan queue:work --daemon & the trailing ampersand (&) causes process start in background, can continue use shell , not have wait until script finished. see nohup nohup - run command immune hangups, output non-tty this output information file entitled nohup.out in directory run command. if have no interest in output can redirect stdout , stderr /dev/null, or output normal laravel log. example nohup php artisan queue:work --daemon > /dev/null 2>&1 & nohup php artisan queue:work --daemon > app/storage/logs/laravel.log & but should use supervisord ensure service remains running , restar...

java - Process list stream and collect into map/ImmutableMap with only non null values -

how process list of string , collec map or immutable map value present string anotherparam = "xyz"; map.builder<string,string> resultmap = immutablemap.builder(..) listofitems.stream() .filter(objects::nonnull) .distinct() .foreach( item -> { final optional<string> result = getprocesseditem(item,anotherparam); if (result.ispresent()) { resultmap.put(item, result.get()); } }); return resultmap.build(); please tell, there better way achieve via collect? if have access apache commons library can make use of pair.class map<string, string> resultmap = immutablemap.copyof(listofitems() .stream() .filter(objects::nonnull) .distinct() .map(it -> pair.of(it, getprocesseditem(it,anotherparam)) .filter(pair -> pair.getvalue().ispresent()) .collect(...

javascript - How can I remove the button label my dataset without affecting my chart -

i want eliminate label of operation, when do, affects function. var ctx = document.getelementbyid("countrychart");<br> var mychart = new chart(ctx, {<br><br> type: 'bar',<br> data: {<br> labels: ["méxico", "japon", "usa", "china", "pakistan"],<br><br> datasets: [{<br> label: '# of votes',**--this label want eliminate--**<br> data: [12, 19, 3, 5, 2, 3],<br> backgroundcolor: [<br><br> add following option: should hide without affecting anything. options: { legend: { display: false }}

graph databases - NullPointerException while trying to update OrientDB Vertex -

i trying update vertex of type user following code. using orientdb enterprise 2.7 public static vertex updatevertex(string id, map<string, object> properties) { orientgraph graph = getgraphfactory().gettx(); // add vertex types int retry = 0; vertex vertex = null; while (retry++ != max_retry) { try { vertex = graph.getvertex(id); (string property : properties.keyset()) { vertex.setproperty(property, properties.get(property)); } graph.commit(); return vertex; } catch (oneedretryexception ex) { logger.warn("retry exception - " + id); } catch (exception e) { logger.error("can not create vertex - ", e); e.printstacktrace(); graph.rollback(); break; } } return vertex; } i following on commit step. not sure wrong code, had similar code working while back. ...

python - train logistic regression model with different feature dimension in scikit learn -

using python 2.7 on windows. want fit logistic regression model using feature t1 , t2 classification problem, , target t3 . i show values of t1 , t2 , code. question is, since t1 has dimension 5, , t2 has dimension 1, how should pre-process them leveraged scikit-learn logistic regression training correctly? btw, mean training sample 1, feature of t1 [ 0 -1 -2 -3] , , feature of t2 [0] , training sample 2, feature of t1 [ 1 0 -1 -2] , feature of t2 [1] , ... import numpy np sklearn import linear_model, datasets arc = lambda r,c: r-c t1 = np.array([[arc(r,c) c in xrange(4)] r in xrange(5)]) print t1 print type(t1) t2 = np.array([[arc(r,c) c in xrange(1)] r in xrange(5)]) print t2 print type(t2) t3 = np.array([0,0,1,1,1]) logreg = linear_model.logisticregression(c=1e5) # create instance of neighbours classifier , fit data. # using t1 , t2 features, , t3 target logreg.fit(t1+t2, t3) t1, [[ 0 -1 -2 -3] [ 1 0 -1 -2] [ 2 1 0 -1] [ 3 2 1 0] [ 4 3 2 1]] ...

qt - Why doesn't a loader change its source on a state change if it has a default state specified? -

i have qml loader , can have 2 states. depending on state, different content loaded. loader { id: mainloader anchors.fill: parent state: "state1" states: [ state { name: "state1" propertychanges {target: mainloader; source: "page1.qml"} }, state { name: "state2" propertychanges {target: mainloader; source: "page2.qml"} } ] } there 2 buttons elsewhere in application, have onclicked: mainloader.state = "state1" , onclicked: mainloader.state = "state2" , respectively. although state indeed changed (verified printing debug message in statechangescript ), page 1 remains loaded @ times, page 2 never appeares. what don't understand, following: if don't assign default state (so remove state: "state1" ), 2 buttons work, , both pages displayed correctly according button pr...

node.js - Azure Functions: How to read blob input for nodejs? -

i have setup azure function triggered blob being added specific container. blob .zip file intention use adm-zip extract blob directory , read contents. confused the documentation here: https://github.com/azure/azure-content/blob/master/articles/azure-functions/functions-bindings-storage.md#blob-trigger-supported-types says input parameter can either object or string. don't see place in function.json specify want input be. in code below, type seems string, since doesn't print assume it's buffer of bytes representing file contents. in order work this, i tried write buffer local file, not successful. did not throw error or print out saved blob to... in function.json have this: { "bindings": [ { "name": "xmlzipblob", "type": "blobtrigger", "direction": "in", "path": "balancedataxml", "connection": "sc2iq_storage" ...

mysql - php select query using parameter from previous page -

Image
i wanted query database not return values @ all. wondered why when not reported error.kindly check attachment. here code made.thank you. echo '<form method = "post" action = "http://localhost:8080/nbm/delivery/show_delivery_details.php">'; $nbm = new db(); $poid = $_get['id'];// taken previous page echo $poid;//tried display , $get_deliveries= $nbm->query("select * `customer_order_list` purchase_order_id = '$poid'"); foreach($get_deliveries $key){ echo $key['purchase_order_id'].'&nbsp;&nbsp;'.$key['customer_id'].'&nbsp;&nbsp;'.$key['amount']; } print_r($get_deliveries);//also tried displays nothing echo '</form>'; $nbm->query("select * `customer_order_list` purchase_order_id = '".$poid."'");

java - Why JsonNull in GSON? -

the docs jsonobject#get method returns null if no such member exists. that's not accurate; jsonnull object returned instead of null . what idiom checking whether particular field exists in gson? wish avoid clunky style: jsonelement = jsonobject.get("optional_field"); if (jsonelement != null && !jsonelement.isjsonnull()) { s = jsonelement .getasstring(); } why did gson use jsonnull instead of null ? there answer what differences between null , jsonnull . in question above, i'm looking reasons why. gson, presumably, wanted model difference between absence of value , presence of json value null in json. example, there's difference between these 2 json snippets {} {"key":null} your application might consider them same, json format doesn't. calling jsonobject jsonobject = new jsonobject(); // {} jsonobject.get("key"); returns java value null because no member exists name. calling jsonobject j...

c# - FFT Convolution - 3x3 kernel -

Image
i have written routines sharpen grayscale image using 3x3 kernel, -1 -1 -1 -1 9 -1 -1 -1 -1 the following code working in case of non-fft (spatial-domain) convolution, but, not working in fft-based (frequency-domain) convolution. the output image seems blurred. i have several problems: (1) routine not being able generate desired result. freezes application. public static bitmap applywithpadding(bitmap image, bitmap mask) { if(image.pixelformat == pixelformat.format8bppindexed) { bitmap imageclone = (bitmap)image.clone(); bitmap maskclone = (bitmap)mask.clone(); ///////////////////////////////////////////////////////////////// complex[,] cpaddedlena = imagedataconverter.tocomplex(imageclone); complex[,] cpaddedmask = imagedataconverter.tocomplex(maskclone); complex[,] cconvolved = convolution.convolve(cpaddedlena, cpaddedmask); return imagedataconverter.tobi...

c - Crash in wcscpy_s -

i getting crash in wcscpy _s while wcscpy works fine. have following struct struct test { ... wchar_t identity[256 * 2]; ... }; i doing member-by-member copy of 1 struct another. below 1 crashing wcscpy_s(t2.identity, sizeof(t2.identity) , t1.identity); while 1 working fine: wcscpy(t2.identity, t1.identity); if read wcscpy_s reference see middle argument number of elements , while pass size of array in bytes . if you're using visual c++ can use e.g. _countof number of elements.

Jquery on form submit after next page load -

i trying write alert jquery function using jquery alert. want submit form, wait page reload, , show alert. however, having trouble trying organize this. here code. $("input.auto").click( function() { $('#form').on("submit", function(){ $(document).ready( function() { jalert('example of basic alert box in jquery', 'jquery basic alert box'); }); }); }); right alert doesn't wait page reload , shows right after clicking. how can around this? you edit code below: $("#form").submit(function(event) { event.preventdefault(); jalert('example of basic alert box in jquery', 'jquery basic alert box'); });

autodesk forge - how to loaded two offline 3d model(.svf) into the viewer -

i hope load 2 offline 3 d model,which have been translated , download , viewer, have try give different document id param of option,but does't work are talking downloading svf files , loading them viewer? if so, have @ this sample on github. it has live version can play with: http://extract.autodesk.io

python - Tensorflow multi-variable logistic regression not working -

i trying create program classify point either 1 or 0 using tensorflow . trying create oval shape around center of plot, blue dots are: everything in oval should classified 1 , every thing else should 0 . in graph above, blue dots 1 s , red x's 0 s. however, every time try classify point, choses 1 , if point trained with, saying 0 . my question simple: why guess 1 , , doing wrong or should differently fix problem? first machine learning problem have tried without tutorial, don't know stuff. i'd appreciate can give, thanks! here's code: #!/usr/bin/env python3 import tensorflow tf import numpy import matplotlib.pyplot plt training_in = numpy.array([[0, 0], [1, 1], [2, 0], [-2, 0], [-1, -1], [-1, 1], [-1.5, 1], [3, 3], [3, 0], [-3, 0], [0, -3], [-1, 3], [1, -2], [-2, -1.5]]) training_out = numpy.array([1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]) def transform_data(x): return [x[0], x[1], x[0]**2, x[1]**2, x[0]*x[1]] new_training_in = numpy.apply_a...

datetime - PHP convert integer to time -

how can convert integer time in minutes e.g. 5 give 30mins . i've tried <?php $tomin = 5; echo date('i', ($tomin*60)).'mins'; ?> but returns 05mins so like: $time='7.5'; //, 8.3, 2.2. $x=explode('.',$time); $min=60*($x[1]/10); echo $x[0] .'hours , '.$min.'mins';

maven - I get a 404 error when trying to access a .jsp file under my WEB-INF directory and I can't figure out why -

i've looked @ every post find on issue every time seems configurations should be. when type in url http:/localhost:8080/ correct index.jsp displayed, when type in http:/localhost:8080/account 404 error. any advice appreciated! project structure projectname -v .idea -v src ---v main -----v java -------v springmvc.controllers ---------> accountcontroller.java -----v resources -------> application-context.xml -------> log4j.properties -----v webapp -------v web-inf ---------v views -----------> account.jsp ---------> web.xml -------> index.jsp -> pom.xml accountcontroller.java package springmvc.controllers; import org.springframework.stereotype.controller; import org.springframework.ui.model; import org.springframework.web.bind.annotation.pathvariable; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web....

sql - Elasticsearch match combos of two fields -

how can simple sql query running on elasticsearch? select * [mytype] (id=123 , cid = classroomida) or (id=234 , cid = classroomidb) or (id=345 , cid = classroomidc) i'm having troubles syntax, multi-match queries doesn't work in case. type of query should use? the right way combine bool/should (for outer or conditions) , bool/filter (for inner , conditions) together. post mytype/_search { "query": { "bool": { "minimum_should_match": 1, "should": [ { "bool": { "filter": [ { "term": { "id": 123 } }, { "term": { "cid": "classroomida" } } ] } }, { "bool": { "filter": [ ...

optimization - How to speed up simple loop in python -

i want accelerate speed of loop in python. there code below. for x in dpath.util.search(self.data, "**", yielded=true): self.contentslist.append(x) dpath.util.search generator. how speed simple loop?? well, loop unnecessary; let python looping & append work single function call instead of many calls with: self.contentslist.extend(dpath.util.search(self.data, "**", yielded=true))

How to use downloaded templates (.sketch files) in android app? -

i had downloaded free templates http://sketchappsources.com/ , of them .sketch files. had search thru net instructions none of results suit me. how import .sketch file in android studio turn them xml design? windows user , saw lot solution work in mac only. thank you.

go - When should I initialize Golang variables -

there kind of variables in golang: global variable: var int local variable: func hello() { var int } return variable: func hello() (a int) {} golang auto-init variables, don't know when , why? confused me. example: type user struct { name string `json:"name"` age int `json:"age"` } func foo(bts []byte) { var user err := json.unmarshal(bts, &a) // it's ok } func bar(bts []byte) (a *user) { err := json.unmarshal(bts, a) // crash } which 1 should have initialize before use? golang init variables (not sometimes , not some ): in code: func bar(bts []byte) (a *user) { err := json.unmarshal(bts, a) // crash } you passed nil pointer need value pointed a , not nil pointer: may create value store address of value inside a : when use var *user or func bar(bts []byte) (a *user) : a pointer user type, , initialized it's 0 value, nil , see ( the go playground ): package main import "fmt...

php - phpexcel with Bloomberg -

i trying create excel workbook using phpexcel... everything works fine of columns i'm creating. however, last column contains formula (bdh) belongs bloomberg's excel addin. workbook used, of course, on bloomberg terminal. phpexcel returns error when try enter bloomberg formula on column. have entered regular formulas in column, assume problem phpexcel doesn't know bloomberg formula entering... any thoughts? $formula="=bdh(\"$my_asset\" , \"px_last\" , \"$my_date\" , \"$my_date\" , \"$my_overrides\" )"; $objphpexcel->setactivesheetindex(0)->setcellvalue("g1",$formula); thanks in advance! you're correct in assumption: phpexcel work functions "native" excel itself, not functions added excel through external packs, nor user-defined functions. nor there method of adding these non-native functions.

SQL: How to return month and character corresponding to an ordinal number in Oracle -

how can return following result? understand how create first column "connect level" query. for lvl between 1 , 12, how generate corresponding month? lvl between 1 , 24 (or whatever "chosen" alphabet has), how generate corresponding letter (lower-case character)? lvl month char 1 jan 2 feb b 3 mar c 4 apr d 5 may e ok, want know how convert level month , character... for month: to_char(to_date(level, 'mm'), 'mon') for letter it's more complicated. in language c , char number , can "char arithmetic" pretty date arithmetic in oracle. however, can't character arithmetic in oracle, or @ least not easily. the best way create table of "ordinal number, corresponding character" (in whatever language need be) , inner join. there other solutions depend on explicit mappings in character sets; not recommended! however, if want use ascii letters, can use chr() , ascii() funct...

Can we use bootstrap grid system to control div width? -

bootstrap has grid system split div 12 divisions. thus, sometimes, intended use anywhere when want split div 2 or 3 equal sub div s. use col-sm-4 or col-sm-6 . our senior engineer told us, never ever try use grid system control div width unless need grid system layout different devices(laptop, tablet, mobile). instead, use fixed div width or other ways. make sense?

javascript - Can you remove wordpress post tags with js/php after certain date (ACF date time picker)? -

so website lists upcoming film screenings in area. i'm using acf date time picker show posts/film screenings in future in wordpress loop. i have tags filtering results dynamically using ajax (thanks https://www.bobz.co/ajax-filter-posts-tag/ ) except there tags aren't relevant results because belong posts older current date (past screenings). *for example on website, 'animated film festival' still coming other tags. i don't know if it's possible delete posts tags php (within post template while loops through other posts) - , delete posts tags if acf date time field post older current date. i haven't found luck googling , bit of noob so... this site: http://pigcine.pamrosel.com/ i'm doing in functions.php file @ moment: // tags , display function tags_filter() { $tax = 'post_tag'; $terms = get_terms( $tax ); $count = count( $terms ); if ( $count > 0 ): ?> <div class="post-tags"> ...

underestimatedCount in Swift's Dictionary -

according documentation, swift's dictionary type has property named underestimatedcount : a value less or equal number of elements in collection. anybody knows why on westeros considered useful??! baffles me... summary : technically speaking, underestimatedcount belongs sequence , , gets inherited collection , , dictionary . dictionary doesn't override default implementation returns zero. looking @ source code, seems underestimatedcount used indicator determine amount of growth of mutable collection when new items added it. here's snippet stringcore.swift : public mutating func append<s : sequence>(contentsof s: s) s.iterator.element == utf16.codeunit { ........... let growth = s.underestimatedcount var iter = s.makeiterator() if _fastpath(growth > 0) { let newsize = count + growth let destination = _growbuffer(newsize, minelementwidth: width) similarily, stringcharacterview.swift : public mutating func ap...

python - How to find the number of ways to get 21 in Blackjack? -

some assumptions: one deck of 52 cards used picture cards count 10 aces count 1 or 11 the order not important (ie. ace + queen same queen + ace) i thought sequentially try possible combinations , see ones add 21, there way many ways mix cards (52! ways). approach not take account order not important nor account fact there 4 maximum types of 1 card (spade, club, diamond, heart). now thinking of problem this: we have 11 "slots". each of these slots can have 53 possible things inside them: 1 of 52 cards or no card @ all. reason 11 slots because 11 cards maximum amount of cards can dealt , still add 21; more 11 cards have add more 21. then "leftmost" slot incremented 1 , 11 slots checked see if add 21 (0 represent no card in slot). if not, next slot right incremented, , next, , on. once first 4 slots contain same "card" (after 4 increments, first 4 slots 1), fifth slot not number since there 4 numbers of type. fifth slot become next lowest...

javascript - Typescript: Create interface based on a class -

i got class called myclass. has bunch of properties. want create interface contains options of class. many options have same name , typing myclass, not all. edit: options properties optional. the goal duplicate least possible. right now, i'm using dummy object avoid code duplication. there cleaner solution this? class myclass { callback:(p0:number,p1:string,p2:string[]) => number[]; myattr:number; composed:string; constructor(options:myclassoptions){ if(options.callback !== undefined) this.callback = options.callback; if(options.myattr !== undefined) this.myattr = options.myattr; if(options.composedp1 !== undefined && options.composedp2 !== undefined) this.composed = options.composedp1 + options.composedp2; } } var dummy = <myclass>null; interface myclassoptions { callback?:typeof dummy.callback; myattr?:typeof dummy.myattr; composedp1:string; composedp2:s...

r - How to use order_by with first()? -

when run simple version of first(...) order_by , r crashes. example following library(dplyr) summarize(group_by(mtcars, cyl), bigmpg = last(mpg, order_by = wt)) crashes r. is bug (perhaps related dplyr issue #626 ) or else wrong? i'm running r version 3.3.1 (x86_64-w64-mingw32/x64) , dplyr version 0.5.0 on windows 10. try qualifying dplyr functions. library(magrittr) requirenamespace("dplyr") dplyr::data_frame(id = 1:9, value = 42) %>% dplyr::summarise( dplyr::first(value, order_by = id) ) this work-around avoids crash me. example crashed on red hat 6.7, ubuntu 14.04, windows 7, & windows 8 machines (r 3.3.1; dplyr 0.5.0).

python - Can I create a new column based on when the value changes in another column? -

let s have df print(df) date_time b 0 10/08/2016 12:04:56 1 5 1 10/08/2016 12:04:58 1 6 2 10/08/2016 12:04:59 2 3 3 10/08/2016 12:05:00 2 2 4 10/08/2016 12:05:01 3 4 5 10/08/2016 12:05:02 3 6 6 10/08/2016 12:05:03 1 3 7 10/08/2016 12:05:04 1 2 8 10/08/2016 12:05:05 2 4 9 10/08/2016 12:05:06 2 6 10 10/08/2016 12:05:07 3 4 11 10/08/2016 12:05:08 3 2 the values in column ['a'] repeat on time, need column though, have new id each time change, have following df print(df) date_time b c 0 10/08/2016 12:04:56 1 5 1 1 10/08/2016 12:04:58 1 6 1 2 10/08/2016 12:04:59 2 3 2 3 10/08/2016 12:05:00 2 2 2 4 10/08/2016 12:05:01 3 4 3 5 10/08/2016 12:05:02 3 6 3 6 10/08/2016 12:05:03 1 3 4 7 10/08/2016 12:05:04 1 2 4 8 10/08/2016 12:05:05 2 4 5 9 10/08/2016 12:05:06 2 6 5 10 10/08/2016 12:05:07 3 4 6 11 10/08/2016 12:05:08 3 2 6 is the...

rust - Is there any way to return a reference to a variable created in a function? -

i want write program write file in 2 steps. file may not exist before program run. filename fixed. the problem openoptions.new().write() can fail. in case, want call custom function trycreate() . idea create file instead of opening , return handle. since filename fixed, trycreate() has no arguments , cannot set lifetime of returned value. how can resolve problem? use std::io::write; use std::fs::openoptions; use std::path::path; fn trycreate() -> &openoptions { let f = openoptions::new().write(true).open("foo.txt"); let mut f = match f { ok(file) => file, err(_) => panic!("err"), }; f } fn main() { { let f = openoptions::new().write(true).open(b"foo.txt"); let mut f = match f { ok(file) => file, err(_) => trycreate("foo.txt"), }; let buf = b"test1\n"; let _ret = f.write(buf).unwrap(); } println...

python - pyqt QTreeWidgetItem double click connect -

is possible connect doubleclick event qtreewidgetitem? something this: def test(self): print("hello") childitem = qtreewidgetitem() childitem.doubleclicked.connect(self.test) the signal want called itemdoubleclicked , belongs qtreewidget itself: from pyqt4 import qtgui def handler(item, column_no): print(item, column_no) def main(): app = qtgui.qapplication(sys.argv) win = qtgui.qtreewidget() items = [qtgui.qtreewidgetitem("item: {}".format(i)) in xrange(10)] win.inserttoplevelitems(0, items) win.itemdoubleclicked.connect(handler) win.show() sys.exit(app.exec_()) if __name__ == '__main__': main()

Is it possible to apply fixes on Visual C++ Build Tools 2015 Update 3 -

visual studio 2015u3 serviced cumulative updates kb3165756, contains, among other things, fixes c++ compiler , libraries. however kb3165756 refuses on computer visual c++ build tools 2015 update 3 installed. wants 1 of vs pro, enterprise, community or express. are there special patches visual c++ build tools, or not updated @ , better idea switch visual studio express 2015 desktop, in order able receive patches? here answer got on msdn visual studio development > visual studio setup , installation forum: however kb3165756 refuses on computer visual c++ build tools 2015 update 3 installed. wants 1 of vs pro, enterprise, community or express. it reasonable, check this: https://msdn.microsoft.com/en-us/library/mt752379.aspx , describes update applies to visual studio professional 2015 visual studio enterprise 2015 visual studio community 2015 visual studio express 2015 web visual studio express 2015 desktop visual studio express 2015 windows 10...