Posts

Showing posts from March, 2011

android - ListView Searching -

this code custom adapter,i have listview populated mysql data doing searching in edittext shows 0 result. lst=(listview) findviewbyid(r.id.listviews); search = (edittext) findviewbyid(r.id.search); items=new arraylist<client_information>(); adapter=new client_storeadapter(getapplicationcontext(),items); lst.setadapter(adapter); thread thread=new thread(doinbackground); thread.start(); search.addtextchangedlistener(new textwatcher() { @override public void ontextchanged(charsequence cs, int arg1, int arg2, int arg3) { // when user changed text adapter.getfilter().filter(cs); adapter.notifydatasetchanged(); log.d("hello", "hello"); } @override public void beforetextchanged(charsequence arg0, int arg1, int arg2, int arg3) { } @override publi...

android - how to take the listview item from addTextChangedListener and display it in the corresponding edittext box -

//listview adapter adapter_q = new arrayadapter<string>(authors.this, r.layout.list_item_author,r.id.product_name, quotes); lv.setadapter(adapter_q); //textviewq=(multiautocompletetextview)findviewbyid(r.layout.list_item_author); system.out.println("before printing"); // filtering text inputsearch.addtextchangedlistener(new textwatcher() { @override public void ontextchanged(charsequence cs, int arg1, int arg2, int arg3) { // when user changed text authors.this.adapter_q.getfilter().filter(cs); } @override public void beforetextchanged(charsequence arg0, int arg1, int arg2, int arg3) { // todo auto-generated method stub } @override public void aftertextchanged(editable arg0) { // todo auto-generated method stub } }); taking...

c# - Entityframework Table name is appended with 'es' on savechanges -

i'm facing strange error using entityframe work. have model entity called "userinfo" , db table name "userinfo". when i'm called savechanges() in entity frame work. i'm getting strange error invalid object name 'dbo.userinfoes'. i searched entire solution, see whether miss typed "userinfoes" , didnt find anything. please me solve issue. how "es" append along it? [table("userinfo")] public class userinfo { public int id { get; set; } public string field1 { get; set; } public string field2 { get; set; } public string field3 { get; set; } public string field4 { get; set; } public int field5 { get; set; } } you need disable pluralize table names linq sql designer. here steps http://msdn.microsoft.com/en-us/library/bb384507.aspx

jsp - How to share a session in two web applications hosted at two different application servers? -

i trying interact payment gateway, want share session can keep track of whether user payment processed payment gateway 1 whom request made. i explain below: 1. http://localhost:7080/requesterapp in websphere application server 1 2. http://localhost:8090/paymentapp in websphere application server 2 i redirecting user payment gateway via submitting html form. so how make sure request made user1 payment http://localhost:7080/requesterapp http://localhost:8090/paymentapp processed same user? should handled via session? the question not payment oriented, rather architectural one. server1 needs pass information server2, , communication needs done in backend. assuming 2 servers host different applications, websphere session replication not solution. need requesterapp call paymentapp in backend , let know user coming way. communication can made via http or rmi or whatever technology pick, long secured (ip whitelisting). so: requesterapp notifies paymentapp u...

Maven 3 upgrage - maven ear plugin bundles diffferent version of libs - ClassNotFoundException weblogic -

i have maven multi module project. in there few web projects , ejb projects. there no cheange in source code of entire project. upgraded maven 3 , built project. resulting ear file has libraries of different versions ear file built using maven 2. older version of particular libs , newer version of particular libs. for eg: commons-logging-1.1.1 maven2 wiht maven 3 resolved commons-logging-1.0.3 the real problem is, when try deploy ear created maven 3 weblogic server, classnotfoundexception spring classes. spring classes there in ear file. double checked it. ear file of same source code built maven 2 deploys successfully. <mar 24, 2014 11:42:17 ist> <error> <http> <bea-101371> <there failure when processing annotations application c:\weblogic\appsrv\domains\mydomain\servers\admin\tmp\_wl_user\myapp-ear\1697udy\app-control.war. please make sure annotations valid. error org.springframework.web.context.support.httprequesthandlerservlet> <mar 24, ...

crontab - Quartz Cron expression :Run every 15 days ie twice in a month -

i want set scheduler quartz cron expression trigger every 15 days ,for example 1st , 15th of every month.the 0 15 10 15 * ? triggering on 15th of every month. i have tested , following expression works fine "0 0 0 1,15 * ?" the 1,15 statement fires triggers on 1st , 15th of every month @ 00:00 hours. can change first 3 zeroes fire them @ particular time want. the 1st 0 -> seconds the 2nd 0 -> minutes the 3rd 0 -> hours

Java EE web application, link to the project's root folder -

in java webapp, create link main page : <a href="/"> main title... </a> but i'm redirected http://myserver.com:8080/ , i'd redirected http://myserver.com:8080/myprojectname/ how can without writing every link <a href="/myprojectname/mypagealias"> main title... </a> <a href="/myprojectname/mypagealias2"> main title... </a> <a href="/myprojectname/mypagealias3"> main title... </a> but <a href="/mypagealias"> main title... </a> <a href="/mypagealias2"> main title... </a> <a href="/mypagealias3"> main title... </a> nb : i'm not using spring or whatever... thanks

java - Hamcrest hasItem not matching in ArrayList -

i testing hasitem() matcher no avail. please see sample code below: list<string> list = new arraylist<string>(); list.add("1"); list.add("2"); list.add("3"); org.junit.assert.assertthat(list, hasitem("3")); it produces java.lang.nosuchmethoderror: org.hamcrest.matcher.describemismatch(ljava/lang/object;lorg/hamcrest/description;)v @ org.hamcrest.core.iscollectioncontaining.matchessafely(iscollectioncontaining.java:31) @ org.hamcrest.core.iscollectioncontaining.matchessafely(iscollectioncontaining.java:14) @ org.hamcrest.typesafediagnosingmatcher.matches(typesafediagnosingmatcher.java:55) @ org.hamcrest.matcherassert.assertthat(matcherassert.java:12) @ org.junit.assert.assertthat(assert.java:865) @ org.junit.assert.assertthat(assert.java:832) ... i did local test , works pretty fine me using junit-4.11 , hamcrest-core-1.3: import java.util.arraylist; import java.util.list; import org...

CSS Firefox 28 box-shadow color spill -

does know happened latest firefox 28 box-shadow? gives me color spilling. never happened before , doesn't repeat in other browser. here live example any appreciated. thank you. i have same problem. using borders instead achieve desired result. instead of 0 -5px 0 0 #4bf25c, use border-top: solid 5px #4bf25c;

objective c - Multirow PDFAnnotationTextWidget in Cocoa -

i trying create editable pdf annotation in pdfkit multirow. user not need able create new rows, want text displayed on entire bounding box (i.e. on several lines). however seems uses standard single line nstextfield when in editing mode. if access object change multiline seems pdfannotationtextwidget not expose object. https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/quartzframework/classes/pdfannotationtextwidget_class/reference/reference.html any ideas? the example found example project pdfkit 2006, support single line annotations. https://developer.apple.com/library/mac/samplecode/pdfannotationeditor/introduction/intro.html if not possible, there way create custom pdfkit annotations, , in case, how? it seems there no public method access nstextfield. can access swizzling methods, did in this example (please note: code has lot of warnings because it's old) in example can write multiple lines in nstextfield, when exit ed...

php - array merge only showing one value -

i have these 2 queries mysql_select_db($database_dbconnect, $dbconnect); $query_asset = "select idasset, assetname asset idlocation = '1'"; $assetup = mysql_query($query_asset, $dbconnect) or die(mysql_error()); $array1 = mysql_fetch_assoc($assetup); mysql_select_db($database_dbconnect, $dbconnect); $query_docup = "select assetdocstand.idasset, asset.assetname assetdocstand inner join asset on assetdocstand.idasset = asset.idasset assetdocstand.iddocumentstandards = '2' , asset.idlocation ='1'"; $docup = mysql_query($query_docup, $dbconnect) or die(mysql_error()); $array2 = mysql_fetch_assoc($docup); one gets me assets in current location. other gets me assets in current location have document uploaded standard of 2. please note have took out error checking purposes of post. if print results so: do{ print_r($array1); echo "<br>"; }while($array1 = mysql_fetch_assoc($assetup)); echo "<br><br><...

syntax error, unexpected T_STRING in php -

hi getting error , has become headache me. can please me have committed mistake. here code. <?php echo mxp_draw_pull_down_menu('datefield', mxpstatistics::getfieldsdropdown(), isset($_session['statistics']['datefield']) ? $_session['statistics']['datefield'] : ' ', 'onchange="javascript: savemodify(document.searchreport'.$rand.', \''.mxp_href_link_admin(filename_default, $mxptemplate->getmodule() . '&module=' . substr($file['name'], 0, strrpos($file['name'], '.'))) ."' , null, " . $_get['windowid']);"');?> just remove last 4 characters( "'); ) code. you can detect syntax errors easily, if use syntax highlighting ide. also, if try save number of line this, real headache find syntax errors , debug. try code <?php echo mxp_draw_pull_down_menu('datefield', mxpstatistics::getfieldsdropdown(), isset($_...

d3.js - Using snap svg for manipulating/dragging/hide/show nodes in SVG diagrams -

i have network diagram(nodes , edges) in svg generated graphviz tool. want make diagram interactive in sense, should draggable, on click of node other nodes hidden.etc. can 1 suggest snapsvg sufficient that? cannot add thing svg diagram restriction. how can make existing svg diagrams forced directed? help, starting point, fiddle helpful. have hands on in d3.js achievable d3.js? this should possible, maybe aware snap.svg isn't compatible older browsers (in case @ raphael snaps older brother, d3 established well). have basics, handlers, animation etc. however, although possible, may quite lot of work (so may want stick know). you may want whether want autocreate connecting elements , move automatically, or happy moving endpoints manually. it may depend on things want happen after dragging elements. want save them ? of may quite important how approach it, maybe more important dragging support that.

.net - How to call a method with the C# collection initializer? -

case this morning refactored logging method , needed change method's 'params' parameter in normal array. consequently, call method had change array parameter. i'd method call change less possible, since it's heavily used utility method. i assumed should able use collection initializer call method, gave me compile-error. see second call in example below. third call fine too, results in error. example void main() { // works. object[] t1 = { 1, "a", 2d }; test(t1); // not work. syntax error: invalid expression term '{'. test({1, "a", 2d }); // not work. syntax error: no best type found implicitly-typed array. test(new[] { 1, "a", 2d }); // works. test(new object[] { 1, "a", 2d }); } void test(object[] test) { console.writeline(test); } question is there way call test() without initializing array first? the problem c# trying infer type of array. howeve...

c# - Create Dynamic TestFixture at runtime -

i working on project in have multiple .ini file(decide @ runtime) in application directory , want create testfixure each ini file @ runtime. [testfixture("card-1.ini")] //herdcode [testfixture("card-2.ini")] //herdcode class classtest { //test } here have create parameterized testfixture @ run time.

bash - Random syntax error!? associative array expansion with a key which contains "operand" -

Image
all i got 2 2d-array files read bash file1.txt (nx6) desc1 dm1 w1 s1 critical1 grade1 #this line dosen't exist eee 1x 9 6 y e2 aaa x 1 2 y e2 c+c x 8 1 y t1 hhh 1x 5 5 y t2 iii x 5 5 y s1 jjj x 5 5 y s1 d+ x 2 3 y t1 file2.txt (mx3) desc2 w2 s2 #this line dosen't exist aaa 1 2 eee 9 5 fff 10 7 ggg 4 9 iii 5 5 c+c 8 1 d+ 2 3 jjj 5 5 what wanna extract elements inside both files comparisons following picture: http://imgur.com/4479luk.jpg i wanna in green labels take 1 element in $desc1 , compare whole elements in ${desc2[@]}, if does/dosen't find element in ${desc2[@]} feedback true/false here work: #!/bin/bash clear esc=`printf "\033"` ##===================================================================## ##===================================================================## ##========== read information file1.txt , file1.txt ==========## ##===================================================================## ##======...

wpf - How to show Column Header of empty collection -

how show column headers empty collection has properties column. properties of collection known in run time. datagrid's autogeneratecolumns set true. update: it bug .net framework 4.0. when check sp1 of vs2010 fixed. how handle this? the best way in opinion test datasource , if empty add null data item give headers, set row[0].isvisible = false hide row. need undo when data has rows

c# - Enforcing public setter -

i ran serialization error only manifested on 1 out of 3 machines tested on. unable generate temporary class (result=1) error cs0200: property or indexer 'xxx' cannot assigned -- read it fixed removing 'private' following line in viewmodel: public observablecollection<contact> recipients { get; private set; } i put commment: // , set must public avoid serialization errors but i'd prefer enforcing setter public via code because comments forgotten when code re factored. i'd compile error if future developer change setter private. i tried using [datacontract] & [datamember] attributes in hope enforce public setter. is possible? you can check whether properties of type readable , writable in following manner: var t = typeof (someclass).getproperties().all(s => s.canread && s.canwrite); and use contract check whether predicate matched. debug.assert these in tests. i'm can't cause compiler errors result of...

javascript - jQuery ajax call not falling into success -

i new doing jquery ajax calls , trying test ajax call have attempted write today. here is. var heartbeatinterval = 30000; var heartbeattimer = null; var retrycount = 0; var maxretries = 10; $().ready(function () { var url = $.url("/pollbulletin.htm"); heartbeattimer = setinterval(function () { $.ajax({ url: url, type: 'get', error: function (data) { retrycount = retrycount + 1; if (heartbeattimer != null && retrycount >= maxretries) { clearinterval(heartbeattimer); } }, success: function (bulletinbarmessage) { retrycount = 0; var respcontent = ""; respcontent += bulletinbarmessage.messagelevel + " : "; respcontent += bulletinbarmessage.message; } }); // when communication server lost stop heartbe...

javascript - How to enable multi-language selection in Phonegap-jQuery Mobile project? -

hi newbie jquery mobile , have created mobile application using jquery mobile , phonegap , want enable multi-language selection dropdown list in app.i know how add dropdown list , putting items in list easy.but difficulty facing translate ..what possible ways enable translation ? example current language english , while choosing language (eg: italian) need translate complete page italian , how using google translator ? i built app in german , english. gave user option select desired language stored response localstorage. then wrote text each page string variables. on each pagebeforeshow did quick check against value in local storage , showed relevant content corresponding string. a more lightweight version might duplicate pages in sub directory. example english lang files in myapp/en , german lang pages in myapp/de. this keeps each page lightweight makes keep track of pages little tricky more languages. it'd make total size of app larger. also, yud have work ...

PHP MySQL remove quantity -

i met situation when need import values quantity spended many times qty. eg. have table product material id type quantity spent 1 1 10 0 2 1 100 0 now spent 20 qty of material once , need update field spent this id type quantity spent 1 1 10 10 <--- 0 left 2 1 100 10 <--- 90 left or spend 8 qty first 20 qty, table needs first - spent 8 id type quantity spent 1 1 10 8 <--- 2 left 2 1 100 0 <--- 100 left second - spent 20 id type quantity spent 1 1 10 10 <--- 0 left 2 1 100 18 <--- 72 left so need separate spended material quantity avaible , reduce till limit reduce other 1 avaible qty. what best way php? please appreciated, thank you! update `tablename` set `spent` = 10, `quantity` = `quantity` - `spent` `id` = 1...

c# - Process.Start does not work when called from windows service -

on windows 8 running windows service. service supposed start program by process.start(exepath); but process exits - first line in main procedure not executed. before, when running same process in same service on windows 7, worked fine. how can make work again? how start process windows service? found solution. process has started this: processstartinfo info = new processstartinfo(exepath); info.createnowindow = true; info.useshellexecute = false; process.start(info); for reason there problems priviledges when creating shell window in background of system.

javascript - How not to display Cursor in a read only input type text box in Mozilla Firefox -

i'm using mozlla firefox vesrion 24.01 . i've text box input field in form whics read only . in mozilla, see cursor blinking inside textbox when pointing text box, in chrome, not. is there way not have cursor shown in mozilla also? i've searched lot, , have seen answers regarding put onfocus="this.blur();" as inline inside input field. but, works in html. when tried rails text_field_tag not taking method ' onfocus '. so, either please suggest me better solution hide cursor or tell me how can achieve text_field_tag , onfocus event. thanks :) suggestion cbroe worked. but, in rails way, <%= text_field_tag "answer_name",truncate(answer.name,:length=>35), :onfocus => "this.blur();", :style=>"cursor:default;", :readonly => true%> it worked. don't forget put css line ' cursor: default; ' change pointer arrow type default, text box have text-mode pointer (the pointer ...

ios - Is it possible to get which class thrown the exception? -

is possible class thrown exception @ runtime? if so, how it? what want detect class did throw exception. i'm using nssetuncaughtexceptionhandler(nsuncaughtexceptionhandler *) detect if app crashes. that, have nsexception , want know class throws it. also, not debugging purposes. #pragma mark - exception handler void handleexception(nsexception *exception) { // handle exception } void installuncaughtexceptionhandler() { nssetuncaughtexceptionhandler(&handleexception); //signal(sigsys, sig_dfl); for(int x = 1; x <= 30; x++) { signal(x, sig_dfl); } } you can read stack trace +callstacksymbols ( nsexception ) inside exception handler. last entries system calls. beneath find thrower. @try { … } @catch (nsexception *e) { nslog( @"%@", [e callstacksymbols] ); }

Color gradient algorithm -

Image
given 2 rgb colors , rectangle, i'm able create basic linear gradient. blog post gives explanation on how create it. want add 1 more variable algorithm, angle. want create linear gradient can specified angle of color. for example, have rectangle (400x100). color red (255, 0, 0) , color green (0, 255, 0) , angle 0°, have following color gradient. given have same rectangle, color , color. time change angle 45°. should have following color gradient. that's quite simple. besides angle, need 1 more parameter, i.e. how tight/wide gradient should be. let's instead work 2 points: __d __-- __-- __-- __-- m where m middle point of gradient (between red , green) , d shows direction , distance. therefore, gradient becomes: m' | ...

matlab - Predefining one element of a row matrix where other elements are created via an equation -

i have matrix created via equation for xxx = 1 : xmid_p - 2 ln_p(1,xxx) = abs(radius_p(1,1) - radius_p(xxx+1)); end however need equation have 0 first element. understand can via ln_p(1,1) = 0; but how combine first element 0 , rest of row matrix taken equation above. solution: it pretty simple , involved concatenating simple 1x1 matrix ln_p matrix. lnzero(1,1) = 0 xxx = 1 : xmid_p - 2 ln_p(1,xxx) = abs(radius_p(1,1) - radius_p(xxx+1)); end ln_p = horzcat(lnzero,ln_p) dirty trick maybe; use inside loop - ln_p(1,xxx) = (xxx~=1).*(abs(radius_p(1,1) - radius_p(xxx+1)));

How to set custom Business Process Flow to default in CRM 2013 -

Image
in crm 2013 have created business process flow. need set default business process flow. please tell me way set default business process flow. appreciate answer. thanks. first of need select switch process option list. please see below. then select business process flow list set default one. please see below. please click on select button , business process flow set default. thanks.

java - Spring Cache: Using memcached as a distributed cache -

for number of java services we're using aws elasticache distributed cache integrated spring cache abstraction , spymemcached. in 1 service see behaviour diffent type of result expect, leading classcastexception. precise: have cache key , result expect list, instead result of type2. we have defined number of caches, of use same cache key: cache1: cachekey -> list<type1> cache2: cachekey -> type2 since in different caches, works when use simple hashmap based cache. elasticache/memcached seems don't have different caches (which make sense know of memcached - not much). i have expected spymemcached take care of manipulating cache keys application wouldnt need aware of actual cache implementation (this done manipulating cache keys , prefixing them cache name i.e.). from few debugging sessions , errors see, doesn't seem case. i've looked @ class: com.google.code.ssm.spring.ssmcache l82: value = cache.get(getkey(key), null); l154: private st...

javascript - Highstock chart - missing data -

Image
i'm using highstock chart display data. i'm showing multiple series on same chart don't start / end @ same time: the problem is, if navigate period of time have data 1 series (green one), disappears chart. in case, should see green line. any appreciated!

javascript - Comparing multiple values to multiple values -

i have couple of select boxes , need rows have compared select boxes. so lets have 3 select boxes #brand_id, #model_id, #memory_id and value empty on default. need check if selected , if selected want add array. if box not selected should add ids of box. the condition can think of this: //phones array contains rows var filterarray = []; if($("#brand").val() != ''){ $.each(phones, function(index, value){ if(value.brand_id == $("#brand").val()){ filterarray.push(value.id); } }); } if($("#brand").val() != '' && $("#model").val() != ''){ $.each(phones, function(index, value){ if(value.model_id == $("#brand").val() && value.model_id == $("#model").val()){ filterarray.push(value.id); } }); } and on hope made clear mean there lot more conditions cov...

How to find distance (by road) between 2 geo points in Android application without using google map direction api? -

i developing android application. need find distance between 2 geo coordinates. i used location.distancebetween() , location.distanceto() functions. these functions give straight distance, actual distance different when travel road. use google api as public float getdistance(double lat1, double lon1, double lat2, double lon2) { string result_in_kms = ""; string url = "http://maps.google.com/maps/api/directions/xml?origin=" + lat1 + "," + lon1 + "&destination=" + lat2 + "," + lon2 + "&sensor=false&units=metric"; string tag[] = {"text"}; httpresponse response = null; try { httpclient httpclient = new defaulthttpclient(); httpcontext localcontext = new basichttpcontext(); httppost httppost = new httppost(url); response = httpclient.execute(httppost, localcontext); inputstream = response.gete...

java - The content of JComboBox is displayed as a single string, not as separate items -

i using following tablecellrenderer in jtable . when click on jcombobox , see list of values single string (like this: [text1, text2] ), not separate items. error? tablecolumn columncombobox = table.getcolumnmodel().getcolumn(5); columncombobox.setcellrenderer(getrenderercombobox()); private tablecellrenderer getrenderercombobox() { return new tablecellrenderer() { private jcombobox<string> box = new jcombobox<string>(); @override public component gettablecellrenderercomponent(jtable table, object value, boolean isselected, boolean hasfocus, int row, int column) { box.removeallitems(); (string q : employees[row].getqualification()) box.additem(q); box.setbackground(isselected ? table.getselectionbackground() : table.getbackground()); box.setforeground(isselected ? table.getselectionforeg...

python - Thumbor installation not working -

i have followed wiki , set necessary, images broken right now. used aptitude package manager install. here configuration files: /etc/default/thumbor # set 0 disable thumbor, remove or set else enable # can temporarily override # sudo service thumbor start force=1 enabled=1 # location of configuration file conffile=/etc/thumbor.conf # location of keyfile contains signing secret used in urls #keyfile=/etc/thumbor.key # ip address bind to. defaults ip addresses # ip=127.0.0.1 # tcp port bind to. defaults port 8888. # multiple instances of thumbor can started putting several ports coma separeted # ex: # port=8888,8889,8890 # or port=8888 #default /etc/thumbor.conf #!/usr/bin/python # -*- coding: utf-8 -*- # thumbor imaging service # https://github.com/globocom/thumbor/wiki # licensed under mit license: # http://www.opensource.org/licenses/mit-license # copyright (c) 2011 globo.com timehome@corp.globo.com # domains can have images resized # use empty list allow sourc...

javascript - Get value from text field and show in select field -

hi have cna me want vlaue text field , show in select javascript or jquery. <ul class="title_customer"> <li> <label for="offaddress" class="title_register"><!--<em>*</em>--><?php echo $this->__('title') ?></label> <div class="input-box"> <div type="text" name="offaddress1" id="offaddress1" value="<?php echo $this->htmlescape($this->getcustomer()->getoffaddress()) ?>" title="<?php echo $this->__('office address') ?>" class="input-text " > <input type="text" name="offaddress1" id="offaddress1" value="<?php echo $this->htmlescape($this->getcustomer()->getoffaddress()) ?>" title="<?php echo $this->__('office address') ?>" class="input-tex...

apache camel - Header set in NMR call does not exists while it is called in In-Out exchange pattern -

i calling nmr endpoint sets headers me. inout pattern while response comes 1 of header set not exists. in log statement give &{headers} print headers names. 1 header set in nmr endpoint(in java class) not exists. please me out here understand happening. @ least me understand on cases lose header . if trying print header not existing @ in logger null or nothing? service mix 4.5.x , camel 2.6 just communicating other routes when call other routes/bundle. if headers sent while calling them removed(either due setbody() or getout().setbody() methods) response not have header sent earlier.

.net - How to create a log file in c# for windows application? -

how create log files in windows application??? please me example, in file can saved on specific path. thanks in advance i doing disservice give "code logging", can point towards file class, contains useful methods writing text file. since specify no other needs, suspect suffice. file http://msdn.microsoft.com/en-us/library/system.io.file.aspx

c# - Optimal data structure for lookup within nested scopes -

say, there's tree data structure, each leaf of defines set of keys lookup: * |- = 1, b = 2 |- * |- c = 4 |- * |- d = 5 |- d = 6, e = 7 i need way of finding value of key given leaf while tree being traversed depth-first. there 2 approaches have thought of: if value not found in current leaf, check dictionary of parent , on root of tree. there global dictionary , each leaf inserts/removes keys when being traversed. lookup in performed in global dictionary. it's there many leafs few keys in each, , 3-4 lookups each key. which approach more efficient? or, maybe, there's way of doing better both? the programming language implementing sure define exact rules name resolution. don't think lead depth-first search. name resolution rules, fruequently, somethink this: search current scope, considering has been declared “up” current position in source code; when specific rules met, e.g. there form of using / import or whatever oth...

How to copy or get access to the file (.zip) from received Email on BlackBerry z10? -

need in copying file received email on blackberry z10. allredy tryed find solution without sucesss. task load file received email clicking on it. allredy implement, app opens on clicking file ending .kdp. bar-descriptor.xml: <invoke-target id="com.example.myapp"> <invoke-target-type>application</invoke-target-type> <invoke-target-name>name of app</invoke-target-name> <icon> <image>icon.png</image> </icon> <filter> <action>bb.action.open</action> <mime-type>*</mime-type> <property var="exts" value="kdp"/> <property var="uris" value="file://,data://"/> </filter> </invoke-target> next step connect invokemanager slot: m_invokemanager = new invokemanager(this); bool connectresult; connectresult = m_invokemanager->connect(m_invokemanager, signal(invoked(const bb::system::invokerequest...

java - what's wrong with this if else? -

this question has answer here: how compare strings in java? 23 answers i want know wrong : if (q == "outside" && q1 == "not alive") { system.out.println("bison"); } this statement works perfectly: if (q == "outside" && q1 == "alive") { system.out.println("bison"); } all of if statements containing "alive" works perfectly, of if statements containing "not alive" not work. this exercise have without using else if or else. full code :- import java.util.scanner; class age04 { public static void main(string [] args) { scanner keyboard = new scanner(system.in); string q, q1,; system.out.println("two more questions, baby!"); system.out.println("think of , i'll try guess it!"); system.out.println("question 1) stay inside or outside ...

c# - List Published Projects From MS Project 2010 API -

the project api allows list projects using projectdataset data = client.readprojectlist(); foreach (projectdataset.projectrow projectrow in data.project){...} this api call deficient due fact returns projects working store , not published store. seems expected check every project guid against published store incredibly slow. int = projectrow.proj_type; if (i == 0){ projectdataset publishedprojectdataset = client.readproject(projectrow.proj_uid, datastoreenum.publishedstore); if (publishedprojectdataset == null) { continue; } } does know of anyway list published projects? projectclient.readprojectstatus should work . e.g. // list of projects. svcproject.projectdataset projectds = projectclient.readprojectstatus( guid.empty, svcproject.datastoreenum.publishedstore, string.empty, (int)pslibrary.project.projecttype.project); documentation located @ here .

iphone - how can i check NSNumber is null? -

nsdictionary *regiondict = (nsdictionary *) region; nsnumber *lat = [regiondict objectforkey:@"lat"]; //[latitude addobject:lat]; nsnumber *lng = [regiondict objectforkey:@"lng"]; //[longitude addobject:lng]; nslog(@"%@%@%@",lat,lng,titles); if(lat == [nsnumber numberwithfloat:0.00] && lng == [nsnumber numberwithfloat:0.00]) { nslog(@"%@%@%@",lat,lng,titles); } else { cllocationcoordinate2d coord; coord.latitude =lat.doublevalue; coord.longitude =lng.doublevalue; mapviewannotation *annotation =[[mapviewannotation alloc]initwithtitle:titles andcoordinate:coord]; [self.mapview addannotation:annotation]; } if condition not satisfied because of nsnumber not check null value. way can check? tell me possible way...

Java min max values -

everything working fine, need output quarter highest/lowest rainfall, not actual values. not sure how tie quarter , values output quarter 1, 2, 3 or 4. import java.util.scanner; public class rainfall { public static void main(string[] args) { scanner scan = new scanner(system.in); double[] rainfall = new double[4]; double totalrainfall = 0.0; double max = 0, min = 0; (int i=0; < 4; i++) { system.out.print("enter rainfall quarter " + (i+1) + ": "); rainfall[i] = scan.nextdouble(); totalrainfall += rainfall[i]; if (i == 0) { max = min = rainfall[i]; } { if (rainfall[i] > max) max = rainfall[i]; else if (rainfall[i] < min) min = (i + 1); //min = rainfall[i]; } } system.out.println("total rainfall = "+totalrainfall); system.o...

sql - Converting geometry(spatial) to longitude and latitude -

i've uploaded .shp files table in sql , got geometry column data. can see points on "spatial results" tab in sql server , that's fine. when run line in sql server select [geom].stastext() mytable i these kind of results point (444386.4927124856 5073381.9183241855) so there way convert regular latitude , longitude.

c++ - Is there any way to use thrust with cufftComplex data type when the data is in device? -

i'm making program have 4d data. in loop iterate through 4th dimension, , take 3d data float , convert data cufftcomplex , copy device , several device operations fourier transform(from cufft library), image denoising(my own cuda kernel). while being in loop in between these operations after fourier transform want find median of 3d data in particular iteration. i know thrust allows me sorting can find median value in following example normal float data type do int row, column, slice; row = 5; column = 5; slice = 5; int alloc_size = row*column*slice; float * themaindata = new float[alloc_size]; srand(time(null)); for(int k=0; k<slice; k++) { for(int j=0; j<column; j++) { for(int i=0; i<row; i++) { themaindata[i+(j*column)+(k*row*column)] = rand()%1000;; } } } thrust::sort(themaindata, themaindata + alloc_size); float median = themaindata[(alloc_size/2)]; cout<<endl<<"the median value "<<median...

Django - does model need own table if it inherits solely to change the manager? -

i've read thread deals issue of making django comments use select_related() on “user” field thereby reducing needless sql queries. the suggestion best create own comment model , override manager used. this have: #models.py class lightcommentmanager(commentmanager): def get_query_set(self): qs = (super(commentmanager, self).get_query_set().select_related('user')) return qs class lightcomment(comment): objects = lightcommentmanager() class meta: managed = false this works fine when syncdb, django still creates table lightcomment. need have table if i'm changing manager, , why django create if managed set false? thanks in advance, for start, inner class should called meta , not meta . but rather managed = false , should using proxy = true signify creating proxy model rather real model.

vba - C# run excel macro that has a password -

i have excel workbook contains macro contains password. have c# app calls excel macro (not design). wondering if there away password protect excel macro people cannot see password can still called c# app. the password has remain in workbook cannot move c# app, again not design. password-protecting macro not prevent being executed , viewed , edited . just go module properties in vba editor, click "protection" tab , add password. note string constants not encrypted in source file, may want obfuscate password if it's human-readable password it's not recognizable looking @ excel file in text editor.

python - OpenERP (View) - change look of selection field? (aka radio button) -

Image
is there way change how selection field looks? need change bunch of boolean fields (technically 1 field, not multiple boolean fields. change)? it should (it looks there multiple fields, technically should one): and should function selection field - can select 1 value. possible it? update: found - http://help.openerp.com/question/29061/how-to-add-radio-button-widget/ it seems possible widget on openerp 8 (using radio widget selection field). think might possible move such functionality in openerp 7. i managed move radio widget openerp 8 openerp 7. post how i've done. maybe 1 need too. basically need 2 main files, 1 js , 1 xml (also empty __init__.py needed, because openerp throw error didn't find module). in __openerp__.py : 'js': ['static/src/js/widget_radio.js'], 'qweb': ['static/src/xml/widget_radio.xml'], widget_radio.js ( web_widget_radio addon name): openerp.web_widget_radio = function (instance) { ...

postgresql - How can we make Django tests faster? -

we using django 1.4 postgresql on ubuntu 12.04. have many tests, , problem running tests slow, think because each test database created scratch. want make tests faster running them database in memory (not hard disk). how do it? have links or tutorials? the best option have separate settings file tests. in settings_test.py tell use sqlite default use in-memory database: from base_settings import * databases = { 'default': { 'engine': 'django.db.backends.sqlite3', 'name': ':memory' } } and run tests adding --settings=settings_test see django docs: https://docs.djangoproject.com/en/dev/topics/testing/overview/#the-test-database

c - Cannot handle consecutive SIGSEGV signal -

i trying handle sigsegv signal code. have written following code in c under fedora 15. problem signal handler not getting called second segmentation fault. can kindly point out doing wrong. typedef struct _st_demo { int m_iunused; _st_demo() { m_iunused = 0; } } st_demo; jmp_buf ex_buf__; static void sig_hdl (int sig, siginfo_t *siginfo, void *context) { cout<<"inside signal handler."<<endl; longjmp(ex_buf__, 1); } int main (int argc, char *argv[]) { st_demo* pstdemo = 0; struct sigaction act; memset (&act, '\0', sizeof(act)); /* use sa_sigaction field because handles has 2 additional parameters */ act.sa_sigaction = &sig_hdl; /* sa_siginfo flag tells sigaction() use sa_sigaction field, not sa_handler. */ act.sa_flags = sa_siginfo; if (sigaction(sigsegv, &act, null) < 0) { perror ("sigaction"); return 1; } if(!setjmp(ex_buf__)...

java - Spring MVC + hibernate batch loading from db -

sorry guys if trivial question, want figure out right way. there large table 'account' (about 10000 entries). want iterate through logic entity , merge if needed. don't want load entries in memory. currently this list<account> accounts = accountsdao.all(); (account a: accounts) { dosomecode(a); accountsdao.merge(a); } how can improve it? have @ setfirstresult , setmaxresults rather manually , quite explicit queries (think sql's limit clause). there setfetchsize let driver/database chunk results of unlimited query ( example in postgresql jdbc docs ). scrollableresults seems quite similar (regarding usage @ least): getting result iterator scroll on matched records ( example in random blog post ). as question database using: there differences between databases and/or drivers. not know specifics here, features regarding loading in chunks must supported respective db driver.

c# - Check for arithmetic overflow and get overflow count? -

what appropriate way detect arithmetic overflow (or underflow matter) , overflow count? for easier understanding i'll using byte , same int or other basic integer type. imagine have value 240 , want add 24 it. arithmetic overflow. using checked keyword easy detect @ least ... byte value = 240; try { checked { value += 24; } } catch (overflowexception e) { // handle overflow, overflow count via % etc. } ... throwing exception. this using @ moment. however, don't quite exception handling in one. exceptions pretty expensive, , want avoid them right start. me seems boneheaded-exception anyways. is there arithmetic wizardry detect upfront? i guess check if difference between current value , maximum if large enough addition: var difference = byte.maxvalue - value; if(difference >= 24)//ok add 24 else//will cause overflow to detect underflows can use byte.minvalue value instead: var difference = value - byte.minvalue; if(dif...

android - Error parsing XML: not well-formed invalid token? -

i keep getting error parsing xml: not well-formed error @ android:layout_height="wrap_content". saw other answers problem opening , closing brackets, these appeared ok me. why getting error? thanks! activity_main: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" > <imageview android:id="@+id/imageview1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignparentleft="true" ...