Posts

c# - Attribute value in root node of xml Linq to XML -

while parsing xml linq xml, came across strange behaviour (atleast me). below first xml parsed `<?xml version="1.0" encoding="utf-8"?> <testrun> <unittestresult testname = "arun" outcome = "i"> </unittestresult> <unittestresult testname = "arun1" outcome = "i"> </unittestresult> </testrun>` my code looks xdocument doc = xdocument.parse(filecontents); var result = doc.descendants("unittestresult"); the above works fine. if root node contain attributes same code not working. reason. xml sample below <?xml version="1.0" encoding="utf-8"?> <testrun id="7903b4ff-8706-4379-b9e8-567034b70abb" name="inaambika@inbelw013312a 2016-02-26 16:55:14" runuser="stc\inaambika" xmlns="http://microsoft.com/schemas/visualstudio/teamtest/2010"> <unittestresult testname = "arun" outcome = "...

android - Retrieve value from radioButtons in alertDialog -

i want retrive value radio buttons. doing below code. when click ok button of alert dialog app force closed. why is so. not retriving value properly final sharedpreferences settings = getsharedpreferences(prefs_name, mode_private); if (settings.getboolean("isfirstrun", true)) { layoutinflater li = layoutinflater.from(this); view promptsview = li.inflate(r.layout.prompts, null); alertdialog.builder alertdialogbuilder = new alertdialog.builder(this); alertdialogbuilder.setview(promptsview); final edittext userinput = (edittext) promptsview .findviewbyid(r.id.edittextdialoguserinput); final radiogroup radiogroup = (radiogroup) findviewbyid(r.id.radiogroup1); // set dialog message alertdialogbuilder.setcancelable(false).setpositivebutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog,int which...

ios swift - uiimage array to video disorted and flipped -

Image
i modified of code in time lapse builder class in link https://github.com/justinlevi/imagestovideo take in array of images instead of url. everything seems working fine far taking images , creating video; however, i'm having issues way images being displayed in video. this how images , under how on iphone: i feel issue in fillpixelbufferfromimage method: func fillpixelbufferfromimage(image: uiimage, pixelbuffer: cvpixelbuffer, contentmode:uiviewcontentmode){ cvpixelbufferlockbaseaddress(pixelbuffer, 0) let data = cvpixelbuffergetbaseaddress(pixelbuffer) let rgbcolorspace = cgcolorspacecreatedevicergb() let context = cgbitmapcontextcreate(data, int(self.outputsize.width), int(self.outputsize.height), 8, cvpixelbuffergetbytesperrow(pixelbuffer), rgbcolorspace, cgimagealphainfo.premultipliedfirst.rawvalue) cgcontextclearrect(context, cgrectmake(0, 0, cgfloat(self.outputsize.width), cgfloat(self.outputsize.height))) let horizontalratio = c...

html - How to set background image using picture tag and src set -

how set image background div.so div should take height of image.this functionality need implemented using picture tag , srcset attribute in html.and if text overlays on image image should remain in same height div height should grow text. below code tried div height not increasing <style> .image { position: relative; width: 100%; /* ie 6 */ } .info{ position: absolute; top: 200px; left: 0; width: 100%; color: yellow; } </style> <script src="picturefill.min.js"></script> <div class="image"> <picture> <source srcset="new-york-city-wallpapers-desk.jpeg" media="(min-width: 1240px)"> <source srcset="new-york-city-wallpapers-tab.jpeg" media="(min-width: 940px)"> <source srcset="new-york-city-wallpapers-mob.jpeg" media="(min-width: 724px)"> <img srcset="" src="new-yor...

multithreading - What is thread local storage? Why we need it? -

i reading threads in os concepts , come across "thread local storage (tls)". understood tls similar static or global data, more unique individual thread. bit confusing on unique here? why can't pass data through runner (i.e., thread's actual codes) functions params function? let's supposed working in ada. in ada program define task (thread) includes [static] variable can accessed task. create multiple instances of task. need copy of [static] variable each task. that's implementation use thread local storage. in other words, static area of memory gets copied each thread in program. as alternative tls, thread allocate such storage @ top of stack.

xml - Xpath with xmlns -

although there tons of question on xpath , xmlns, not able achieve desired result. my xml :- <project xmlns = "https://afdsl/skdflsk/d"><name>amcr_positions</name><property name="included" type="hidden">true</property><locales><locale>en</locale><locale>de</locale></locales> <defaultlocale>en</defaultlocale> <namespace><name locale="en">amcr_positions</name> <name locale="de">amcr_positions</name> <lastchanged>2015-04-06t17:37:40</lastchanged> <lastchangedby>i575079</lastchangedby> <property name="included" type="hidden">true</property> <namespace> <name locale="en">database layer</name> <querysubject status="valid"> <name local...

scala, transform a callback pattern to a functional style internal iterator -

