Posts

Showing posts from April, 2013

javascript - Node.js TCP server incoming buffer -

i have 2 node processes speak each other. call them [node server] , [node sender] . [node sender] continually processes information , writes message on tcp connection [node server] . [node server] writes status message. example of [node sender]: var message = "test message"; [node sender].connection.write(message); example of [node server]: [node server].socket.on("data", function(p_data) { this.write("ok"); // work p_data } this works without issue, p_data contains "test message" when sent @ above 5 milliseconds. however, if speed [node sender] write every millisecond, p_data ends "test messagetest messagetes" . i understand buffer in [node sender] filling faster write command sending it. there way force one-to-one ratio in sending messages while still remaining asynchronous? i can add terminator message , fill buffer in [node server] , wanted make sure there wasn't obvious missing.

c# - String formatting using LINQ2SQL -

i have textbox (which shows notes). user selects his/her name , add note. want show note in right hand side of page can review his/her , past notes. table contains these items: memo datecreated user this code here: var showmemo = r in em.entitymemovs_1s r.entityid == getentity select r.memo; var showuser = r in em.entitymemovs_1s r.entityid == getentity select r.user; tbshownote.text = string.join(environment.newline, showmemo); tbshownote.text += string.join(environment.newline, showuser); this showing me notes in fashion: test1 test2 test3 user1 user2 user3 i dont want way...i want this: 5/5/2011: first note. -user1 5/6/2011: second note. -user2 how should achieve this? thanks! well, if want inline, do: var notes = r in em.entitymemovs_1s r.entityid == getentity select r.createddate.toshortdat

php - copying data from multiple table and insert into one? -

i copy data multiple table , insert 1 table in same database. how can same php , mysql? to general question, example insert query: insert table3(col1, col2, col3, col4) select t1.col1, t1.col2, t2.col1, t2.col2 table1 t1, table2 t2 t1.idcolumn = t2.colid

Merging two very divergent branches using git? -

i have master branch , verydifferentbranch these had same ancestor ... 300 commits ago. verydifferentbranch feature complete i'd put under master branch . doing rebase results in every single patch having lot of merge conflicts, point large project unto go through conflicts. i have no idea except force pushing head of verydifferentbranch master branch. i'd losing history doing this, , that's not want do. what other options? it sounds history looks this: ...---o---a---o---...---o---o---b master \ o---o---...---o---c verydifferentbranch you worried losing history if force push verydifferentbranch master . such operation throwing away after a , b . you can preserve history merging it, or dropping tag @ abandoned branch tip , leaving unmerged. use merge a merge allow keep both sides of history: ...---o---a---o---...---o---o---b \ \ o---o---...---o---c---m master the ki

Ruby on Rails UI Layer - managing divs -

i have ruby web application , want structure ui layer have few templates made of number of various divs - header, footer, , other things repeat throughout pages. what wondering is: 1) within ruby on rails directory structure, should these divs live? somewhere under app/views/layouts ? 2) syntax import div in order still preserve values of variables set in controllers? thanks! you referring "partials" http://guides.rubyonrails.org/layouts_and_rendering.html (section 3.4) specifically, @ locals option. layouts in 'views' can change exist. views/layouts work fine.

python - Problem with form in Django -

i'm trying implement form let user change password. here code: forms.py class changepasswordform(forms.form): password1 = forms.charfield(widget = forms.passwordinput(), required = true) password2 = forms.charfield(widget = forms.passwordinput(), required = true) def clean_password2(self): password1 = self.cleaned_data.get("password1", "") password2 = self.cleaned_data["password2"] if password1 != password2: raise forms.validationerror("the 2 password fields didn't match.") return password2 def save(self, *args, **kw): self.user.set_password(self.cleaned_data['password1']) print "pass setted." self.user.save() views.py def change_password(request): form = changepasswordform() if request.method == 'post': form = changepasswordform(request.post, instance = request.user) if form.is_valid():

c# - Update web.config file in asp.net -

i working on web application sits on server , connects various client machines based on ipaddress.i have change ipaddress every time in web.config file in order connect particular client machine. i want put text box can enter ipaddress , updates web.config file based on button click should connect respective client machine. is possible way or thinking wrong way ? can 1 guide me in right path ? it sounds me thinking backwards. if application dependent on inputting ip address every time, why store in web.config? why not build application part of process connect machine? run application page, request ip input, utilize input connect targeted machine. the config file meant changing settings , other application configuration data. value needed on per use basis, request on per use basis.

Can php get value from another page's url? -

