Posts

Showing posts from July, 2012

Python global variable and class functionality -

im creating simple python program gives basic functionality of sms_inbox. have created sms_inbox method. store = [] message_count = 0 class sms_store: def add_new_arrival(self,number,time,text): store.append(("from: "+number, "recieved: "+time,"msg: "+text)) **message_count += 1** def delete(self,i): if > len(store-1): print("index not exist") else: del store[i] message_count -= 1 in bolded bit getting error: unboundlocalerror: local variable 'message_count' referenced before assignment. i created global variable store empty list , works when use add_new_variable object. reason not adding values global message_count variable. please help that's not how classes work. data should stored within class instance, not globally. class smsstore(object): def __init__(self): self.store = [] self.message_count = 0 def a

android - Is there an easier way to use AlarmManager or to set real-time based alarms? -

it seems way time actions based on actual elapsed time (as opposed uptime, stops when device sleeps) alarmmanager. is there an easy way "wallclock"-based delayed exectuion, example through open-source wrapper around alarmmanager? for normal timing operations, can use handler, easy such simple task should be: implement handler callback (no registration necessary) instantiate handler call sendemptymessagedelayed or similar functions to clean set delays, call removecallbacksandmessages(null) however, handler supports uptime-based delays, not sufficient (e.g. if want check server new messages every 15 minutes). if want those, seems have use alarmmanager, not comfortable: define action alarm create receiver (either creating dedicated receiver class , declaring manifest, or implementing interface, registering receiver using registerreciever, , unregistering when done) create intent action wrap said intent in pending intent, , store pending intent if want c

c# - How to overcome the exception "The Type Initializer for "SAP.Middleware.Connector.RfcConfigParameters" threw an exception - Error#:-2146233036" -

we have applications fetching data sap systems through dcom sap connector. have replaced .net connector. after deploying production worked 1 day. giving specified error while accessing 1 rfc. exception message is the type initializer "sap.middleware.connector.rfcconfigparameters" threw exception - error#:-2146233036. the code use create object sap.middleware.connector.rfcconfigparameters , use below string value1 ="val1"; string value1 ="val2"; string value1 ="val3"; string value1 ="val4"; string value1 ="val5"; string value1 ="val6"; string value1 ="val7"; rfcconfigparameters parms = new rfcconfigparameters(); parms.add(rfcconfigparameters.param1, value1); parms.add(rfcconfigparameters.param2, value2); parms.add(rfcconfigparameters.param3, value3); parms.add(rfcconfigparameters.param4, value4); parms.add(rfcconfigparameters.param5, value5); parms.add(rfcconfigparameters.param6, value6); par

belongs to - Laravel Relationships -

i've been looking on relationships in laravel 4 in documentation , i'm trying work out following. i have table in database called 'events'. table has various fields contain id's relate other tables. example, have 'courses' table. events table contains field called 'course_id' relates id of 'id' field in courses table. so basically, i'm after advice on how go relating 2 (belongsto()?) , passing connected data view. here @ far http://paste.laravel.com/pf3 . i hope guys able give me advice on how best approach problem. thanks. gaz this same answer @marko aleksić, hasone() , belongsto() relationships right way around. class course extends eloquent{ protected $table = 'courses'; public function event() { return $this->hasone('event'); // links this->id events.course_id } } class event extends eloquent { protected $table = 'events'; public function co

c++ - Signals and slots QT -

