Posts

Showing posts from May, 2013

Multithreading in listbox read and write using c# -

here using 2 list boxes . after reading data listbox1 should perform tasks assigned after add result list box2 . have created 3 threads.those threads should not fetch same data list box1, once thread fetch 1 data other threads should not fetch again . static int i; void add() { for(i=0;i < listbox1.items.length;i++) { string x = listbox1.items[i]. string(); checker obj = new checker(x); string s = obj.check(); add item (s); } } private void button4_click(object sender, event args e) { thread[] threads = new thread[3]; (int l = 0; l < 3; l++) { threads[l] = new thread(new threadstart(bul_add)); } foreach (thread t in threads) { t.start(); } } when run code, first value listbox1 read thrice , adding 3 same item listbox2 . next values added listbox2 once. please experts , me overcome problem ... thanks in advance !!

clojure - lib names inside prefix lists must not contain periods -

i learning clojure now, wrote file this: ;; file ./mycode/myvoc.clj (ns mycode.myvoc (:use 'clojure.java.io) (:import (java.io.file))) ; more code here... this file resides in ./mycode/ , when run repl, wanna use function in myvoc.clj , this: user=> (use 'mycode.myvoc) java.lang.exception: lib names inside prefix lists must not contain periods (myv oc.clj:1) i don't know why. if change myvoc.clj : (ns mycode.myvoc) ; (:use 'clojure.java.io) ; (:import (java.io.file))) it'll ok report no "reader in context" commented import part. could fix this? alse use require same kind of error. you need remove quote :use clause: (ns mycode.myvoc (:use clojure.java.io) ; note no ' (:import java.io.file)) ; parens removed here; no harm, ; though 'clojure.java.io shorthand (quote clojure.java.io) , original :use clause was (:use (quote clojure.java.io)) this looks if trying :u

ember.js - How to differentiate between empty data and pending data -