suppose api given , cannot change it: object providerapi { trait receiver[t] { def receive(entry: t) def close() } def run(r: receiver[int]) { new thread() { override def run() { (0 9).foreach { => r.receive(i) thread.sleep(100) } r.close() } }.start() } } in example, providerapi.run takes receiver , calls receive(i) 10 times , closes. typically, providerapi.run call receive(i) based on collection infinite. this api intended used in imperative style, external iterator. if our application needs filter, map , print input, need implement receiver mixes these operations: object main extends app { class myreceiver extends providerapi.receiver[int] { def receive(entry: int) { if (entry % 2 == 0) { println("entry#" + entry) } } def close() {} } providerapi.run(new myreceiver()) } now, question how use providerapi in functional style, internal ...

node.js - Socket.io using default namespace with some custom namepsace, not working -

i trying use default namespace '\' connecting general android application sockets socket.io , want make custom namespace website '/web' when client io.connect('/web') connects default namespace. basically want authorization of all, not /web namespace. here code io.sockets.on('connection', function (socket, next) { //some handshaking data varify connection } io.of('/web').on('connection', function(socket, next) { //here want skip verification } got request on default instead of /web. socket.io connection event trigger / default namespace on socket connections. later events client trigger on namespace connected to.

Make camera in webgl with vertex shader? -

i have idea, i'm not sure it, because i'm no guru in webgl. in webgl, there no camera. if 1 want simulate it, has operations lot of objects... precise, must change position hundreds of thousands of vertices. didn't study three.js or babylon js deep, have no clue, how work cameras. since vertex shader can transform vertex positions , because can pass camera matrix vertex shader, make sence let make calculations, gpu hard work instead of cpu? do mean : create view matrix in vertex shader using data position , orientation instead of create application , send resulting matrix in shader ? actually last case solutions three.js , lot of others : object representing camera can manipulated javascript. @ draw, view matrix built position , orientation parameters, , sent active shader program. creating view matrix done in steps : create identity matrix (no transformation) ; combine matrix each transformations apply camera : translations , rotations ; invert...

c# - How to make a StackPanel fit its Children's width -

i'm writing down here because i'm having lots of issues thing, , hope able me out :p i want create dynamic stackpanel fits children's width. i'll make example. let's stackpanel empty. width 10 (f.e.) , fixed height 30. want add image, , wrote down: bitmapimage myimage = new bitmapimage(new uri("[path]")); image realimage = new image(); realimage.source = myimage; realimage.width = 50; realimage.height = myimage.height; mystackpanel.children.add(realimage); the stackpanel not enlarge 50px though; it's stuck 10px, cutting image. same happens when try add other ui elements, textblocks , on. i tried like mystackpanel.width += realimage.width; but of course didn't work. i've tried set stackpanel's width "auto", didn't either. stackpanel declaration in xaml: <window x:name="mainwindow1" x:class="proj.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"...

Printing from a buffer using the read(2) function in C -

i'm trying read in bits using read function , i'm not sure how i'm supposed printf results using buffer. currently code fragment follows char *infile = argv[1]; char *ptr = buff; int fd = open(infile, o_rdonly); /* read */ assert(fd > -1); char n; while((n = read(fd, ptr, size)) > 0){ /*loops reads file until returns empty */ printf(ptr); } the data read ptr may contain \0 bytes, format specifiers , not \0 terminated. reasons not use printf(ptr) . instead: // char n; ssize_t n; while((n = read(fd, ptr, size)) > 0) { ssize_t i; (i = 0; < n; i++) { printf(" %02hhx", ptr[i]); // on older compilers use --> printf(" %02x", (unsigned) ptr[i]); } }

javascript - Turn script content of a function into string -

