Posts

Showing posts from May, 2011

Build a binary Tree from inOrder and preOrder data in Java -

i've gone through program few times, can't see issue. basically, supposed reconstruct binary tree inorder , preorder traversal data (sent in integer arrays) it's binary tree of integers. here's tree i'm using: 234 / \ 98 678 / \ \ 45 124 1789 preorder 234, 98, 45, 124, 678, 1789 inorder 45, 98, 124, 234, 678, 1789 the problem comes 1789. code reconstructs tree 1789, leaving out odd reason. decided switch 678 , 1789 in inorder array, , put 1789 left of 678, , 0 right of 678. in code below, arrays in order supposed (or assume supposed be). build tree code: public class buildtree { public static binarytreenode buildtree(int inorder[], int preorder[], int preindex ) { if (inorder.length > 1) { int inindex = 0; (int = 0; < inorder.length; i++) { if (preorder[preindex] == inorder[i]) { inindex = ; break;

delphi - Delphi7: TBitmap.Canvas.Handle = 0 -

i facing problem long time, , have not found me solve it. use tbitmap receive data coming camera (stream) , save image disk. exception occurs. after several tests found flaw: handle property of tbitmap's canvas value 0. bypass problem, when detect value 0 in handle, restart application (destroy , recreate tbitmap did not work), error occurs frequently. has had problem this? doing wrong? welcome. thank you. tbitmap internally uses tbitmapcanvas wrapper object tbitmap.canvas. if have access source (graphics.pas) should have look. chances 1 or more winapi gdi calls don't handle return value in case of error. gdi calls have slim chance of failing, it's of gamble leave out checking each , every returned value gain bit of performance, in cases of high load these may first indicators things go wrong anyway. i suggest try use debug dcu's step through program using tbitmap.canvas, list gdi calls used make things work, code these operations checking returned value

ruby on rails - replace relative path urls with absolute path urls -

i have bunch of html content stored in database , i'm looking convert of relative asset references use absolute paths instead. instance, of image tags looking this: <img src=\"/system/images/146/original/03.png?1362691463\"> i'm trying prepend " http://mydomain.com " "/system/images/" bit, had following code hoping handle sadly doesn't seem result in changes: text = "<img src=\"/system/images/146/original/03.png?1362691463\">" text.gsub(%r{<img src=\\('|")\/system\/images\/}, "<img src=\"http://virtualrobotgames.com/system/images/") instead of manipulating url string using normal string manipulation, use tool made job. ruby includes uri class, , there's more thorough addressable gem. here's i'd if had html links wanted rewrite: first, parse document: require 'nokogiri' require 'uri' source_site = "http://virtualrobotgames.c

dom - can we create an xml using SaxParser -

i have requirement merge 2 xml files comparing particular attribute id.i new xmlparsing. used saxparser parse xmls. don't know how move forward merging thing. suggest proper , better way merge 2 xml files. output of requirement should new xml document. supposed keep performance in mind. sax better in terms of performance. without code, can point useful article. http://www.informit.com/library/content.aspx?b=sty_xml_21days&seqnum=221

java - Printing limited number of words in String -

i new java programming, , having hard time project due in class. have synopsis retrieved netflix wsdl, , task limit large paragraph 10 words. in other words, code should use limit large string specific number of words? the tool need string.split() method. you split string blank space delimiter, i.e. " " , if resultingarray.length <= 10 save first 10, discard rest. simple :) edit: not homework service, need show faith. usage of string.split seen below public static void main(string[] args) { final string sentence = "this really, really, really, super line"; final string[] words = sentence.split(" "); for(int = 0; < words.length; i++){ system.out.printf("word %d: %s\n", i, words[i]); } }

jQuery list item Menu -

we have main menu, consist of number or parent child items. want children uls hidden start with, on click of given li it's child ul shows. you can see working degree here: http://jsfiddle.net/jnl58/12/ $("ul.nav_categories ul").hide(); $("ul.nav_categories li").click(function(el){ el.preventdefault(); var cur_el = $("> ul", this); if (cur_el.length > 0) { $("> ul", this).show(); } }); the thing struggling hiding relevant ul's apart clicked elements parent ul's or sibling ul's. so drop down menu http://jsfiddle.net/fjcct/4/ works on click rather rollovers : $("ul.nav_categories ul").hide(); $("ul.nav_categories li").hover(function(){ if ($("> ul", this).length > 0) { $("> ul", this).show(); } }, function(){ if ($("> ul", this).length > 0) { $("> ul", this).hide(); } }); pl

asp.net insertCommand resulting in NULL values -

i have 2 listboxes values sent tablec via button. <asp:sqldatasource id="sql1" runat="server" connectionstring="<%$ connectionstrings:connectiondatabase %>" selectcommand="select [name] + ' (' + [cnbr] + ')' fullname, [cnbr] cnum [tablea] order [name]"> </asp:sqldatasource> <asp:listbox id="lst1" runat="server" datasourceid="sql1" datatextfield="fullname" datavaluefield="cnum" autopostback="true"> </asp:listbox> <asp:sqldatasource id="sql2" runat="server" connectionstring="<%$ connectionstrings:connectiondatabase %>" insertcommand="insert [tableb] ([cnbr], [rdate]) values (@cnbr, @rdate)" <insertparameters> <asp:parameter name="cnbr" type="string" /> <asp:para