i want use jquery make page partly refresh. page b loaded in page a. , page b has mysql search gets values depending on url rule. possible php value page's url? thanks. page a: <script type="text/javascript"> jquery(document).ready(function(){ $('#pagecontent').load('b.php'); }); </script> <div id="pagecontent"></div> page b: <script language="javascript"> function pagination(page) { window.location = "a.php?more="+document.form.more.value; } </script> <form name="form" action="a.php" method="get"> <input type="text" name="more" value="<? echo $_get['more'];?>"> <input type="submit" value="search"> </form> maybe can try this: <script type="text/javascript"> jquery(document).ready(function(){

c# - How to make a dropdown list of all cultures (but no repeats) -

i'm trying make 2 dropdown lists. the top 1 offers cultures, (but no repeats). example: english, spanish, filipino after selecting top list bottom list show specific types. i right use code top list. foreach (cultureinfo cultureinfo in cultureinfo.getcultures(culturetypes.neutralcultures)) however not show filipino (philippines) i'd rather not use getcultures(culturetypes.allcultures)) because shows many @ once. it seems may need load neutralcultures ilist. iterate through allcultures make sure it's threeletterisolanguagename in list, if not add it. there best practice this? thanks look @ reference different culturetypes values. tells included each. i guess want that's in specific cultures? either combine non-specific cultures set or cultures , exclude specific ones. second approach easiest express in linq: var cultures = cultureinfo.getcultures(culturetypes.allcultures) .except(cultureinfo.getcultures(cult

java - How to put an image in the background of a window -

i'm done hangman java code. want add picture in background though.(nightsky.png) how do in paint graphics method? created imageicon in beginning. public hangmanrevised() { setsize(600,400); setlocationrelativeto(null); setdefaultcloseoperation(exit_on_close); setlayout(new flowlayout()); imageicon background = new imageicon("nightsky.png"); letter = new textfield(); jlabel label = new jlabel("pick letter"); button = new button("enter"); add(label); add(button); add(letter); button.addactionlistener(this); creategame(); } public void paint(graphics g) { super.paint(g); g.drawimage(background, 0, 156, color.green, button); } if painting image @ actual size, there no need custom painting. as has been suggested add icon jlabel , add label frame (or panel). if want image appear @ certion position within label, add emptyborder label.

wpf - How to find the thumb of a slider to set its width -

i creating "range slider" 3 slider controls stacked on top of each other. basic idea here uses 2 sliders. http://www.thejoyofcode.com/creating_a_range_slider_in_wpf_and_other_cool_tips_and_tricks_for_usercontrols_.aspx i'm adding third slider thumb fill space between the thumbs other slider. user able drag center thumb move 2 ends , maintain constant spacing between 2 ends. the xaml 3 sliders. secret getting layer nicely in using control template (not reprodiced here. can find @ above url). <grid verticalalignment="top"> <border borderthickness="0,1,0,0" borderbrush="green" verticalalignment="center" height="1" margin="5,0,5,0"/> <slider x:name="lowerslider" minimum="{binding elementname=root, path=minimum}" maximum="{binding elementname=root, path=maximum}" value="{binding elementname=root, pat

iphone python or perl processor, or similar -

i have application develop problem is must download part of behavior list of instructions server. ideally download scripting code , execute it. question if there libraries make it? example, have python script , want to execute on device... any options? thank you lua popular games. can embed python, too. apple won't enforce "objective-c only" clause unless make obvious use python script behavior. think games on store scripted in objective-c? no way. don't make transgressions obvious , you'll fine.

Change value of control on a form from class (C#) -

this should quite simple - not sure problem is. i have c# class (public.cs) , windows form (form1.cs). through function in public.cs, want value of control on form1 (without having use object parameters). // code appears in public.cs public string myfunction(int num_val) { if (chk_num.checked == true) { // here... } } the issue class cannot find control on form. there way must reference in c#? thank you. i suggest exposing checked property via specific property on form1 (perhaps more meaningful name). hide implementation details (i.e. control structure) of form1 it's caller , instead expose logic required other consumers job for example: public bool isnumberrequested { { return chk_num.checked; } } or alternatively, if still want access control directly, designer can select control , change it's modifier property public (or else) enabling access control object using code wrote above. edit: (response based on comment) public.cs st

parsing - Trying to write a c# program that parses a text file that contains data seperated by headers in square brackets -

im writting program parses specific text file has data in im going prcess later. each part seperated header in square brackets wondering how put each segment array using header name array. below example of begining of text file. ive set form lets choose file want process , ive set way of processing line line using objreader.readline in loop [params] version=106 monitor=34 smode=111111100 date=20090725 starttime=13:56:44.0 length=00:24:30.5 interval=1 upper1=0 lower1=0 upper2=0 lower2=0 upper3=0 lower3=0 timer1=00:00:00.0 timer2=00:00:00.0 timer3=00:00:00.0 activelimit=0 maxhr=180 resthr=70 startdelay=0 vo2max=51 weight=0 [note] tt warm [inttimes] 00:24:30.5 140 83 154 174 0 0 0 41 112 33 0 0 0 0 0 0 12080 0 280 0 0 0 0 0 0 0 0 [intnotes] [extradata] [summary-123] 1470 0 1470 0 0 0 180 0 0 70 1470 0 1470 0 0 0 180 0 0 70 0 0 0 0 0 0 180 0 0 70 0 1470 [summary-th] 1470 0 1470 0 0

flex4 - Spring 3, Flex 4 Integration with SpringFlex 1.5.0.M2 api + configuration -

we working on project using spring 3 create web platform , using flex 4 create specific client side application. currently, need integrate spring project flex. we using spring-flex integration library version: 1.5.0.m2 i checked older questions integration configurations defined @ entries previous versions of blazeds , spring. , understad, there may differencies. can tell me how configuration in web.xml , other xml files needed,and how folder structures be. up-to-date tutorial links appreciated. our business requirements are: two servlets should exist: 1) projectservlet has mappings / .html 2) flexservlet has mappings /messagebroker/ our service classes can used in flex side like: package com.ecognitio.service; import org.springframework.flex.remoting.remotingdestination; import org.springframework.flex.remoting.remotinginclude; import org.springframework.stereotype.service; @service @remotingdestination public class foo { @remoti

installer - Innosetup - are user CreateInputOptionPage "wizard" pages shown when /silent, etc is specified? -

innosetup setup executables have command line options permit unattended or batch file operation - i.e. possible have command-line parameters /silent, /verysilent, such no "wizard" pages displayed. if add own wizard pages using createinputoptionpage these still display, i.e. need add further command-line options suppress these (and provide default responses) well? (yes, could try myself, answer useful others, , there might further issues haven't thought of) when run /silent or /verysilent dialogs create such createinputoptionpage not shown. initializewizard() still called , forms still created. so values read these wizard pages default values. you can have specific behavior in pascal script when silent using wizardsilent() function. you can check parameters sent install in pascal script using paramcount , paramstr functions or can whole string using getcmdtail .

database - How do I update two models with one form in Ruby on Rails? -

i have 2 models, page , pagecontent. class page < activerecord::base has_many :page_contents end class pagecontent < activerecord::base belongs_to :page end page has :css_design attribute, want able edit attribute pagecontent form. ideas? i see lot of accepts_nested_attributes , fields_for advice, don't work , because seem forms either a. creating entire new instances of different model form (for example, creating tasks project form), or b. updating associated records thru parent. i want opposite- want update parent's record thru associated records. any appreciated! many in advance! --mark update i have added following pagecontent model: def css_design page ? page.css_design : nil end def css_design= (val) if page page.update_attribute 'css_design', val else @css_design = val end end after_create :set_page_css_design_on_create def set_page_css_design_on_create self.css_design = @css_design

How to use different resources in android app based on user settings? -

i working on application asks user specific settings @ start. example, first activity asks user: use option? -option a -option b now, after user selects option he/she use able change resources app uses. talking values/strings.xml have different strings different options of application. for now, using option default 1 , put strings in default strings.xml file , option b shares same strings, expecting option b need few specific strings need define in file, cannot figure out way decide best approach this? thanks in advance edit: answer jkhouw1's question, option b change existing strings. if use string arrays resources, how able specify in layout.xml file , configured user chose on first activity? - translate in example: if have textview want define text in layout.xml <textview android:text="@string/(key)" /> if use string arrays not common strings, how define android:text attribute view in layout.xml file depending on option user selects? th

javascript : function and object...? -

can call function object? example: function tip(txt){ this.content = txt; this.shown = false; } and: var tip = new tip(elem.attr('title')); my questions: can call new function, object? the use of "this" made possible, because use function object? you looking constructor concept. all functions in javascript are objects , can used create objects: function make_person(firstname, lastname, age) { person = {}; person.firstname = firstname; person.lastname = lastname; person.age = age; return person; } make_person("joe", "smith", 23); // {firstname: "joe", lastname: "smith", age: 23} however, in order create new objects of particular type (that say, inherit prototype, have constructor, etc), function can reference this , if called new operator return object of attributes defined on this in function - this in such cases references new object creating. fu

c# - Finding all properties and subproperties of an object -

Image
sometimes want know if object has property looking object has lot of properties , may take time find debugging it. nice if write function find properties , values in a string can paste string in notepad instance , value looking find feature notepad has. far have this: public void getallpropertiesandsubproperties(system.reflection.propertyinfo[] properties) { foreach (var in properties) { //messagebox.show(a.tostring()); // here test if property 1 // looking system.reflection.propertyinfo[] temp = a.gettype().getproperties(); // if property has properties call function again if (temp.length > 0) getallpropertiesandsubproperties(temp); } } editing question have worked: so far have added following code. can pass whatever object want following method , can see properties. having trouble viewing values of properties ![public void

html - JavaScript: How to redirect a page after validation -

i want redirect page after validation. have ff. example: form.html: <form method="post" action="" enctype="multipart/form-data" onsubmit="return checkform(this);"> <p><span style="width:180px">username: </span><input type="text" name="username" id='un'></p> <p><span style="width:180px">password: </span><input type="password" name="password" id='pw'></p> <input type="submit" value="submit" /> </form> script: <script type='text/javascript'> function checkform(){ if(document.getelementbyid("un").value == 'jayem30' && document.getelementbyid("pw").value == 'jayem' ){ alert("login successful"); window.location = "http://www.google.com/" }else{ alert("acces

oauth 2.0 - Need help trying to understand the OAuth2 Spec -

the bearer token spec 1 have question about. i'm trying figure out characters allowed in token when placed in authorization: oauth ...... header. here's spec says credentials = "oauth2" rws access-token [ rws 1#auth-param ] access-token = 1*( quoted-char / <"> ) quoted-char = "!" / "#" / "$" / "%" / "&" / "'" / "(" / ")" / "*" / "+" / "-" / "." / "/" / digit / ":" / "<" / "=" / ">" / "?" / "@" / alpha / "[" / "]" / "^" / "_" / "`" / "{" / "|" / "}" / "~" / "\" / "," / ";" i'm not sure how read this. i'm new

amazon s3 - S3 storage fails with fog 0.7.2 + carrierwave master branch -

when trying store file following: typeerror: can't convert nil string /users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/core/hmac.rb:23:in `digest' /users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/core/hmac.rb:23:in `block in setup_sha1' /users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/core/hmac.rb:15:in `call' /users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/core/hmac.rb:15:in `sign' /users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/storage/aws.rb:309:in `signature' /users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/storage/aws.rb:317:in `request' /users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/storage/requests/aws/put_object.rb:43:in `put_object' /users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/storage/models/aws/file.rb:119:in `save' /users/nick/.rvm/gems/ruby-1.9.2-p180/gems/fog-0.7.2/lib/fog/core/collection.rb:50

Insert the xml file data into a database using java? -

i wanted insert data xml file database java. includes creating table, followed inserting data in xml file. i'm not going supply code it, give direction: there 2 parts task: parsing xml - can done 1 of many xml parsers java. refer this question . communicating database - can done using jdbc , has nice tutorial here , another 1 here .

java - How can I optimize search on array of String array? -

i have string arrays of arrays. list<string[]> mainlist = new arraylist<string[]>(); string[] row1 = {"foo", "bar", "moo"} string[] row2 = {"cocoa", "zoo", "milk", "coffee"} mainlist.add(row1); mainlist.add(row2); let's want find element "milk". i n^2. for(int i=0, j=mainlist.size(); i<j; i++) { for(int x=0, y=mainlist.get(i).length(); x<y; x++) { string item = mainlist.get(i)[x]; if(item.equals("milk")) { return true; //found milk } } } i tried make faster putting elements map key. //put elements map key map m = new hashmap<string, string>(); for(int i=0, j=mainlist.size(); i<j; i++) { for(int x=0, y=mainlist.get(i).length(); x<y; x++) { m.put(mainlist.get(i)[x], "whatever"); } } //now iterate , see if key "milk" found if(m.contains("milk")) { return true

tabs - Create custom TabItem in WPF -

i want create custom tabitem in project treeview , stackpanel inside tab item. new wpf. please suggest me how can done. regards. <tabcontrol> <tabitem> <dockpanel> <treeview/> <stackpanel /> </dockpanel> </tabitem> </tabcontrol>

IN Clause in SQL Query -

i had 1 sql query: select name category_language category_id in (11, 22) , language_id=1 in query: 11 -> aa 22 -> bb i want records returned this: aa bb while running query returns: bb aa kindly, let me know further elaborate question. here new: select name category_language category_id in (11, 22) , language_id=1 order field(category_id, 11, 22) this catered mysql. make sure ids in same order in field() function in in() function.

rounding - MS Excel scientific notation (example: 2.231321654E+01) -

i editing legacy visual basic 6.0 program. reads gpib instrument , obtains raw string in scientific notation. example: 2.231321654e+01 another line in program processes string suitable input spreadsheet: round(2.231321654e+01, 1) returns 22.3 i want have 2 decimal places: round(2.231321654e+01, 2) should return 22.31 , no, returns 22.3 . why? another approach: tried bypass round() processing , have program input raw string directly spreadsheet. still 22.3 yet approach: bypassed program entirely , manually input 2.231321654e+01 cell in spreadsheet. still 22.3 summary: want write 2 decimal places spreadsheet. how do it? think original author manipulated cell number properties retain 1 decimal place. how manipulate it? should in code? it's like mycell.numberformat = "#.00"

iphone - How to determine if phone number has changed? -

currently developing authentication module application. user provides phone number , sms pin code send him. the user enters code , if valid phone number authenticated. maybe know whatsapp, quite same when run app first time. however if user puts new sim card in phone should authenticate again. i want know how determine if phone number has changed. read in other question not possible determine phone number itself. e.g. whatsapp recognizes there phone number. any ideas? update 2 one (not best) way it's detecting carrier changing. here can see how carrier's name. save @ first launch , compare on next launches. update 3 i'd recommend @ core telephony network reference , @ cttelephonynetworkinfo reference subscribercellularproviderdidupdatenotifier allow respond on events such like: ... when user’s cellular provider information changes. occurs, example, if user swaps device’s sim card 1 provider, while application running

How to add check box inside combobox in c# -

i want add check box inside combobox in c#. purpose user can select multiple values 1 combobox ( check , uncheck ). please help you have extend combobox control providing own rendering strategy, , "manually" adding checkbox. theses open source project ready use : http://www.codeproject.com/kb/combobox/checkcombobox.aspx http://www.codeproject.com/kb/combobox/extending_combobox.aspx

uiwebview - How to extract text contents from html like Read it later or InstaPaper Iphone app? -

i want extract main article content html on iphone app , show on textview or coretext. read later , instapaper iphone apps have feature, after researching on web, still can't tell how this. at moment, take text content html code, takes lots of no need contents too. textarticle = [webview stringbyevaluatingjavascriptfromstring:@"document.body.innertext"]; this question wanted, sadly not iphone app. instapaper-like algorithm this open source kind of feature, not sure if can use iphone app. https://github.com/jiminoc/goose/wiki it seems smartr provided api before, not available now. http://smartrmobi.blogspot.com/2011/02/smartr-api-withdrawn-until-further.html maybe, easiest way article content xml element, guess. i know start i'd appreciate suggestions. thanks after researching, seems can use api extract text contents web. means need access webpage after got url , render result again. it slower using js script showed above because need

Detect which SDK Version was used to build a OSX Framework -

i need detect sdk version used build osx framework. any helpful hints appreciated florian thanks hint solved problem i need validate framwework built 10.6 sdk hint, solved problem otool using otool -l prints the following lines if link against 10.6 sdk /system/library/frameworks/corefoundation.framework/versions/a/corefoundation (compatibility version 150.0.0, current version 550.29.0) if still use 10.5 sdk different current version number /system/library/frameworks/corefoundation.framework/versions/a/corefoundation (compatibility version 150.0.0, current version 476.19.0)

PHP MongoDB errors when using automatic failover -

i'm having hardest time trying figure 1 out. have 2 server replica set 1 arbiter running alongside current primary. when connect or issue queries, intermittent errors range 1 of following: could not determine master. could not connect [put host here]. broken pipe exceptions. mongocursorexceptions. it seems happen more longer servers up. after awhile, no connections can made , following error when try , login mongo shell: mongodb shell version: 1.8.1 connecting to: test wed may 11 16:36:50 messagingport recv() errno:104 connection reset peer 127.0.0.1:27017 wed may 11 16:36:50 socketexception: remote: error: 9001 socket exception [1] wed may 11 16:36:50 dbclientcursor::init call() failed exception: dbclientbase::findone: transport error: 127.0.0.1 query: { whatsmyuri: 1 } (btw, verbose (-vvvv) logging, 9001 socket exception seems come every query run.) when restart mongo servers, things come , start working, not long. no matter combination of connection opti

sql - Hide Database Login Information in PHP Code -

im total beginner in web programming. im trying create simple website reading data sql database. @ first wrote database password , login directly php code: <?php $username = "login"; $password = "pw"; mysql_connect("server", $username, $password); ... ?> this isn't idea! (much) more "secure" way this? read putting php code seperate file, meaning not main php document of website, , restricting access file. maybe .htaccess file. way go? the config.php file , .htaccess classic/good way go . it's way done cms or frameworks. as pointed johnp , can store config.php outside of public directory , means can't accessed via http. little better security (if don't make mistake .htaccess, there no more risks). file structure example : config/ -> configuration files lib/ -> libraries , utils php files public/ -> public pages/files/images... that way, http://www.your-site.com/ points public/ , th

flex - Is labelFunction useless with a heirarchical AdvandedDataGrid? -

the signature labelfunction is: mylabelfunction(item:object, column:datagridcolumn):string where item contains datagrid item object, , column specifies datagrid column. flat data can value need format item[column.datafield]. however heirarchical data given whole "folder" - i.e. items in heirarchy - in item parameter how can choose 1 use? eg. weather data organized heirarchically state groups arizona - maxtemp - jan, feb, march, april arizona - mintemp - jan, feb, march, april california - maxtemp - jan, feb, march, april california - mintemp - jan, feb, march, april if want format this, you'll given entire arizona item children array containing both maxtemp , mintemp data, there no way tell whether formatting maxtemp or mintemp. or there??? wait... seems work after all. don't anyway item[column.datafield] works.

visual studio 2005 - How to improve link performance for a large C++ application in VS2005 -

we have large c++ application composed of 60 projects in visual studio 2005. takes 7 minutes link in release mode , try reduce time. there tips improving link time? most of projects compile static libraries, makes testing easier since each 1 has set of associated unit tests. seems use of static libraries prevents vs2005 using incremental linking, incremental linking turned on full link every time. would using dlls sub projects make difference? don't want go through headers , add macros export symbols (even using script) if reduce 7 minute link time consider it. for reason using nmake command line faster , linking same application on linux (with gcc) faster. visual studio ide 7 minutes visual c++ using nmake command line - 5 minutes gcc on linux 34 seconds if you're using /gl flag enable whole program optimization (wpo) or /ltcg flag enable link time code generation, turning them off improve link times significantly, @ expense of optimizations. also

Porting Java code for creating Excel sheet to Android? -

i newbie in android please me solve problem. trying create .xls sheet in android , save on sd card, produces error. code working in java. main problem unable convert complete code in android. any appreciated. lot. most library using writing excel file not android compatible. read post , part ""things watch out for".

asp.net - Blink a label inside a repeater control -

i have label in itemtemplate in repeater control. want text of label blink on conditions. how do that? using asp.net 3.5. as <blink> tag long time obsolete , officially dead can use jquery blink plugin . however think twice before adding such thing live website, people not blinking test. tag killed reason..

html - Hyperlink in a div with jQuery.toggle Event -

i have div element wich has jquery.toggle event. if add hyperlink content of div, click on hyperlink fire jquery.toggle event of parent div. possible prevent ? hyperlink should open weblink, , not fire event. try : $("#linkinsideyourdiv").click(function(event)) { event.stoppropagation(); // other stuff }

parallel processing - MPI: all to all broadcast on one dimensional array -

i have number of processors , 1 array, , each processor fills work into, 1 dimensional array like: dense_process_array process 1: |process1|0000000000000| dense_process_array process 2: |000000|process2|000000| each process fills interval, want processors have others results same array. process 1 => dense_process_array |process1|process2|.....|processn| process 2 ... process n (like all2all bcast) therefore, every process calls function: void docommunication(int id, int numprocs, int start_point, int end_point) { int size_of_length = end_point - start_point + 1; mpi_scatter(dense_process_array+start_point, size_of_length, mpi_double, dense _process_array +start_point, size_of_length, mpi_double, id, mpi_comm_world;

delphi - Hide VCL Classes -

there program tools such winspy++ allow hover on handle of control/component , return class name of handle. example, if dropped tmemo on delphi form , compiled application, if used winspy++ , hovered on application (above memo), reveal class name of editor tmemo. now, suppose dont want using such program determine components using in application, how prevent class names showing in tool, such winspy++? i ask because dont want create clones of applications may create , release, if class names of components using discovered make task easier because know use. simply put, how can hide class names of vcl use in delphi application external viewer tools winspy++. winspy++ can found here: http://www.catch22.net/software/winspy to add, know can custom derive these components change class names own, must easier way. you override createparams , put own class name params.winclassname . default behaviour implemented in twincontrol.createparams : with params ... strpcopy

mysql - InnoDB and tmp_table issue -

i have set of 3 innodb tables in mysql server on simple select. select s.type, s.price,l.ratio, o.type, structures s, orders o, legs l s.type in ('type1','type2',...) , o.id >= s.id* 10 , o.id<= s.id * 10 + s.ordernumber -1 , l.id >= s.id * 10 , l.id <= s.id * 10 + s.legnumber -1 order s.type, s.furthestexpiration, s.nearestexpiration after number of rows added (around 1,800 structures, 3,000 legs , orders), cannot execute request , see in mysql workbench request's state copying tmp table. the request never finishes. some remarks: if same request in workbench, succeeds. if remove order clause, succeeds. if switch engine innodb myisam, works. i don't care using innodb or myisam, not sure that's incompatibility innodb, suspect there issues in db parameters/design. thanks clue! i'm not sure agree "simple select". want here? because if see correctly, huge (implicit) join. joining saying th

java - Focus on first cell in excel -

hssfworkbook wb = new hssfworkbook(new fileinputstream(file)); hssfsheet s = wb.getsheetat(0); wb.setactivesheet(0); s.showinpane(0, 0); fileoutputstream out = new fileoutputstream(file); wb.write(out); out.close(); i using above code taking focus first cell (when open excel first cell shouldd selected). opening excel correctly because of showinpane , selecting first cell not working. something this hssfworkbook wb = new hssfworkbook(new fileinputstream(file)); hssfsheet s = wb.getsheetat(0); s.setactive(true); hssfrow row = s.getrow(0); hssfcell cell = row.getcell(0); cell.setasactivecell(); fileoutputstream out = new fileoutputstream(file);

MATLAB neural networks -

i'm using simple xor input , output data set in order train neural network before attempting harder reason won't work. may please explain doing wrong please? code: %user specified values hidden_neurons = 3; epochs = 10000; t_input = [1 1; 1 0; 0 1; 0 0]; t_output = [1; 0; 0; 1]; te_input = [1 1; 1 0; 0 1; 0 0]; net = newff(t_input, t_output, 1); net = init(net); net = train(net, t_input, t_output); net.trainparam.show = 50; net.trainparam.lr = 0.25; net.trainparam.epochs = epochs; net.trainparam.goal = 1e-5; net = train(net, t_input, t_output); out = sim(net, te_input); this error message: ??? error using ==> network.train @ 145 targets incorrectly sized network. matrix must have 2 columns. error in ==> smallnn @ 11 net = train(net, t_input, t_output); you must have samples on columns , not rows (like nn software in world do), change data sets creation lines in: t_input = [1 1; 1 0; 0 1; 0 0]'; t_output = [1; 0; 0; 1]'; t

implement COM interface type library in python -

i have plugin i'm trying create sample application company work for. i'm trying write plugin in python. the way plugin architecture works plugin needs implement interface defined in provided com type library. com client type library , in end gets registered com server registry , application giving classid late-bound com application. i'm using pythoncom , win32com , have used makepy.py generate needed python code type libarary can't seem find way create class implements interface type library. any pointers on appreciated. thanks when try run dispatch com object following exeption: >>> interface = win32com.client.dispatch('{68ac7909-804f-4d6d-861c-8382daa7b029}') traceback (most recent call last): file "<stdin>", line 1, in <module> file "c:\python26\lib\site-packages\win32com\client\__init__.py", line 95, in dispatch dispatch, username = dynamic._getgooddispatchandusername(dispatch,username,clsct

android - How to store the "lastBuildDate" of an RSS feed -

i'm develloping android application has local database synchronizes whith online rss. the issue i'm encountering follwoing: want store "lastbuilddate" of rss feed (i have date in string ready store) don't know best way store date after application got closed. i'm thinking of creating new database whith lastbuilddate in sounds bit weird me, figured there might better more suitable solution store 1 string can access later. so there way store in application (like preferences?) or should eventualy create database or file store date in? regards you should create sharedpreference value case. im sure smart enough implement :) sharedpreferences sp= this.getsharedpreferences("sharedp", mode_private); sharedpreferences.editor editor = sp.edit(); editor.putstring("lastbuild", date); editor.commit();

Groovy as List Question -

i ran across bit of code , me seems not needed there reason following def answers = [] list instead of def answers = [] in groovy thought [] empty list there no need have list no, there no difference, both create arraylist , list ( java.util.list ) interface anyway.

properties - How to determine class of Objective-C Property? -

ok, have property on class: @interface myobject : nsobject { myotherobject *someotherobject; } @property (nonatomic, copy) myotherobject *someotherobject; @end i'm trying create deserialize api response correct objects without explicitly defining class each api attribute maps to. so, there way me find out class property is, if it's nil ? i'm looking method [myobject classforproperty:@"someotherobject"] return class object. note--i'm not looking iskindofclass: or class , won't work on nil value. worst case, can manually define list of property classes, it'd nice if there built in way it. ok, ended figuring out after coming across question: in objective-c determine if property int, float, double, nsstring, nsdate, nsnumber, etc here's code: @interface nsobject (properties) + (class)classforproperty:(nsstring *)propertyname; @end #import <objc/runtime.h> @implementation nsobject (properties) + (class)classfo

windows - C++ TCP Socket Plugin -

i working simulation engine vbs2 , attempting write tcp socket plugin. have client application want connect plugin , send single message. perhaps make more sense if post existing plugin code: #include <windows.h> #include "vbsplugin.h" // command function declaration typedef int (winapi * executecommandtype)(const char *command, char *result, int resultlength); // command function definition executecommandtype executecommand = null; // function register executecommand function of engine vbsplugin_export void winapi registercommandfnc(void *executecommandfnc) { executecommand = (executecommandtype)executecommandfnc; } // function executed every simulation step (every frame) , took part in simulation procedure. // can sure in function executecommand registering done. // deltat time in seconds since last simulation step vbsplugin_export void winapi onsimulationstep(float deltat) { //{ sample code: executecommand("0 setovercast 1", null, 0); //

multithreading - How to "try start" one thread from several other threads, java -

i wrote in function: if(mythread.isalive()) { } else { mythread.start(); } but unsafe if many threads call function same time. start running thread throws exception. so except putting try-catch around it, have other options? make method synchronized. also, check ( isalive() ) unsafe because if thread have been finished cannot start again (and isalive() return false...)

jQuery Mobile 'return false' on form submission -

i have form on jquery mobile site validate, , stop submission if validation not pass. however, 'return false' not stop form being submitted, because jquery mobile submitting form via ajax. how can stop form submission? $("#form").live('submit', function(){ alert('test'); return false; }); the above code fires alert, not stop form being submitted. if use data-ajax="false" on form tag works correctly, rather use ajax submission if possible. use data-ajax="false" , bind own ajax form submission code runs if validation passes: $("#form").live('submit', function() { if (formvalidates) { $.post(...); } return false; });

arrays - Possible to pass a closure to usort in PHP? -

i have array sorting function follows: public function sortascending($accounts) { function ascending($accounta, $accountb) { if ($accounta['amountuntilnexttarget'] == $accountb['amountuntilnexttarget']) { return 0; } return ($accounta['amountuntilnexttarget'] < $accountb['amountuntilnexttarget']) ? -1 : 1; } usort($accounts, $ascending); return $accounts; } clearly not ideal hard-coding key search for. thought make generic passing key param outside function, out-of-scope in inner function. tried around using closure, have access param, instead of inner function follows: public function sortascending($accounts, $key) { $ascending = function($accounta, $accountb) { if ($accountsa[$key] == $accountb[$key]) { return 0; } return ($accounta[$key] < $accountb[$key]) ? -1 : 1; } usort($accounts, $ascending); return $accounts; } however us

wysiwyg - Too many problems on tables in Tinymce? -

im working on cms finished im struggling serious unfamiliar problems in wysiwyg editor. i first using ckeditor after experiencing problems switched tinymce. problems solved time someother problems showed up. problems occuring on tables. 1-anchor element underline removal not working 2-duplicating phone numbers --->might due skype phone number converting toolbar 3-too many &nbsp;s how clean why there? 4-how convert <p>text</p> back text because tinymce converting texts p element *automatically if it's not client doing unknowingly. *=even though did force_paragraph:false setting. 5-as client reports : cursor turns loading cursor , wysiwyg editor causes browser stuck.not allowing click links outside of editor. 6-as experience stuck , not allow edit @ all. here problematic page created tiny_mce , causing lots of errors in process of editing: here answers 2 -duplicating phone numbers --->might due skype phone number conv

Silverlight datapager not firing load events -

here's problem: i have datagrid bound collection of objects. 1 column contains id , need turn id user's name associated it. in datagrid, have template column contains textblock. textblock has loaded event take id, user, , set textblock text user's name. <sdk:datagridtemplatecolumn width="auto" header="user"> <sdk:datagridtemplatecolumn.celltemplate > <datatemplate> <textblock name="lbluser" height="25" margin="10" loaded="lbluser_loaded" /> </datatemplate> </sdk:datagridtemplatecolumn.celltemplate> </sdk:datagridtemplatecolumn> everything works without datapager, add 1 fires loaded event first page. every page after contain results of first page. how work. on right track of this? there better way lookup ids in datagrid? no not on right track this. loaded event fire once. why can not use binding , change bound data objects i

PostgreSQL - ERROR: column "date" cannot be cast to type date -

i want cast specific column in postgresql database character_varying type type date. phppgadmin gives me following error: error: column "date" cannot cast type date in statement: alter table "public"."tablename" alter column "date" type date what should ? thanks you might need convert text first: alter table "foo" alter column "date" type date using ("date"::text::date);

silverlight - How to use the Expression Blend 4 ranged property control -

Image
is there way use nifty expression blend ranged value control in own projects? this one: edits: i really, love know. i made attempt while in wpf remake colorpicker , needed similar control enter r, g, b , values. it's not complete gives pretty start. supports dragging , typing picked different dragging scheme because dislike blend drag. here's did: [templatevisualstate(groupname = "editstates", name = "dragmode")] [templatevisualstate(groupname = "editstates", name = "typemode")] public class colorcomponentslider : control { static colorcomponentslider() { defaultstylekeyproperty.overridemetadata(typeof(colorcomponentslider), new frameworkpropertymetadata(typeof(colorcomponentslider))); } private bool _istemplateapplied = false; private textbox _textbox; private textblock _textblock; private gradientstop _gradientstart; private gradientstop _gradientend; private grid