Posts

Showing posts from August, 2014

c# - Convert Text file to Excel -

i have text files convert excel copy/pasting them excel go data -> text columns. then choose delimited. then select delimiters tab , semicolon. in last step choose text fields. now want automate making program in c#. i editing on data in excel file. make new excel file if specific column have specific name , on. 1 text file end 3 or 4 excel files. what relative merits of: read text file string/list check data write data different excel files? or use texttocolumn() method in c# start editing write new excel file? if there other, better ways accomplish such thing please suggest. edit: see lot of 3rd party suggestions, myself can learn. epplus start. helps create excel files programmatically. our company using long time , has proven work well. you might want try older version 3.1.3, if encounter crashes/bugs. had issues current version, tip. otherwise, can export csv if don't want libraries reason. should no problem implement.

Is a connected iOS device required for a successful build in Xcode? -

Image
i'm new xcode , first project simple ios 8 app share extension target. noticed files marked in red (missing) if select >product >build . if same thing connected device went red black , build successful. why need connect device successful build? @matt, depends on profile building for. i'll attach image of current build profiles have selected in xcode 6.1. if target simulator, gonna want click play button, , project copied simulator selected, , launched. when build app device, select >product >build because don't have apple developer's license, still builds myapp.app binary / executable project in derived data location specified preferences. hope answer helps out.

Allowed Memory in R and C Stack Usage -

i'm trying read in large file (~5gb) r , process data. can read in entire 5gb file, trouble comes when apply processing. don't have great grasp on memory basics in r, , i'm hoping of can me understand better. here example of i'm running file = fread("file.txt") #file.txt 5gb of unprocessed data t.str <-strptime(file$time, "%m/%d/%y %h:%m:%s"")#convert column date class month = as.numeric(format(t.str, "%m"))#create vector file column high = ifelse(file$age>70,1,0) #create vector file column #there ten more lines operate on file. fread fine job of reading in file. , first 3 or 4 operations run on 'file' data frame work. however, after number of them run, error says: c stack usage 19923892 close limit i'm pretty sure issue isn't command i'm running since worked on smaller data sets. i've read bit on stacks are, warning isn't totally making sense me. mean r using pointer run through these bi...

Is it OK to use indentation in Windows batch files? -

is style ok, or each line must started line 1st position? not impact on execution, readability. if not exist "%aaa%" ( %%f in (*.*) ( echo copying %%f copy %%f "%aaa%" > nul ) ) it's not okay, preferred.

asp.net web api - Web API using Entity Framework to query by multiple columns -

