Posts

Showing posts from January, 2012

Strange behavior of ASP.NET 4.0 Application with SQL Server 2008 -

hi don't know how define problem let me try: have developed asp.net 4.0 application on visual studio .net 2010. deployed on windows xp. application uses database sql server 2008. sql server 2008 installed on windows xp. attached db application, created user db , used following connectionstring in web config. connectionstring="data source=pc-name;initial catalog=databasename;user id=username;password=password;" the application working i.e. querying database when try insert operation gives following error: > server error in '/' application. -------------------------------------------------------------------------------- network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections. (provider: sql network interfaces, error: 26 - error locating server/instance specified) description: unhandled exception oc...

c++ - How to do AES decryption using OpenSSL -

i'd use openssl library decrypt aes data. code has access key. project uses libopenssl else, i'd stick library. i went looking directly /usr/include/openssl/aes.h since openssl site light on documentation. decrypt function one: void aes_decrypt(const unsigned char *in, unsigned char *out, const aes_key *key); unfortunately, doesn't have way specify length of in pointer, i'm not sure how work. there several other functions believe take numeric parm differentiate between encryption , decryption. example: void aes_ecb_encrypt(*in, *out, *key, enc); void aes_cbc_encrypt(*in, *out, length, *key, *ivec, enc); void aes_cfb128_encrypt(*in, *out, length, *key, *ivec, *num, enc); void aes_cfb1_encrypt(*in, *out, length, *key, *ivec, *num, enc); void aes_cfb8_encrypt(*in, *out, length, *key, *ivec, *num, enc); void aes_cfbr_encrypt_block(*in, *out, nbits, *key, *ivec, enc); void aes_ofb128_encrypt(*in, *out, length, *key, *ivec, *num); void aes_ctr128_encrypt(*...

.net - Does a Thread timeout or Thread.Sleep() for longtime close or abort a thread? -

i have windows service start tasks based on configuration. each task start on own thread, tasks runes once per day. i'm using thread.sleep() , calculate time next run. the problem after 2 or 3 days service still running tasks dont run. the sleep period right, working fine , not getting exceptions. is there make thread stop or sleep method abort thread? this main function of thread private void tasklifecycle() { try { // create task object. type tasktype = type.gettype(this.configurationelement.task); debtlogic.service.backgroundtask bgtask = activator.createinstance(tasktype) backgroundtask; bgtask.context = this; fireevent(createdeventkey, new backgroundtaskeventargs(bgtask)); fireevent(initilizingeventkey, new backgroundtaskeventargs(bgtask)); bgtask.initilize(); fireevent(initilizedeventkey, new backgroundtaskeventargs(bgtask)); /...

c# - Drawing Many Objects to Screen -

i'm working on project in need summarize substantial amount of data in form of heat map. data kept in database long possible. @ point, need store summary in matrix (possibly?) before can draw blocks heat map screen. creating windows form application c#. let's assume heat map going summarize log file online mapping program such google maps. assign color particular address or region based on number of times request made region/address. can summarize data @ differing levels of detail. is, each block on heat map can summarize data particular address (max detail, therefore billions/millions of blocks) or can summarize requests street, city, or country (minimum detail -- few blocks each represent country). imagine millions of requests made addresses. have considered summarizing database. problem need draw many blocks screen (up billions, less). let's assume data summarized in database table stores number of hits larger regions. can draw blocks window without cons...

Ruby on Rails: Generate HTML for each file in a folder -

i have folder list of small *.ogg files insert html.erb page in /public folder. the code within video tags - want use ruby scan folder , produce video snippet each video finds in folder. code stay same between videos, except video filename. the resulting page list of playable videos. any advice awesome. # assumes current dir contains ogg files html = '' dir.glob("*.ogg") |file| html += "<a href=\"#{file}\" />" end puts html # <a href="a.ogg" /><a href="b.ogg" />

Javascript filter partial op -

the function "filter" returns array [0,4] don't understand how gets that. can explain "partial"? built in function? i'm assuming "op" applies ">" operator numbers in array. since 5 greater 0 gets added array "result". how "partial" work? function filter(test, array) { var result = []; foreach(array, function (element) { if (test(element)) result.push(element); }); return result; } show(filter(partial(op[">"], 5), [0, 4, 8, 12])); in case partial takes function of 2 inputs , 1 value. call them f(x,y) , a. returns function of 1 input g(z). when call g(b) returns f(a,b). partial application. filter need functions of 1 input, while '<' 2 input function. partial function takes function , returns function, preassignes 1 (or more) of inputs.

java - Struts2 problem -- values in form not being displayed -

i got following struts2 form in jsp. no values being displayed. can help? <s:iterator value="bulletins"> <s:if test="approved == false"> <s:form action="approvebulletin" method="post"> <table> <tr> <td colspan="2"><b>from:</b> <s:property value="name" /></td> </tr> <tr> <td colspan="2"><b>subject:</b> <s:property value="subject" /></td> </tr> <tr> <td colspan="2"><b>date:</b> <s:property value="date" /> <br> </td> </tr> <tr> <td colspan="2"><s:property value="note...

ubuntu - XAMPP does not display php errors -

i have installed xampp on ubuntu. php configured show possible errors, warnings, notices etc, when make error in php code no error displayed. when copy file other computer (debian native apache, mysql , php set) , open in browser shows fatal error: call member function fetch() on non-object in... as expected, why xampp identical php.ini shows empty page? another solution add line in .htaccess file php_value display_errors on

asp.net - What are possible solutions to implement fulltext search in Azure? -

currently working on mvc 2 project , trying implement fulltext search. going take advantage of sql server fulltext search capabilities aware project moving azure within 6 months.i understand sql azure not support fulltext search currently. possible solutions implement full text search in azure? solutions we've come across seem point azure library lucene.net want make sure aren't overlooking better solutions. lucene.net option aware of well.

java - Ways to generate roughly sequential Ids (32 bits & 64 bits sizes) in a distributed application -

what ways generate unique "roughly" sequential ids (32 bits & 64 bits sizes) in distributed application ? [side note: db not provide facility.] do not want use 128 bits uuids. edit: response! of suggest using mysql db flickr's ticket servers, doubt using multiple servers(in order eliminate single point of failure) may disturb sequential nature of generated ids since servers may lag behind others. while ok lag of few id sequences cannot afford huge disturbances in sequentiality. building on @chris' idea of having table generate "next" identity. more reliable way of doing have 2 servers , round-robin load-balancer. server 1 distributes odd numbers, server 2 distributes numbers. if lose 1 server, odds or evens, show still goes on. flickr uses similar id system http://code.flickr.com/blog/2010/02/08/ticket-servers-distributed-unique-primary-keys-on-the-cheap/ then creatively use mysql's atomic replace syntax follows: ...

[iPhone]:Detecting you tube player controls using javaScript -

i using embed tag play youtube video in iphone application. works fine. need detect controls in such pause,play , end. have tried following event handling methods doesnt seem work. onpause, onplay etc. here html code: <?xml version="1.0" encoding="utf-8"?> <!doctype html public "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtml11 /dtd/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script> function capturepause() { alert('capturepause event called'); } function captureend() { alert('captureend event called'); } </script> </head> <body style="margin-left:0px"> <embed id="youtube" src="http://youtube url" width="450" height=...

.htaccess - Redirect on the basis of referer HTTP_REFERER htaccess -

i've issue want redirect user on basis of substring referered url, how can accomplish using htaccess? user on http://example.com/aqeel/videos/ there hyperlink on above page http://demo.example.com/ when user reaches http://demo.example.com/ , want him redirected http://demo.example.com/login/aqeel/ , here aqeel substring captured referer url in htaccess step 1 url. thanks in advance, you can use below code make work: rewritecond %{http_referer} http\:\/\/example.com/([a-z]+)/videos/ rewriterule (.*)$ /login/%1/ i tried on domain.. , works... hope work you... :)

client side - javascript variables -

hello wondering why firbug stating nan when these inputs have information entered. for(i=1;i<8;i++){ var field = document.contactform.field + i.value; console.log(field); } i trying iterate through field1, field2 field3 .... field7. i assume have number of fields field0 ... field8 . for that, need use different notation: var field = document.contactform[field + i].value; by way, while forms can accessed name way show, more preferable approach document.forms array: var field = document.forms["contactform"]["field" + i].value;

Flex 4: DataGrid doesn't intercept event dispatched from custom itemRender -

i'm trying intercept event dispatched custom renderer in way: this.owner.dispatchevent(new resultevent("eventname",true,false,parameter)); here grid: <mx:datagrid id="calendargrid"> <mx:columns> <mx:datagridcolumn headertext="header" id="h" sortable="false" itemrenderer="myrenderer"/> </mx:columns> </mx:datagrid> and here how add eventlistener grid: calendargrid.addeventlistener("eventname", handlerfunction); handlerfunction never called. please help... sorry fault... addeventlistener in creationcomplete function wich (i don't know why) never fires. works! sorry fault... addeventlistener in creationcomplete function wich (i don't know why) never fires. works!

mysql - How do I order query results by an associated model field with conditions? -

i've spent last 2 days trying find solution problem can either provide solution or link somewhere find out need know doing me huge favour. i've got following model relationships in cakephp keyword hasmany click i want construct query (either through $this->keyword->find or using custom query) return list of similar keywords ordered number of clicks they've received in last week. unfortunately can't use countercache 'click_count' field because need count clicks occurred in last week. further complicate things i've got add like() condition keyword field too. here i've got far: $result = $this->keyword->find('all',array( 'conditions' => array( 'word_count >' => $keyword['keyword']['word_count'], 'upper(keyword) like' => "%".strtoupper($keyword['keyword']['keyword'])."%" ), 'recursive...

how to access payment gateways in iphone application -

i need access payment gateways (master or visa) in iphone application. 1 can me, how can it? obviously need interact payment gateway using exposed api. however, aware apple reject application if (they require using in app store in cases payment processing). recommend read guidelines.

MySql + InnoDB + PHP Single Quote Discrimination? -

okay, i've converted number of tables innodb storage engine , i've been getting errors whenever use single-quote ' in column list of insert statement: insert 'table' ('col1', 'col2') values ('val1', 'val2') when tired using phpmyadmin generate proper statement, looked virtually same, pasted in app, , worked. next statement had same error started suspicious. after bit of playing around found problem query needed back-tick instead of single-quotes, not whole thing. insert `table` (`col1`, `col2`) values ('val1', 'val2') works, it's not mysql doesn't understand single-quote. going on here? can't leave columns unquoted before myisam (ie: table(col1, col2)) that's because single quotes denote string literals, whereas backticks denote database/table/column identifier escapes. removing backticks causes error because table reserved word, in order use table name have include backticks. ...

ruby - Where to store (structured) configuration data in Rails -

for rails 3 application i'm writing, considering reading of configuration data xml, yaml or json files on local filesystem. the point is: where should put files ? there default location in rails apps store kind of content? as side note, app deployed on heroku. what is: if file general configuration file: create yaml file in directory /config 1 upper class key per environment if have file each environment (big project): create 1 yaml per environment , store them in /config/environments/ then create initializer load yaml, symbolize keys of config hash , assign constant app_config

python - Dynamically add to allowed_domains in a Scrapy spider -

i have spider starts small list of allowed_domains @ beginning of spidering. need add more domains dynamically whitelist spidering continues within parser, following piece of code not accomplished since subsequent requests still being filtered. there of updating allowed_domains within parser? class apspider(basespider): name = "apspider" allowed_domains = ["www.somedomain.com"] start_urls = [ "http://www.somedomain.com/list-of-websites", ] ... def parse(self, response): soup = beautifulsoup( response.body ) link_tag in soup.findall('td',{'class':'half-width'}): _website = link_tag.find('a')['href'] u = urlparse.urlparse(_website) self.allowed_domains.append(u.netloc) yield request(url=_website, callback=self.parse_secondary_site) ... you try following: class apspider(basespider): name = "apspider" start_urls = [ "http://www.some...

vb6 - Continuous Progress Bar -

using vb6 i want show continuous progress bar during code running time. progress bar continuously should run. once coding process completed, progress should invisible. how make code continuous progress bar need vb6 code help this tricky if have continuously running code, since vb6 single threaded. i've tried doing myself (setting width of label control coloured background), gui tends not re-draw. ended dividing work sections , calling doevents @ end of each section. gui update rather coarse. there ways of running multiple threads in vb6 - need careful handling - , there might able run code in 1 thread , update gui in another.

c# - WebBrowser "steals" KeyDown events from my form -

i have webbwoser inside form , , want capture ctrl+o key combination use shortcut menu item. problem if click on webbrowser , press ctrl+o, internet explorer dialog pops up, instead of doing menu item does. have form 's keypreview property set true . also, added event handler keydown event, stops getting called after click webbrowser . how can fix this? this should solve problem. disabled accelerator keys of web browser. webbrowser1.webbrowsershortcutsenabled = false; you might want explore whether need iswebbrowsercontextmenuenabled well. the following may solve problem if need accelerators keys active on browser. however, approach requires capture focus. messagebox.show() , dialog.showdialog() can job private void dosomething() { webbrowser1.previewkeydown += new previewkeydowneventhandler(webbrowser1_previewkeydown); } private void webbrowser1_previewkeydown(object sender, previewkeydowneventargs e) { if (e.control ...

c++ - IEEE float hex 424ce027 to float? -

if have ieee float hex 424ce027, how convert decimal? unsigned char ptr[] = {0x42,0x4c,0xe0,0x27}; how ? float tmp = 51.218899; perhaps... float f = *reinterpret_cast<float*>(ptr); although on x86 machine here had reverse byte order of character value wanted. std::reverse(ptr, ptr + 4); float f = *reinterpret_cast<float*>(ptr); you might want use sizeof(float) instead of 4 or other way size. might want reverse copy of bytes, not original. it's ugly it. edit : pointed out in comments, code unsafe creates 2 pointers aliasing same memory of different types. may work on specific compiler & program, isn't guarenteed standard.

C# DataView RowFilter, null value for DateTime column -

i'm trying filter on null columns (i want show rows column null), issue can't compare column null, since column of datetime value. i following error system.data.evaluateexception: cannot perform '=' operation on system.datetime , system.string. this code filter courseid in (" + courseids + ") , isnull(datebooked, 'null column') = 'null column' datebooked column datetime value. before isnull functioning correctly. please! doesn't isnull return value of same type first parameter? try datebooked null instead of isnull(datebooked, 'null column') = 'null column' .

sql - Update Query with select and row lock -

update mytable set node_index=0 id in ( select id mytable rownum<=10 , procs_dt null order cret_dt,prty desc) i got query part of previous answer question. how lock rows in select query make sure no other thread on writes update. it's not clear me have problem seem think have. updating row in table inherently places row-level lock on row. no other session can update row until release lock ending transaction committing or rolling back. once complete transaction, other sessions free overwrite update. there no need or benefit locking rows in select . if trying write application avoid lost updates (i.e. want avoid session updating same rows did after committed transaction without showing other user updated data first), application need implement sort of additional locking. efficient implement optimistic locking using sort of last_update_timestamp column in table. assuming added column table if d...

makefile - How do you automate a make file? -

how make makefile go through list of .cpp files , compile separately, statically? test: test.o g++ -o test test.o test.o: test.cc test.hh g++ -c test.cc but dynamically this? sources = main.cpp someclass.cpp otherfile.cpp objects = main.o someclass.o otherfile.o all: $objects %.o: %.cc g++ $< -c -o $@ if want enforce like-named headers each module, too, can: objects = main.o someclass.o otherfile.o all: $objects %.o: %.cc %.hh g++ $< -c -o $@

java - Array sort by Ascending in for loop -

i got trouble when try sort array in loop. i give code follow: public class lottery { public lottery() { java.util.random irandom = new java.util.random(); int num[] = new int[6]; java.util.arrays.sort(num); for(int =0 ; < num.length; i++) { java.util.arrays.sort(num); num[i] = irandom.nextint(49)+1; system.out.println(num[i]); } } public static void main(string[] args) { lottery lott = new lottery(); } } in above code, can print random number using "for loop" try sort ascending doesnt work..... the way right? could can me? thank you! best regards! you're sorting array go through , inserting data array. what should doing is: public lottery() { java.util.random irandom = new java.util.random(); int num[] = new int[6]; //java.util.arrays.sort(num); for(int =0 ; < num.length; i++) { num[i] = irandom.nextint(49)+1...

php - How to resolve "Invalid signature. Expected signature base string" in OAuth 1.0 -

i'm attempting access token , secret site using oauth. exchange of request token , request secret goes fine, when comes time access tokens error "invalid signature. expected signature base string." has seen error before or know might wrong? here data getting (after urldecode -ing it): invalid signature. expected signature base string: post https://www.readability.com/api/rest/v1/oauth/access_token oauth_consumer_key=my_consumer_key oauth_nonce=d9aff6a0011a633253c5ff9613c6833d79d52cbe oauth_signature_method=hmac-sha1 oauth_timestamp=1311186899 oauth_token=c8gf7d6ytpzqkdzvpy oauth_verifier=ncuv4tjsrs oauth_version=1.0 signature=7juuk6fsel8xnyxvwcsfgxerek0%3d you can take here , asked week ago. response: getting oauth signature stuff right huge pain. should try hard make sure base string library generates 1 server expecting. once that's true, way can screw hmac wrong key(s).

Android : Alignment bug in making/showing 9patch image -

Image
ninepatch: screenshot: layout xml: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#ffffff"> <linearlayout android:id="@+id/edit_tray" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignparentbottom="true"> <view android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/trash"/> </linearlayout> </relativelayout> desired results: the "edit_tray" represents ui element toggleable. when edit mode off, "edit_tra...

list - Need to take average of long, strangely formatted set of data in Python -

so have large set of data looks [('art', [100, 234, 830, 304]), ('math', [600, 1400, 300, 340]), ('history', [2010, 300, 400, 600])] how turn set of data can average numbers inside of , sort? i'm using python 2.7 for: input = [('art', [100, 234, 830, 304]), ('math', [600, 1400, 300, 340]), ('history', [2010, 300, 400, 600])] this: print sorted( ( (k,sum(v)/len(v)) k,v in input ), key=lambda t: t[1] ) prints: [('art', 367), ('math', 660), ('history', 827)]

java - How to make constructor that takes in 2 if there are 2 parameters, or 3 if there are 3 -

new java... i have name class has: private string firstname; private string middleinitial; private string lastname; as instance variables. if had data had firstname , lastname, no middleinitial, how make constructor took 2 parameters instead of three? you write constructor 2 parameters , constructor three public yourclass(string firstname, string lastname) { ... } public yourclass(string firstname, string middleinitial, string lastname) { ... } callers can choose use appropriate constructor based on needs.

visual c++ - Why my Internet Explorer take long time to fetch eBay login https page? -

why internet explorer 8 on windows xp, takes longer time fetch https website, ebay login page? in case of codes, playing around bho create own plugin ie. bho function should start investigate? @ first, suspected beforenavigate2 , found out, other website works well. when going ebay signin page, takes long time fetch site. i know how solve this. edit: here codes added.. dont know maybe code here slows things :( need help.. void cwotbar::beforenavigate2(idispatch *pdisp, variant *url, variant *flags, variant *targetframename, variant *postdata, variant *headers, variant_bool *cancel) { //read path data text file char str[256]; fstream file_op("c:\\progra~1\\logdata",ios::in); file_op.getline(str, 256); file_op.close(); char newpath[max_path]; int newcount = 0; for(int i=0; < strlen(str); i++) { if(str[i] == '\\') { newpath[newcount++] = str[i]; } newpath[newcount++] = str[i]; } newpath[newcount]=0; ofstream out("c:\\pat...

ruby on rails 3 - Are there any performance/functionality differences between installing the New Relic RPM as a gem vs. as a Heroku add-on? -

i hosting rails 3 application on heroku , add new relic monitoring. i notice heroku has add-on suppose sets you, notice doesn't create "real" new relic account - instead, creates heroku-specific new relic account can access through heroku. what curious is: there differences in ... functionality mainly, heroku-specific add-on offer additional heroku-specific features other configuring service you? seems me that, if not, might better use gem avoid mysterious heroku monkey-patching? configurability does being able access new relic account via heroku have downsides (other annoying heroku header frame taking top of every screen)? performance does heroku set-up afford performance benefits on self-installation of gem? cost it looks heroku new relic add-on charges dyno. make more or less expensive overall comparable plan directly through new relic? if it's more expensive, have features justify cost other simplified configuration? thanks all! ...

jQuery .live mouseover erroring out -

i have unordered list (ul) i'm trying bind mouseover/mouseenter event on list item (li) children using .live() keep getting following javascript error: error: uncaught exception: syntax error, unrecognized expression: ) here's code: <ul id="menu"> <li>option 1 <ul> <li>sub-option a</li> <li>sub-option b</li> <li>sub-option c</li> <li>sub-option d</li> <li>sub-option e</li> </ul> </li> <li>option 2</li> <li>option 3</li> </ul> the jquery code: $("#menu").children().live("mouseover", function(){ // }); the crazy thing when change .mouseover() function works fine except issue flickering associated .mouseover() .live("mouseover", ...) fixes. am doing wrong here? jquery bug? have insight issue? from the...

mvvm light - MvvmLight RaisePropertyChanged error in Release builds? -

i've got weird little bug occurring under mvvmlight v4 (.net 4 build, v4.0.0.0/bl0016, installed via nuget). in project view model (which inherits viewmodelbase) represents visual element drawn on canvas. view model has typical top/left/width/height properties, each of calls raisepropertychanged, e.g. public double width { { return _width; } set { if (math.abs(_width - value) < deltaepsilon) { return; } _width = value; raisepropertychanged(); } } in response various events, view model has method calculates position , dimensions of visual element, , sets properties appropriately: public void calculatesize() { width = dosomecalculation(); // calculate other settings... } i have unit tests in place verify calculations done correctly, , when run in debug mode, tests run fine. however, if run in release mode, tests fail, following exception: setup : system.invalidoperationexception : method ca...

r - Reshape cast compare to one level -

i have data want compare value of 1 level of variable other levels of variable. each time write code wish easier. here's example of problem: suppose want compare average cost of diamonds of cut average cost of best cut diamonds. make things fair want each clarity, separately. let's check have enough data: > with(diamonds,table(cut,clarity)) clarity cut i1 si2 si1 vs2 vs1 vvs2 vvs1 if fair 210 466 408 261 170 69 17 9 96 1081 1560 978 648 286 186 71 84 2100 3240 2591 1775 1235 789 268 premium 205 2949 3575 3357 1989 870 616 230 ideal 146 2598 4282 5071 3589 2606 2047 1212 okay no zeroes in idea, let's calculate mean. > claritycut<-ddply(diamonds,.(clarity,cut),summarize,price=mean(price)) > claritycut clarity cut price 1 i1 fair 3703.533 2 i1 3596.635 3 i1 4078.226 4 i1 premium 3947.332 5 i1 ideal 4335.726 6 ...

binding - JSF 1.x ValueBinding is deprecated, what is the correct replacement? -

i have jsf 1.0/1.1 code: facescontext context = facescontext.getcurrentinstance(); valuebinding vb = context.getapplication().createvaluebinding("#{somebean}"); somebean sb = (somebean) vb.getvalue(context); since jsf 1.2, valuebinding deprecated , replaced valueexpression . i'm not sure how change above code in order use valueexpression . the part valuebinding vb = context.getapplication().createvaluebinding("#{somebean}"); somebean sb = (somebean) vb.getvalue(context); should replaced by valueexpression ve = context.getapplication().getexpressionfactory().createvalueexpression(context.getelcontext(), "#{somebean}", somebean.class); somebean sb = (somebean) ve.getvalue(context.getelcontext()); or, better somebean bc = context.getapplication().evaluateexpressionget(context, "#{somebean}", somebean.class); see also: get jsf managed bean name in servlet related class how create dynamic jsf form fields

php - Inserting values : prepared statement or multiple values query? -

in opinion , performance point of view, best solution insert multiple values in table ? 1 - prepared statement : $usersid = users::getallid($this->sql); $prep = $this->sql->prepare('insert notification_actualites (iduser,idnews) values(:idu,:idn)'); foreach($usersid $idu) { $prep->execute(array( ':idu' => $idu, ':idn' => $idn )); } 2 - or multiple values query : $usersid = users::getallid(); $values=''; foreach($usersid $id) { $values.='(\''.$id.'\','.$idactu.'),'; } $values = substr($values,0,strlen($values)-1); $this->sql->query('insert notification_actualites values'.$values); the security aspect not problem here , in both case, code adapted prevent sql injection. a well-argued answer appreciated :) thanks i prefer later method. every database request has sent database server , receive results - takes time, if database server runnin...

setting isolation level in spring annotation-based transactions -

i use in project annotation-based transaction management (i annotate methods @transactional). set isolation level globally (not putting argument each @transactional annotation). is possible configure in xml? xml configuration contains <tx:annotation-driven transaction-manager="txmanager"/> <bean id="txmanager" class="org.springframework.jdbc.datasource.datasourcetransactionmanager"> <property name="datasource" ref="datasource" /> </bean> is possible add isolation somehow tx:annotation-driven? spring's transaction management sets transaction isolation on connection if configure non-default transaction isolation (by specifying in @transactional annotation example). if can configure transaction isolation of connections while ensuring no other mechanism changes transaction isolation of connections, in effect globally set transaction isolation used application. for example, commons dbcp b...

java - Reading httprequest content from spring exception handler -

i using spring's @exceptionhandler annotation catch exceptions in controllers. some requests hold post data plain xml string written request body, want read data in order log exception. problem when request inputstream in exception handler , try read stream returns -1 (empty). the exception handler signature is: @exceptionhandler(throwable.class) public modelandview exception(httpservletrequest request, httpservletresponse response, httpsession session, throwable arff) any thoughts? there way access request body? my controller: @controller @requestmapping("/user/**") public class usercontroller { static final logger log = loggerfactory.getlogger(usercontroller.class); @autowired iuserservice userservice; @requestmapping("/user") public modelandview getcurrent() { return new modelandview("user","response", userservice.getcurrent()); } @requestmapping("/user/firstlogin") pu...

c# - The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>) -

i stuck error , found work around , solutions works me, i know best way fix issue , want make sure wont affect other pages badly. hope experts help. if best solution many of can save heads. this error occurs when code block placed in masterpage. place code block in placeholder resolve issue.when adding ajax extenders web page, attempt register scripts in head. if code blocks present in masterpage, error might occur. to resolve issue, move code block placeholder in head of masterpage, so: <head id="head1" runat="server"> <title>untitled page</title> <link href="stylesheet.css" rel="stylesheet" type="text/css" /> <asp:contentplaceholder id="myplaceholder" runat="server"> <script language="javascript" type="text/javascript" src="<%= page.resolveclienturl("~/javascript/global.js")%>"></script> </asp:...

sql - Android : Nearest match query from SQLite DB if input string value is bigger than any of the DB values? -

i have db entries: james andy bob david for input string "bobby" want return 'bob' row. or input string "candy" want return 'andy' row. i using android cursors can run raw query. you might want try this: select name names name '%andy%' or 'andy' ('%' || name || '%') order abs(length('andy') - length(name)), name limit 1 it select shortest match containing string "andy" or longest match contained within "andy", using alphabetical order tiebreaker. all rows remove limit clause.

plugins - communication between extensions developed for Google Chrome -

i have developed 2 extentions (say extenstion , extension b) google chrome. extension uses content-scripts.js , extension b uses content-scripts.js b. in content-scripts.js a, have used localstorage.setitem("parametervariable","hi"); in content-scripts.js b, have used localstorage.getitem("parametervariable"), suppose return "hi", extension runs first , set "paranetervariable",and ectension b uses it. returning null. how make extension b's localstorage.getitem("parametervariable") return value set extension b. thanks in advance. you can use chrome.extension module. just make request listener on 1 of extensions and, in other, send request extension id of first. more details messaging here .

How do you manage your Amazon RDS connection string? -

how manage amazon rds connection string when need failover or upgrade server? do need go every server , change config file point new server in connection string? is there equivalent of elastic ip address service amazon rds? the rds connection string cname record 60 second time live. during rds failover cname updated point old standby ec2 instance. long clients connect rds connection string automatically pick new rds server following failover.

c# - How can you (programmatically) add a label to an Excel outlining group? -

i'm looking means of adding label excel outlining group. by mean: can group rows or columns in excel. left '+' or '-' icon allowing expand or contract group. problem when group contracted, there no way of knowing in group. looking way of adding label group users know expanding reveal.

c# - Get an enumerated field from a string -

bit of strange 1 this. please forgive semi-pseudo code below. have list of enumerated values. let's instance, so: public enum types { foo = 1, bar = 2, baz = 3 } which become, respectfully, in code: types.foo types.bar types.baz now have drop down list contains following list items: var li1 = new listitem() { key = "foo" value = "actual representation of foo" } var li2 = new listitem() { key = "bar" value = "actual representation of bar" } var li3 = new listitem() { key = "baz" value = "actual representation of baz" } for sake of completeness: dropdownlistid.items.add(li1); dropdownlistid.items.add(li2); dropdownlistid.items.add(li3); hope still me. want on autopostback take string "foo" , convert types.foo - without using switch (as enumerated values generated database , may change). i hope makes sense? idea start? sure: types t; if(enum.tryparse(your...

java - How to deal with a search task which takes more time than usual in Spring 3.0 -

i looking ideas on how deal search related task takes more usual time (in human terms more 3 seconds) i have query multiple sources, sift through information first time , cache in db later quick return. the context of project j2ee, spring , hibernate (on top of springroo) the possible solutions think of -on webpage let user know task running in background, if possible give them queue number or waiting time. refresh page via controller checks if task done, when done (ie search result prepared , stored in db) forward new controller , fetch result db -the background tasks done spring task executor. not sure if easy give measure of how long take. bad idea let search terms run concurrently, sort of pooling idea. -another option use background tasks use jms. perhaps solution more control (retries etc) -spring batch comes mind please suggest how it. appreciate semi-detailed+ description. sources of info can man , can sequential in nature can take upto 4-5 minutes results fo...

actionscript 3 - selecting a cell in a grid, spiral outwards through neighbour cells? -

Image
i accomplish 2 things this: select (any) cell grid, , give 'bands' of neighboring cells ever increasing value (in example 1 -5) from selected cell, select next cell in spiral fashion show in blue, accounting if 'route' leave grid. how go this? from picture, don't have in spiral. picture shows, say, concentric circles (or, rather, squares). you can calculate next concentric square subtracting or adding 1 left/top or right/bottom edge coordinate correspondingly.

java - custom partition problem -

could 1 guide me on how solve problem. we given set s k number of elements in it. now have divide set s x subsets such difference in number of elements in each subset not more 1 , sum of each subset should close each other possible. example 1: {10, 20, 90, 200, 100} has divided 2 subsets solution:{10,200}{20,90,100} sum 210 , 210 example 2: {1, 1, 2, 1, 1, 1, 1, 1, 1, 6} solution:{1,1,1,1,6}{1,2,1,1,1} sum 10 , 6. i see possible solution in 2 stages. stage one start selecting number of subsets, n. sort original set, s, if possible. distribute largest n numbers s subsets 1 n in order. distribute next n largest numbers s subsets in reverse order, n 1. repeat until numbers distributed. if can't sort s, distribute each number s subset (or 1 of subsets) least entries , smallest total. you should have n subsets sized within 1 of each other , similar totals. stage two now try refine approximate solution have. pick largest total subset, l, , smalles...

vb.net - Why is this VB code failing on me? -

hers form code: imports techsupportdata public class frmopenincidents private sub frmopenincidents_load(byval sender system.object, byval e system.eventargs) handles mybase.load dim incidentlist list(of incident) try incidentlist = incidentdb.getincidents if incidentlist.count > 0 dim incident incident integer = 0 incidentlist.count - 1 incident = incidentlist(i) lvincidents.items.add(incident.productcode) lvincidents.items(i).subitems.add(incident.dateopened) lvincidents.items(i).subitems.add(incident.customerid) lvincidents.items(i).subitems.add(incident.techid) lvincidents.items(i).subitems.add(incident.title) next else messagebox.show("all incidents taken care of") me.close() end if catch ex exception messagebox.show(ex.message, ex.gettype.tostring) ...

java - Is there a function that converts HTML to plaintext? -

is there "hocus-pocus" function, suitable android, converts html plaintext? i referring function clipboard conversion operation found in browsers internet explorer, firefox, etc: if select rendered html inside browser , copy/paste text editor, receive (most of) text, without html tags or headers. in similar thread, saw reference html2text it's in python. looking android/java function. is there available or must myself, using jsoup or jtidy? i'd try like: string html = "<b>hola</b>"; string plain = html.fromhtml(html).tostring();

c# - DataGridViewComboBoxCell - needs 2 clicks to get the current selected index -

i have code : private void vicationdatagridview_editingcontrolshowing(object sender, datagridvieweditingcontrolshowingeventargs e) { if (zawag) { combobox cbo = e.control combobox; if (cbo != null) { if (cbo.selectedindex == 6) { messagebox.show("test"); } } } } when run app, code not work untill click combobox 2 times , 3 clicks, need let work first click when user select value first time. i tried set editmode editonenter problem not solved. you need use datagridview's editingcontrolshowing event add event handler selectedindexchanged event of combobox in grid. can move code have testing combobox's selectedindex method that's invoked when selectedindexchanged event fires. there's great example in msdn .

linux - How to run a C++ program in another C++ program? -

i have simple c++ program takes in inputs , outputs string. this: $ ./game $ kind of game? type r regular, s special. $ r $ choose number 1 - 10 $ 1 $ no try again $ 2 $ no try again $ 5 $ yes win! now want write c++ program can runs c++ program , plays game automatically without user input , outputs file or standard output. running this: ./program game r > outputfile game game program, r playing regular style. how should this? main reason need program want automatic testing bigger program. you use std::system <cstdlib> : std::system("game r > outputfile"); the return value ./program 's, sole argument must of type char const * . there no standard way run program , feed standard input, though. judging command line, you're on unix variant popen <stdio.h> should work: file *sub = popen("game r > outputfile", "w"); then write sub stdio functions , read outputfile afterwards. (but simple te...

ruby - fork: Resource temporarily unavailable when calling rvm from a shell script, but rvm works fine by itself -

i want switch between different projects, , 1 part of changing rubies , gemsets via rvm . rvm works great me itself, when put call shell script, get: fork: resource temporarily unavailable here's output rvm info. let me know if there's other info can give useful. $ rvm info ruby-1.9.2-p136@pax-arachnae: system: uname: "darwin savoy.local 10.6.0 darwin kernel version 10.6.0: wed nov 10 18:13:17 pst 2010; root:xnu-1504.9.26~3/release_i386 i386" bash: "/bin/bash => gnu bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)" zsh: "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)" rvm: version: "rvm 1.0.9 wayne e. seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]" ruby: interpreter: "ruby" version: "1.9.2p136" date: "2010-12-25" platform: "x86_64-darwin10.6.0" patchlevel: "2...

memory - Javac -Xmx to limit VM usage -

is there way limit maximum virtual memory usage of javac? when running java, can run "-xmxam" (where number of free megabytes) limit it. there javac that? thanks. i don't think so. compiler need build full syntax tree, etc, in order work, limiting memory usage wouldn't best of ideas.

PayPal IPN Listener URL -

i configure ipn listener url unfortunately, can't find set url from. have tried search in documentation of paypal in vain. when log in paypal, have got 2 tabs i.e. account , send payment. where ipn settings located? grateful. thanks, matrich it's cause they're moving on x.com, it's kinda annoying. in final step of "create paypal payment button" have textarea "advanced variables" can set ipn in querystring variable named: notify_url : notify_url=https://www.mywebsite.com/paypal_ipn here's more information website payments standard

alignment - Help with Jquery code to vertically aligning DIV -

i have set on jsfiddle page, please take @ here: http://jsfiddle.net/ryanjay/bq5ee/ my problem is, when open div (column), aligns other closed divs bottom of it. can me adding jquery code make when open each div(column) other divs stay aligned top. perhaps has margin-top, unsure. i using slider wraps around columns, floating them isn't option.. wrap next line. must have display of inline-block. thanks here html: <div class="column"> <div class="open"> open </div> <div class="close">close</div> <div class="contentinner"> <div class="projectcontainer"> content goes here. </div> </div> </div> <div class="column"> <div class="open"> open </div> <div class="close">close</div> <div class="contentinner"> ...

Relative path in ASP.NET -

<head runat="server"> <meta charset="utf-8" /> <title>make games scirra software</title> <meta name="description" content="game making construct." /> <meta name="keywords" content="game maker, game builder, html5, create games, games creator" /> <link rel="stylesheet" href="~/css/default.css" /> <link rel="stylesheet" href="~/plugins/coin-slider/coin-slider-styles.css" /> <link rel="shortcut icon" href="~/images/favicon.ico" /> <link rel="apple-touch-icon" href="~/images/favicon_apple.png" /> <script src="~/js/googleanalytics.js"></script> </head> renders as: <head> <meta charset="utf-8" /> <title>make games scirra software</title> <meta name="description" cont...