i have asked number of different questions regarding 1 main issue in program , still not solved @ all, i'm using threading keep ui locking up, still because apparently can't ui stuff in threads. so i've been told use custom signals , slots (not examples given). so documentation i've read came code: .h signals: void paint_signal(double x, double y); .cpp connect(this,signal(paint_signal(double x, double y)), this, slot(paintsomething(x,y))); the paintsomething function within same class of this.... thread: *future2 = qtconcurrent::run(this, &gui::paintall); paint emits paint_signal , passes 2 doubles emit paint_signal(x, y); but error don't understand @ all connect: no such signal gui::paint_signal(double x, double y) connect(this, signal(paint_signal(double, double)), this, slot(paintsomething(x,y))); remove parameter names , should work. if 1 doesn't work 1 will: connect(this,

ios - Master view controller disappears after tapping an item and quickly changing orientation from portrait to landscape -

Image
xcode 4.5 application ipad device. for ipad master view controller application, master view controller disappears after tapping item , changing orientation portrait landscape mode. i used default template master-template application ipad. in portrait mode (ipad) tapped "+" button on master controller , added multiple items around 10. after tapped 1 of highlighted item in master controller (refer screen shot) changed orientation portrait landscape. in landscape mode master controller disappears , blank (black) screen appears. i analysed further , found issue in following line of code [self.masterpopovercontroller dismisspopoveranimated:yes]; in detailviewcontroller.m - (void)setdetailitem:(id)newdetailitem { if (_detailitem != newdetailitem) { _detailitem = newdetailitem; // update view. [self configureview]; } if (self.masterpopovercontroller != nil) { [self.masterpopovercontroller dismisspopoveranimated:yes];

java - Detect when user closes floating toolbar frame -

is possible capture event when user tries close floating toolbar window in swing? in advance. there's awesomely simple solution, why use that? the best come (without extending out own tool bar) add ancestorlistener toolbar , monitor it's events. the problem have approach, though, need know main frame attached to, may not convenient. import java.awt.borderlayout; import java.awt.eventqueue; import java.awt.event.componentevent; import java.awt.event.componentlistener; import java.awt.event.containerevent; import java.awt.event.containerlistener; import java.awt.event.hierarchyevent; import java.awt.event.hierarchylistener; import java.beans.propertychangeevent; import java.beans.propertychangelistener; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jtoolbar; import javax.swing.swingutilities; import javax.swing.uimanager; import javax.swing.unsupportedlookandfeelexception; import javax.swing.event.ancestorevent; import javax.swing.e

c# - Parsing text file separated by comma -

i developing application read text file , plot graph. text file #pattern name item1, item2, item3, gx1, gy1, gz1 115, 80, 64, 30.752, 27.587, 15.806 195, 151, 130, 108.983, 102.517, 66.353 94, 123, 156, 43.217, 50.874, 93.700 88, 108, 65, 26.158, 37.980, 17.288 130, 129, 177, 68.096, 66.289, 127.182 100, 190, 171, 71.604, 119.764, 122.349 ......................................... ........................................ #pattern name2 item1, item2, item3, gx1, gy1, gz1 115, 80, 64, 30.752, 27.587, 15.806 195, 151, 130, 108.983, 102.517, 66.353 94, 123, 156, 43.217, 50.874, 93.700 88, 108, 65, 26.158, 37.980, 17.288 130, 129, 177, 68.096, 66.289, 127.182 100, 190, 171, 71.604, 119.764, 122.349 etc. i need value gx1,gy1 . planned read them counting spaces , commas (3 each). sounds in appropriate? there optimized or more logic that? you should use existing csv-parser this . however, assuming name of pattern unique , want acess later: var gxdict = new di

html - CSS span overflow auto or scroll not working with child element -

i have following setup:- http://jsfiddle.net/ykxub/1/ and css this:- .two { height: 100%; width: 100%; border:1px solid green; } .hold { float: left; height: 100%; width: 35%; border:1px solid green; } .right { height: 100%; border:1px solid green;} .hold > img{width: 100%;height:100%;} #one{ height: 300px; width: 600px; margin: 0 auto;} .center{text-align:center;margin:0 auto;} .rights{text-align:right;} .main{width:100%;display:block;border:1px solid green;} .five{width:20%; border:1px solid green;float: left;} .six{border:1px solid green;display:block;} as can see , contents exceeds span width keeps on going , i've tried overflow:scroll , overflow:auto nothing seems work any appreciated guys :) overflow:auto works me .six{border:1px solid green;display:block; overflow:auto} demo

html - change image display into inline -

i making image slider .i trying display images inline .i have apllied css not working :( image not displayed inline. property need change please help. <div id="f1_container"> <div id="f1_card1" class="shadow"> <div class="front face"> <img src="thumb1.jpg" style="height: 281px; width: 450px;" /> </div> <div class="back face center"> text inside here </div> </div> <br/> <br/> <div id="f1_card2" class="shadow"> <div class="front face"> <img src="thumb2.jpg" style="height: 281px; width: 450px;" /> </div> <div class="back face center"> text2 </div> </div> </div> this css file, #f1_container { position: r

php - Adding zeros to specific place in mySQL table row -

i have mysql table alot of links this: id - link 1 | index.php?video=12 2 | index.php?video=345 3 | index.php?video=6789 4 | index.php?video=123&other=variable 5 | www.site.com/index.php?video=456&other=variable one link per text row. add zeros before numbers has 9 numbers in total. video=12 video=000000012 , video=6789 video=000006789. is there way acheive using sql query? edit: solution tombom submitted worked fine if have links don't have video=x variable? update yourtable set `link` = replace(`link`, substring(`link` locate('=', `link`) + 1), right(concat('000000000', substring(`link` locate('=', `link`) + 1)), 9)) see working live here in sqlfiddle. update: what if have links more url variables? like: index.php?video=123&play=1&search=hello that's bit trickier, here go: update yourtable set `link` = replace(`link`, substring(`link`, locate('=', `link`) + 1, abs(locate('&', `link

jquery - How do I increment a variable in javascript? -

this json: {"0":0,"1":1,"2":2,"3","4":4,"5":5,"7":"ocupat","8":8,"9":9,"10":10,"11":11,"12":12,"13":13,"14":14,"15":15,"16":16,"17":17,"18":18,"19":19,"20":20,"21":21,"22":22,"23":23,"24":24,"25":25} this js code function populatelocuriliberedus(id_cursa, data_rezervare) { var data = id_cursa + "-" + data_rezervare; $.get(path + 'rezervaribilete/locuridisponibile/' + data, function(o) { $.each(o, function(i, value) { if(value != "ocupat"){ $('#locuridus').append('<option value="'+ value +'">'+ value +'</option>'); } }); }, 'json'); } the option show starting 0 25, want show 1 26 thanks help. replace value (value+1) wh

regular expression validation in asp.net -

i using regular expression validator c# in asp.net login page..i have different login pages student,lecturer , admin..the login ids of form 1rnxxcsxxx,1rnlecsxxx,1rnadcsxxx respectively(x-digits) problem validates text box , displays error message.. still continues n logs in..my code is.. <asp:regularexpressionvalidator id="regularexpressionvalidator1" runat="server" controltovalidate="textbox1" errormessage="enter in 1rnxxcsxxx format" validationexpression="[1][r][n][0-9][0-9][c][s][0-9][0-9][0-9]"></asp:regularexpressionvalidator> ie..if type lecturer id in student login page can still login inspite of gettin error message..any appreciated.thank u it seems name of textbox you're using custom login logic. suggest using membership provider more robust in securing entire application. check out how configure member ship database other aspnetdb for immediate problem though in method logs u

Why is the performance for this Java code so inconsistent? -

i'm running small test although micro benchmark mimic doing in production pretty well. i'm creating 2d array, 5 columns , 10,000,000 rows filled random integers between 0-19 inclusive. want sum numbers in 3rd column long value in 2nd column even. 100 times warm , 100 times , time how long takes. on machine vast majority of time takes around 9 seconds, however, takes under 6 seconds. it doesn't garbage collection, or jit compilation. does have idea why faster occasionally? i run code jdk7u11 on linux these arguments: -server -xx:+printcompilation -xms500m -xmx500m -verbose:gc -xx:+printgctimestamps -xx:+printgcdetails however, using various different jdks (from 6 way 8) , removing these parameters doesn't seem effect timings significantly. here code: import java.util.arraylist; import java.util.random; public class javaperformancetest { public static void main(string[] args) { int numcolumns = 5; int numrows = 10000000; int[

html - add border-bottom to nested list items -

i want add bottom border every list item css. here css code: ul,ol{ li{ list-style-type: none; margin: 0; padding: 0; padding-top: 3px; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid #eeeeee; ul,ol{ margin-left: 2em; li{ border-bottom: 1px solid #eeeeee; } } } } it gives output this: screenshot url: http://oi34.tinypic.com/ih1eea.jpg the css code working fine on top level item. not on sublists. please see screenshot , me, in advance. demo give class ul demo .demo li { border-bottom: 1px solid #000; } if want each , every li in website should border-bottom won't great idea use ul li { border-bottom: 1px solid #000; } if want indent nested li can use text

How to get the doctype declaration using DOM on Xerces 2.8 -

i trying add doctype declaration output xml file using xerces 2.8 i using domdocument* doc1 = implementation->createdocument(); create document and want add doctype doc doc1. i obtain doctype doc follow: domdocumenttype* document_type = doc->getdoctype(); however, can not pass document_type function createdocument(). does has example of how this? thank you, gilmer you have set " http://xml.org/sax/properties/lexical-handler " property of xerces instance object of type "lexicalhandler". informed events on "startdtd" callback. @ least true java. should identical c.

java - Find available "number" in a 2d array -

i have problem need solve in effecient way. have 2d array contains following: 1 "wall" means cannot go through it. 2 entrance "enter" array or map if like. 3 things need find. here example of map: 1111111 1 3131 2 11111 1 31 1111111 this example of array need in. can see there 3 "unreachable, since it's surrounded wall "1". means there 2 available numbers in array. first need find entrance. since entrance can anywhere need search entire array. have done following: int treasureamount = 0; point entrance = new point(0,0); (int = 0; < n; i++) { (int j = 0; j < n; i++){ if(map[i][j] == 2){ entrance.x =i; entrance.y =j; } } this takes o(n^2) time, , don't see way this, since entrance can anywhere. i'm not sure how find available numbers effectivly , fast. thought while searching arrays entrance @ same time find number 3 in array th

vb.net - InStr array is in string -

currently i'm using instr find string in string, i'm new vb.net , wondering if can use instr search every element of array in string, or similar function this: instr(string, array) thanks. you need loop: dim bfound boolean = false each elem string in array if mystring.contains(elem) bfound = true exit end if next you can transform function call more once easily: public function myinstr(mystring string, array() string) boolean each elem string in array if mystring.contains(elem) return true next return false end function then: myinstr("my string text", new string() {"my", "blah", "bleh"})

Magento set template variable programatically -

i need able send transactional emails include conditional sentence. want include sentence in order confirmation emails orders contain products. there plenty of examples of how use conditionals within transaction emails based on built in variables, want base conditional on own variable i'll create programatically within own extension. the mailer class mage_core_model_email_template_mailer have public settemplateparams method, method calls base classes setdata method, if access method set own parameters overwrite core template parameters nessesary show contents of basket. any ideas on how achieve appreciated. you should create new order attribute save conditional sentence. can access attribute in transactional email template via {{htmlescape var=$order.getyourattribute()}}

interface builder - Xcode quickly jump to Action associated with a Control -

is there quick way jump action associated control. say there button on xib file has associated action. way find code associated rather tedious. there short cut can jump code. i spoiled visual studio - double click on button , takes it's handler the fastest way know @ least source file in action resides following: select button in ui editor hit ctrl + 1 (this open “related files” drop down) navigate “sent actions” sub-menu, e.g. via s , enter select relevant class (i think in case there can one, hit enter again) once in class, action should easy find. if that's not case, because source file big, type ctrl + 6 open “document items” drop down , start typing name of action. once see action, select via keyboard or mouse. if don't know name of action, have before navigating class, e.g. right clicking on button.

phpexcel - PHP Excel - extracting data to a variable -

i've been working phpexcel, , have been able take dataset data , create arrays on large data sets. if want allow client draw data single cell, can't seem make work. what i'm looking take data single cell in excel , place in php variable. assuming you're using phpexcel library. to "raw" cell value: $cella1value = $objphpexcel->getactivesheet()->getcell('a1')->getvalue(); or calculated value cell containing formula: $cellb2value = $objphpexcel->getactivesheet()->getcell('b2')->getcalculatedvalue() or formatted value cell: $cellc3value = $objphpexcel->getactivesheet()->getcell('c3')->getformattedvalue()

javascript - XDomainRequest post data not displaying -

i can't post data trough internet explorer xdomainrequest. nothing showing up.. i created fiddle parim.ee/test.php prints out $_post , $_request variable so: header('access-control-allow-origin: *', true); header("access-control-allow-headers: *", true); echo "var_export(\$_post):\n"; var_export($_post); echo "\n\n"; echo "var_export(\$_request):\n"; var_export($_request); found solution: instead of using $_post have use $http_raw_post_data .

multithreading - Use of PBO and VBO -

my application (qt/opengl) needs upload, @ 25fps, bunch of videos ip camaras, , process applying: for each videos, demosaic filter, sharpening filter, lut , distortion docrretion. then need render in opengl (texture projection, etc..) picking 1 or more frames processed earlier then need show result widgets (qglwidget) , read pixels write movie file. i try understand pros , cons of pbo , fbo, , picture following architecture want validate help: i create 1 thread per video, capture in buffer (array of images). there 1 buffer video. i create upload-filter-render thread aims to: a) upload frames gpu, b) apply filter gpu, c) apply composition , render texture i let gui thread render in widget texture created in previous step. for upload-frames-to-gpu process, guess best way use pbo (maybe 2 pbos) each video, load asynchronously frames. for apply-filter-info-gpu , want use fbo seems best render-to-texture. first bind texture uploaded pbo, , render texture, filtered

sql - select top 10 with the highest average score -

lets say, have product , score tables. product ------- id name score ----- id productid scorevalue i want top 10 products highest average scores, how average , select top 10 products in 1 select statement? here mine selects unexpected rows select top 10 product.productname score.score product, score product.id in (select top 100 productid score group productid order sum(score) desc) order score.score desc give try, with records ( select a.id, a.name, avg(b.scorevalue) avg_score, dense_rank() on (order avg(b.scorevalue) desc) rn product inner join score b on a.id = b.productid group a.id, a.name ) select id, name, avg_score records rn <= 10 order avg_score desc the reason why not using top because not handle duplicate record having highest average. can use top ties instead.

php - Simple keyword search with full match -

i need simple keyword search. i have objects have associated set of keywords them. need way reliable search these keywords. after search set of keywords search library should return ids of objects associated these keywords. additional need know there full match(all searched keywords presented in single set [associated object]). i want avoid building query multiple or operators. can point me library or tutorial how can achieve this? as see php tag assume no db involved. list of objects state. i don't quite know mean building query when there not db, question bit unclear. i assume class objects talking about: class someobject { private $id; private $keywords = array(); public function getid() { return $this->id; } public function getkeywords() { return $this->keywords; } } then solution: function filterobjectarray($objectarray, $search) { $resultids = array(); $resultobjects = array(); f

nested - MySQL in clause to Enumeration Path on Table Heirachy -

i had investigation using mysql hierarchical data, (currently table uses adjacency list model) getting breadcrumb via loop sending parent id , re-cursing same function in php, fires query each time. want improve creating _construct method fire query once , return object can refer to. to have done research nested sets, path enumeration (materialized path) , closure table. i have chosen materialised path. my sql select t1.* menu t1 t1.menu_id in ( select trim(replace(t2.lineage,'/',',')) cat_idd menu t2 t2.page_id = 52 ) my table such, i'll paste in dump can test it... structure create table if not exists `menu` ( `menu_id` int(11) unsigned not null auto_increment, `menu_text` varchar(255) not null default 'new !!!', `menu_alt_text` varchar(255) default null, `menu_alt_location` varchar(255) default null, `page_id` int(11) unsigned not null default '0', `parent_menu_id` int(11) unsigned not null default '0&

ios - How to share iPhone application video on You Tube? -

Image
i uploading video on youtube app. have followed these steps http://urinieto.com/2010/10/upload-videos-to-youtube-with-iphone-custom-app/ but getting 19 errors of not finding library classes in sample code. in gdataoauthviewcontrollertouch.m file getting error "expected type" gdataoauthauthentication class. snap shot i have tried these steps http://hoishing.wordpress.com/2011/08/23/gdata-objective-c-client-setup-in-xcode-4/ , in if use gdata client library provided urinieto sample code getting errors. please me now got final solution link share videos facebook . it's helpful. github.com/eternalstorms/essvideoshare-for-os-x-lion

ios - Sphero's modal views with iPhone 5? -

Image
i've noticed sphero modal views don't cover entire parent view on iphone5 , can't change nibs. there property can set make modal view cover entire parent view? also no sphero connected modal view doesn't right portrait (ruinospheroconnectedviewcontroller_portrait) this not expected behavior, , we've noted it, , we're working on ironing out. for now, can fix issue colorpicker view setting bounds of view bounds of parent view in viewdidload method of view controller: colorpickerview.bounds = self.view.bounds .

css - Responsive segmented dropdown group with block level input -

Image
i'am using bootstrap framework develop responsive hotel search page. need segmented dropdown group block level input shown in below image. here, input full width, floated left action dropdown. text "action" dynamic , change according user selects dropdown. width of dropdown may increase. the input text should start left dropdown , fits full width also. i managed static, there lot of issues faced width when doing responsive , when dropdown text increased. does have idea how implement ? advanced help.. edit : here js fiddle : http://jsfiddle.net/surjithctly/mp8ab/ html <form class="bs-docs-example"> <div class="input-prepend"> <div class="btn-group" style=" z-index: 1; "> <button class="btn" tabindex="-1">action</button> <button class="btn dropdown-toggle" data-toggle="dropdown" t

c# - Listbox ItemTemplate Selector does not pick a template -

i trying use itemtemplateselector on listbox within grid creating on different file later called mainwindow. here datatemplateselector code public class templateselector : datatemplateselector { public override datatemplate selecttemplate(object item, dependencyobject container) { frameworkelement element = container frameworkelement; if (element != null && item != null && item myclass) { myclass agg = item myclass; if(agg.mytype == a) { return element.findresource("greenitemtemplate") datatemplate; } else if (agg.mytype == b) { return element.findresource("yellowitemtemplate") datatemplate; } else if (agg.mytype == c) { return element.findresource("reditemtemplate") datatemplate; } } return null; } } here xaml

access JavaScript variable in new window -

this first javascript attempt, apologize if things little mangled. i have 2 html pages (certificate1.html , certificate2.html). i'm trying prompt user his/her name on certificate1.html, pass information certificate2.html. @ point user's name displayed in certificate (s)he can print. both html pages reference same javascript file (certificate1.js). first page calls passname(): function passname() { firstn = document.frmusername.infirstn.value; lastn = document.frmusername.inlastn.value; // alert(firstn); // // alert(lastn); // var cert = window.open("certificate2.html"); cert.firstn = firstn; cert.lastn = lastn; //alert(cert.firstn); //good //alert(cert.lastn); //good } this seems working correctly. i'm stuck function placename() certificate2.html calls. have firing onload, , know it's accessing function correctly (i stuck alert in there , came up). don't know how access firstn , lastn variables passed cer

Is it possible to replace the version of the JAXB implementation in Java JRE 1.6 SE? -

i have test class import javax.xml.bind.annotation.xmlelement; class compiletest { void foo( @xmlelement string in ) { } } my java version is $ java -version java version "1.6.0_23" java(tm) se runtime environment (build 1.6.0_23-b05) java hotspot(tm) client vm (build 19.0-b09, mixed mode, sharing) and when try compile class i'm getting javac compiletest.java compiletest.java:5: annotation type not applicable kind of declaration void foo( @xmlelement string in ) { ^ 1 error and that's valid java 6. when tried add newer jaxb library class path, didn't help. there way solve this? javac -cp jaxb-api-2.2.4.jar compiletest.java use java endorsed standards override mechanism put jaxb-api-2.2.4.jar inside <java-home>\lib\endorsed directory. or, use -d java.endorsed.dirs option javac -djava.endorsed.dirs=/your/path/to/jaxb-directory compiletest.java references: http://docs.oracle.com/javase/6/docs/tech

iphone - IOS isEqualToString Not Working -

the following example program outputs same, program not work correctly. nsdirectoryenumerator *directoryenumerator = [[nsfilemanager defaultmanager] enumeratoratpath:kdocdir]; (nsstring *pathi in directoryenumerator) { nsstring *filename_manager = [pathi lastpathcomponent]; nslog(@"filename_manager = %@",filename_manager); artist *name_databse = [self.fetchedresultscontroller objectatindexpath:indexpath]; nslog(@"name_databse = %@",name_databse.name); if ([filename_manager isequaltostring:name_databse.name]) { nslog(@"same name"); }else{ nslog(@"different name"); } } outputs: 2013-04-25 15:37:43.256 player[36436:907] filename_manager = alizée - mèxico - final j'en 2013-04-25 15:37:43.272 player[36436:907] name_databse = alizée - mèxico - final j'en 2013-04-25 15:37:44.107 player[36436:907] different name does not

Spring Transaction Manager: Rollback doesnt work -

i wish execute few insert queries within transaction block if there error inserts rolled back. i using mysql database , spring transactionmanager this. table type innodb i have done configuration following steps mentioned here . following code (for 1 query) transactiondefinition def = new defaulttransactiondefinition(); transactionstatus status = null; status = transactionmanager.gettransaction(def); jdbctemplate.execute(sqlinsertquery); transactionmanager.rollback(status); spring config xml: <bean id="jdbctemplate" class="org.springframework.jdbc.core.jdbctemplate"> <property name="datasource"> <ref bean="datasource" /> </property> </bean> <bean id="transactionmanager" class="org.springframework.jdbc.datasource.datasourcetransactionmanager"> <property name="datasource" ref="datasource" /> </bean> datasource config

javascript - How to avoid TypeError: Cannot set property 'onchange' of null -

how can avoid error? works, i've seen error, here code: function separe(price) { nstr = number(document.getelementbyid(price).value) * 100 nstr += ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(nstr)) { nstr = nstr.replace(rgx, '$1' + ' ' + '$2'); } return nstr + " centimes" } function forma(price, dest) { var handler = function(e) { document.getelementbyid(dest).innerhtml = separe(price) }; document.getelementbyid(price).onchange = handler; //line 50 document.getelementbyid(price).onkeyup = handler; } and html: <input id="prix" type="number" name="prix" min="1" step="1"> <script> forma("prix", "hhh"); //profil 148 </script> <h1 id="hhh" >&nbsp;</h1> my page issuing error on load: uncaught typeerror: cannot set property 'onchange' of null formatter

php - Do I need a foreach with MultipleIterator? -

this code comment , write file , work fine. $comment1 = $xpath->query('//*[comment() = "abc"]'); $comment2 = $xpath->query('//*[comment() = "cde"]'); $commentiterator = new multipleiterator(); $commentiterator->attachiterator(new iteratoriterator($comment1)); $commentiterator->attachiterator(new iteratoriterator($comment2)); foreach ($commentiterator $comments) { file_put_contents('page1.php', $dom->savehtml($comments[0])); file_put_contents('page2.php', $dom->savehtml($comments[1])); } the problem result correct if have file_put_contents outside foreach. $comments local variable inside loop. need foreach? this code works $comments outside foreach $comment1 = $xpath->query('//*[comment() = "abc"]'); $comment2 = $xpath->query('//*[comment() = "cde"]'); $commentiterator = new multipleiterator(); $commentiterator->attachiterator(new iteratoriterator

Printing jetty output to Eclipse console window -

i developing eclipse plugin includes starting embedded jetty server, i.e. server jetty = new server(8080); webappcontext webapp = new webappcontext("webapp", "/webapp"); webapp.setwar("path/to/webapp); jetty.sethandler(webapp); jetty.start(); program.launch("http://localhost:8080/webapp"); i see jetty's output in console window of eclipse contains plugin. instead jetty's output appears in eclipse developing plugin. look logging framework of jetty. start creating custom org.eclipse.jetty.util.log.logger can write eclipse console window of choice. example implementations: the default strerrlog.java used jetty itself. the slf4jlog.java using slf4j logging jetty. the javautillog.java using java.util.logging jetty. then, before instantiate jetty classes, call org.eclipse.jetty.util.log.log.setlog(logger log) set underlying logging framework jetty uses custom logger implementation. good luck

c# - How to dispose a resource shared between UI thread and background thread -

lets start ui thread (wpf, winforms fine too), , ui thread creates background thread somework (threadpool) , when completed background thread updates ui (using dispatcher). ui thread shares resouce background thread , needs disposed of when background thread completes process. what best way achieve this, dispose resouce background thread when finishes job? if cannot use resouce ui thread after creating thread don't know when background thread completes , vice versa. (and no async/await features avaiable here). dealing ui thread here, need keep gui active time. my preference 1 thread "own" resource , manage it. if ui thread owns can "loan" resource background thread ui thread still responsible disposing of it. way ui thread can use resource , knows whether it's disposed or not. if possible it's better background worker "own" resource can dispose sounds not possible in situation.

java - My Lucene search doesn't return results -

i'm studying lucene , first test class. i'm trying implement in memory search , borrowed codes examples. search cannot return hits. can me please? thanks. package my.test; import java.io.ioexception; import org.apache.lucene.analysis.standard.standardanalyzer; import org.apache.lucene.analysis.util.chararrayset; import org.apache.lucene.document.document; import org.apache.lucene.document.field; import org.apache.lucene.document.stringfield; import org.apache.lucene.index.indexwriter; import org.apache.lucene.index.indexwriterconfig; import org.apache.lucene.index.indexwriterconfig.openmode; import org.apache.lucene.index.term; import org.apache.lucene.search.booleanclause; import org.apache.lucene.search.booleanquery; import org.apache.lucene.search.indexsearcher; import org.apache.lucene.search.prefixquery; import org.apache.lucene.search.scoredoc; import org.apache.lucene.search.searchermanager; i

How to export mysql database into ms access using php -

i looking way export mysql table ms access file using php. server windows based , want export data in mysql table msaccess file. know mysql csv mbd conversion(using phpmyadmin , ms access s/w), there easy , better way convert tables access file on mouse click using php ? please note there lots records in mysql table in advance. there couple of ways this. i'd connect access directly mysql db described here . i'm assuming, though, not option you. assuming can't whatever reason can put script connect both mysql , msaccess databases via php+sql. this link has guide connecting access db via php.

Round float values accurately with output required decimal point in Objective-C -

how round float value 1.449567 accurately. the output value should required decimal point floate value . output should this: for 1 decimal point **f=1.5** 2 decimal point **f=1.45** 3 decimal point **f=1.450** 4 decimal point **f=1.4496** i'd recommend looking using nsnumberformatter . example: float roundedvalue =1.45999f; nsnumberformatter *formatter = [[nsnumberformatter alloc] init]; [formatter setmaximumfractiondigits:1]; [formatter setroundingmode: nsnumberformatterrounddown]; nsstring *numberstring = [formatter stringfromnumber:[nsnumber numberwithfloat:roundedvalue]];

javascript - Knockout observable subscribe doesn't recognize a change with date input in google Chrome -

weird issue knockout.js whereas won't recognize date has been selected after reset, same date. to replicate in jsfiddle: http://jsfiddle.net/v5jcq/ follow these steps: pick date cllick reset pick same date you've picked in step 1 how? what? why? code: <input type="button" data-bind="click: resetdate" value="reset"> <input data-bind="value : estimateddeliverydate" type="date"> <span data-bind="html: selecteddate" /> var viewmodel = { estimateddeliverydate: ko.observable(), selecteddate: ko.observable() }; viewmodel.estimateddeliverydate.subscribe(function (date) { viewmodel.selecteddate("date selected: " + date); }); viewmodel.resetdate = function () { viewmodel.estimateddeliverydate(""); }; ko.applybindings(viewmodel); n.b. : issue applicable google chrome v20+ comes built-in date picker html5 date input control. hence tags. not s

sql - Get rows where two values are unique to each other -

the values of interest ein , registration number reg . there lots of records each value. what want know pair of values appears each other (or blank ein ). id ein reg 12 321 124 13 321 125 14 322 168 15 322 168 16 323 171 17 323 171 18 323 so in above example, i'd want select 322 , 168, every time appear, appear together, want select 323 , 171, since never appear value, non-value. 100% of records have ein, smaller portion have registration id. any suggestions on how query this? one of many possible ways: select distinct ein, reg test t reg not null , not exists ( select 1 test t1 t1.ein = t.ein , t1.reg <> t.reg or t1.reg = t.reg , t1.ein <> t.ein); ein | reg ----+----- 323 | 171 322 | 168 -> sqlfiddle. i assuming ein not null , reg can null , since wrote: 100% of records have ein, smaller portion have registration id. null never qualifies

regex - how to replace more than one matched string in Emacs Regexp? -

in emacs regexp, i'm doing replace-regexp, searching this <span class="small">\([^<]+\)</span>\([^<]+\)<span class="small">\([^<]+\)</span> and trying replace this <span class="small">\1\2</span> i'm trying concatenate 2 matched strings. doing wrong? without description of how doesn't work you, can guess intended replace \1\3 rather \1\2 . a second possibility text operating on doesn't match regex. (switch-to-buffer (get-buffer-create "nst.html")) (insert "<span class=\"small\">foo</span>bar<span class=\"small\">baz</span>") (goto-char (point-min)) (replace-regexp "<span class=\"small\">\\([^<]+\\)</span>\\([^<]+\\)<span class=\"small\">\\([^<]+\\)</span>" "<span class=\"small\">\\1\\3</span>") try m-x undo i

How to DELETE Records from Target Database in SSIS -

same database exist on 2 servers. call them source , destination simplicity here. need compare records , delete exist in target not in source. can't use execute sql both databases exist on different servers , there no link between them. can propose solution? you populate table on target ids source table. use execute sql task on destination database delete rows target table not exist in table populated. eg, like: delete targettable id not in (select id tableidsfromdestination)

xml - Ignore child nodes in XSLT template using mode -

i'm transforming xml document html file online display (as electronic book). each chapter in xml file contained within <div> , has heading ( <head> ). need display each heading twice - once part of table of contents @ start, second time @ top of each chapter. i've used mode="toc" within <xsl:template> this. my problem few of <head> headings have child element <note> , contain editorial footnotes. need these <note> tags processed when headings appear @ top of chapters, don't want them show in table of contents (i.e. when mode="toc" . my question how tell stylesheet process <head> elements table of contents, ignore child elements (should occur)? here's example heading without note, displays fine in table of contents mode: <div xml:id="d1.c1" type="chapter"> <head>pursuit of pleasure. limits set virtue— asceticism vice</head> <p>contents of ch

javascript - Storing a big 2d map in memory efficiently -

i'm creating 2d tiled game pokemon-like i'm creating map editor create maps. game on web, map editor must web. don't know how store map in memory: thought use 2 dimensional array, map can bery big, leading massive memory usage/out of memory problem. how can store entire map in memory efficiently, without using browser memory? the standard seems not having entire map loaded in memory, current viewport or bounds referred in mapping world. you check bounds on map pan, scroll or zoom , fetch corresponding tiles.

backbone.js - How to set/initialize collection from it's model -

i'm trying build application on backbone.js uses html5 localstorage store , retrieve data. instead of retrieving data localstorage, method getlocalstoragedata on model return localstorage data. now problem here, i'm unable initialize/set collection model's method. any highly appreciated. thanks. router: (collection shared across 2 routes). var workspace = backbone.router.extend({ routes: { 'dashboard': 'dashboard', 'newsearch': 'newsearch' }, collection: new mmm.common.collection.studycollection(), dashboard: function () { $("#newsearch").css('display', 'none'); $("#dvdashboard").css('display', 'block'); activestudylistview = new mmm.dashboard.view.activestudylistview({ collection: this.collection }); }, newsearch: function () {

google app engine - In gae datastore, are all entities in a namespace are stored in same part of distributed network? -

referring gae docs: https://developers.google.com/appengine/docs/java/datastore/transactions it says: entity group relationships tell app engine store several entities in same part of distributed network. my questions: 1) hold true in case of namespaces? mean, in case of multitenant app, namespace each tenant dictates storage of entities belonging namespace @ same part in distributed network? 2) nice idea use entity group each tenant , namespace well? 1) no 2) not true. depends on goal , access pattern.

how can i use access pass through query to access sql sp -

i have store procedure has 4 paramater in sql, , want bulid applcation in access exec sp. i have access form has 4 text box type pass through paramater , 1 button click , has code these private sub command13_click() dim dbs dao.database dim qdf dao.querydef dim strsql string const c_strsql string = "exec sp_xcopy @curco={p1}, @curnumber={p2}, @newco={p3}, @newnumver={p4}" set dbs = currentdb set qdf = dbs.querydefs("querycopyvendor") strsql = replace(c_strsql, "{p1}", "forms!copyvendor!curco") strsql = replace(strsql, "{p2}", "forms!copyvendor!curnumber") strsql = replace(strsql, "{p3}", "forms!copyvendor!newco") strsql = replace(strsql, "{p4}", "forms!copyvendor!newnumber") qdf.sql = strsql qdf.execute set qdf = nothing set dbs = nothing end sub but when submit, fellowing error: run_time error '3065' cannot execute select query does