using ef6, i'm creating web api project. when add controller, entitykey default column queried ("id"), works fine. want add additional columns query within same table via api, i'm unable work. for example, can query id (/api/ctrlname/123456), if want query via title column, /api/ctrlname?title="value", comes notfound message. is there simple tutorial set functionality within controller? [responsetype(typeof(article))] public ihttpactionresult getarticle(string id) { article article = db.articles.find(id); if (article == null) { return notfound(); } return ok(article); } [responsetype(typeof (article))] public ihttpactionresult getarticlebytitle(string title) { article article = db.articles.find(title); { if (article == null) return notfound(); } return ok(article); } private bool articleexists(strin...

java - FasterXML/jackson-dataformat-xml deserialize mixed ordered tag -

i have xml customer: <a> <b id="id1"/> <any-tag/> <b id="id2"/> </a> and simple java class import com.fasterxml.jackson.dataformat.xml.annotation.jacksonxmlelementwrapper; import com.fasterxml.jackson.dataformat.xml.annotation.jacksonxmlproperty; import lombok.tostring; import java.util.list; @tostring public class { @tostring public static class b { public string id; } @jacksonxmlproperty(localname = "b") @jacksonxmlelementwrapper(usewrapping = false) public list<b> blist; } when jackson finish parsing have result a(blist=[a.b(id=id2)]) it evident got second tag, expected 2 tags in blist . realized due fact any-tag tag between first , second tag b. how can read b tags in list? ps tag contains other content should read. i'm using: 'com.fasterxml.jackson.core:jackson-databind:2.5.1', 'com.fasterxml.jackson.dataformat:jackson-dataformat-xm...

c# - WPF checkbox twoway binding from property to UI is not working on propertychanged event -

i using twoway binding in checkbox data column in telerik grid view control. when change state of checkbox on ui, working fine triggering property changed event. want vice versa, on changing property value on code behind, checkbox state should update on ui. <button x:name="btn1" grid.row="0" content="refresh" click="btn1_click" width="100" margin="0,5"/> <telerik:radgridview grid.row="1" x:name="gridview" showgrouppanel="false" isfilteringallowed="false" selectionmode="multiple"> <telerik:radgridview.columns> <telerik:gridviewdatacolumn width="70" header="color"> <telerik:gridviewdatacolumn.celltemplate> <datatemplate> <stackpanel orientation="horizontal"> <checkbox ischecked="{bin...

ios - Error Domain=kCLErrorDomain Code=2 "The operation couldn’t be completed. (kCLErrorDomain error 2.)" -

import uikit import corelocation class viewcontroller: uiviewcontroller, cllocationmanagerdelegate { @iboutlet var latlabel: uilabel! @iboutlet var longlabel: uilabel! @iboutlet var courselabel: uilabel! @iboutlet var speedlabel: uilabel! @iboutlet var altlabel: uilabel! @iboutlet var addresslabel: uilabel! var manager:cllocationmanager! var userlocation:cllocation = cllocation() override func viewdidload() { super.viewdidload() manager = cllocationmanager() manager.delegate = self manager.desiredaccuracy = kcllocationaccuracybest manager.requestwheninuseauthorization() manager.distancefilter = 50 manager.startupdatinglocation() } func locationmanager(manager: cllocationmanager!, didupdatelocations locations: [anyobject]!) { userlocation = locations[0] cllocation println(userlocation.coordinate.latitude) var latitude:cllocationdegrees = userlocation...

java - StringTokenizer getting whole line -

i'm using stringtokenizer read game map. problem don't know how whole line of file. example here's .txt file block 128 0 52 3 block 192 0 speeditem 200 64 block 256 0 platform 150 70 500 0 false block 320 0 12 75 block 384 0 and here how try print whole line filehandle file = gdx.files.internal("data/" + level + ".txt"); stringtokenizer tokens = new stringtokenizer(file.readstring()); while(tokens.hasmoretokens()){ string type = tokens.nexttoken(); system.out.println(type); // first word of line if(type.equals("block")){ list.add(new brick(integer.parseint(tokens.nexttoken()), integer.parseint(tokens.nexttoken()))); } so here's results block block speeditem block platform block block but need print numbers in lines example block 128 0 52 3 block 192 0 speeditem 200 64 .... .... why using stringtokenizer class? it...

WCF with IOperationInvoker using Entity and Ninject -

i have wcf service need log calls methods. this, used this solution able track calls , call internal audit service, uses entity 5.1 , injects services/repositories/dbcontext using ninject. my invoke method looks this: public object invoke(object instance, object[] inputs, out object[] outputs) { var methodparams = (instance).gettype().getmethod(_operationname).getparameters(); var parameters = new dictionary<string, object>(); (var index = 0; index < inputs.length; index++) parameters.add(methodparams[index].name, inputs[index]); _auditservice.trackfilterparametersvalues(_operation.parent.type.fullname, _operationname, _operation.action, parameters); return _baseinvoker.invoke(instance, inputs, out outputs); } in ninject module have internal stuff registered this: bind<iauditservice>().to<auditeservice>().inrequestscope(); bind(typeof(irepository<>)).to(typeof(repository<>))....

Enumerating domains in Prolog's clpfd -

i'm exploring dependent structures of constraints one: assign(x,y) :- x in 1..5, ((x mod 2 #= 1) #=> y in 2..3), ((x mod 2 #= 0) #=> y #= 5). what i'm looking representation of x 's , y 's domains sparse possible - in case along lines of x in {1,3,5} , y in {2,3} or x in {2,4} , y = 5 . one way of doing detect variables on left side of #=> , enumerate values , collect , merge them together, ?- assign(x, y), findall(x-d, (indomain(x),fd_dom(y,d)), c), stuff c , maybe there more efficient way? i've encountered error trying label([x,y]) : arguments not sufficiently instantiated goes away when add constraint on y 's domain. when should expect error occur? feel have poor understanding of clpfd's mechanisms , limitations, there resources learn from? know basics of constraint programming, arc consistency etc. to keep clpfd enumeration predicates (like indomain/1 , label/1 , labeling/2 , etc.) ever throwing instantiati...

What's the meaning of some advanced patterns in vim errorformat? (%s, %+, %\\@=) -

i tried reading :help errorformat , googling (mostly stackoverflow), can't understand of patterns mentioned there: %s - "specifies text search locate error line. [...]" um, first of all, trying understand sentence @ all, put "text search", after %s ? before it? or, don't know, maybe taint whole pattern? wtf? secondly, pattern do, how differ regular text in pattern, kinda set efm+=,foobar ? "foobar" here me "text search for"... :/ %+ - e.g. i've seen used in 1 question : %+c%.%# does mean whole line appended %m used in earlier/later multiline pattern? if yes, if there not %.%# (== regexp .* ), but, let's say, %+ccont.: %.%# - work capture stuff after cont.: string %m ? also, what's difference between %c%.%# , %+c%.%# , %+g ? also, what's difference between %a , %+a , or %e vs. %+e ? finally, example python in :help errorformat-multi-line ends following characters: %\\@=%m -- wtf %\\@= mean?...

javascript - <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> Breaks my Site, but I need for Event Tracking -

i need jquery event tracking plugins. work following: <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> & $('.home .et_pb_more_button').on('click',function() { ga('send', 'event', 'button', 'click', 'case study'); }); problem...the jquery code breaks functionality of website. how can track events in google analytics, not break jquery functionality? the site directiveconsulting.com wordpress loads in jquery automatically admin side of things among other things. try using jquery in noconflict mode or calling function using jquery instead of $ jquery('.home .et_pb_more_button').on('click',function() { ga('send', 'event', 'button', 'click', 'case study'); }); read here noconflict : documentation

ruby on rails - NoMethodError undefined method -

working on final class project. need calculate gpa of major credits , non major credits separately transcript page. when run code below controller works fine , show total credit hours major , non major when put code @gpa_for_major = (course.credits * course.grade.scale) / course.credits in if statement nomethoderror in transcontroller#transcript undefined method 'credits' # course::activerecord_relation:0x00000007b99798> class transcript def initialize (course_array) @course = course_array @total_non_major_credits = 0 @total_major_credits = 0 @gpa_for_major = 0 @gpa_for_non_major = 0 item in @course if item.is_for_major @total_major_credits = @total_major_credits + item.credits else @total_non_major_credits = @total_non_major_credits + item.credits end end end def course @course end def total_non_major_credits ...

Visual Studio C Programing 'Fatal Error LNK1168'? -

i using visual studio 2013 c programming error this. http://i.imgur.com/bqiltyu.png i try not work : https://stackoverflow.com/a/17500526/2184315

javascript - How would I auto Populate a Input Text Box VALUE to be the same as the NAME? -

i working client needs forms show value inside of text box on form, system unable due how module coded. what best way unable edit source code of form creation module allow value set automatically when user creates form. i know there ways javascript done, have found require editing input boxes or placing styles / attributes on form not have access to. i have pre-existing styles on these areas of code along wrapper around form target specific areas inside styling or script. html example: <form name="foobar"> <input name="my_name_1"/> <input name="my_name_2"/> <input name="my_name_3"/> </form> javascript: function putnamesasvalues(formname){ var elements = document.forms[formname].elements; for(var i=0;i<elements.length;i++) if( elements[i].tagname.tolowercase().indexof('input') != -1 ) elements[i].value = elements[i].name; } putnamesasvalues(...

python - pass argument to function in a dictionary -

i've switch, given option call function e.g. #... capture option op = getoption() #.. capture metric mt = getmetric() def zipcode(): print "you typed zero.\n" def desc(): print "n perfect square\n" def address(): print "n number\n" #call desired option options= {0 : zipcode, 1 : code, 2 : desc, 3 : address } options[op]() i trying pass parameter ( mt ) options dict call function, i'm not being able so. if op received 1 , mt foo, how call right function (zipcode) done passing mt parameter? ideally: options[op](mt) , defining 1 parameter in function? thanks your code not indented properly, important in python , cause syntax errors is. however, suggesting work perfectly. consider following: def multiply(m,n): return n*n def add(m,n) return m,n my_math = { "+":add, "*":multiply} you call follows: >>> print my_math["+...

javascript - Setup webpack hot dev-server with a Node backend for production -

i have front-end application bundled webpack, served , talks node backend server. webpack hot dev server running on 8080 . node backend running on 1985 . i want serve index.html node, want assets served hot dev server during development. achieve have: set absolute publicpath value in webpack config: output: { publicpath: 'http://localhost:8080/' }, and used absolute urls in index.html point hot dev server: <script src="http://localhost:8080/webpack-dev-server.js"></script> <script src="http://localhost:8080/js/vendors.js"></script> <script src="http://localhost:8080/js/bundle.js"></script> so can run hot dev server , run node server , browse http://localhost:1985 . great. but when come deploy / run in production, not want. i'd relative urls vendors.js , bundle.js , don't want include webpack-dev-server.js script. i use handlebars or other templating on server specify a...

ios - Display questions from an array in order on a button press in swift -

i new learning ios swift, apologies if easy. my apps first page has simple layout: uilabel (my question) uitextfield (where user writes answer) uibutton (active once user has input text field) i have made array of 4 questions. trying code when user presses uibutton, display next question in array, long text field has been populated. this have far: @iboutlet var textfield: uitextfield! @iboutlet var questionlabel: uilabel! @iboutlet var buttonlabel: uibutton! let questions = ["where going?", "do know city?", "what doing there?", "when go?"] @ibaction func nextbutton(sender: anyobject) { textfield.hidden = false textfield.placeholder = "country" var = 0; < 5; i++ { questionlabel.text = questions[0] } buttonlabel.settitle("next", forstate: uicontrolstate.normal) } override func viewdidload() { super.viewdidload() // additional setup after loading view, typically ni...

Trying to setup an audio unit graph with a buffer of samples as the input -

i trying implement simple audio unit graph goes: buffer of samples->low pass filter->generic output where generic output copied new buffer processed further, saved disk, etc. all of examples can find online having setting audio unit graph involve using generator kaudiounitsubtype_audiofileplayer input source... dealing buffer of samples acquired, examples not help... based on looking around in audiounitproperties.h file, looks should using using kaudiounitsubtype_scheduledsoundplayer? i can't seem documentation on how hook up, quite stuck , hoping here can me out. to simplify things, started out trying buffer of samples go straight system output, unable make work... #import "effectmachine.h" #import <audiotoolbox/audiotoolbox.h> #import "audiohelpers.h" #import "buffer.h" @interface effectmachine () @property (nonatomic, strong) buffer *buffer; @end typedef struct effectmachinegraph { augraph grap...

Why does OCaml modify the type of a value on first use when it contains a universal? -

this question has answer here: why ocaml require eta expansion? 1 answer why ocaml change type of value of first use when contains universal? example, if define church encoding tuples, have: # let pair x y z = z x y;; val pair : 'a -> 'b -> ('a -> 'b -> 'c) -> 'c = <fun> # let first p = p (fun x y-> x);; val first : (('a -> 'b -> 'a) -> 'c) -> 'c = <fun> # let second p = p (fun x y -> y);; val second : (('a -> 'b -> 'b) -> 'c) -> 'c = <fun> # let foo = pair 1.2 "bob";; val foo : (float -> string -> '_a) -> '_a = <fun> # first foo;; - : float = 1.2 # foo;; - : (float -> string -> float) -> float = <fun> # second foo;; error: expression has type (float -> string -> float) -> float ...

Weird behaviour when the inventory loads c# unity3d -

Image
i making rpg save , load inventory function. using playerperfs , have problem. let's id of items when save this: 18, 19, 20 , 21 , when load, become this: 20, 21, 22 , 23 , seems items did not in correct order, , every time loads, increase id 2 last saved. here image of when save , load: save: load: here code: public static void saveitem() { try { (int = 0; < inventory.count; i++) { playerprefs.setint("inventory: " + i, inventory[i].itemid); } } catch { debug.logerror("failed save items database!"); } } public static void loaditem() { try { (int = 0; < inventory.count; i++) { inventory[i] = playerprefs.getint("inventory: " + i, -1) >= 0 ? itemdatabase.items[playerprefs.getint("inventory: " + i)] : new itemmanager(); } } catch { debug.logerror("failed load items database!");...

meteor - How to handle CollectionFS saving failures -

i'm using collectionfs , in particular s3 storage adapter. most files uploaded fine , can download them afterwards no problem. occasionally file appears load fine ( files.insert(blob,callback) returns callback no error) later when go download them fsfile.url() returns null . https://github.com/collectionfs/meteor-collectionfs#after-the-upload says: if storage adapters fail save of copies in designated store, server periodically retry saving them. after configurable number of failed attempts @ saving, server give up. but there no callback i'm aware of such failure. furthermore when looking @ fsfile.uploadprogress() 100%. the basic problem during upload looks fine , app detects problem when trying download file. is there way detect upload failure in storage adapter? what else fsfile.url() returning null symptomatic of? here's example of 1 of these broken fsfile objects in mongodb: { "_id" : "uqayajqcv68hmejhu", ...

dart - Exception when trying to load .mp3 file in Phaser -

i trying load very short .mp3 file in preload() function this: game.load.audio('sword', '$assetpath/swordraw.mp3', true); as code gets executed, crashes error breaking on exception: invalid arguments(s) pointing console.warn in phaser's loader 's fileerror function below: fileerror(int index) { this._filelist[index]['loaded'] = true; this._filelist[index]['error'] = true; this.onfileerror.dispatch([this._filelist[index]['key'], this._filelist[index]]); window.console.warn("phaser.loader error loading file: " + this._filelist[index]['key'] + ' url ' + this._filelist[index]['url']); this.nextfile(index, false); } through debugger of darteditor have seen reason _filelist[10]['url'] (url audio file) picked being null here, , cause of exception (can't concat. null string) why url null? i've checked obvious: file name correct , assetpath initialised c...

javascript - Pass variables to base layout from extending pug/jade template -

i set class on body tag declaring variable in template extends base layout. when try, body_class variable undefined in layout. it appears layout executed before extending template, or executed in different scopes or something. is there way? mixin work here? _layout.jade: doctype html html(lang="en-au") head meta(charset="utf-8") block css body(class=(body_class || "it-did-not-work")) block header block content block footer home.jade: var body_class = 'i-am-the-home-page' extends _layout block header h1 home ah ha! figured out. create block @ top of base layout , add variables in there. _layout.jade: block variables doctype html html(lang="en-au") head meta(charset="utf-8") block css body(class=(body_class || "it-did-not-work")) block header block content block footer home.jade: exte...

python - Reading file and making into dictionary with the values as a list of integers -

i have file in format shown below. 83 140 228 286 426 612 486 577 836 0 0 aaliyah 0 0 0 0 0 0 0 0 0 380 215 aaron 193 208 218 274 279 232 132 36 32 31 41 abagail 0 0 0 0 0 0 0 0 0 0 958 abbey 0 0 0 0 0 0 0 0 537 451 428 abbie 431 552 742 924 0 0 0 0 752 644 601 abbigail 0 0 0 0 0 0 0 0 0 953 562 abby 0 0 0 0 0 906 782 548 233 211 209 abdiel 0 0 0 0 0 0 0 0 0 925 721 abdul 0 0 0 0 0 0 0 903 0 0 0 abdullah 0 0 0 0 0 0 0 0 0 1000 863 abe 248 328 532 764 733 0 0 0 0 0 0 abel 664 613 626 575 542 491 497 422 381 385 354 abigail 0 0 0 0 854 654 615 317 150 50 14 abigale 0 0 0 0 0 0 0 0 0 0 959 how able make dictionary name key , list of integers following each name values? pretty straightfoward: d = {} open('file.txt') f: line in f: parts = line.split() d[parts[0]] = map(int, parts[1:]) the result dictionary d , keyed on first token of each line, list of integers dictionary values. ...

mysql - Group by words in a comma separated string -

in mysql, given following table tags column contains comma separated strings id name salary tags ---------------------------- 1 james 5000 sales, marketing 2 john 4000 sales, finance 3 sarah 3000 hr, marketing, finance how sum(salary) each word/tag in tags? result this? tag totalsalary ------------------------ sales 9000 marketing 8000 finance 7000 hr 3000 any appreciated. thank you! while i'd highly recommend normalizing data structure , not store comma delimited lists, here's 1 handy approach utilizing "numbers" table: select substring_index(substring_index(tags, ',', n.n), ',', -1) value, sum(salary) tags cross join ( select a.n + b.n * 10 + 1 n (select 0 n union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) ,(select 0 n union select 1 union select 2 ...

Constant garbage collection Java -

i check application log , see following: 163.029: [gc163.029: [parnew: 545354k->8k(613440k), 0.0421560 secs] 547578k->2232k(20903424k), 0.0422630 secs] [times: user=0.27 sys=0.03, real=0.04 secs] 164.014: [gc164.014: [parnew: 545352k->6k(613440k), 0.0438010 secs] 547576k->2230k(20903424k), 0.0439220 secs] [times: user=0.30 sys=0.00, real=0.04 secs] 164.995: [gc164.996: [parnew: 545350k->10k(613440k), 0.0350310 secs] 547574k->2234k(20903424k), 0.0351570 secs] [times: user=0.27 sys=0.00, real=0.04 secs] 165.967: [gc165.967: [parnew: 545354k->8k(613440k), 0.0532350 secs] 547578k->2232k(20903424k), 0.0533560 secs] [times: user=0.39 sys=0.00, real=0.06 secs] 166.946: [gc166.946: [parnew: 545352k->10k(613440k), 0.0308930 secs] 547576k->2234k(20903424k), 0.0309980 secs] [times: user=0.25 sys=0.00, real=0.03 secs] 167.919: [gc167.919: [parnew: 545354k->12k(613440k), 0.0393180 secs] 547578k->2236k(20903424k), 0.0394180 secs] [times: user=0.30 sys=0.00, ...

c# - GeocodeQuery is not searching with current location -

i want search nearby hotel using 'searchterm'. geocodequery giving far away results if set 'mygeocodequery.geocoordinate' current location. ( have checked current location co-ordinates debugging accurate) not able figure out went wrong. please me.. mygeocodequery = new geocodequery(); mygeocodequery.searchterm = searchterm; mygeocodequery.geocoordinate = mycoordinate == null ? new geocoordinate(0, 0) : mycoordinate; mygeocodequery.querycompleted += geocodequery_querycompleted; mygeocodequery.queryasync();

Python Main Function Command Line Argument Long List -

i'm trying make simple main function caesars shift cryptography program, i'm not quite sure how configure command line opt/arg stuff. want configure program accept command line arguments so: ./caesars.py -e 13 message encrypt with 13 being amount of shifts , following lines message encrypt. have functions defined, not sure how configure opt arg stuff accept first argument after argv[1] key, after split list/long string. here have far: def main(): global decoder global encoder if not len(sys.argv[1:]): usage() # read commandline options try: opts, args = getopt.getopt(sys.argv[1:],"hd:e:", ¬ ["help","decode","encode"]) except getopt.getopterror err: print str(err) usage() o,a in opts: if o in ("-h","--help"): usage() elif o in ("-d","--decode"): decode = true elif o in ("-e...

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

this question has answer here: what's mongoose error cast objectid failed value xxx @ path “_id”? 7 answers even though has been asked many times because entity has no valid objectid field. i came across situation objectid set value can casted objectid still error. the schema: var serviceschema = parammongoose.schema({ servicename:{ type: parammongoose.schema.types.objectid , ref: 'servicenames',required:true } }); pseudo code: servicefromdb=new service({servicename:'some name'}); servicefromdb.servicename='000000000000000000000001'; servicefromdb.save(function(paramerror,paramdata){ if(paramerror){ console.log('but but...',servicefromdb,paramerror) } }); the output of code is: but but... { servicename: 000000000000000000000001, _id: 55079a90286f49280364f78b } { [casterror: cast objectid faile...

machine learning - How to choose the right normalization method for the right dataset? -

there several normalization methods choose from. l1/l2 norm, z-score, min-max. can give insights how choose proper normalization method dataset? i didn't pay attention normalization before, got small project it's performance has been heavily affected not parameters or choices of ml algorithm way normalized data. kind of surprise me. may common problem in practice. so, provide advice? lot!

python - set_aspect() and coordinate transforms in matplotlib -

i run seems bug in matplotlib (version 1.4.3 )/pyplot when attempting draw line between subplots: after setting set_aspect("equal") , appears relevant coordinate transformation functions ( transdata ) don't update. execute code below ax.set_aspect("equal") uncommented see difference. import matplotlib.pyplot plt import matplotlib mpl f, (ax1, ax2) = plt.subplots(1, 2, sharey='all', sharex='all') ax in (ax1, ax2): # ax.set_aspect("equal") ax.set_ylim([-.2, 1.2]) ax.set_xlim([-.2, 1.2]) # http://stackoverflow.com/questions/17543359/drawing-lines-between-two-plots-in-matplotlib transfigure = f.transfigure.inverted() coord1 = transfigure.transform(ax1.transdata.transform([0,0])) coord2 = transfigure.transform(ax2.transdata.transform([1,0])) line = mpl.lines.line2d((coord1[0],coord2[0]),(coord1[1],coord2[1]), transform=f.transfigure) f.lines.append(line) plt.show() the relevant imag...

c - struct assignment: segment fault 11 -

#include <stdio.h> #include <string.h> #include <stdlib.h> union value { long long i; unsigned long long u; double d; long double ld; void *p; void (*g) (); }; struct foo { struct { union value max; union value min; }limits; }; struct bucket_info { void *p; // free position void *limit; // end position struct bucket_info *next; // next bucket }; #define nodes 8192 void * my_malloc(size_t size) { void *p = malloc(size); if (!p) exit(1); memset(p, 0, size); return p; } void * alloc_bucket(size_t size) { struct bucket_info *pb; pb = my_malloc(sizeof(struct bucket_info) + size); pb->p = pb + 1; pb->limit = (char *)pb->p + size; return pb; } void * alloc_for_size(struct bucket_info *s, size_t size) { void *ret; while (s->next) s = s->next; if ((char *)s->p + size > (char *)s->li...

java - load image from storage and display it into listview -

i creating application in want load images device gallery , display listview . i need step step working code example here code getting list of images gallery - public static arraylist<string> getimagesfromgallery(activity activity) { uri uri; cursor cursor; int column_index_data, column_index_folder_name; arraylist<string> listofallimages = new arraylist<string>(); string absolutepathofimage = null; uri = android.provider.mediastore.images.media.external_content_uri; string[] projection = { mediacolumns.data, mediastore.images.media.bucket_display_name }; cursor = activity.getcontentresolver().query(uri, projection, null, null, null); column_index_data = cursor.getcolumnindexorthrow(mediacolumns.data); column_index_folder_name = cursor .getcolumnindexorthrow(mediastore.images.media.bucket_display_name); while (cursor.movetonext()) { absolutepathofimage = cursor.getst...

javascript - option in form field hides option in next field -

i trying "10.30am" option dissapear in workshop time field when "monday 13th april" selected in workshop date field. failing happy if option disabled. <div class="form-group"> <form action="ksmail.php" method="post"> <div class="form-group"> <div class="row"> <p class="control-label blue">workshop date:</p> <select name="date" class="finput" id="wdate"> <option value="11th_apr">saturday 11th april</option> <option value="13th_apr" id="dt">monday 13th april</option> <option value="18th_apr">saturday 18th april</option> </select> </div> </div> <div class="form-group"> <div class="row"> ...

python - Pandas time series time between events -

how can calculate time (number of days) between "events" in pandas time series? example, if have below time series i'd know on each day in series how many days have passed since last true event 2010-01-01 false 2010-01-02 true 2010-01-03 false 2010-01-04 false 2010-01-05 true 2010-01-06 false the way i've done seems overcomplicated, i'm hoping more elegant. loop iterating on rows work, i'm looking vectorized (scalable) solution ideally. current attempt below: date_range = pd.date_range('2010-01-01', '2010-01-06') df = pd.dataframe([false, true, false, false, true, false], index=date_range, columns=['event']) event_dates = df.index[df['event']] df2 = pd.dataframe(event_dates, index=event_dates, columns=['max_event_date']) df = df.join(df2) df['max_event_date'] = df['max_event_date'].cummax(axis=0, skipna=false) df['days_since_event'] = df.index - df['max_event_d...

java - Need help setting the background image using JLabel? -

i started gui programming in java , having trouble setting background image jframe using jlabel . have read many answers same question on website code complicated beginner. my source code follows , image i'm using in src folder (i output window there no image in it): public class staffgui extends jframe { private jlabel imagelabel = new jlabel(new imageicon("staff-directory.jpg")); private jpanel bxpanel = new jpanel(); public staffgui(){ super("staff management"); bxpanel.setlayout(new gridlayout(1,1)); bxpanel.add(imagelabel); this.setlayout(new gridlayout(1,1)); this.add(bxpanel); this.setvisible(true); this.setdefaultcloseoperation(jframe.exit_on_close); this.setlocationrelativeto(null); this.setresizable(false); this.pack(); } imageicon(string) "creates imageicon specified file" . actual physical image loaded in background thread, though call might return immediately, loading still ...

html - Make inner element wider than parent element by a set amount -

Image
i have element inside element, , inner element wider parent set amount - lets 40px. if parent 500px wide: but if parent 600px wide, example, i'd child 640px wide. without tying outer element particular width, i'd inner element 40px wider outer element. there css way achieve this? i don't know width increase, can give padding of inner div via css may work you. you can give inner div css like .innerdiv { /*padding-right: 20px; */ padding:20px; /*this give left , right side 20px padding*/ } how increase width:auto div's width x pixels using pure css

kendo ui - Configure all popup editor buttons in KendoGrid to display 'Save' or 'Add' instead of 'Update' -

in popup editor in kendogrid, default buttons (if not specified), "update" , "cancel". if have lot of popup editors in different pages, kendo provide specific config file can write scripts popup editors must have button of "save" or "add" , "cancel" instead of having "update" , "cancel"? you can @ these @ runtime per control kendo.ui.<widget-name>.prototype.options.messages , in source @ src/messages/kendo.messages.en-us.js . (en-us example, see section on localization )

go - Variable defined in Golang -

this question has answer here: assigning value in golang 3 answers i create var of type var respdata []responsedata type responsedata struct { datatype string component string parametername string parametervalue string tablevalue *[]rows } type tabrow struct { colname string colvalue string coldatatype string } type rows *[]tabrow i want fill tablevalue of type *[]rows . can please tell me example assigning values in tablevalue . slices reference type (it kind of pointer ), don't need pointer slice ( *[]rows ). you can use slice of slices though tablevalue []rows , rows being slice of pointers tabrow : rows []*tabrow . tr11 := &tabrow{colname: "cname11", colvalue: "cv11", coldatatype: "cd11"} tr12 := &tabrow{colname: "cnam...

Add the current url dynamic paramater into a jQuery script -

can update below jquery code current url parameter? parameters changed each time. $("#hotel-list").load("rezults2.php?id=value&id2=value2 #hotel-list> *"); where values changed each time ?id=value&id2=value2 as example: on page 1 - main page have below code, url param : ?desinationid=bo9b&roomsno=1&city=barcelona&in=2015-05-01&out=2015-05-08&rooms%5b0%5d%5badult%5d=2&rooms%5b0%5d%5bchild%5d=0 i need send same param rezults2 page when try pull data. the name id`s url same values changed each time. so question: can update below jquery code current url parameter? so guess want location's search. try this: var datastring = window.location.search; // can update var , use $("#hotel-list").load("rezults2.php"+ datastring + " #hotel-list> *"); maybe want use , append var then: var datastring = "?id=value&id2=value2"; // can update var , use $("...

reactjs - How get the value from a select in flux -

i have following code on render function using jflux framework. please can give me idea. render: function(compile){ newcondominium: {province: ''}, return compile( <select name="provincecondominium" id="selprovince" $$-value="newcondominium.province" class="form-control"> <option disabled="true">--select--</option> <option>provincia 1</option> <option>provinicia 2</option> <option>provincia 3</option> )}; and want assign new selected option variable. how can selected option?

windows - Win32, How can i hook functions in compiled programs with C++? -

Image
take instance function (viewed in ollydbg debugger) the first push ebp instruction start void* f(int32_t n) (idk returns, guessing void*), know input parameter n @ stack, , ebp+8 pointer variable, guess int* n=(int*)(uint32_t(ebp)+0x08); /*assuming ebp void* , sizeof(ebp)==sizeof(uint32_t)==sizeof(void*) , +8 math same in c++ uint32_t , x86 assembly..*/ i want make hook, check if n above 7, or below 0, , if is, change 1. ollydbg, writing assembly code directly, can do: patch first mov ebp,esp instruction jmp short int3 instructions behind (i'll need 7 bytes), change (unused) int3's mov ebp,esp jmp long 0068bccd 0068bccd unused 0x000000000000's @ end of file , @ 0068bccd , can write assembly codes check int pointed @ ebp+8 , , modify if necessary: pushad cmp dword ptr ss:[ebp+8],7 ja short error cmp dword ptr ss:[ebp+8],0 jl short error jmp short finished error: pushad push offset thestring call onlink-x86.app::output add esp,4 popad mov dword ptr ss:[ebp+8],...