ios6 - iOS MKLocalSearch only returns 10 results -

i'm starting use mklocalsearch api mapkit. it works, , returns data, appears return 10 results, no matter size region or search term is. there doesn't appear other configuration options or parameters change options this. does know if it's possible more 10 results @ time local search request?

aspectj - When we used aop compile and classloader weaving? -

what better use or maybe when use : weaving compile time , classload time or runtime default spring strategy? give me practical example using weaving compile time or classload time? . what better depends on situation, e.g.: for production aspects makes sense weave them during compile-time because way right in class files, have no overhead load-time weaving , need during runtime aspectjrt.jar on classpath. for development or debugging aspects might mean overhead in production (specific types of fine-grained logging, tracing, monitoring necessary support bug tracking in production) more flexibly applied on demand via load-time weaving. if want weave (third-party) class files not have sources, can either use post compile time (binary) weaving , create new, woven classes or jars replacing original ones , deploy those, or can use ltw. whatever makes more sense in situation , dependent on whether aspects production or debugging/monitoring. this list incomplete, there

Using node.js, how can I write to one MySQL DB and read from another? -

specifically, i'm talking mysql master-slave(s) replication . understand it, of reads should happen slave (or multiple slaves hid behind load balancer) , of writes directly master. how can node.js ? i'm using mysql active record package database queries , don't think supports natively. supposed can hack away @ package , have if write-query, use db1 type of situation, wonder if there's easier way. you can create 2 adapters this: var activerecord = require('mysql-activerecord'); var readdb = new activerecord.adapter({ server: 'slave.db.com', username: 'user', password: 'pass', database: 'db' }); var writedb = new activerecord.adapter({ server: 'master.db.com', username: 'user', password: 'pass', database: 'db' }); when go update or other writing query, use writedb ; when go select use readdb . another option switch orm supports out of box. know

python - Processing vars in playbook -