in 1 of templates doing following: {{#if controllers.nodesindex}} {{outlet}} {{else}} <div style="text-align:center;"><br/><br/><img src="images/circular_loader.gif" /><br/><br/>loading data...</div> {{/if}} i showing spinner while data loading. problem not able differentiate between case when server has not yet replied, , case when server has replied empty set. how can verify in controller (or somewhere else) if data has arrived?

random - Using a Handler in combination with an animation with a ViewFlipper -

hello dear programmers! i trying make animated menu application flips randomly @ random time intervals between 5 viewflipper children. in between each flip, want "insert" animation based on frame frame drawables. far, able display either random flipping or animation based on whether call animation method @ beginning of "run" method or @ end. can't figure out how make sure executed "in between" each iteration of handler. here code: public class btg extends activity { private viewflipper fliptest; private handler testhandler = new handler(); private random mrand = new random(); private random timermenu = new random(); int randomtime; animationdrawable menuanimation; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_btg); fliptest = (viewflipper) findviewbyid(r.id.menuflipper); testhandler.postdelayed(mflip, randomtime); } private runnable

visual studio 2012 - TypeScript - compile errors in vs.net? -

in vs.net in mvc4 project, possible make project build stop incase typescript files contains errors? currently can see errors active file i'm editing, don't break build say. i'd have true build errors incase typescript file doesn't compile correctly. if run compiler using before build target, you'll errors part of build: <target name="beforebuild"> <exec command="&quot;$(programfiles)\microsoft sdks\typescript\tsc&quot; @(typescriptcompile ->'&quot;%(fullpath)&quot;', ' ')" /> </target> you need point @ "top level" file (such app.ts) , walk of dependencies, can set build action typescriptcompile on file alone (properties window).

Admob for website -

Image
i want integrate ads via admob in website, can't choose type website if there seems option anywhere. it says "select site or app type", offers app types. admob's dashboard confusing me in many ways. what should do? admob provides ads mobiles not web sites. use adsense instead. https://www.google.com/adsense

asp.net - Visual Basic.Net DataGrid Display zero(0) as - -

in short have datagrid.i retrieving details access database.a number retrieved can zero(0). is there anyway display zero(0) "-" in datagrid column , @ same time if number not 0 format using "f4" you use datagridview instead of datagrid , handle cellformatting event, see how to: customize data formatting in windows forms datagridview control , like: if e.value = 0 # ommiting type-/errorchecking brevity e.value = "-" end if

authentication - Gitlab clone over http fails to authenticate from external network -

i have gitlab 5.2 + nginx installed on local machine in university. clone on http works machines within internal network, trying clone machine on external network results in "fatal: authentication failed" message, though exact same credentials supplied. (i use same credentials ones use log in gitlab via web interface) the gitlab web interface accessible external networks. clone on http fails (clone on ssh not possible because port 22 blocked) here lines relevant configuration files: from config/gitlab.yml host: mydomain port: 80 https: false here relevant lines ngnix config file server { listen *:80 default_server; # in cases *:80 idea server_name mydomain; # e.g., server_name source.example.com; root /home/git/gitlab/public; # individual nginx logs gitlab vhost access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; location / { # serve static files defined root folder;. # @gitlab named lo

c# - Oracle ManagedDataAccess and special characters when logging in -

i've encountered issue oracle.manageddataaccess seems impossible use non-ascii connectionstring (non-ascii empirical guess). this fine , dandy: var cs = string.format("data source={2};password={1};user id={0}", "user", "pwd", "mydb"); var connection = new oracleconnection(cs); connection.open(); but not work (å, ä , ö swedish letters): var cs = string.format("data source={2};password={1};user id={0}", "åäö", "lösenord", "mydb"); var connection = new oracleconnection(cs); connection.open(); and throws oracle.manageddataaccess.client.oracleexception: ora-01017: invalid username/password; logon denied both users capable of logging on via sqldeveloper. does know of way around this? or known limitation manageddataaccess (well, dataaccess ) libraries oracle? ninja stuff, ie using chr(int) , hard when signing in.. db info: nls_language american nls_territory america nls_currenc

c++ - Advanced issues with GPU thread divergence -

my situation - have dynamic programming algorithm implement on gpus using opencl part of phd studies. gpus working include amd hd 7970, 7750, a10-5800k apu , nvidia gtx 680. understand principles involved , of best practices necessary obtaining performance. my program contains 4 nested loops , in data-parallel formulation able unfold 2 of outer loops. due nature of problem inner-most loop cannot without causing divergence. output table represents schedules of jobs on machines (computer science). when threads diverge (work-items in wavefront take different routes) wrong values, looks if work-items repeat themselves. example, t = 0, 1, 2, 3, 4, ... 63 , 64, 65, 66, 67, ... m1 0, 0, 0, 9, 9, ... 9, 0, 0, 0, 9, ... above work-group size 64. first values t=63 correct notice how repeats again @ t=64! shouldn't zeros. here each work-item mapped time t. if fix parameter causes divergence table gets filled expected (wrong) results, no gaps (zeros), value 9 t=0 tmax, tm

javascript - How to know the exact children number of Ul element? -

i newbie in web development. not sure if dumb question. <nav class="navigation"> <ul class="navigation-items-container"> <a href="#"><li class="navigation-items">home</li></a> <a href="#"><li class="navigation-items">about</li></a> <a href="#"><li class="navigation-items">blog</li></a> <a href="#"><li class="navigation-items">contacts</li></a> </ul> /nav> on hover of each li want know in children number of ul. i.e on hovering "home" should give children number 0 , on hovering "blog" should give children number 2. as you've included jquery tag i'll post jquery based answer - if want non-jquery answer let me know: $(".navigation-items-container li").hover(function(e) { var index = $(

javascript - mousedown Events in RaphaelJS not working -

i have run problem raphaeljs doesn't react mousedown/mousemove/mouseup events works fine .click(). i created http://jsfiddle.net/jmu7z/2/ show mean. js code: var containerdivs = document.getelementsbyclassname('container'); var overlaydiv = null; for(var k=0;k<containerdivs[0].childnodes.length;k++) { if (containerdivs[0].childnodes[k].classname.indexof("holder") !== -1) overlaydiv = containerdivs[0].childnodes[k]; } var canvas = raphael(overlaydiv,208,270); var bgr = canvas.rect(10,10, canvas.width-10, canvas.height-10).attr({fill: "0xff0000", stroke: "none", opacity:"0.2"}); bgr.mousedown( function(e) { alert ("down"); }); //doesn't work bgr.click( function(e) { alert ("click"); }); // works html: <div class="container" style="position: relative; left: 0; top: 0;"><img class="corepic nonselectable" style="position:relative; top: 0; le

python - HTML templating using Jinja2 No module named your app -

i trying create html template in python using jinja2. have templates folder 'template.html' don't know how deal environments or package loaders. i installed jinja2. these simple codes from jinja2 import environment, packageloader env = environment(loader=packageloader('ap', 'templates')) template = env.get_template('template.html') print template.render(title='hello') i error: file "a.py", line 3, in <module> env = environment(loader=packageloader('ap', 'templates')) file "/usr/local/lib/python2.7/dist-packages/jinja2-2.7-py2.7.egg/jinja2/loaders.py", line 214, in __init__ provider = get_provider(package_name) file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 213, in get_provider __import__(moduleorreq) importerror: no module named ap this folders ap/ __init__.py a.py templates/ template.html where wrong ? why error "no

java - Issue with sun.security.util while upgrading to from jdk 1.4 to jdk1.6 -

i porting webapplication written in jdk1.4 1.6. while compiling getting warnings related sun.security package deprecation. though can compile warnings, prefer compile without warnings.also become errors in future when using jdk 1.7 version. warnings warning: sun.security.util.derencoder sun proprietary api , may removed in future release i ready change source code removing sun packages , use third party free package. fixing other issues have rewritten other parts of code(which uses classes sun.misc.base64decoder ) using org.apache.commons.codec .but couldn't find replacements sun.security.util . my server apache tomcat, using other server libraries *ibm* won't feasible. edit i using classes including(not limited to) sun.security.util.derencoder, sun.security.util.derinputstream ,sun.security.util.dervalue,sun.security.util.objectidentifier ,sun.security.x509.x500name etc in fact, sun.security.util.derencoder interface , trivially create own version.

Lua sorting tables -

i know nothing lua, able modify script wanted to. i'm having troubles sorting table though. i've found table utils (convert table string), here's table: {{line="(golden aura) challenging owl either brave or stupid.",range="(+16 +21)",message="(golden aura) challenging owl either brave or stupid.",colour="crimson",srt=9,keyword="owl",name="an owl"}, {line="(golden aura) busy squirrel chuckles @ thought of fighting him.",range="(+3 +8)",message="(golden aura) busy squirrel chuckles @ thought of fighting him.",colour="gold",srt=7,keyword="squirrel",name="(golden aura) busy squirrel"}, {line="(red aura) parakeet should fair fight!",range="(-2 +2)",message="(red aura) parakeet should fair fight!",colour="springgreen",srt=5,keyword="parakeet",name="(red aura) parakeet"}, {line="(golden aura

java - Reading string values under if/else commands -

im new android im gonna need little help. created 4 activities in app. first activity mainactivity. assigned listview in first activity. listview redirected second activity string says item clicked. doesn't matter item selected, redirected second activity only. diffrence values of strings passed different. used code in listview's onitemclick function: string item = (string) listview.getadapter().getitem(position);; intent = new intent(mainactivity.this, activity2.class); i.putextra("item_selected", item); startactivity(i); this code redirects me second activiy string without problem. in second activity there 2 options "launch type 1" , "launch type 2" inside radiobutton group , button perform function. used code inside button's onclick method determine activity go next: intent intent = getintent(); string item = intent.getextras().getstring("item");

java - Notify threads running in different objects -

i have read oracle documentation , not find design pattern solution issue. have 2 anonymous threads , 1 needs notify other. public static void main(string[] args) { myclass obj = new myclass(); obj.a(); obj.b(); } the myclass has 2 different functions, each 1 launches anonymous thread. b person expects woken wife, a. public class myclass{ public myclass(){ } public void a() { new thread(new runnable(){ @override public synchronized void run() { system.out.println("a: going sleep"); try { thread.sleep(1000); system.out.println("a: slept 1 full day. feels great."); system.out.println("a: hey b, wake up!"); notifyall(); } catch (interruptedexception e) { // todo auto-generated catch block e.printstacktrace();

c - Logic behind sizeof operator -

this question has answer here: how sizeof work int types? 3 answers how sizeof(array) work 5 answers here have sizeof operator in c . returning size of datatypes, printf("%d",sizeof(some datatype)); and result 4 (os dependent). i want know how calculating. logic behind operator. if ask write code sizeof operator. answer? note : want know how sizeof written code capable calculate size. as may not able ask question properly,i trying here again. write 1 function can use instead of sizeof operator. the compiler knows size of types, has or not able generate code correctly. information used sizeof operator. also note sizeof not function being called @ runtime, it's operator evaluated during compilation.

google app engine - appengine custom 404 page for static website -

i trying host simple static website on google appengine, have problem setting custom 404 page. my app.yaml serves static files (from www subdir) requests: application: id version: v runtime: python27 api_version: 1 default_expiration: "1d" threadsafe: yes handlers: - url: (.*)/ static_files: www\1/index.html upload: www/index.html - url: / static_dir: www error_handlers: - file: 404.html but while trying access file not exist, not see 404.html, default gae error message. logs show: static file referenced handler not found: www/does-not-exists/index.html or static file referenced handler not found: www/does-not-exists.html what doing wrong? this won't work. static handler match things, , can not error_handler 404.

ember.js - How to load an external html into an html using emberjs -

my current html page has run 1000 lines of code. wanted make more manageable. so kind of solution i'm looking - <script type="text/x-handlebars" data-load-template="detail.html"> and code should able load detail.html external source. how do it? you may choose use kind of build tool grunt compile handlebars files javascript , attach them code. here project may find useful: https://github.com/yaymukund/grunt-ember-handlebars

ios - Is it possible to get notified if user clicks on UITableView sectionIndex -

Image
i want change the color of section index of uitableview , if user clicks on it. i can set sectionindexcolor , sectionindextrackingbackgroundcolor while initializing tableview , on other state, i've found no method change index color on click. update: i mean a-z side bar @ larger tableviews. here images (see grey bar @ image 2) unselected state: selected state: i have rather dirty solution this, apple not support public api. implemention works quit , should not crash if api changes in future (just not work anymore). subclassing uitableview , adding own callbacks sectionindex view on time added subview table. @interface mytableview : uitableview @end @implementation mytableview - (void)selectionstarted { [self setsectionindexcolor:[uicolor greencolor]]; } - (void)selectionstoped { [self setsectionindexcolor:[uicolor redcolor]]; } - (void)addsubview:(uiview *)view { [super addsubview:view]; if ([nsstringfromclass([view class]) isequal

java - Compere if statement short form -

ı want use short form if statement. how can ı write if statement @ one line ? , how can ı compare them ı know there same question @ here. statement not have else ı not without else statement. public int compareto(uyum u) { if (uyum < u.uyum) return -1; if (uyum > u.uyum) return 1; return 0; } you can use ternary operator : return uyum < u.uyum ? -1 : uyum > u.uyum ? 1 : 0;

height - Fancybox does not center when title outside -

i using fb 1.3. i have got images lot of text show title outside. the problem image centered correctly title runs out of viewport @ bottom. on smaller screens cannot read entire text whats pretty bad. any ideas?

c++ - WaitForMultpleObjects in boost (any updates?) -

well, trying port code win32 application multiplatform application using boost. going smoothly until hit "waitformultipleobjects" problem. basically, have few different boost::recursive_mutexes need grabbed @ once. waitformultipleobjects grabs them when ready, regardless of order. this has been bit of missing functionality quite while now, stated in thread: waitformultipleobjects functionality in boost anyone find solutions problem since then?

c# - SQL Syntax Error: Remove/Disclude Apostrophe's? -

i use below code update business' information on 1 of windows forms. when user puts business name in txtbusname " sandy's place " receive incorrect syntax near ';'. unclosed quotation mark after character string ';'. what best way handle issue? conn = new sqlconnection(connstring); conn.open(); sqlcommand cmd = conn.createcommand(); mskzip.textmaskformat = maskformat.excludepromptandliterals; string zip = mskzip.text; mskzip.textmaskformat = maskformat.includeliterals; mskmailzip.textmaskformat = maskformat.excludepromptandliterals; string mailzip = mskmailzip.text; mskmailzip.textmaskformat = maskformat.includeliterals; mskphone.textmaskformat = maskformat.excludepromptandliterals; string phone = mskphone.text; mskphone.textmaskformat = maskformat.includeliterals; mskfax.textmaskformat = maskformat.excludepromptandliterals; string fax = mskfax.text; mskfax.textmaskformat = maskformat.includeliterals; cmd.commandtext = "update business

backbone.js - A "url" property or function must be specified -

i'm trying download collection of documents mongodb, using nodejs, browser, using backbone. can use simple ajax request take advantage of backbone, backbone should request. there empty collection: //create model , collection task_lists var mtasklist = backbone.model.extend({ defaults: { title: 'untitled task list' }, urlroot: '/task_list' }); var ctasklists = new backbone.collection({ model: mtasklist, url: '/task_list' }); when try fetch data server: ctasklists.fetch({reset: true, data: {workspace: swsurl}}); //ask data server it throws error: uncaught error: "url" property or function must specified i tried different combinations of url same error thrown. the first parameter expected in collection constructor list of models, options hash comes second: constructor / initialize new collection([models], [options]) when creating collection, may choose pass in initial array of model

android - FragmentTabHost triggers onCreateView even though fragment is hidden -

i have fragmenttabhost in fragment. have 4 tabs. when click tabs, tab's oncreateview triggered though use fragment transaction hide it? i debugged , found when click create tab home tab createfragment createfragment = (createfragment) fm.findfragmentbytag(create_tag); is null though added in tabhost.addtab? how can move between tabs , not call oncreateview of each fragments? thank you this fragment class public class tabfragment extends fragment { public static final string home_tag = "home"; public static final string create_tag = "create"; public static final string search_tag = "search"; public static final string profile_tag = "profile"; private myfragmenttabhost tabhost; private myfragmenttabhost.tabinfo tabinfo; @override public view oncreateview(layoutinflater inflater, viewgroup viewgroup, bundle savedinstancestate){ view view = inflater.inflate(r.layout.fragment_tab, viewgroup, false); tabhost = (myfrag

magento - Display specific category products on no results search page -

when search wrong keyword "sdfsdf" in magento site, displays "your search returns no results". here want display category products "similar products" category display "best sellers" on home page. have tried calling block in catalogsearch.xml. catalogsearch.xml doent contain block no results. how can display category products on no results page. i have idea can display specific category products on .phtml page? if can display specific category of products can call category "result.phtml". help? my result.phtml <?php if($this->getresultcount()): ?> <?php echo $this->getmessagesblock()->getgroupedhtml() ?> <div class="page-title category-title"> <?php if ($this->helper('rss/catalog')->gettagfeedurl()): ?> <a href="<?php echo $this->helper('rss/catalog')->gettagfeedurl() ?>" class="nobr link-rss"><?php echo $this-&

node.js - express3 js req.body is undefined -

i using express2.js when using req.body undefined or empty {}: exports.post = function (req: express3.request, res: express3.response) { console.log(req.body); }); i have following configurations: app.use(express.bodyparser()); app.use(app.router); app.post('/getuser', routes.getuserprofile.post); the request body in xml , checked request header correct. i missed part had xml. guess req.body doesn't parse default. if using express 2.x perhaps this solution @davidkrisch adequate (copied below) // script requires express 2.4.2 // echoes xml body in request response // // run script so: // curl -v -x post -h 'content-type: application/xml' -d '<hello>world</hello>' http://localhost:3000 var express = require('express'), app = express.createserver(); express.bodyparser.parse['application/xml'] = function(data) { return data; }; app.configure(function() { app.use(express.bodyparser()); }

ios - Taking square photo in the app -

i want take square photo instagram app since not make crop photo. not want put filters want take photo square. there away in ios6? you want create new image context uigraphicsbeginimagecontext , within draw image have taken camera in cgrect using drawinrect: method.

itunesconnect - How to preserve already approved app in itunes connect? -

the first version of our app 1.0.0 uploaded , approved apple , currently, has status "developer removed sale". version has severals bugs , features missing, decided not release it, improve , release version. so, uploaded version 1.1.0 after time, , currently, has "pending developer release" status. funny thing managing guys decided add yet features, have upload third version. the question second approved app version (1.1.0) there after uploading third version itunes connect, or deleted? don't need first version because there bugs it's unable delete if not released app store. prefer have second version until third approved (just in case). the current approved version remain ready sale (wether choose put live on app store making in available in one, or countries or not) while update waiting review, in review, , processing app store, , removed when update's status goes ready sale. (it remain should update rejected.)

clojure maven plugin: clojure tests succeed when using mvn clojure:test but NOT during test phase when using mvn install -

i using clojure maven plugin build project. projects contains test, let mytest.clj , has content following: (def ^:dynamic *server* (create-server "tcp://bla.bla:9999")) (deftest blabla1...) (deftest blabla2...) if run mvn clojure:test , build runs successfully. but if run mvn install when test phase reached, server declared in mytest.clj started. after start, nothing more happens: clojure test script seems frozen , building of project cannot continued (without error message): maven hangs. although, said, mvn clojure:test runs same project. does know how solve problem? any appreciated. thx in advance regards horace p.s: can use standard mvn install compile , test clojure sources because project's packaging configured 'clojure' 1 in pom.xml . consequence of it, clojure maven plugin automatically binds maven phases compile, test , test-compile. the problem starting server when tests run, not shutting down server when finished.

php - Downloaded file is empty or fails to find it to begin download -

i'm trying download files site keep encountering problems. firstly downloading empty file, thought because of content type, on suggested application/octet-stream doing. had lot of issues finding file. after few test cases whitespace issue, amend (put in "") , download empty file again. rudimentary code hoping can help: <?php $filename = $_get['filename']; $dir = "training/trainingdocuments/"; $downloadfilename = $dir.$filename; //ftp://site.com///training/trainingdocuments/8%20-%20subsea%20questions__51f034ab37a8e.xls //$downloadfilename = preg_replace('/\s/', '%', $downloadfilename); //8 - subsea questions__51f034ab37a8e.xls //if filename exists if(is_file($downloadfilename)){ //send headers header('pragma: public'); //fix ie6 content-disposition header('content-description: file transfer'); header('content-transder-encoding: binary'); header(sprintf('content-length: %u', filesize($download

c# - Referencing a class that inherits from another class -

i creating library , referencing class main inherits body public class main:body i added main using references when go initiate instance - tried: main _main = new main() underlines new main() saying doesn't contain constructor takes 0 arguments. how can adjust referencing class - need included inherited class well? main _main = new main() underlines new main() saying doesn't contain constructor takes 0 arguments. it's telling problem is. there isn't public constructor on main takes 0 arguments. you need 1 of following: add public constructor takes 0 arguments: public main() { } . invoke different constructor public on main class: if signature public main(object o) you'd main _main = new main(o) o object. let's @ example: class foo { public foo() { } } this class has public constructor 0 arguments. therefore, can construct instances via foo foo = new foo(); let's @ example: class bar { public bar(

Python List of Dictionaries[int : tuple] Sum -

this question has answer here: python how sum of numbers in list has strings in well 4 answers i have list of dictionaries. each dictionary has integer key , tuple value. sum elements located @ position of tuple. example: mylist = [{1000:("a",10)},{1001:("b",20)},{1003:("c",30)},{1000:("d",40)}] i know : sum = 0 in mylist: in mylist: temp = i.keys() sum += i[temp[0]][1] print sum is there more pythonic way of doing ? thanks use generator expression, looping on dictionaries values: sum(v[1] d in mylist v in d.itervalues()) for python 3, substitute d.itervalues() d.values() . demo: >>> sum(v[1] d in mylist v in d.itervalues()) 100

view - Android AsyncTask accessing and updating VideoView -

i need monitor buffer percentage of videoview continuously while video playing on foreground. created asynctask class , passed videoview on class. however, when try access buffer percentage return 0. initialized , started video playback on oncreate method of main activity. code: public class mainactivity extends activity { static mediacontroller mc; static videoview vw; /** called when activity first created. */ @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); setcontentview(r.layout.activity_main); mc = new mediacontroller(this); vw = (videoview) findviewbyid(r.id.videoview); vw.setvideopath("http://173.45.164.105:1935/live/mystream/playlist.m3u8"); vw.requestfocus(); vw.start(); // execute async task st

xslt - remove duplicate nodes from xml file using xsl -

i looking solution delete duplicates xml file not based on exact node name, instead, looking solution can identify duplicate nodes , delete them. first node should exist, , rest of duplicate nodes deleted. i read couple of similar posts: xsl - remove duplicate node keep original removing duplicate elements xslt example: <?xml version="1.0" encoding="utf-8" standalone="no"?> <projects> <project id="staticproperties"> <property name="prop1">removing prop if duplicate</property> <property name="prop2">removing prop if duplicate</property> <property name="prop3">removing prop if duplicate</property> <property name="prop4">removing prop if duplicate</property> </project> <project id="febrelease2013">

c# - What goes in the params parameter of the .SqlQuery() method in Entity Framework? -

the method takes string query, , array of object [] parameters, presumably avoid sql injection. however on earth documented should put object array. there question on asks exact same thing, accepted answer doesn't work: when using dbset<t>.sqlquery(), how use named parameters? i've tried forms of parameter replacement can think of , of them throw exception. ideas? would simple as: sqlquery("select * @table", "users") edit: here things i've tried (exception sqlexception ): var result = context.users.sqlquery<t>("select * @p0 @p1 = '@p2'", new sqlparameter("p0", tablename), new sqlparameter("p1", propertyname), new sqlparameter("p2", searchquery)); this gives must declare table variable "@p0". var result = context.users.sqlquery<t>("select * {0} {1} = '{2}'", tablename, propertyname, searchquery); this gives must declare table varia

android - Clarification needed regarding invoking a library -

please can me out usage of android libraries. i hit go button needs invoke library. library in turn launches login screen the login screen accepts user id,password hits url , gives response(success/failure) the code http post(which needs used library) : username = (edittext) findviewbyid(r.id.edittextusername); password = (edittext) findviewbyid(r.id.edittextpassword); submit = (button)findviewbyid(r.id.submit); submit.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub if(username.gettext().length()>0 && password.gettext().length()>0) { urlconnector ss = new urlconnector(); ss.execute("http//ipchicken.com"); } } }); } private class urlconnector extends asynctask<string, void, string> { @override protected string doinbackground(string... urls) { string response = ""; (string ur

html - how to position a css sprite as background for another class -

Image
sorry if layout of question seems weird, i've wrote question 10 times on , on again in editor, resulting in getting error message "unformatted code found etc." - removed code , placed picture examples. (2 hours simple question) hello folks! have .png image , containing several icons works css sprite . creation of each css class no problem use generator that. (works charm) problem is, want use, example: created .iconinfo_32 class, background property another css class. what want achive? simple said, custom css - messagebox, icon on left side. icon in original sprite containing multiple icons. that's problem starts. what have the icons (thats 1 png) the icon want use how result should like how looks use div, in div yes, work - i'd have "one" css class, without need put div, div, position should , on - had problems position of div. i've provided source example, being able understand question , goal. excuse me if

winforms - Dynamically call a label in c# -

i trying call label dynamically have no idea how it. i want make label visible depending on integer. so if int = 1 , label1 should turn visible , if i = 2 , label2 should turn visible, , on , forth. how do this? int = word.indexof("t"); //this need label dynamically called i tried ("label" + i.tostring()).visible = true;" in lazy attempt. here's dynamic solution: foreach (var label in controls.oftype<label>()) label.visible = (label.name == "label" + i); note that: this hide labels not named "label" + i . may need additional filtering logic if there other labels on form/container the above code works if labels direct descendants of form. if that's not case (for example, labels children of panel called panel1 ), you'll need replace controls panel1.controls

Trouble with C unit conversion -

i developing android application uses native c library. unfamiliar c, , having conversion problems. know problem has signed/unsigned numbers, cannot figure out need fix this. the c library works fine on own, , produces correct results. when port android, positive values correct. negative values returned 256 minus value. for example: 8 -> 8 5 -> 5 1 -> 1 0 -> 0 -3 -> 253 -5 -> 251 -8 -> 248 this c code looks when assigns value: byte *parms; word __stdcall getvalue(byte what, long *val){ char mystringparmsone[255]; sprintf( mystringparmsone, "parms[1]=%d", parms[1] ); log_info( mystringparmsone ); char mystringisg[255]; sprintf( mystringisg, "api_isg=%d",api_isg ); log_info( mystringisg ); char mystringcharparmsb[255]; sprintf( mystringcharparmsb, "(char)parms[1]=%d", (char)parms[1] ); log_info( mystringcharparmsb ); *val=(char)parms[1]-(api_isg?11:0); } the log_info stat

c++ - ComboBox & ON_WM_CONTEXTMENU - sometimes have to double-right-click -

Image
we call on_wm_contextmenu() inside begin_message_map in our dialog class. combo-box control, right-clicking on drop-down arrow on right side triggers context menu. rest of control, user has double -right-click working. what cause? there special little down-arrow?

r - Why does NaN^0 == 1 -

prompted spot of earlier code golfing why would: >nan^0 [1] 1 it makes perfect sense na^0 1 because na missing data, , any number raised 0 give 1, including -inf , inf . nan supposed represent not-a-number , why so? more confusing/worrying when page ?nan states: in r, mathematical functions (including basic arithmetic), supposed work +/- inf , nan input or output. the basic rule should calls , relations infs statements proper mathematical limit. computations involving nan return nan or perhaps na : of 2 not guaranteed , may depend on r platform (since compilers may re-order computations). is there philosophical reason behind this, or how r represents these constants? this referenced in page referenced ?'nan' "the iec 60559 standard, known ansi/ieee 754 floating-point standard. http://en.wikipedia.org/wiki/nan ." and there find statement regarding should create nan: "there 3 kinds of operations can r

vim - Leader command in Vrapper for Eclipse -

i've been using vrapper in eclipse, , leader key doesn't seem work. i looked @ documentation , didn't see it. command not let mapleader = ',' vrapper not vim: don't expect accustomed in vim work in vrapper or other vim emulator. <leader> useful configuration purpose because mapleader can changed @ runtime seen drawback some... anyway, these 2 mappings behave same way so, if don't use <leader> specific reasons, using second 1 should enough: nnoremap <leader>a dosomething nnoremap ,a dosomething

c# 4.0 - Castle windsor wcf facility - add clients through config file -

i'm using castle windsor wcf facility self hosting services. on client side use wcf facility again consuming them. want register services @ client side dynamically looping getting operationcontracts , register them through code endpoint configuration config file. most of examples saw on internet using code register them. cannot use client want more flexibility manipulating config file if , when needed. below code came fails read configuration of client endpoints config file. container.register( classes .fromassemblycontaining<ixxx>() .pick() .if(x => x.isclass && hasservicecontract(x)) .configure(c => c.aswcfclient().lifestyle.perwcfoperation())); please advise. thanks in advance sai here's how i'm doing it: container.register( component.for<isomeservice>() .aswcfclient(wcfendpoint.fromconfiguration("*")) ); the "*" wil

sql - Top level MySQL statistics -

have not been able find information on this, in own feel keeping in query might best option, if possible. basically want try add top level "statistics" portion of query. so when results see so num_rows = 900 distinct_col = 9 results = array() this way can loop results normally, , pull out information need once outside of it. possible? edit: not looking normal mysql statistics num_rows exactly. in case lets limit results ten, num_rows return 10, want total results, 900. in cases use query , amount, combining 1 query logically seems faster me. there more num_rows may need, products , have specific category, need count amount of categories items fall under. looping raw results when there 1 result columns sillyness. edit 2: clarify further need counts on columns, , maybe min-max result on join. having return on every loop work, same exact return uselessly returning on every loop when needed once not seem logical. no mysql expert , trying make sure come logical , f

ssh keys - How to make Git not ask me for password when accessing remote repositories? -

i've been looking @ few different posts , other forums explanation of how prevent git asking password whenever interact remote repository, understood need create ssh key. if want make private key more secure, passphrase used encrypt it. can use ssh-agent store passphrase once terminal/console session, don't have keep entering time . you'll need use eval `ssh-agent -s` start agent, ssh-add enter passphrase private key, , ssh-agent -k kill agent when you're done. comes timeout, ssh-add -t <timeout> , <timeout> can xh x hours, xm x minutes, , on. ssh-agent available on msysgit , cygwin. i'm not sure availability on other platforms unix/linux/*nix systems , apple osx. you can read more ssh-agent usage this stack overflow answer , this stack overflow answer , googling around instructions online.

java - Best practice to avoid side effects -

i have question how avoid side effects on java objects. let suppose have instance myobject of class myobject . process myobject through chain of methods/commands , @ each command level, want enrich myobject method/command has computed. here class myobject instance of: public class myobject { private int resultofcommand1; private int resultofcommand2; private int resultofcommand3; private int resultofcommand4; .... .... } here methods/commands myobject has processed through: private myobject command1(myobject myobject) { return myobject.setrresultofcommand1(1); } private myobject command2(myobject myobject) { return myobject.setrresultofcommand2(2); } private myobject command3(myobject myobject) { return myobject.setrresultofcommand3(3); } private myobject command4(myobject myobject) { return myobject.setrresultofcommand4(4); } so design shown above have side-effects , avoid such thing. could tell me best way avoid side effects? better make

android - how to stop audio from playing when image has been touched -

i have got imageview when user taps image audio starts playing, , works great here code that: final imageview imageview = (imageview) findviewbyid(r.id.image7); imageview.setimageresource(mfullsizeids[position]); imageview.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { mediaplayer mp = mediaplayer.create(audio.this,maudio[position]); mp.start(); return false; } }); now when want user touch image again audio should stop. have added code: if (mp != null && mp.isplaying()) mp.stop(); return false; } }); but sound doesn't play. confused logic tells me should work. doing wrong here? please help... not quite sure mean block code? did call function prepare or prepareasync on media? then, when stoping media, think must reset it.

r - Order dataframe chronologically based on dates which are formatted %d/%m/%Y -

i have data has formatted (%d/%m/%y). data out of chronological order because sorted first number day, not month. i'm hoping can specify order or reorder want sorting happen differently. i'm not sure how this. here date data ordered: date 1/1/2009 1/1/2010 1/1/2011 5/4/2009 5/4/2011 10/2/2009 10/3/2011 15/9/2010 15/3/2009 31/12/2011 31/7/2009 thanks suggestions. when order column date convert date format. df[order(as.date(df$date,format="%d/%m/%y")),,drop=false] date 1 1/1/2009 6 10/2/2009 9 15/3/2009 4 5/4/2009 11 31/7/2009 2 1/1/2010 8 15/9/2010 3 1/1/2011 7 10/3/2011 5 5/4/2011 10 31/12/2011

listbox - Displaying a multivalued list box/combo box in Access 2010 -

i have table containing information teachers university. 1 of fields multivalued list box containing choices types of students person teaches (pre doctoral/post doctoral/residents etc). trying display field on form, letting form wizard create controls form ends giving copies of same record each copy showing different selection students field (i.e. if select pre , post doctoral, record selector shows 2 records, both exact same information except 1 of student fields says pre doctoral , other says post doctoral). i want show each option in list on 1 record. can't seem find kind of property can this. want able show possible options when adding new record. there options/code allow this? my answer, may not like, not use multi-value listbox (or attachments field either). create hidden tables , relations cannot control and, want useful them, becomes problematic. cause issues exporting well. i create, , maintain, own tables (a many-to-many relationship).

automake with fortran: order of file -

i facing small problem when trying build code autotools. file structure is: $ tree . |-- configure.ac |-- makefile.am `-- src |-- constants.f90 |-- environment.f90 |-- init.f90 |-- main.f90 `-- util.f90 (deleted possibly unnecessary lines) , makefile.am is: #subdirs= bin_programs = scasr scasr_sources = \ src/constants.f90 src/environment.f90 src/util.f90 \ src/init.f90 src/main.f90 scasr_ldadd = extra_dist= autogen.sh cleanfiles =*.mod the problem src/(*.f90)'s except main.f90 module. hence, if have write makefile hand, have: constants.o : constants.f90 environment.o : environment.f90 init.o : init.f90 util.o constants.o main.o : main.f90 init.o constants.o environment.o util.o : util.f90 constants.o so, makefile.am, have make strict order of files in scasr_sources. i.e. sources : scasr_sources = \ src/constants.f90 src/environment.f90 src/util.f90 \ src/init.f90 sr