this question has answer here: how functions's body string? 2 answers for example, if have this: function hello() {console.log("hello")} i want able make function in java script return string value: "console.log("hello");" is there way plain javascript? you can of code including function declaration calling tostring() method on function. can parse string remove unwanted information. something this: function hello() { console.log("hello"); } var f = hello.tostring();//get string of whole function f = f.substring(f.indexof('{') + 1);//remove declaration , opening bracket f = f.substring(0, f.length - 1);//remove closing bracket f = f.trim();//remove starting/eding whitespace console.log(f); here working example

SSAS Many-to-Many relation without bridge table -

is possible many-to-many relation without bridge table in ssas ? have 1 fact table subjectid , fact table fk_subjectid , many others keys (related others dimensions). in view datasource 2 fact table connected each other, can't chose many-to-many relationship in dimension tab ? i'm missing maybe ? thanks lot. you @ least have define intermediate dimension. can defined based on first of fact tables, , can have subjectid attribute. , invisible users. analysis services requires intermediate dimension many-to-many relationships.

Python Barcode Generation -

i'm using elaphe package python generate ean-13 barcode images. package installed source using tar file found @ https://pypi.python.org/pypi/elaphe . when run code: barcode_image_path = "/tmp/" def create_barcode_image(product_barcode): path = barcode_image_path + product_barcode + '.png' img = barcode('ean13', product_barcode, options=dict(includetext=true, height=0.4), margin=1) img.save(path, 'png') return path from python interpreter seems work perfectly. correct barcode generated path specify. when run apache using web.py web framework receive error: traceback (most recent call last): ... img_path = create_barcode_image(barcode) file "/var/www/py/documents/barcode_images.py", line 27, in create_barcode_image img.save(path, 'png') file "/usr/local/lib/python2.7/dist-packages/pil/image.py", line 1406, in save self.load() file "/usr/loca...

coldfusion - Unable to access shared folder on windows via apache on mac -

i trying setup local site on mac. the configuration - application server: coldfusion 9 webserver: apache 2 i have got local site , running. in site, wish access images hosted on dev server (windows 2003). images folder shared , can mount mac. i have added virtual director in httpd.conf - alias /images/covers/uk "//xxx.xx.x.xx/imagesfolder/covers/uk/" <directory "//xxx.xx.x.xx/imagesfolder/covers/"> options indexes followsymlinks allowoverride order allow,deny allow require granted </directory> alias /images/covers "//xxx.xx.x.xx/imagesfolder/covers/" <directory "//1xxx.xx.x.xx/imagesfolder/covers/"> options indexes followsymlinks allowoverride order allow,deny allow require granted </directory> here xxx.xx.x.xx ip of windows server. imagesfolder name of shared folder on server. however, not able access folder , getting 403 error. any idea how fix please. you sh...

php : test for lines of array the condition range of date is between range of date -

i have logic problem on how filter entries within range of date. an array $price contains prices flight depending of period of travel, ordered date: print_r($price) [21] => array [date_beg] => 2014-07-05 [total1] => 648 [22] => array [date_beg] => 2014-08-05 [total1] => 750 [23] => array [date_beg] => 2014-08-12 [total1] => 520 it 648 euros 2014-08-05, becomes 750 2014-08-05 ... i have special offers @ periods. the same information present each element of array: print_r($price) [21] => array [date_beg] => 2014-07-05 [total1] => 648 [special_beg] => 2014-07-07 [special_end] => 2014-08-06 [special_price] => 600 [22] => array [date_beg] => 2014-08-05 [total1] => 750 [special_beg] => 2013-10-27 ...

cuda - On plans reuse in cuFFT -

this may seem simple question cufft usage not clear me. my question is: which 1 of following implementations correct ? 1) // called in loop cufftplan3d (plan1, x, y, z) ; cufftexec (plan1, data1) ; cufftexec (plan1, data2) ; cufftexec (plan1, data3) ; destroyplan(plan1) 2) init() //called 1 time in application { cufftplan3d (plan1, x, y, z) ; } exec () //called many times data changing size remains same { cufftexec (plan1, data1) ; cufftexec (plan1, data2) ; cufftexec (plan1, data3) ; } deinit() //called 1 time in application { destroyplan(plan1) } 3) cufftplan3d (plan1, x, y, z) ; cufftexec (plan1, data1) ; destroyplan(plan1) cufftplan3d (plan2, x, y, z) ; cufftexec (plan2, data2) ; destroyplan(plan2) .... ... assume data sizes of data1 , data2 , data3 same. please ignore correctness of syntax. need conceptual answer. the third implementation doesn't correct me... i think 3 can made work. method 2 fa...

php - CodeIgniter Routing 404 Error -

i new codeigniter , having trouble figuring out routing. getting 404 page not found error when go "/simplepie1". routing issue, or have messed controller or view? thanks. my controller: class feeder extends ci_controller { public function index() { $this->load->library('rss'); $feed = $this->rss; $feed->set_feed_url('http://www.theverge.com/rss/frontpage'); $success = $feed->init(); $feed->handle_content_type(); $this->load->view('feed_view', array('feed' => $feed)); } } my view: <?php include_once('header.php'); ?> <?php include_once('navbar.php'); ?> <?php foreach($feed $item) : ?> <br /> <a href="<?php echo $item['permalink']; ?>"><?php echo $item['title']; ?></a> <?php endforeach; ?> <?php include_once('footer.php'); ?>...

python - While Trying to def: TypeError: unsupported operand type(s) for ** or pow(): 'NoneType' and 'int' -

i using code in python 2.7 produce new number by: def alg(n): n=((n**2)-1)/4 return n and error message: typeerror: unsupported operand type(s) ** or pow(): 'nonetype' , 'int' any great! thanks! somehow, you're passing none when call function, what's happening: alg(none) ... n none inside function, causing error. in other words: problem not in function, it's in point you're calling it. also word of warning - you're performing division between integers, better play safe , make sure @ least 1 of division's operands decimal, or else loose precision: def alg(n): # there's no need reassign n return ((n**2)-1)/4.0 # notice .0 part @ end

PHP Regex: group must end with character but do not capture this character -

example regex: /^([\w]+:)?other:(.*)$/ example string: test:other:words... the first group match "test:", want capture "test". @ first thought: /^([\w]+)?:?other:(.*)$/ but realised can't have single : in beginning. how can capture group if exists must end : : must not captured group? example input , output: randomstring:constantstring:somethingelse should give 'randomstring' first group. and constantstring:somethingelse should give first group empty here go: ^(?:(\w+):)?constantstring:(.*)$ (?:) non capturing group demo