Posts

Showing posts from January, 2014

swift - Using the Map Method to Call a Class Method -

i learning map method in swift. standard definition the map method takes function (transform), , returns array containing results of calling transform on each element in array. this makes sense. if wanted add text string each string element in array following. var stringarray = ["blue", "green", "brown", "white"] var newstringarray = stringarray.map({"\($0)color"}) this adds "color" each element. my question has proper use of map function. if use create number of objects class methods acceptable use. example if have array number of objects used create new objects, calling class function map method ok? works want make sure it's not bad practice. xmlparseddataarray!.map({article.createfloarticlewithstructure($0, inmanagedobjectcontext: self.articlecontext)}) each element in xmlparseddataarray structure defined below. struct datetitlelink { var date : nsdate? var title : string? var

javascript - Events not propagating across react components -

i have following react components: class button extends react.component { constructor(props){ super(props); this.state = { disabled: false }; } render() { return <button disabled={this.state.disabled} onclick={this.clicked.bind(this)}>save</button>; } clicked(event) { this.setstate({disabled: true}); } } class form extends react.component { contructor(props) { super(props); this.state = { foo: "bar" }; } render() { return ( <form onsubmit={this.submit.bind(this)}> <input valuedefault={this.state.foo} /> <button /> </form> ); } submit(event) { event.preventdefault(); // stuff } } however, when button clicked clicked method triggered submit method isn't. there way can make event propagate? there reason event isn't propagating normal html form event? since setstate re-render entire component event stop there , cannot cont

An iOS app want to play flash video -

my app supports playing videos, of them in flash format. how can make app support flash playback? thank you. unfortunately, there no way support flash format on ios except through proxy browser photon , works remote desktop. if must include flash videos, can consider converting them mp4.

xampp - Importing external joomla site in newly installed joomla -

how import external joomla website(saved in folder) newly installed joomla in localhost without joomla extension? copy template, import data via database (sql-import) , modify configuration.php in root folder new connection. thats in cases, try , tell if went wrong.

haskell - Which unix compatibility toolchain to use with cabal install on windows? -

trying install blogliterately on win7/64. installed hp 2014.2/64 cabal update cabal install cabal-install renamed c:\program files\haskell platform\2014.2.0.0\lib\extralibs\bin\cabal.exe *.old cabal update cabal install blogliterately fails cuz needs unix toolchain install new version of network tried installing mingw , gave cuz package manager pops lists packages suffix 32 , want 64 , can't tell http://www.mingw.org/ if supports 64 bit. tried installing cygwin64 , added c:\cygwin64\bin end of path , didn't work, see on internet people think cygwin doesn't work ghc anymore, though original error said cygwin work found http://msys2.github.io/ , installed it, followed instructions update pacman on page, used win64 shell got error hsopenssl missing c libs eay32 ssl32 , googling says install http://slproweb.com/products/win32openssl.html cabal install hsopenssl --extra-include-dirs="c:/openssl-win64/include" --extra-lib-dirs="c:/openssl

php - Quantity not appearing on invoice created by WHMCS -

i trying place order via whmcs api on local environment. order code, $postfields["action"] = "addorder"; $postfields["clientid"] = "104"; $postfields["billingcycle"] = "monthly"; $postfields["pid"] = "55"; $postfields['configoptions'] = base64_encode(serialize(array(1 => 3))); $postfields["regperiod"] = "5"; $postfields["paymentmethod"] = "paypal"; it listed on api doc 'configoptions', $postfields['configoptions'] = base64_encode(serialize(array(1 => 3))); ^ changing order quantity , other options(first element quantity). problem invoice generated whmcs contains quantity 1 , not 3. --------------------------------------------------------- edit 1 ------------------------------------------------------------------ i have looked product configurations, " tick box allow customers specify if want more 1 of item when orderi

javascript - Chrome and Firefox are cancelling my local requests -

i'm trying test local flash development injecting swf file website being served test server. i've set --disable-web-security on chrome allow me load local resources. on firefox i've set: security.fileuri.strict_origin_policy = false security.checkloaduri = false in both cases code failing. here markup looks like: <object style="visibility: visible;" id="flash_test" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="480"> <param name="movie" value="file:///c:/users/peter/desktop/test.swf" /> <param name="allowscriptaccess" value="always" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <param name="type" value="application/x-shockwave-flash" /> <param name="pluginspage" value="http://www.macromedia

bash - Shell: How can I make a text-mode bar chart from parsed data (numbers)? -

Image
i developing linux's bash shell script extracts data text file leaving numbers . these example parsed data: 3 4 4 5 6 7 8 8 9 11 i create simple text-mode bar chart one, corresponding these values: details: i need graphic chart vertical . the first numbers should appear on left , latest on right . a n (parsed number) characters high column appropriate me. first bar on left in example should 3 characters high, second 4, third 4, fourth 5, , on. more precisely, example, (using █ character) like: █ █ ██ ███ ████ █████ ██████ ███████ █████████ ██████████ ██████████ ██████████ note 3 characters high first (left) column , 11 characters high last (right) column. same example $ characters, make more readable: $ $ $$ $$$ $$$$ $$$$$ $$$$$$ $$$$$$$ $$$$$$$$$ $$$$$$$$$$ $$$$$$$$$$ $$$$$$$$$$ the closest know of method progress bar until now, have used in

node.js - When does socket.io use polling instead of websockets? -

i pretty new socket.io , have written first app in node/express/socket.io. right works great on nginx server. want release app public, gripped fear won't work lot of people. have had few friends test app , went smoothly (it pretty simple app). here concern: right every connection seems using websockets, want. app downgrade "polling" due weird on clients' end? if so, how socket.io decide when use polling , when use websocket (is based on browser/version or connection or what)? pretty sure uses websocket when possible, there list somewhere of conditions knock down "polling"? also, there way can test application using "polling" see if works? i can post code, think general question on how socket.io works. the time client downgrade ajax polling (assuming server support does) when browser client doesn't support websockets (e.g. old client) or perhaps if proxy in client path doesn't support websockets. websockets supporte

html - Inline list heights not consistent with wrapped text -

Image
hi have inline list behaving strangely if text in anchor wraps onto next line. can solve line-height: 0; messes text. ideas on how them on same line? code snippet #communityboardslinks{ margin: 10px 0 20px 0; list-style: none; padding: 0;} #communityboardslinks li{ display: inline-block; background-color: black; } #communityboardslinks li a{ font-family: sans-serif; display: block; color: white; font-weight: bold; font-size: 24px; width: 96px; height: 96px; padding: 10px; text-decoration: none; } #communityboardslinks li a:hover{ color: red;} #communityboardslinks li:last-child{ width: 115px;} #wrapperman{ width: 715px;} <div id="wrapperman"> <ul id="communityboardslinks"> <li><a href="#">link</a></li> <li><a href="#">link</a></li> <li><a href="#">link</a></li> <li><a href=

ubuntu - View graphml file -

i found .graphml file have no idea how open command line. need install view such files in ubuntu command line? tried google not find result related topic. graphml standard file format graph yed editor . editor can downloaded on platform (linux, mac ,windows). the documentation graphml format itself, xml-based, can found here .

python - Regular expressions in Beautiful soup don't work -

i'm trying find tag. tag's class contains substring: borderbox flightbox p2 . for example this: <div class="borderbox flightbox p2 my-repeat-animation ng-scope"... so suppose should works: soup.find_all('div',class_=re.compile(r"borderbox flightbox p2"+".*")) but can't find anything. have advice? this should want: def match_tag(tag, classes): return (tag.name == 'div' , 'class' in tag.attrs , all([c in tag['class'] c in classes])) divs = soup.find_all(lambda t: match_tag(t, ['borderbox', 'flightbox', 'p2')) in beautifulsoup 4, regex passed class_ argument applied each css class individually. beautifulsoup checking each individual css class held div see whether matches regular expression gave it. put in code, it's doing like: for class in div['class']: if regexp.search(class): yield div of course no individual cla

java - RecyclerView item removal -

i trying remove specific items recyclerview list not know how approach it. cannot use notifyitemremoved method because error says method cannot used static context. can see have of event listeners in adapter's view holder because more convenient. here code public class cartlistadapter extends recyclerview.adapter<cartlistadapter.restaurantholder> { list<cartitem> cartlist; private static string log_tag = "myrecyclerviewadapter"; private static myclicklistener myclicklistener; static context context; public static class restaurantholder extends recyclerview.viewholder { textview cartitem; textview cartprice; textview cartquantity; imageview increaseicon; imageview decreaseicon; imageview deleteicon; int selectedposition; int quantity; double price; boolean pricestored = false; restaurantholder(view itemview) { super(it

c# - Using StringComparer with StringBuilder to search for a string -

i need use globalization rules search occurrences of string within document. pseudocode is: var searchtext = "hello, world"; var compareinfo = new cultureinfo("en-us").compareinfo; documentiterator start = null; // start position if match occurs var sb = new stringbuilder(); // document not string, exposes iterator content (var iter = doc.start(); iter.isvalid(); ++iter) { start = start ?? iter; // start of potential match var ch = iter.getchar(); sb.append(ch); if (compareinfo.compare(searchtext, sb.tostring()) == 0) // exact match { console.writeline($"match @ {start}-{iter}"); // not shown: continue search more occurrences. } else if (!compareinfo.isprefix(criteria.text, sb.tostring())) { // restart search character following start sb.clear(); iter = start; // gets incremented start = null; } } this delegates compareinfo difficult job of culture-sensitive st

c# - Read Node attributes from XML file -

i have following xml file. <?xml version="1.0" encoding="utf-8" ?> <countries> <country> <id>101</id> <city>austin</city> </country> <country> <id>102</id> <city>dallas</city> </country> <country> <id>103</id> <city>chicago</city> </country> <country> <id>104</id> <city>aman</city> </country> </countries> i trying read code behind. here code list<city> citylist = new list<city>(); string url = "/app_data/countries.xml"; xmldocument doc = new xmldocument(); doc.load(server.mappath(url)); xmlnodelist nodelist = doc.selectnodes("country"); foreach (xmlnode node in nodelist) { if (node != null) { int id = int.parse(node.attributes[&quo

r - Align text right justified but center of each box in geom_text -

Image
i have created graph ggplot using geom_tile , geom_text. want able read numbers down 1 column , have them lineup. set font courier , used hjust justify numbers (otherwise negative sign throws off alignment). cant find way keep right justification , center text in middle each box. ideas on how numbers line can scan column quickly? reproducible example below. require(reshape2) require(ggplot2) require(scales) set.seed(504) df_graph <- data.frame("category"=c("green","blue","red","yellow","black","random1","random2","random3","random4","random5","random6","random7", "random8","random9","random10"),"test1"=rnorm(15),"test1"=rnorm(15),"test2"=rnorm(15),"test3"=rnorm(15), "test4"=rnorm(15),"test5"=rnorm(15

javascript - How to call Azure Blob Storage using REST API with SAS -

Image
i attempting call azure storage blob container using postman no luck. here javascript code generating shared access signature: <script src="https://github.com/dmester/sffjs/blob/master/src/stringformat.js"></script> <script src="https://github.com/caligatio/jssha/blob/master/src/sha256.js"></script> var method = "get"; //build date in utc var dateinrfc1123format = new date(); dateinrfc1123format = dateinrfc1123format.toutcstring(); console.log(dateinrfc1123format); //azure blob account info var accountname = "siteassets"; var containername = "test"; var key = "supersecretomitted"; //required stuff var canonicalizedheaders = string.format("x-ms-date:{0}\nx-ms-version: 2009-09-19\n", dateinrfc1123format); var canonicalizedresource = string.format("/{0}/{1}/", accountname, containername); // building string need signed key var stringtosign = string.format("{0}\n\n\n\n\

delphi - Exception loading ssleay32 with Indy10 with HTTP Server -

i'm trying implement ssl support on http server , i'm getting exception when activate server component: the ordinal 3314 not located in dynamic link library "ssleay32.dll". this application ported delphi 2007 delphi xe7. had been working in 2007. here's i've tried: got latest openssl dlls. same error created new xe7 test project form httpserver , openssl iohandler components. worked. i'm not using visual components in primary app; thought i'd try creating form in primary app. added appropriate components, , failed same error. since project ported d2007, thought there may settings in old project may interfering. created new dxe project , imported forms, units, etc. same error. i thought possibly manually generated code may incorrect, copied on test dxe project; , worked. i did discover error being thrown call loadlibrary in safeloadlibrary in system.sysutils. my conjectures are. there's setting somewhere interfering corr

c++ - clEnqueueNDRangeKernel fills up entire memory -

Image
i trying write opencl application doing memory intensive calculations. track progress of calculations created for loop creates different kernel groups. unfortunately, calculation fills whole memory. guess kernels not done executing before next heap added. for (unsigned long i=1; i<maxglobalthreads; i+=1000000) { // calculating offset size_t temp = 1000000; size_t offset = 0; if (i>1000000) { offset = i-1000000; } cl_event tmp; clenqueuendrangekernel(command_queue, kernel, 1, &offset, &temp, null, null, 0, &tmp); // wait until threads finished (-- not working) clwaitforevents(1, &tmp); // copy results memory buffer int *res = (int*)malloc(64*sizeof(int)); int *indexnum = (int*)malloc(14*sizeof(int)); err = clenqueuereadbuffer(command_queue, foundcombimem, cl_true, 0, 64*sizeof(int), res, 0, null, null); err = clenqueuereadbuffer(command_queue, indexnummem, cl_true, 0, 14*sizeof(int), index

javascript - AngularJS Directive how to show/hide custom(appended) element on a condition -

i' working on angular directive , show error msg on exceeding character count on textarea. with following code, can show error(div) msg appending on element, cannot hide after showing first time, need in else block remove "elcharlimiterror". angular.module('app', []).directive('wordcount', ['$compile', function($compile) { function wordcountlinkfunc(scope, ele, attr, ngmodel) { var charlimit = attr.wordcount; console.log(charlimit); var elcharlimiterror = angular.element('<div class="alert alert-danger">cannot exceed character limit<b>' + charlimit + '</b></div>'); ele.bind('keyup', function(event) { if (ngmodel.$viewvalue && ngmodel.$viewvalue.length >= charlimit) { $compile(elcharlimiterror)(scope); ele.append(elcharlimiterror); } else { //todo: need hide err

Openshift origin builder fails to push to docker registry -

i'm trying work through openshift origin 'get started' tutorial using docker image i'm having problems builder; can't push image docker, says authentication required. i0618 19:34:12.387273 1 sti.go:96] using provided push secret pushing openshift/ruby-20-centos7:latest image i0618 19:34:12.387301 1 sti.go:99] pushing 172.30.205.86:5000/test/origin-ruby-sample image ... e0618 19:34:20.595037 1 dockerutil.go:50] push image 172.30.205.86:5000/test/origin-ruby-sample failed, retry in 10s ... e0618 19:34:38.535347 1 dockerutil.go:50] push image 172.30.205.86:5000/test/origin-ruby-sample failed, retry in 10s ... f0618 19:34:59.341670 1 builder.go:70] build error: failed push image: error pushing registry: authentication required. i'm new docker/kubernetes/openshift, i'm not sure if missed when setting docker registry or if there's parameters supposed supply somewhere. so restarted tutorial after removing old fold

buffer overflow - Assignment from Incompatible Pointer Type In C Script -

in course i'm taking, given broken buffer overflow script written in c, , have fix broken coding. i've patched few things far, receiving error message when trying compile (the error showed initial code, not edited):   646-fixed.c: in function ‘exploit’: 646-fixed.c:48: warning: assignment incompatible pointer type   below function error occurring. i'm not familiar c - responses received yesterday, understand happening due ptr's type being int, & evil's type being char. don't understand can fix - can this? can see full script here   void exploit(int sock) { file *test; int *ptr; char userbuf[] = "user madivan\r\n"; char evil[3001]; char buf[3012]; char receive[1024]; char nopsled[] = "\x90\x90\x90\x90\x90\x90\x90\x90" "\x90\x90\x90\x90\x90\x90\x90\x90"; memset(buf, 0x00, 3012); memset(evil, 0x00, 3001); memset(evil, 0x43, 3000); 48

python - Regex not working for multiple pattern occurence -

i want grab every first occurence of strings followed "genome_" ending before ",(" , replace particular string, "xxx" in text below: (id_bxylanisolvens_nlae-zl-c182_genome_orf00003____bxylanisolvens_nlae-.._843_unknown___1278-2120_1_^^ neighbours_id_bxylanisolvens_nlae-zl-c182_genome_orf00002_1__id_bxylanisolvens_nlae-zl-c182_genome_orf00004_1__neighbour_genes_bxylanisolvens_nlae-.._bxylanisolvens_nlae-.. :0.00000230914009336068,((id_bxylanisolvens_nlae-zl-g421_genome_orf00003____bxylanisolvens_nlae-.._843_unknown___1315-2157_1_^^ neighbours_id_bxylanisolvens_nlae-zl-g421_genome_orf00002_1__id_bxylanisolvens_nlae-zl-g421_genome_orf00004_1__neighbour_genes_bxylanisolvens_nlae-.._bxylanisolvens_nlae-.. :0.00000230914009336068,id_bxylanisolvens_nlae-zl-c339_genome_orf00003____bxylanisolvens_nlae-.._843_unknown___1084-1926_1_^^ neighbours_id_bxylanisolvens_nlae-zl-c339_genome_orf00002_1__id_bxylanisolvens_nlae-zl-c339_genome_orf00004_1__neighbour_

D3.js Simple Line Chart on Array with Dates -

im d3 newbie , having problems creating simple line chart x data being date. having problems reading in date variable (x) local array x. problem partly call of d3.time.format , returning of svg.line function. <title>d3 paths 2 tutorial </title> <script src="http://d3js.org/d3.v3.min.js"></script> </head> <body> <script> var linedatanew = [['2014-07-22 14:00:00',22979.57],['2014-07-22 14:15:00',22980.77],['2014-07-22 14:30:00',22981.99]]; var newdata = []; var newlinedata; (index = 0; index < linedatanew.length; index++) { var strelement = linedatanew[index].tostring() ; var arr = strelement.split(","); newlinedata = newlinedata + "{" + "x:'" + arr[0] + "', y:" + arr[1] + "}" newdata.push(newlinedata); if (index < arr.length) { newlinedata = newlinedata + &qu

arrays - Rotation of 3D data in XY plane (Matlab) -

Image
i have 3d array contains probability values function of spatial position (x , y coordinates). when plot array using imagesc or surf, elliptic profile maximum. rotate data around point of maximum probability in xy plane such y axis becomes parallel major axis of ellipse (which computed using regionprops). don't want rotate image or surface using imrotate or geometric object rotation, since need array containing rotated data. how achieve if know angle of rotation around z axis (obtained regionprops)? edit : here code used rotate matrix around centroïd. however, when plot result using surf, weirdest result... % translation , anti-translation matrix translate = [1 0 0 -centroide(1); 0 1 0 -centroide(2); 0 0 1 0; 0 0 0 1]; anti_translate = [1 0 0 centroide(1); 0 1 0 centroide(2); 0 0 1 0; 0 0 0 1]; % rotation matrix rotate = [cosd(-orientation) -sind(-orientation) 0 0; sind(-orientation) cosd(-orientation) 0 0; 0 0 1 0; 0 0 0 1]; % temporary cell array data transformation da

java - Partitioner for result set from oracle database in spring batch -

i need extract results query in flat file. there way partition result set can accessed multiple threads. i tried partitioning based on rownum without sort, when same query executed multiple threads rownum not remain same(because not sorting due performance impact) , creates duplicates in output. use rowid instead. rowid immutable every record. or use primary key (or other field enough distinct values mather) devide data in subsets. select * table substr(rowidtochar(rowid),-1) in ('a','a','0'); select * table substr(rowidtochar(rowid),-1) in ('b','b','1'); or select * table substr(rowidtochar(rowid),-1) between 'a' , 'z'; etc. you'll have experiment little clause. far know last character of rownum can contain [a-z][a-z][0-9] + , /

html - Image overlap on css responsive page -

this first try @ responsive design , can't quite right. seen in first screenshot tower image overlaps div , i'm not sure i've done wrong. image here: http://postimg.org/image/l9ax77rhz/ the width of container 1170px , wanted trigger scaling of images , text once screen size dropped below point. image here: http://postimg.org/image/n420djzlj/ dropping below 760 sections begin overlap. want fix overlap , have images display first on small screens title , text below. can explain me how or i've done wrong? html , css below <style> .lenovo-container { width: 1170px; height: 381px; min-width: 858px; } .lenovo-container img { float: left; } @media (max-width:1170px) { img { max-width: 100%; height: auto; } .lenovo-container { max-width: 100% @media (max-width: 858) { .lenovo-container p { display: block; } } </s

html - Elegant Themes – Background image in Divi theme zooms in on mobile -

i'm using normal section module , have image background of module. looks fine on desktop when viewed on mobile device bg zoomed in , looks terrible. can't seem figure out why mobile not adjusting or if there need image mobile friendly? here test website http://test.mutualmind.com , problem i'm having worth last section right before footer. can compare desktop view vs mobile view t see mean. it's because background-size of section set cover means background image scale until fills both width , height of container. in case, height large image must scale fit. if trim of height off of section on smaller devices, you'll see image scale down along it. you can giving section custom class or id on page builder , targeting on smaller screens through media queries in stylesheet.

the coeff of pca in matlab is not a p*p matrix -

my data matrix x 4999*37152 . use command in matlab: [coeff, score, latent, tsquared1, explained1] = pca(x); the output: coeff 37152*4998 , score 4999*4998 , latent 4998*1 . according http://www.mathworks.com/help/stats/pca.html , coeff should p*p. wrong code ? as matlab documentation says, "rows of x correspond observations , columns correspond variables". feeding in matrix 4999 observations 37152 observations. geometrically, have 4999 points in 37152-dimensional space. these points contained in 4998-dimensional affine subspace, matlab gets 4998 directions there (each expressed vector 37152 components). for more, see statistics site: why there n-1 principal components n data points if number of dimensions larger n? pca when dimensionality greater number of samples the matlab documentation written under assumption have @ least many observations variables, how people use pca. of course, it's possible data has 37152 observations 4999 variabl

icalendar - Is it possible to generate an ICS file in Javascript and then pass it via webcal: url? -

i aware it's possible generate ics file , prompt user download via javascript: https://github.com/nwcell/ics.js and possible set webcal url points ics file hosted on internet, such as: webcal://ical.mac.com/ical/us32holidays.ics but possible, without server-side intervention, give user webcal url uses dynamically generated ics? generate dynamic calendar event in front-end javascript application , ideally not involve backend in process.

Make an Argument Optional in Python -

this question has answer here: is there way pass optional parameters function? 5 answers i'm making script gui box in cad program, , user selects 7 different surfaces in viewport. pass values onto function when user hits "ok" the function passed looks this def meshingtools(od_idsurf, trgsurf, pipebodysurf, sealsurf, threadsurf, bodysurf, cplgendsurf): the problem is: if user not need select 1 of surfaces, error saying, meshingtools() takes 7 non-keyword arguments (2 given) how can around issue? update: i tried keyword arguments , not quite getting need. def meshingtools(**kwargs): print kwargs when select 1 surface, following out {'pipebodysurf': (mdb.models['fullcal4'].rootassembly.instances['pinnew-1'].edges[151], mdb.models['fullcal4'].rootassembly.instances['pinnew-1'].edges[153])} if t

javascript - HTML Links do not work after AJAX POST -

background: working on small web application. ajax post data action(create.php) , create.php execute necessary mysql query. once ajax done, append message div id="container"></div> informing user of successful execution clear content "container" future use; however, here in lies problem. problem: after ajax executes, can not click on html links loaded onto page(page.php). have refresh page in order click on links , follow them destination. causing happen , how can fix it? ajax not need return result. needs execute specified jquery code once request done. on hunch, altered create.php echo $_post array , have ajax return result. once ajax loads result "container" still can not click on links loaded on page.php answer: dom not being reloaded after ajax calls causing bootstrap dropdown menus not function properly. bootstrap dropdown class had manually reinitialized after each call. has been answered in detail here create.php <?ph

python 3.x - Label keeps on appearing -

so using python 3.4 , tkinter. and when call function again n again contains label, label keeps on appearing in window previous label doesn't go away? how can remove printed label gui window function called , display new one? here code:- #def prestart(): #here check if number of match okay, if not, user redirected setting else, call start() def start(): #cpu choice cpu_choice = label(historyframe, text = "cpu choosed: {}".format(dict['cpu_choice'])) #played match #played_num_of_match = label(scoreframe, text = "number of matches played: {}".format(int(dict['match_played']))) #display status status_disp = label(scoreframe, text = "current status: {}".format(dict['status'])) if(int(dict['match_played']) < int(dict['num_of_match'])): playframe.grid(row = 1, column = 0) historyframe.grid(row = 2, column = 1) status_disp.pack(fill=x) elif(

c# - Using Linq to get XML data from database -

i'm struggling values of single xml node using linq. here xml. <?xml version="1.0" encoding="utf-8"?> <record> <addressline1>abcd street</addressline1> <addressline2>xyz ave</addressline2> <addresscity>illinois</addresscity> <addressstate>chicago</addressstate> <addresszip>23434</addresszip> </record> and here c# code xelement xmldoc = xelement.parse(varq.content); //when debug find xmldoc contains xml. alright. var q = (from lpi in xmldoc.descendants("record") select new { addressline1 = lpi.element("addressline1").value, addressline2 = lpi.element("addressline2").value, addresscity = lpi.element("addresscity").value, addresscountry = lpi.element("addresscountry").value, addressstate = lpi.elem

java - Calling HashMap data from a separate class/method -

my question revolves around how call hashmap data have stored in method main junit testing class. @test public void pcitest() throws exception { hashmap<string, string> examples = new hashmap<string, string>(); examples.put(pcitestdata()); //remaining testing code below } //storing data here public hashmap<string,string> pcitestdata() { hashmap<string, string> examples = new hashmap<string, string>(); public static hashmap<string, string> getexamples() { return examples; } examples.put("credit card", "4929028573388403\n" + "4024007140713941\n" + "4528684534391095\n" + "5188872375900391\n" + "5449835900541183\n" + "5525878422452056\n"); //more data below } i want take data pcitestdata() , place in hashmap examples in pcitest(), seen examples.put(pcitestd

floating point - multiplication R without float -

is there way multiplication float in serie sof 2 multiplications integers. need write function accepts input values such as 3.4556546e-8 1.3 0.134435 instead of doing 100*0.134435 100/1000000 , multiply 134435 the function should output give 1000000 , 134435 - needed because need work large numbers in big integers , mutipliying anythign except intgers doent work apparently want arbitrary precision arithmetics. don't need reinvent wheel. library(gmp) x <- as.bigq(0.134435) 100 * x #big rational ('bigq') : # [1] 121088283181110525/9007199254740992

r - Plot with 2 y axes, one y axis on the left, and another y axis on the right -

i need plot bar chart showing counts , line chart showing rate in 1 chart, can both of them separately, when put them together, scale of first layer (i.e. geom_bar ) overlapped second layer (i.e. geom_line ). can move axis of geom_line right? <rant> client wants 2 y scales. giving them "flawed" speech pointless. ggplot2 insistence on doing things right way. sure ggplot in fact educating average user proper visualization techniques. </rant> maybe can use faceting , scale free compare 2 data series? - e.g. here: https://github.com/hadley/ggplot2/wiki/align-two-plots-on-a-page

java - Input variable created at Main is a different value to that created in Method -

i have created method gets input user. however, issue when attempt return value of method, continuously asks new number input. instead, want ask number once, return it. for example: following code illustrates want achieve without method, including within method causes difficulties: working code inside main: public static void main(string[] args) { scanner input = new scanner(system.in); int age; system.out.print("enter age: "); age = input.nextint(); system.out.print("/nyou're " + age + " years of age."); } however, when try within method, have difficulties: code inside method: public static int getage() { scanner input = new scanner(system.in); int number; number = input.nextint() return number; } the issue is, whenever try print system.out.print(getage()); asks number each time. why first code allow me print age without asking new number, calling method print number cause

How can I extract data of an external XML to PHP? -

i have external xml of forex, in url: http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote and want extract info of it. i have code in php: $abc = simplexml_load_file('http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote'); $abc->query->results->rate[0]->name; and throws this: notice: trying property of non-object in /var/www/html/prueba.php on line 3 how can extract data of it, , how can i, example, extract data of usd/eur using filter of words? thanks

Generating JSON with Rails? -

i need generate json string looks like: def self.feedback_request(history_event) @event = history_event.event @case_tracking_id = history_event.case_tracking_id @request_type = "feedback" return "{ "event":@event "case_tracking_id":@case_tracking_id "request_type":@request_type "event_data":historic_event.to_json }" end does rails have way generate json strings? the right way using jbuilder part of rails. so documentation: # app/views/message/show.json.jbuilder json.content format_content(@message.content) json.(@message, :created_at, :updated_at) json.author json.name @message.creator.name.familiar json.email_address @message.creator.email_address_with_name json.url url_for(@message.creator, format: :json) end if current_user.admin? json.visitors calculate_visitors(@message) end json.comments @message.comments, :content, :created_at json.at

javascript - How to render an existing template as a popup form on a separate page on the click of button? -

i making web app using django, have template contains form needs filled user, want provide option user can fill form separate template means of button on template, clicking on button displays original form popup form. able open original form on button click on separate window not popup on same page. i know use jquery , ajax i'm not sure how implement it. you should separate template form two: form.html {# usual header , containers work on separate page correctly #} ... {% includes "your_app/includes/ajax_form.html" %} .... ajax_form.html {# form here or container sent via ajax #} <form ...> </form> also inside template want have popup should again include ajax_form.html template. don't forget set correct action in form send requests formview . then have create view overriden get_template_names method: class yourformview(formview): ... def get_template_names(self): if self.request.is_ajax(): return [

php - how to find a specific objet in a liste of object (other way than a loop) -

i know if possible retrieve object list through id (or other way). far have loop , test each object see if correct one. exemple here exemple retrieve dbb liste of object picture (this list pictures ). step_1 => determining best picture id depending on attribut scorelike. highest scorelike picture best picture) step_2 => want set attribut bestpicture yes picture id equal value of variable $id_of_best_picture, otherwise should set no. // step_1 - determining best picture id // ---------------------------------------- $bestscorelike = o; foreach($pictures $picture) { $scorelike = $picture->getscorelike(); if($scorelike > $bestscorelike) { $bestscorelike = $scorelike; $id_of_bestpicture = $picture->getid(); } } // step_2 - having loop find object again // ------------------------------------------------------ foreach($pictures $picture) { if($picture->getid() == $id_of_be

c - Passing struct to main via char* pointer -

what i'm ask bit hacky (in it's poor method of attacking problem) - understand , not plan on using long-term solution, proof-of-concept. that said, i'm working on project uses qemu foundation migrate processes (eventually threads) 1 machine another. i'm starting process on native machine, pausing using ptrace, , copying cpu's registers , stack , pushing values newly-created instance of qemu (with same underlying architecture, i.e. x86-64 --> x86_64, arm64 --> arm64). (eventually) resume execution in qemu. i've reached stage need pass registers + stack qemu, i've hit bit of wall; ideally, break apart qemu , compile entire program part of own program, proof-of-concept comes play. qemu massive program, , breaking apart/reconstructing makefiles i'm not terribly keen on approaching right now. so... is possible me fill struct registers + stack in program, create pointer struct, cast pointer char*, , pass char* pointer execlp, recast in (a m