i want make script setup tinc vpn between computer instances. need way pass through command line of "/tmp/setup_tinc.py" following args: --connect-to %{{ ' '.join( groups['do'] }}% where %{{ part }}% interpreted in python. can't seem find way this. can me fix code ? i made following playbook : - name: tinc install & setup hosts: user: root vars: tincnet: cloudnet tasks: - name: install tinc package action: command apt-get install tinc python-argparse -y - name: copy tinc setup script action: copy src=setup_tinc.py dest=/tmp/setup_tinc.py mode=755 - name: run tinc setup script action: command /tmp/setup_tinc.py --network $tincnet --tinc-ip $tinc_ip --hostname $hostname - name: fetch tinc file action: fetch src=/etc/tinc/$tincnet/hosts/$hostname dst=hosts - name: adding firewall rule action: command ufw allow 514 in ansible 1.1 , earlier little tricky do. can't in-line python code in

Jquery slide and Margin -

i have jquery slide in place slide in error message. $('form').submit(function(){ var $emptyfields = $(); $('form').find('input').each(function(){if($(this).val() == ""){$emptyfields.push(this)}}); if($emptyfields.length != 0){ $('form').find('input').css("border",""); $("#error").show("slide", { direction: "down" }, 1000); return false; }else{ return true; } }); and im centering error message via following css. #error { display: none; font-size: 14px; margin-left: auto; margin-right: auto; width: 24%; } what happens though slides in applies css. there anyway around ? you use slidedown() or slidetoggle(), i've had css problems show before, behaves differently.

iOS6 MapKit (MKLocalSearch): How to get Address of a mapItem? -

ios6 apple mapkit so understand code in link below part. http://phpadvocate.com/blog/2013/01/ios-6-1-simple-example-using-mklocalsearch/ however, how address mapitem? seems other properties include: placemark, iscurrentlocation, name, phonenumber, , url. http://developer.apple.com/library/ios/documentation/mapkit/reference/mkmapitem_class/mkmapitem_class.pdf basically, once data fetched, i'd display name of retail location cell.text , address cell.detailtext. mapitem.placemark.thoroughfare.copy, // return first single line address mapitem.placemark.locality, // return city mapitem.placemark.administrativearea //will return state. below more: clplacemark | property meaning thoroughfare | street address. first line if multiple lines. subthoroughfare | street address, second line (e.g., apartment or unit number, box number) locality | city sublocality | might contain neighborhood or landmark name, though it’s nil administrativearea | sta

php - Initiate a class instance with dynamic parameters? -

this question has answer here: how call constructor call_user_func_array in php 1 answer i'm trying make new class instance dynamic parameters e.g.: $controller = 'classname'; $parameters = array('hello', 'world'); new $controller($parameters); except parameters passed class naturally, if called method via call_user_func_array(); , want avoid having pass parameters in array. is there way initiate class while calling call_user_func_array(); on constructor? or prevent automatic running of constructor can run via call_user_func_array(); properties array? my actual code right is: if(!class_exists($controller)) require('controllers/' . $controller . '.php'); return new $controller(); i pass array of parameters constructor $controller($parameters) , in single array, not individual parameters. the full file source

asp.net mvc - Rendering view using ViewModel or JSON object -

my searching failed find thought travelled subject. options outlined @ bottom reflect things found. i need render view server side viewmodel or via json object. json object come server. on client side use ajax , determine insertion based on other id/attributes on page whether append/prepend/replace or ignore-placing target element. what options have use same view viewmodels or json objects? i had considered, on compile, render file.js version of view. include resource on page , perform replaces on var viewhtmltemplate = "<div>@model.message</div> . have disciplined in moving formatting/if-statement logic viewmodel json serialized. or, view has script tag bind viewmodel serilized js var , run function on document ready. the 3rd option instead of returning json object, return array of serverside html-rendered views. what inside of view model have field string serialized json structure. public class somevm { /* other properties */ public strin

orchardcms 1.6 - Razor helper intelligence not showing up on Orchard CMS -

i not able razor intellisense on view in orchard cms? example need intellisense when type @html in vs 2012 orchard cms view in module. let me knwo need install or razor helpers working in views ( cshtml) the project types orchard cms modules not mvc projects. instead, c#, asp.net projects. since intellisense based on project type (inside .csproj file), won't razor syntax within orchard module. as not using mvc project type guid, design, , there no plans add guid orchard future or existing orchard projects. see https://orchard.codeplex.com/workitem/19328 more info.

java - Using simple arrays to sort numbers by stacking them? -

this homework question (sorry, know these frowned upon), neither nor teacher knows how solve efficiently, wanted put here see if wonderful brains on out. an array of unspecified size given, containing random numbers. must sorted increasing order. each element can either moved adjacent empty space, or moved on top of adjacent larger element. need write method returns minimum number of moves needed sort given array. the question has been labeled 'optional', since teacher realized problem far difficult, i'm curious how might solved. suggestions arrays of size (it can arrays of length 3 care) appreciated. edit: pointing out unclear. i'm using array represent hypothetical real world situation. let's use example of coins: laid out on table in row, , there specified number of 'spaces' can put in. can put on top of adjacent larger coins, or slide adjacent empty space (which has been vacated coin had presumably moved on top of pile). i decided exam

java - Find all records close to particular record using Map Reduce -

i trying implement map reduce program find records in 2gb dataset close each other (something each record , neighbors should output). close to, mean euclidean distance. in dataset each record has x , y coordinate. suggest me intuition doing this. know map should emit each record , reduce can run double loop each entry in list inputted find neighbors, there better solution implementation horribly slow. in advance. map(rid,r): emit(key,r) reduce(key,lst=[r1,r2....]): elm1 in lst: elm2 in lst: if elm2 in range of elm1: process(elm1,elm2) the process function puts elm2 neighbor or elm1 mongodb database. each record in mongodb database structured follows record 'r' | list of neighbors of record 'r' you may able speed implementation indexing records in buckets. let's of records in grid [0,100] x [0, 100]. create 99 x-buckets [0, 1), [1, 2), ... [99, 100] , 99 y-buckets. given record [x1, y1] , distance d, take intersection of x-buckets [x

artificial intelligence - AIML Interpreter Algorithm -

i'm trying write aiml interpreter develop ai bot. went through several implementations of aiml interpreters still find difficult understand algorithm behind it. so if can describe general aiml interpreter algorithm or point out proper specification or document can used understand great help. thank you. you should use newer java aiml 2.0 interpreter program ab @ https://code.google.com/p/program-ab/

ios - UILocalNotification sound settings in iPad simulator -

i'm testing app on ipad simulator. have problem notification sound play. notification sound played when app running on foreground, not on background. shows banner type notification without sound. i'm wondering if notification settings in ipad simulator determine situation. iphone's settings app has 'notifications' menu , can set notification types-none,banner,alert- , sound etc. can't figure out ipad device settings app because don't have ipad :( the iphone simulator , iphone device work properly. not ipad simulator. -(void) registernoti { localnotif.firedate = noti.date; localnotif.timezone = [nstimezone defaulttimezone]; //payload localnotif.alertbody = [nsstring stringwithformat:@"%@",cell.textlabel.text]; localnotif.alertaction = @"run app"; localnotif.soundname = @"sound.mp3"; [[uiapplication sharedapplication] schedulelocalnotification:localnotif]; } is there way fi

how to make interactive svg with apache batik? -

my java app needs create svg files hover texts , bit interactivity. batik have apis this? see rhino engine can bundled batik classes. believe java app 'displaying' svg in own window. pointers? you can find plenty of information question on internet. few examples: http://comments.gmane.org/gmane.text.xml.batik.user/3811 http://batik.2283329.n4.nabble.com/rendering-css-in-jsvgcanvas-td4470592.html http://osdir.com/ml/text.xml.batik.user/2003-12/msg00185.html

performance - mysql improve view with subquery -

i need compare rows in same column, have following mysql query works giving expected result. select x.aord, x.anode parent, x.bnode child (select a.ordinal aord, a.id_dt_graph_node_edge aid, a.id_dt_graph_node anode, b.ordinal bord, b.id_dt_graph_node_edge bid, b.id_dt_graph_node bnode dt_graph_node_edge join dt_graph_node_edge b on a.ordinal < b.ordinal) x left join (select a.ordinal aord, a.id_dt_graph_node_edge aid, a.id_dt_graph_node anode, b.ordinal bord, b.id_dt_graph_node_edge bid, b.id_dt_graph_node bnode dt_graph_node_edge join dt_graph_node_edge b

linux - grep -v do not filter the lines outputs -

i doing search on linux console find /export/home01/ -name sql | grep -v 'permission denied' however, failed filter out lines "permission denied" like showing lines of find: /export/home01/oracle/oracle/product/11.2.0/db_1/network/log: permission denied . what's wrong command? however, failed filter out lines "permission denied" this expected: filtering stdout , error messages (usually) go stderr . try this: find /export/home01/ -name sql 2>&1 | grep -v 'permission denied'

Request not ending in node.js (used to work) -

i have piece of code: var app = require('http').createserver(function(req, res){ console.log(req); req.addlistener('end', function () { fileserver.serve(req, res); }); }); var statics = require('node-static'); var fileserver = new statics.server('./'); app.listen(1344, '127.0.0.1'); app.on('error', function(err){ console.log(err); }) it working fine, till made couple of changes, node gives error, , when went back, error wasn't there anymore, instead of work working before end event not being fired. so, inside req.addlistener('end', function (){}); is not called. and if run node.js uses same event, not being fired either. if end event of request broken. how can possible? is not first time happens. last time ended re-installing node (after try lots of different things). prefer find solution, can understand problem! note: original code include socket.io , other kind of connections, i'

join - increase query performance in mysql -

i have used query select count(case when c <= 1 1 end) nooffamilieshavingcount1, count(case when c between 2 , 4 1 end) nooffamilieshavingcountbetween2and4, count(case when c > 4 1 end) nooffamilieshavingcountgreaterthan3 ( select count(*) c user user_id = (select user_id location location_id in(select location_id country state_name='state')) group house_no ) t here sub query returning approximately 10000 records . user table has 10,00,000 records. taking time.then error saying server gone away. using mysql. i searched google.but no luck me. what changes need tables.how can execute query increasing query performance.please suggest me.thanks in advance.... try query select count(case when c <= 1 1 end) nooffamilieshavingcount1, count(case when c between 2 , 4 1 end) nooffamilieshavingcountbetween2and4, count(case when c > 4 1 end) nooffamilieshavingcountgreate

android - Error while sending data from service to activity -

my application described follows: application receive push information server , displayed on notification bar of android. when click on notification of application load url server. problem now, can not send url received server original activity. below error when run application. 04-09 11:25:26.503: e/androidruntime(1030): fatal exception: intentservice[gcmintentservice-810012644757-1] 04-09 11:25:26.503: e/androidruntime(1030): android.util.androidruntimeexception: calling startactivity() outside of activity context requires flag_activity_new_task flag. want? 04-09 11:25:26.503: e/androidruntime(1030): @ android.app.contextimpl.startactivity(contextimpl.java:624) 04-09 11:25:26.503: e/androidruntime(1030): @ android.content.contextwrapper.startactivity(contextwrapper.java:258) 04-09 11:25:26.503: e/androidruntime(1030): @ com.ketan.demo.gcmintentservice.generatenotification(gcmintentservice.java:118) 04-09 11:25:26.503: e/androidruntime(1030): @ com.ketan.demo

scala - Cannot specify main class for both running AND packaging jar in SBT 0.12.3 -

for reason cannot simultaneously specify main class run , packaging jar in sbt 0.12.3. the problem sbt publish-local doesn't put name of main class jar's manifest if don't set explicitly. but interestingly enough this mainclass in (compile,run) := some("hi") and mainclass in (compile,packagebin) := some("hi") work separately this mainclass in (compile,run,packagebin) := some("hi") causes sbt fail following error c:\work\test_projects\hw\build.sbt:13: error: reassignment val mainclass in (run,compile,packagebin) := some("hi") ^ [error] type error in expression is bug or missing ? the (compile,run) in mainclass in (compile,run) := some("hi") is specifying 2 axes of 4 axes setting has, (compile,run,packagebin) doesn't make sense. if want grab value other, say: mainclass in (compile,packagebin) <<= mainclass in (compile,run) for more det

g wan - How to read, write file over gwan -

i new gwan, , coding read/write static file on gwan, however, found when try open file (corresponding parameter pass gwan), run main() twice (or infinite looping), 1 ? thanks! here getanddelivery.c int main(int argc, char *argv[]) { global_count = 1; printf("global count : %d\n", global_count); xbuf_t *reply = get_reply(argv); char *name = 0; while(global_count<argc){ get_arg("zoneid=", &name, global_count, argv); if(hadcache(name)){ printf("have file\n"); }else{ printf("no file found!\n"); } global_count++; } xbuf_xcat(reply, "work!"); return 200; } function hadcache check whether static file exist or not! again!! thank gil answering question! had modified code , work now! however, try use own header file , function file on gwan under gwan/include/myownfunction.h & hadcache.c, foun

javascript - How can I perform an add function using jQuery -

Image
i'm new javascript , need perform function! scenario is, there 2 elements used increase , decrease numerical value. value shown in element. i've shown image elements are! how can using javascript? update : i wrote following jquery function element click event. result doesn't change when click element. jquery(document).ready(function(){ jquery(".amount-increase").click(function( var amount = parseint($(".bill-item-amount span")text(),10); amount = amount + 1; $(".bill-item-amount span").text(amount); )); }); here html element map. <div class="bill-item-description"> <!-- section item description , pricing --> <div class="bill-item-name"> <p class="bill-item-name-left">normal cofee</p><p class="bill-item-name-right">170.00</p> <div class="clear"></div> </div>

html - Safari PHP form submission -file upload hangs -

i have issue safari 5+. when client selects image file upload through simple html form mac version of safari 5.1 (so far browser found doing this) keeps hanging indefinitely. i have upload time , size in php.ini set correctly , works in other browsers (ff, opera ie!) not suppose have rookie mistake in html or php. i have searched through many posts , found bug report related issue ( https://bugs.webkit.org/show_bug.cgi?id=5760 ). found several ajax workarounds none of them has been right fit. not using ajax on page , due redirects not want anyway. does know solution? also.... suggestions adding <? header('connection: close'); ?> file make things worse opera. edit: april 10, 2013 still did not figure out why safari hangs on image uploads. making edit in case has similar problem. btw when safari ran in virtualbox upload fails every time unlike firefox or ie works fine. (perhaps settings issue?) i found workaround easy implement , far worked every mainstrea

Error with shell scripting -

!#/bin/bash svnadmin dump /path/to/repo | gzip -9 > /path/to/backup.bak-$(date +"%d\%m\%y--%t").dump.gz if ( `echo $?` -eq 0) echo "hello world" | mail -s "a subject" someone@wherever.com else echo "sorry, no way out" | mail -s "a subject" someone@wherever.com exit 1 fi there edit question any appreciated. output else part " sorry no way out! expect hello world dump command works your if clause should be: if [ $? -eq 0 ] . notice square brackets , whitespaces around them.

process - Multiple Processes on Microchip PIC32 Ethernet Starter Kit -

i have received microchip pic32 ethernet starter kit. i have 0 prior experience pic devices , know whether pic32 devices can run multiple processes @ same time? yes. 1 way: can write scheduler. relatively simple way set timer, , when timer ticks, run interrupt service routine runs 1 of tasks each time through. called cooperative multi-tasking, if of tasks overruns timer tick, other tasks have wait complete. if task crashes, whole system crashes. or operating system of sort, example freertos has pic32 port. have scheduling (and inter process communication primitives, , host of other o/s services) ready made you.

ruby on rails - Convert serialized-hash to Model attributes -

i have serialized data on activerecord model, , want delegate attributes it. this: class object < ar::base serialize :data delegate :title, to: :data end but of course doesn't work hash. there other way? what want in end this. give activerecord model list of symbols: [ :title, :size, :color ] they transformed getters , setters so: def title data[:title] end def title=(val) data[:title]= val end and represented next rest of ar attributes: #<model id: 21, title: "foo", size: 4, color: nil> you looking store : class user < activerecord::base store :settings, accessors: [ :color, :homepage ] end u = user.new(color: 'black', homepage: '37signals.com') u.color # accessor stored attribute u.settings[:country] = 'denmark' # attribute, if not specified accessor

Using Comparable interface to sort JAVA -

hi example have : string1[0] ="banana"; string1[1] ="apple"; string1[2] ="pineapple"; string1[3] ="mandarin"; i want sort alphabetically using comparable , compareto() method. result be: string1[0]="apple"; string1[1]="banana"; string1[2]="mandarin"; string1[3]="pineapple"; could show me skeleton of code plz ? and there better way sort ? just use arrays.sort() : arrays.sort(string1); this reorder strings lexicographically .

java - How to restrain checking single checkbox in multiple columns in Jtable -

Image
i trying implement jtable includes 3 check-box tables this: can tell me how set single selection group of checkboxes allows 1 selected check-box in single row @ time? i know of nothing out-of-the-box doing this. i´d have tablemodellistener check these columns every time change made , call setvalueat on checkboxes needed.

c# - Removing element from array: convert to list, remove element, convert back to array? -

in program have class called album. have array album objects go on creation. need let user change albumname of album later if want to. need let user delete albums array if want to. understand, can't delete objects arrays, if stored in list, not array. from understand of lists (i haven't used them before this), can't put album objects list instead of array on creation if want change variable in album object later. can't delete , replace album object new 1 in list if want change albumname, since album object storing array (mymusics) lost if did that. so question is, how allow user make changes album objects while letting them delete them? think i'd have change array stored in, list. delete object fromt list, change list same array. correct? how if right way go this? also, if helps/makes difference, array containing albums created in form1, album objects deleted form 1, changes albumname in album object happen in form2. any appreciated. i'm pretty new u

multithreading - when all thread kernel object handles is closed, does the thread still running -

Image
i'm curious when thread kernel object handles closed, thread still running in win32? so write simple test codes like #include <cstdio> #include <windows.h> #include <process.h> unsigned int __stdcall thread1_main(void* p) { while(1) printf("thread1 running!\n"); return 0; } int main() { handle h = (handle)_beginthreadex(null, 0, thread1_main, null, 0, null); closehandle(h); while(1) printf("main thread running!\n"); return 0; } and output it looks when handle closed, thread still running. however, msdn says "an object remains in memory long @ least 1 object handle exists". strange. yes, thread run until exits (by returning initial thread procedure), forcibly terminated (via terminatethread or _endthread(ex) ), or parent process exits. whether handles thread exist or not irrelevant. if think it, never work other way - since can wait on thread handle determine if has ex

undefined - dojo aspect not defined, dont understand why -

i want update dojo 1.7 1.8.3 have replace dojo.connect command. switch: < div id="universalpushswitch" data-dojo-type="dojox.mobile.switch" style="float:right" class="mblswroundshape1"></div> now have: dojo.require("dijit/registry"); dojo.require("dojo/ready"); dojo.require("dojox/mobile/listitem"); dojo.require("dojo/aspect"); dojo.ready(function(){ dojo.aspect.after(dijit.registry.byid("universalpushswitch"), "onstatechanged", function(newstate){ alert(newstate); } )}); firebug says: "aspect not defined" ps: know don't use new amd loader. old project , new dojo stuff. simple translate dojo.require("x");dojo.require("y"); require(["x","y"], function (x,y){...} doesn't work me there still old style require. try using: dojo.aspect.after(...); instead of aspect.aft

c# - How to implement a customized sortable and expandable list in WPF -

Image
i need implement list customized below. should able sort items on given field clicking on header. line should expandable. when user clicks on +, line should expand , disclose more information under field2 value. i have tried use listview in gridview. each column, have defined template (a template field1 values + on left, 1 field 2 values , 1 field 3 values). implementation, problem "how expand 1 line". i looked @ listbox component, need create headers manually , align content. need sort manually. doesn't seem solution me. do have better idea, or advice? the correct base control appears datagrid . provide functionality sorting on headers, etc. you have modify controltemplate through style if want in screenshot. as inspiration how ge detail expansion, following article you: grouping in datagrid in wpf you can consider having @ third party datagrids, in case standard datagrid doesn't cover of needs, individual templating can pretty far.

android - R.java has been generated, still getting 'cannot be resolved to be a variable' -

i'm thinking might have packages, can't find error. there no errors(red marks) in xml files, , drawables , xml files conform naming convention. have tried cleaning project, , there no import r.java anywhere. the classes cannot find r.java is: com.datafetcher.main.menu.java com.datafetcher.showperson.mainactivity.java com.datafetcher.showperson.displaymessageactivity.java in android manifest have declared: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.datafetcher" ... and activities declared: <activity android:name=".main.menu" android:label="@string/title_activity_display_message"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity

onclick - Jquery z-index, Strange behaviour on trigger buttons -

i don't know how ask question i'll start code. here html , js <html> <head> <link rel="stylesheet" href="style.css"> <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> </head> <body> <div id="behind-bg"></div> <div id="code" class="code"> <a id="testlink" href="#">click here</a><br> <a id="testlink" href="#">click here</a><br> <a id="testlink" href="#">click here</a> </div> <div id="curl" class="curl"></div> <div id="check-box-float"> <div id="open" class=

ios - Upload photo to Facebook and keep link Upload by AppName -

i use following code post photo wall [fbrequestconnection startforuploadphoto:img completionhandler:^(fbrequestconnection *connection, id result, nserror *error) { }]; it works fine. in ios 5.1 there link under photo directs itunes download app. that. but in ios 6.1 there link ios. tells uploaded ios. how replace app name in ios 5.1 or add link app? i use fb ios sdk 3.2 you can use opengraph it. it's fair bit of work implement, give more prominent link , lots of other options. i contacted @ facebook ask advice , sent me these links. https://developers.facebook.com/docs/opengraph/usergeneratedphotos/ https://developers.facebook.com/docs/concepts/opengraph/overview/ https://developers.facebook.com/docs/technical-guides/opengraph/creating-open-graph-stories/

ruby on rails - I18n.l displays wrong month (one month later) -

i have strage issue i18n.l helper. i've got following date in updated_at database field: 2013-04-09 08:17:26 i display date in view <%= l product.updated_at %> , the first time load page: dienstag, 09. april 2013, 10:17 uhr . when refresh page becomes dienstag, 09. mai 2013, 10:17 uhr . can see date 1 moth later. sticks until restart server. once again displays correctly 1 time. what issue here? found it. bug in spree version using. deleting nil key month_names accidentally: https://github.com/spree/spree/pull/2427

freeRADIUS with LDAP SASL/Certificate based binding -

i working on freeradius v1.1.7-r0.0.2 ldap backend authenticating users. i want configure freeradius server certificates instead of using usernames , passwords. how configure radius+ldap using sasl/certificate based binding ? please guide me how achieve this,is there help/doc how configure ldap sasl bind radius server. support sasl binding added in v3.0.x, both administrative binds, , user binds, it's not available in previous versions. see sasl sections in config here certificated based binding has been supported. it's configured certificate_file , private_key_file config items. you cannot pass ssl tunnel through eap conversation.

c# - When to check List<T> for null, when for 0 and when both -

i use ado.net entity framework , there code snippets : list<sole> entity = soleservice.all() .where(s => (s.shoelastid == shoelastid) && (s.status == 20)) .tolist(); since haven't think , made check: if (entity.count > 0) believing enough. see many people check any() , null . how sure @ situation kind of checks need , in scenario said - use if (entity.count > 0) enough? if (entity.count > 0) or if (entity.any()) identical in case. fetched data db, list has been built , knows size. .count property doesn't iterate on anything. in other hand, not call .count() ienumerable extension if didn't fetched data, because it'll enumerate items nothing. use instead: bool test = soleservice.all() .any(s => (s.shoelastid == shoelastid) && (s.status == 20)); if (test) { ... } also, linq extensions won't return null empty ienumerable , don't check null .

angularjs - Angular js: what is the difference between $http and $resource -

i need better understand difference between $http , $resource , when use each $resource built on top of $http. $http normal ajax, can used form of web service. $resource restful service. more details on angularjs $http , $resource

javascript - Drop-down list not working in a Knockout KoGrid -

i'm trying display drop-down list in kogrid cell using custom cell template , have no ideea why it's not working should. i have example of working drop-down list using options, optionstext, optionsvalue , optionscaption , bindings work should. similar drop-down in kogrid not display elements. question missing/doing wrong , how can fix problem? link jsfiddle: http://jsfiddle.net/axywz/6/ html: <p> working drop-down list: <select data-bind="options: data, optionstext: 'name', optionsvalue: 'id', optionscaption: '-', value: selecteditemid"></select> </p> <p> drop-down list not working in kogrid: <div class="grid" data-bind="kogrid: gridoptions"></div> </p> <pre data-bind="text: ko.tojson($root, null, 2)"></pre> <script type="text/html" id="template"> <select data-bind="options: $root.data,

html - Body only includes header? -

i have following html code: <!doctype html> <html> <head> <title>contest coding</title> <meta charset = 'utf-8'> <meta name = 'description' content = 'the free programming competition everyone'> <meta name = 'keywords' content = 'programming competition, coding competition, programming contest, coding contest, progrramming puzzles, coding puzzles, contestcoding, contest coding, c, c#, c++, python, ruby, java, javascript, php, haskell, perl, programming, coding'> <meta name = 'author' content = 'lewis cornwall'> <style type = 'text/css'> body { margin: auto; width: 960px; font-family: helvetica, sans-serif; font-size: 16px; } #header { text-align: center; } #leaderboard

jquery - creating csv file in ipad application using javascript -

this question exact duplicate of: create csv file using javascript 1 answer please let me know possible in ipad application. get text field data html page , save html5 local storage . data local storage , write csv file , save inside ipad using javascript. able fetch csv file ipad location. have @ jquery plugins data tables eg table2csv also have @ answer: export csv in jquery this may work or half way there, ie have data save local storage?

java - Bundling .dll inside of .jar -

i'm using xfiledialog ( https://code.google.com/p/xfiledialog/ ) instead of jfilechooser, want bundle dll's inside .jar don't have ship them application. so added them project, i'm not sure how reference them. inside xfiledialog.class found system.loadlibrary("xfiledialog64"); i guess has changed system.load("xfiledialog64") . is correct? the other issue not able edit .class file inside eclipse. mean have edit .class in source , re-compile it? since apparently desktop app., 1 strategy launch using java web start . if launched using web start, natives loaded loaded. here jnlp used load applet demo. <?xml version="1.0" encoding="utf-8"?> <jnlp spec="1.0+" codebase="" href=""> <information> <title>helloapplet</title> <vendor>stevpan</vendor> </information> <resources os="windows" arch="x86

node.js - Different socket connections or namespace in socket.io? -

i need have different channels socket.io implementation. these different channels have different processing , different data passed clients connected different channels. bit confused whether use different socket connections in guess have create different connections on different ports? or use standard namespace functionality socket.io provides. main concern if choose namespaces use 1 socket connection channels, performance of sending data across lots of clients on different channels affected because of it? any suggestions or inputs highly appreciated. thanks

arrays - Sorting dicom dataset in Matlab -

hi have 5000 2d images multiple ct-scans , need them sorted. dataset directly imported ge workstation. right images in bunches of 10 sorted images @ time in random order. how these images sorted? if suggest dicominfo please tell parameter go after. thank you! how dicom ct images should sorted dependent on usage context, rule of thumb recommend first group images based on (patient), study , series using these tags: (0010,0020) patient id (0020,000d) study instance uid (0020,000e) series instance uid to sort images within 1 series, use instance number (0020,0013) , although there no guarantee value set since type 2 attribute. another alternative use image position (patient) (0020,0032) , mandatory in ct images. need check image orientation (patient) (0020,0037) decide how sort on position. ct image orientation (1,0,0), (0,1,0), , z (third) component of image position can used basis sorting. if series contains localizer image, image have excluded positional

sql - VB.NET How do I apply decimal formatting to a specific column in a Gridview? -

how apply decimal formatting specific column in gridview? eg 83.7837837837838 being populated sql, how convert 83.8. i want apply 1 column other columns integers, won't necessary. one way using dataformatstring property. example: <asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" datakeynames="productid" datasourceid="sqldatasource1"> <columns> <asp:boundfield datafield="listprice" headertext="listprice" sortexpression="listprice" dataformatstring="{0:f1}" /> </columns> </asp:gridview> you use rowdatabound have more control: protected void gridview1_rowdatabound(object sender, gridviewroweventargs e) { if(e.row.rowtype == datacontrolrowtype.datarow) { // assuming using boundfields , // column want format first // if using t

sql server - LongListSelector in Windows Phone 8 -

i encountring issues longlisselector in windows phone 8. i display list, problem being entity of sql database retrieved wcf dataservices. wrote function return elements of problem observablecollection: private observablecollection<problem> createproblemgroups() { observablecollection<problem> listpb = new observablecollection<problem>(); var l = (from lp in problems lp.idproblem == lp.idmainproblem select lp).firstordefault(); listpb.add(l); return listpb; } then, in load event of long list selector (called listproblems), bind previous observablecollection item source of listproblems: private void listproblems_loaded(object sender, loadcompletedeventargs e) { observablecollection<problem> data = new observablecollection<problem>(); data = createproblemgroups(); longlistproblems.itemssource = data; } the code compiled no error , application runs fine, nothing displayed in end. i tried test tutorial msdn ( h

PHP : timezone_name_from_abbr() always return false -

code $c_tme = -330; $this->_client_t_z = timezone_name_from_abbr("", $c_tme*-60, 1); if( $this->_client_t_z == false ){ $this->_client_t_z = timezone_name_from_abbr("", $c_tme*-60, 0); } this code working fine in local. after uploading server returns false. bcoz of coding issue ?

android - Holo progressbar glow effect -

Image
i'm using canvas draw custom shape, , want add glow effect on it's end in android progressbar view. tried @ android sources, did not found how such effect achieved. the glow effect part of png image, see source file . used (indirectly via drawable/progress_horizontal_holo_light ) value of android:progressdrawable .

remotewebdriver - Selenium Server - Google Captcha issue -

i have selenium server running on remote server, , on same server have public-facing site configured in iis implements remotewebdriver run automated tests. i accessing site local machine, , it's working fine. one of tests have in place involves going google.com , entering search term. problem have each time run test, google shows 'unusual traffic computer network' captcha page. can recommend way around issue? thanks in advance. i able resolve adding following parameter when launching selenium server jar: -dwebdriver.firefox.profile=default it appears that, default, firefox remote webdriver uses new clean, anonymous profile. google didn't this. above forces use existing 'default' firefox profile. @ least that's understanding anyway!

stack - Is there a programming language that only has the power of a deterministic push-down automata, and no more? -

some programming problems don't require full power of turing machine solve. can solved less power. seeking programming language lesser power. does there exist high-level programming language constrained support these capabilities: a stack operations push values onto stack , pop values off stack. a finite state machine (fsm) input values, move state state, interact stack, , output results. i realize use java or c or python (etc.) , constrain language writing program uses stack , fsm. however, seeking programming language has these capabilities , no more. in other words, don't want use turing-complete programming language solve problems requires power of deterministic push-down automata. want use programming language has power of deterministic push-down automata. in short, you're not going find high level language little power. isn't strictly definition, high level implies amount of abstraction corresponds complexity. however, isn't issue: do

Android :voice recognition service -

[possibly duplicate] didn't find answers questions below. is possible run voice recognition service? implement this: need call number though phone through voice recognition in sleep mode. there sensor detect voice apart voice recognition? i'm working voice recognition, , think it's impossible run voice recognition service. because of: problem performance : run service must call voice recognizer continous. don't have api supports: run service must use service , call voice recognizer continous. so, find other solution instead voice recognition.