Posts

Showing posts from June, 2014

ajax - http packets in dynamic web pages -

Image
i want know in web pages yahoo every example 5 min news changes, send http packet server? if want implement feature ajax need send http packet again? can 1 explain dynamic structure(like updating news)for me. you can find out what's going on on page: example use firefox , download firebug addon. open firebug after installation , open network tab. may have enable it. reload page in question, you'll see evere request made. , of course see timed requests done later update page. details pretty thorough. this how firebug network tab looked after posting first paragraph of answer:

c# - When is the variable from the calling scope altered, if using out parameters? -

i cannot try rigth now, sure, knows: void func(out mytype a) { = new mytype(); // other stuff here // take time ... , return } when call in asynchronous manner that: mytype a; func(out a); will altered immediately, once assigned in function? or new object reference assigned when function returns? are there specifications if want relay on implemented behavior? it's assigned once assigned in function. use of out provides reference whatever passed in, means gets modified whenever modified in method. an extract c# language spec: 5.1.6 output parameters a parameter declared out modifier output parameter. an output parameter not create new storage location. instead, output parameter represents same storage location variable given argument in function member or delegate invocation. thus, value of output parameter same underlying variable. the following definite assignment rules apply output parameters. note different rule...

android - Starting new Activity in OnCreate -

i got android app based on 2 activities. main activity input field , button user information. when user press button barcodescanner (zxing) start. every thing works perfect. know try check in oncreate if user information known. if true -> start barcodescanner. looks barcodescanner activity starts twice, because: pressing button once: annother barcodescanner wil active. pressing button twice: main activty active. this check inside oncreate: if(pref.length() == 6){ startactivityforresult(intent, 0); } and function called when clicking button: public void onclick(view view) { switch (view.getid()) { case r.id.button1: final edittext edit = (edittext) findviewbyid(r.id.panelid); if(edit.gettext().tostring().length() == 6){ string temp = edit.gettext().tostring(); log.e("click", temp); editor e = this.getpreferences(context.mode_private).edit(); e...

c++ - Dynamic Programming Problem -

well, don't need code itself, understanding trying in order write code. in nutshell, given 1000 projects each set of resources, , have (set ammount) of resources utilize calculate best projects can pick. the pseudocode bestprofit function follows: bestprofit: parameters - projects: vector of projects r: resources available solve subinstance valuemap: map data structure used memoization n: projects numbered 0,...,n-1 may used solve subinstance returns - maximum amount of profit may obtained on subinstance of optimization problem post-condition – if n > 0, valuemap contains entry key (r, n). if n equals 0 return 0 check valuemap see whether subinstance has been solved - if so, return computed result (function terminates) best1 = bestprofit(projects, r, valuemap, n-1) check whether r provides enough resources undertake project n-1 - if so, best...

c# - ActiveX works on localhost, doesn't work on external server -

edit2: users having same problem, have managed solve using this page . luck! edit: apperently problem need install activex component on client computer. right way this? i wrote small activex component in c# searches removable drives usb flash drives. have followed steps here , in short wrote code , did: regasm aclass.dll /tlb /codebase i wrote activex component because needs executed on external server. made small webpage uses activex. when use localhost code gets executed , usb key gets detected. works inside asp.net page final goal. however, when accessing page external server, code doesn't executed. placed javascript alerts before , after loading activex component. alert after loading activex doesn't fire. the webpage uses code: <html> <head> <script language="javascript"> alert("loading activex"); var x = new activexobject("anamespace.aclass"); alert(x.getdrives()); alert("done")...

Refactor reading elements in an XML file - C# -

can refactor following piece of code reading elements in xml file: if (!(xmldoc.element("element1").element("element2").element("element3").element("element4").element("element5").element("element6") == null)) { } try use xpath expression find element want, code submited can easly throw unexpected nullreferenceexception don't want catch . something this: if (xpath.evaluate("count(/element1/element2/element3/element4)", xmldoc) > 0) { } ps. why negating expression of == null ? better readable , maintainable != null without negation , trailing () in boolean expression.

java - What is the largest possible heap size with a 64-bit JVM? -

the theoretical maximum heap value can set -xmx in 32-bit system of course 2^32 bytes, typically (see: understanding max jvm heap size - 32bit vs 64bit ) 1 cannot use 4gb. for 64-bit jvm running in 64-bit os on 64-bit machine, there limit besides theoretical limit of 2^64 bytes or 16 exabytes? i know various reasons (mostly garbage collection), excessively large heaps might not wise , in light of reading servers terrabytes of ram, i'm wondering possible . if want use 32-bit references, heap limited 32 gb. however, if willing use 64-bit references, size limited os, 32-bit jvm. e.g. on windows 32-bit 1.2 1.5 gb. note: want jvm heap fit main memory, ideally inside 1 numa region. that's 1 tb on bigger machines. if jvm spans numa regions memory access , gc in particular take longer. if jvm heap start swapping might take hours gc, or make machine unusable thrashes swap drive. note: can access large direct memory , memory mapped sizes if use 32-bit referenc...

Rails: Order with nulls last -

in rails app i've run issue couple times i'd know how other people solve: i have records value optional, records have value , null column. if order column on databases nulls sort first , on databases nulls sort last. for instance, have photos may or may not belong collection, ie there photos collection_id=nil , collection_id=1 etc. if photo.order('collection_id desc) on sqlite nulls last on postgresql nulls first. is there nice, standard rails way handle , consistent performance across database? adding arrays preserve order: @nonull = photo.where("collection_id not null").order("collection_id desc") @yesnull = photo.where("collection_id null") @wanted = @nonull+@yesnull http://www.ruby-doc.org/core/classes/array.html#m000271

list - Is there a better way to read an element from a file in Python? -

i have written crude python program pull phrases index in csv file , write these rows file. import csv total = 0 ifile = open('data.csv', "rb") reader = csv.reader(ifile) ofile = open('newdata_write.csv', "wb") writer = csv.writer(ofile, delimiter='\t', quotechar='"', quoting=csv.quote_all) row in reader: if ("some text") in row[x]: total = total + 1 writer.writerow(row) elif ("some more text") in row[x]: total = total + 1 writer.writerow(row) elif ("even more text i'm looking for") in row[x]: total = total + 1 writer.writerow(row) < many, many more lines > print "\ntotal = %d." % total ifile.close() my question this: isn't there better (more elegant/less verbose) pythonic way this? feel case of not knowing don't know. csv file i'm searching not large (3863 lines, 669 kb) don't t...

facebook - Cannot get the Likes of a Photo Object -

i using graph api in ios app. when request of type [facebook requestwithgraphpath:@"me/photos"] .. expected result (the 25 recent photo object). can see in results comments, tags... each photo cannot see likes each photo. else experienced before or missing permissions approval? prior retrieving photos, [facebook authorize:] following permissions : "user_photos", "friends_photos". seems me likes property missing returned objects... thanks help. getting likes separate graph api call. wouldn't count on comments in photo call, seems undocumented feature. the url is: https://graph.facebook.com/{photo id}/likes , comments: https://graph.facebook.com/{photo id}/comments the photo object documentation page friend here. you combine these calls using batch request of photo ids gets likes , comments each photo id.

wordpress - Pagination not working using a custom SQL query with a custom type -

i've been struggling problem 2 days now. i've read dozens of posts can't solution. note: var names in spanish since spanish website. i've created custom type named "promocion", when listing archives when try go page 2 404 error. the structure i'd set following: domain.com/promocion/new-promocion -> works well domain.com/promociones -> list of promociones, works too domain.com/promociones/page/2 -> error 404 - not found name of archive file in template: archive-promocion.php name of single page view in template: single-promocion.php wordpress version: 3.1 plugins: wp-page-navi posts 2 posts plugin (http://wordpress.org/extend/plugins/posts-to-posts/), used create relation between posts , promociones. here's custom type created in functions.php register_post_type('promocion', array( 'label' => 'promociones', 'description' => 'promociones', 'public' ...

dynamic - How to Merge Java Objects Dynamically -

public class myclass{ public string elem1; public int elem2; public mytype elem3; ................. } myclass object1=new myclass(); myclass object2=new myclass(); object1.elem1=... object1.elem2=... ... object2.elem1=... object2.elem2=null ..... what want object1.merge(object2); where dynamically traverse members on myclass , run on every member if(object1.elem != object2.elem && object2.elem!=null) object1.elem=object2.elem; is such mechanism exist in java? use reflection. go on fields of class. psuedo: field[] fields = aclass.getfields(); (field field : fields) { // value object value = field.get(objectinstance); // check values different, update field.set(objetinstance, value); } and match values. if differ, update value.

Rails 3.1 Passenger/Apache/force_ssl getting 404 error -

i'm trying force application using ssl. i've inserted "force_ssl" application controller. when try access application i'm getting 404s every page. application being redirected https, though. i'm using passenger , apache. is there else need do? hints/tips appreciated. thanks try putting config.force_ssl = true into application.rb .

android - Business logic of the CheckBox listener inside a ListView -

i have implemented custom adapter listview, includes checkbox in each row. as have click listener in custom adapter, i'm forced implement there business logic (that is, happens when checkbox clicked... access database, etc). is correct? wouldn't better practice implement business logic outside custom adapter? (i think adapter should care visualization). try this..hope helps you lv_archiveist.setonitemclicklistener(new onitemclicklistener(){ @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { // todo auto-generated method stub if(view.findviewbyid(r.id.chkbox).ischecked()) { //your method// //you can position of selected checkbox parameter "position" }

Is there a javascript library for creating graphs? -

i need javascript/jquery library dynamically create graphs. libraries found visualization. i need 1 can add node nodes, remove nodes, trace paths, etc. jsplumb page excerpt: jsplumb provides means developer visually connect elements on web pages. uses svg or canvas in modern browsers, , vml stone-age browsers. latest version - 1.3.3 - can used jquery, mootools , yui3. full transparent support dragging included , api super simple. project activity pretty high. requires 1 of few other js libraries work (jquery, mootools, yui). here few demos . mxgraph page excerpt: mxgraph simple, include javascript link in html file , instantly have access cleanest, functional native browser diagramming component available. wireit page excerpt: wireit open-source javascript library create web wirable interfaces dataflow applications, visual programming languages, graphical modeling, or graph editors. cytoscape.js page excerpt: an open-source javascript graph theory library...

java - How can I get the result of a Count query in TopLink? -

i have this: reportquery query = new reportquery(openedfilesreport.class, generateexpressionopenedfilesreport()); query.addcount(); object result = gettoplinktemplate().executequery(query, true); as can see, result vector , has 1 result of type reportqueryresult. there smarter way of getting result then ((reportqueryresult)((vector)result).get(0)).getresults()//.. additional class casts/getter calls query.setshouldreturnsinglevalue(true); number result = (number) gettoplinktemplate().executequery(query, true); here link eclipselink javadocs: http://www.eclipse.org/eclipselink/api/2.2/org/eclipse/persistence/queries/reportquery.html#setshouldreturnsinglevalue%28boolean%29 doug

syntax highlighting - Change font color for comments in vim -

i'd change default font color comments dark blue yellow color. difficult read on black background. advise me how change 1 color? i'm satisfied other colors. i'm using xfce4-terminal (not gvim gui). so far, have done settings in ~/.profile file according this link follows if [ -e /usr/share/terminfo/x/xterm-256color ]; export term='xterm-256color' else export term='xterm-color' fi and set t_co=256 in ~/.vimrc thank you :hi comment guifg=#abcdef pick color! if using color terminal, replace guifg=#abcdef ctermfg=n n being color number. also type :help :hi more information.

Delphi XE2 Cannot get BPL plugin work -

i tried implement simple module system xe2 couldn't work. when try run under ide, can handle loadpackage() cannot class getclass() (even though registerclass()ed within initialization section of bpl). when try run under windows, "this application has failed start because rtl160.bpl not found" error, , cannot load package. module code type tfrmodule = class(tframe) button1: tbutton; procedure button1click(sender: tobject); private { private declarations } public { public declarations } end; implementation {$r *.dfm} procedure tfrmodule.button1click(sender: tobject); begin showmessage('hello'); end; initialization registerclass(tfrmodule); showmessage('registered'); finalization unregisterclass(tfrmodule); showmessage('unregistered'); also, initialization section not being executed because see no 'registered' message box. and host app this; var hmod: hmodule; fcmod: tpersistentclass; ...

java - Fastest way to format a String using concatenation and manipulation -

string temp = ""; temp = string.format("%02d", ""+hour)+":"+string.format("%02d", ""+min)+":"+string.format("%02d", ""+sec); is fastest way format numbers concatenation specify leading zeroes, or there way? i have display string in format 00:00:00. hour, min, , sec int variables start 0 , put thread counts time elapsed , displays time accordingly. correct way, or there better way? try this. assume hour, min , sec ints. string temp = ""; temp = string.format("%02d:%02d:%02d", hour, min, sec);

iphone - UITableView scroll problem -

i have created tableview in application 5 sections in it. sections 1 - 4 contain 1 row each minute , section 5 contains 5 rows. everything works fine until scroll tableview off screen. in first section , row (cell) have accessoryview set uilabel text in it. every other cell has disclosure button accessorytype. when scroll tableview text have in first cell somehow appears in the last cell!? i have set data adding nsstrings array's , adding them dictionaries nsmutablearray. and here cell set up: - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease]; } // uiswitch *auiswitch = [[[uiswitch alloc]initwithframe:cgrectz...

cryptography - should you authenticate the initialization vector in ipsec? -

i'm trying implement ipsec in form of esp in transport mode using aes in galois/counter mode, according rfc4106. i'm supposed put initialization vector before ciphertext in transformed packet. should part of authenticated (but non-encrypted) data? (i'm assuming don't encrypt it...) i can't see rfc specifies this. should obvious , if why? as far understand gcm definition, there no need include initialization vector in associated data - using different initialization vectors give both different encryption results different integrity check value anyway. this advantage of using combined authenticated-encryption mode, don't have care including initialization vectors in mac. so, encode packet esp gcm, this: fetch key generate iv calculate associated data (from spi , sequence number) get plaintext pass iv, associated data, key, plaintext gcm algorithm get ciphertext , icv gcm algorithm send iv, ciphertext , icv

How can I store primary keys within an url path in slickgrid rows? -

i have been trying follow examples no success. you're question might bit specific answer. might want try slickgrid wiki. luck, jeff. https://github.com/mleibman/slickgrid/wiki

Java convert any integer to 4 digits -

this seems easy question. 1 of assignments sends time in military format (like 1200 , 2200 , etc) class. how can force integer converted 4 digits when it's received class? example if time being sent 300 , should converted 0300 . edit: turns out didnt need problem had compare values. thanks as simple that: string.format("%04d", 300) for comparing hours before minutes: int time1 = 350; int time2 = 1210; // int hour1 = time1 / 100; int hour2 = time2 / 100; int comparationresult = integer.compare(hour1, hour2); if (comparationresult == 0) { int min1 = time1 % 100; int min2 = time2 % 100; comparationresult = integer.compare(min1, min2); } note: integer.compare(i1, i2) has been added in java 1.7, previous version can either use integer.valueof(i1).compareto(i2) or int comparationresult; if (i1 > i2) { comparationresult = 1; } else if (i1 == i2) { comparationresult = 0; } else { comparationresult = -1; }

vb.net - calculating the values from the formula -

using vb.net (windows application) table1 id formula 001 a+b+c 002 a-b*c 003 a*b 004 a/b ... ... user input's textbox1.text = id of formula (users input) textbox2.text = value1 textbox3.text = value2 textbox4.text = value3 conditons if user enter value in textbox1.text = 001 add 3 value (textbox2.text + textbox3.text, + textbox3.text), because user selected formula1 if user enter value in textbox1.text = 003 should multiply (textbox2.text * textbox3.text), because user selected formula2 .... i want take formula according id, want pass value = textbox2.text, b = textbox3.text, c= textbox4.text code cmd = "select formula table1 id = '" & textbox1.text & "'" dim f1 string f1 = cmd.executescalar so formula stored in f1, want pass user entered value for example f1 = + b * c means have pass value = textbox1.text, b= textbox2.text, c = textbox3.text how this. need vb.net code help here's site has source...

Have div appear to the right of a TD onclick of TD with jquery/javascript? -

so have absolute positioned div of 5x5 pixel square. if have table <table><tr><td>something</td></tr></table> i want div show right of td when click anywhere inside of td, should appear snapped right side of td regardless of click in td. there simple way accomplish in jquery/javascript? i'd suggest using hidden table cells, , showing div within that: <table> <tr> <td>something</td> <td class="hidden"><div></div></td> </tr> <tr> <td>something</td> <td class="hidden"><div></div></td> </tr> </table> jquery: $('tr td').click( function(){ $(this).closest('tr').find('.hidden').toggle(); }); css: td { vertical-align: middle; width: 5em; height: 2em; } .hidden { display: none; } .hidden div { ...

javascript - Found this in the jquery source, how does it work? -

all 1 expression. gets put inside div in end? what's called when have bunch of comma delimited expressions? var div = document.createelement( "div" ), documentelement = document.documentelement, all, a, select, opt, input, tds, events, eventname, i, issupported; it declaration of bunch of variables inside function scope. first 2 variables initialized declaration. can declare/initialize multiple variables @ once separating each comma done here. in other uses, comma character operator in javascript. mdn : the comma operator evaluates both of operands (from left right) , returns value of second operand. the variable div initialized here empty div tag. there nothing inside yet until later code uses it. code following in jquery, puts content div , runs series of test operations on feature tests , see features supported in current browser.

xcode - What is your preferred workflow when using PhoneGap and iOS? -

what workflow like? i'm trying understand best. phonegap works in simulator, seems rather tough try , develop outside of that. here's i've got right now: open xcode , phonegap project www folder in it open pycharm (my ide) , point @ www folder edit html , javascript in pycharm press build/debug in xcode , test in simulator this method super slow. test without simulator, phonegap won't work. you don't have test in simulator. of functionality work if browse www folder using chrome or safari. true, phonegap functionality won't work (camera, geolocation, etc) web storage works, can test ui, etc.

model view controller - Building a Play framework module for sharing a data layer among several services -

keeping notion of soa in mind, intent provide several different services, leverage same data model. imagine poker application - may have following services: game frontend administrative frontend player rank / leaderboard service player finances service bank integration service ... all of these services can leverage same model (perhaps providing additional model information neccessary). in play! framework, possible me externalize data model, maintain benefits gain using play. example, runtime re-compilation. modules seem might serve job, there little documentation them, , examples given suggest opposite paradigm - services modules, , core play application pulls in features. any guidance appreciated. it's hard true soa style using play. because play not framework - it's web platform providing services right httprequest database persistence , not in isolation. in case, if have externalize data-layer- suggest try spring module . spring should take...

rest - (Ab?)using http custom headers to return metadata about an entity -

if, in addition binary image data, want return data structure in same http response message. data structure describe image further receiving application use information process image if wanted to, way it? when transmitting data structure without image data, i'd return json. like other image, image/... content-type, adding custom http response headers containing data using application/json (or xml or ...) containing json data structure , field containing encoded binary image data as metadata in image binary itself , although specific type of image used (png different gif etc.) 1) easiest me implement both server-side , client-side, wonder, if that's not abusing http headers, otoh. maybe similar of standard http headers etags. 2) , 3) aren't easy use both client- , server-side, , 2) not efficient (cpu, bandwidth) 1) , 3). the nice thing 1) , 3) clients unaware of metadata (js client?) @ least display image. any objections 1) http police? other option mis...

c# - Dynamically programming a grid consisting of 64 buttons (8x8) -

i'm trying create chess game purely learning c# , chess. start off with, create 8x8 grid of buttons through code rather designer. save me hard coding each button individually. a button array seem way start have no idea how implement this. int buttonwidth = 40; int buttonheight = 40; int distance = 20; int start_x = 10; int start_y = 10; (int x = 0; x < 8; x++) { (int y = 0; y < 8; y++) { button tmpbutton = new button(); tmpbutton.top = start_x + (x * buttonheight + distance); tmpbutton.left = start_y + (y * buttonwidth + distance); tmpbutton.width = buttonwidth; tmpbutton.height = buttonheight; tmpbutton.text = "x: " + x.tostring() + " y: " + y.tostring(); // possible add buttonclick event etc.. this.controls.add(tmpbutton); ...

c# - Select records from SQL Server if greater than 6 months -

i creating mvc app need send out email records value ( dateupdated ) not updated in customer table. my customer table looks this: id (pk) name address datelastupdated now have mysql query: select * users datelastupdated >= now() - interval 6 month how write in t-sql , perform task in mvc3? please help! your query should be: select * users datelastupdated >= dateadd(month, -6, getdate()) additionally, may want strip out time portion left date e.g. 2011-04-12 00:00:00.000 can use this: select * users datelastupdated >= dateadd(month, -6, cast(floor(cast(getdate() float)) datetime))

codeigniter - Problems with MongoDB query -

i developing api using codeigniter , alex bilbies oauth2 , mongodb libraries. need mongodb query query document _id of 1 , access token null. i have far not work: $exists_query = $this->ci->mongo_db->select('access_token')->where(array('_id' => $session_id, 'access_token' != null))->get('oauth_sessions'); i tried too: $exists_query = $this->ci->mongo_db->select('access_token')->where(array('_id' => $session_id))->where_not_equal('access_token', null)->get('oauth_sessions'); how can change query work? this seems weird.. not using id's mongo provides?? if are, have use special mongoid function converts raw string mongo id. if not using default mongoid... should! also why having set nulls?? mongo structure unspecific, if field isn't used dont need set null value it.. dont include field.. isn't mysql need store null values.. each row in mongo db can ...

sql - How to specify explicit locking while creating a table in PostgreSQL -

what default locking mechanism in postgressql when create table ? row, page, table level or else? is possible specify row level locking when create table ? below in sybase. create table user (...) lock datrarows or not need specify locking strategy , leave postgres choose best while dealing crud ? cheers! there isn't can specify @ create table time postgresql. @ run time, can select rows for update or for share . if you're coming postgresql platform, should skim docs on concurrency control .

c# - VS 2010 pdf shortcut in setup project -

i have setup project , add shortcut pdf file within user's programs menu. pdf file located within application folder , creating shortcut in user's program menu far doesn't seem work. know how solve problem? we using visual studio 2010 , c#, winforms.

jquery ui tabs prevent ui-tabs-selected ui-state-active being added -

looking way prevent jquery adding ui-tabs-selected , ui-state-active tab bar / menu when changes tab tab. add own styles if possible. tried find solution, nothing yet... anyone? there few ways this. download full jquery ui code , strip out code adds styles tab, minify again if needed: http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js use jquery ui tabs select event remove classes: $( ".selector" ).tabs({ select: function(event, ui) { $(".selector .ui-tabs-nav > li").removeclass("ui-state-active ui-state-selected"); } }); just override styles ui-state-active , ui-state-selected own css: .selector .ui-tabs-nav > li.ui-state-active { color: #ff0000; } .selector .ui-tabs-nav > li.ui-state-selected { color: #ff00ff; }

sql - How to identify the highest normal form of a relation schema? -

let's have relation schema. how can state highest normal of relation? for example: art_object (art_id, title, description, country, artist, epoch, year) "i wanna know normal form art_object in? test school." normal form of given design depends on which functional dependencies hold. without being given set of functional dependencies, question unanswerable. if fd holds art_id -> {all attributes}, design in 5nf. if on contrary there additional fd artist -> country, design isn't 3nf.

jquery - Circumvent random number in ID -

i got line in script, check items class: $('#post').attr('class'); is there chance, read like: $('#post*').attr('class'); so if id fe. post405 still read this? i've checked , won't work * , so there other way read items way? $('[id^=post]').attr('class'); you're looking [attribute^=*] selector.

iphone - Type in two uitextfield at the same time -

i want type in 2 uitextfield @ same time.is possible? you can using following code: typein2.h - class 3 textfields declared. "textfieldbeingedited" textfield know textfield (text1 or text2) being edited #import <uikit/uikit.h> @interface typein2 : uiviewcontroller <uitextfielddelegate> { uitextfield *text1; uitextfield *text2; uitextfield *textfieldbeingedited; } @property (nonatomic, retain) iboutlet uitextfield *text1; @property (nonatomic, retain) iboutlet uitextfield *text2; @end in viewdidload method following: - (void)viewdidload { [super viewdidload]; text1.delegate = self; text2.delegate = self; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(changebothfieldstext:) name:uitextfieldtextdidchangenotification object:nil ] ; } textfield delegate method: -(void)textfielddidbeginediting:(uitextfield *)textfield { if ( [textfield isequal:text1] ) { ...

how to add a string to the path in link_to of ruby on rails -

for example have code: <%= link_to "start", start_path(:id=>1,:box=>1)%> the id , box parameters right? , example, generated url: http://localhost:3000/start?id=1&box=1 how can add string it, make this: http://localhost:3000/start?id=1&box=1#box_1 use :anchor key: <%= link_to "start", start_path(:id => 1, :box => 1, :anchor => 'box_1') and answer first question, yes, id , box parameters. passed in request part of params hash.

c# - Hiddenfield is null when accessing from FetchCount() on Objectdatasource -

i using subsonic , gridview objectdatasource (i have not used objectdatasource before) the grid binds fine, problem don't want keep calling database count of records in table. when call "fetchcount" (the selectcountmethod) first time want store ina hiddenfield (or viewstate). reason hiddenfield null when try , access it, not value, actual hidden field. case if try storing in viewstate. this aspx. gridview, objectdatasource , hiddenfield <asp:gridview id="grdresults" runat="server" allowpaging="true" autogeneratecolumns="false" datasourceid="propertiesdatasource" pagesize="10" > <columns > <asp:boundfield datafield="propertyname" /> </columns> </asp:gridview> <asp:objectdatasource id="propertiesdatasource" runat="server" selectmethod="fetchpageddata" typename="testwebsite.usercontrols.search.searchresults" sel...

javascript - How to get css width of class? -

my question is, how can width parameter of class css style? example have <div class="page css-1" id="page1"> div id=page , classes "page" , "css-1". want width parameter of css-1 class style? the easiest way ignore <div> , create new 1 class care , check style attributes. need add dom adopt css of document. var div = $('<div>').addclass('css-1').hide(); $('body').append(div); var width = div.css('width'); div.remove();

java - Dynamic Hibernate Query -

i have method use return dynamic query. method shown below public query getlastid(string sprovider) { string serviceprovider = sprovider.tolowercase(); string query2 = "select max(:serviceprovider.id) " + " :sprovider :serviceprovider "; return em.createquery(query2) .setparameter("sprovider", sprovider) .setparameter("serviceprovider", serviceprovider); } i want method return this select max(multichoice.id) multichoice multichoice when call method this getlastid("multichoice"); please how write query variable return answer? to task can use criteria object model , projections run query on different types: take @ article (15.7. projections, aggregation , grouping) here code : list results = session.createcriteria(class) .setprojection( projections.max("id")) .list(); then instead of string should send class method. ...

flash - Disable List selection but keep childrens functions -

i got s:list dataprovider , custom itemrenderer. itemrenderer has button within. every time choose item list, focus on item, clicking button within item causes s:list select hole item , wont let me press button within item. is there solution disable "list" selection functionallity keeping items within list enabled / clickable? as requested, here code (relevant parts) categorytree.mxml <s:list id="data1" name="d1" x="-2000" height="100%" minwidth="600" width="{this.width}" dataprovider="{this.childrenresult1.lastresult}" itemrenderer="gui.components.category"> <s:layout> <s:verticallayout gap="10" clipandenablescrolling="true" variablerowheight="true"></s:verticallayout> </s:layout> </s:list> category.mxml <s:itemrenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xm...

jquery - Make Dailymotion videos work with Prettyphoto -

after lot of searching i've found here changes should done in order dailymotion videos should work prettyphoto. i've done these changes , it's working... not first time after refresh page. i mean if have rel="prettyphoto[videos]" , here have 3 videos youtube, vimeo , dailymotion, it's working if don't hit first time dailymotion video. if hit vimeo video , going next video...it's working. if refresh page , hit dailymotion video first... it's not working. i'm sure minor change because doesn't recognize path first time or don't know... a live example here . the code added this: case 'dailymotion': correctsizes = _fittoviewport(movie_width,movie_height); // fit item viewport // remove url's beginning var videoid = pp_images[set_position].replace(/http:\/\/www\.dailymotion\.com\/video\//i, ''); // "explode" end of string catch video id var spt = videoid.split('_'); ...

positioning - CSS: aligning elements inside a div -

i have div contains 3 elements, , having problems correctly positioning last one. div @ left has @ left, 1 in middle needs centered, , third 1 needs to right. so, have like: #left-element { margin-left: 9px; margin-top: 3px; float:left; width: 13px; } #middle-element { margin:0 auto; text-align: center; width: 300px; } #right-element { float:right; width: 100px; } my html looks this: <div id="container-div"> <div id="left-element"> <img src="images/left_element.png" alt="left"/> </div> <div id="middle-element"> text inside middle element </div> <div id="right-element"> text in right element </div> </div> any ideas? thanks! you haven't included css container div, whenever contains floating elements should hide overflow ...

c# - Can't reference System.ServiceModel.EndpointNotFoundException -

i'm trying catch exception: system.servicemodel.endpointnotfoundexception but visual studio isn't finding it. there's no little red dash @ end, , if try doing using on system.servicemodel namespace, there no servicemodel in system. though system.servicemodel namespace in .net framework class library. is there reason cannot reference it? i error when application cannot access web-service. edit : target framework is: 3.5 client framework not checked. edit : i'd added system.servicemodel namespace, apparently (it wasn't obvious @ time), i'd added class library instead of program. whole bother. when suggested close , start new project, add library, worked, went , looked. vs different on re-open , obvious i'd added system.servicemodel library , not main project. thanks help! (added @ request of asker, in response discussions in comments.) if you've definitely added reference, , you're definitely targeting .net 3.0+, ...

javascript - The chicken and the egg -

i have 2 big functions, a , b , in 1 big javascript file. goal have each function in separate javascript file. the problem a makes calls b , , b makes calls a , if put both functions in different files, 1 missing definition of other, , error message , things break. when in same file, under same closure, things don't break because of hoisting. how can have 2 functions in different files when each references other? if they're going in different files, won't have them in same closure, that's fire problem. after that, if you're willing enforce load order (i.e. load first, b), have define stub of b, , b redefine when loads. long doesn't execute before b loads, should fine.

assigning the id in html through the javascript DOM concept -

<body> <input type="button" value="add" onclick="add()"> <table id="mytable"> </table> <table id="mytable2"> </table> <table id="mytable3"> </table> </body> in above code creating 1 table dynamically programming part, based on result get. my question, how can give id part in table dynamically? ie table id="mytable3" ---> table3 given 3rd row element 2) table2 given 2nd row element since cant have same id in same html creating sequentially , assigning id can 1 suggest sample javascript code assigning id dynamically. can have better control later in order need 1 simple dom traversal function. getelementsbytagname . you can create purpose function loops through elements , adds id. function addids(container, elname, prefix){ // container var container=document.getelementbyid(container); // tables var tables=containe...

Migrating a Google App Engine application from Django 0.96 to Django 1.2 -

i start port different google app engine applications built default version of django (0.96) django 1.2. don't use specific django modules apart i18n stuff websites translated. i plan go through backwards-incompatible changes django 0.96 1.0 , different django release notes . current release notes available between 0.96 , 1.2: 1.2 release django 1.2.5 release notes django 1.2.4 release notes django 1.2.2 release notes django 1.2 release notes 1.1 release django 1.1.4 release notes django 1.1.3 release notes django 1.1.2 release notes django 1.1 release notes 1.0 release django 1.0.2 release notes django 1.0.1 release notes django 1.0 release notes i wondering if there better way of doing migration/upgrade, or if has done have useful tips. know there's lot of reading involved, , that's not i'm trying prevent, more pointers smoothen process. i have different applications migrate, start simple/small application gist of it. rather tr...

assembly - Having trouble calling C functions in NASM -

i creating nasm program calling c function in nasm code simplify life. undefined reference errors. have done wrong? here code below: command line commands used compile nasm -fwin32 calculator.asm gcc - wall -c print.c -o print.obj $ ld calculator.obj print.obj -o calculator.exe calculator.obj:calculator.asm:(.text+0x6): undefined reference `print' calculator.obj:calculator.asm:(.text+0x15): undefined reference `sum' calculator.obj:calculator.asm:(.text+0x24): undefined reference `int2string' calculator.obj:calculator.asm:(.text+0x2a): undefined reference `print' calculator.obj:calculator.asm:(.text+0x2f): undefined reference `ps' print.obj:print.c:(.text+0xd): undefined reference `printf' print.obj:print.c:(.text+0x20): undefined reference `atoi' print.obj:print.c:(.text+0x8b): undefined reference `printf' print.obj:print.c:(.text+0xbe): undefined reference `system' platform windows 7 64-bit compiling in 32-bit. shouldn't prob...

iphone: unable to post image on wall (facebook) -

i trying upload image facebook , gam getting image id uploaded in facebook , after getting id trying create request appending photo id in grap library everytime getting error. code worked failing nsstring *message = [nsstring stringwithformat:@"for test --> think uploaded !"]; nsurl *url = [nsurl urlwithstring:@"https://graph.facebook.com/me/photos"]; asiformdatarequest *request = [asiformdatarequest requestwithurl:url]; [request addfile:savedimagepath forkey:@"file"]; [request setpostvalue:message forkey:@"message"]; [request setpostvalue:_accesstoken forkey:@"access_token"]; [request setdidfinishselector:@selector(sendtophotosfinished:)]; [request setdelegate:self]; [request startasynchronous]; } - (void)sendtophotosfinished:(asihttprequest *)request { // use when fetching text data nsstring *responsestring = [request responsestring]; nsmutabledictionary *responsejson ...

invalid tokens in android XML -

just starting android development , trying create ui here.. getting following: /res/layout/main.xml:13: error: error parsing xml: not well-formed (invalid token) any ideas? <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <tablelayout android:id="@+id/entrybar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:stretchcolumns="1" > <tablerow <edittext android:id="@+id/taskentry" /> </tablerow> <tablerow <button android:id="@+id/add" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=...

flash - Copy to clipboard or download image of widget from web-app -

i'm using gwt develop web-app , want user able image of chart displayed. specific widget linechart (com.google.gwt.visualization.client.visualizations.corechart.linechart). the user should able copy contents of chart clipboard (as image) or download image of widget. i read zeroclipboard uses invisible flash movie copy text clipboard. there similar can used more text? my current work around provide imagelinechart (com.google.gwt.visualization.client.visualizations.imagelinechart) user can right-click save image. though don't since requires opening new chart in popup (so user can click on it) , imagelinechart looks different original linechart.

sql server - How to store data from a richtexteditor to accommodate searches? -

we're considering adding rich text editing our system. understand we'll heavily tagged string our textareas. wonder database searches text within data. there might non-html tags containing versioning comments or other stuff wouldn't want searched. how implemented? store data twice, once tags , once without? or there sql server tools skip tags during searches won't kill performance-wise? (we're on sql server 2005 now, moving 2008) i use full text search , include html tags stopwords. can read more these here . good luck!

symfony1 - Symfony 1.4 Ajax -

i want make form on ajax in symfony framework. problem way found jquery , .load function. way how pass post values? don't want hardcode flexible, how make ajax submission form in symfony 1.4 post data? how pass input posts in load function? thanks lot. .load fine. can grab values of form jquery. http://www.ryancoughlin.com/2009/05/04/how-to-use-jquery-to-serialize-ajax-forms/ the issue have bind form manually yourself(in controller). consider bigger issue :p

installation - Installing visual studio 2010 -

possible duplicates: visual studion iso file https://stackoverflow.com/questions/7774852/have-an-exe-file-that-opens-to i down loaded visual studio 2010 , went through installation process of choicing location , thought use program. asking me burn image disk. don't understand because thought exe file. name of file is: en_visual_studio_2010_premium_x86_dvd. how change exe file can use it. there way me convert it. kind of remember instructions saying have change extension exe. go make change in extension , redownload? have gotten copy of program @ school told download exe file computer. i'm confused. unfortunately can't. file provide iso, dvd image intended burned. you have other options: may want mount iso virtual optical drive, using software daemon tools lite or alcohol 120% . another option extract files iso folder, using compressing software winrar , 7-zip , etc..

c# - WPF Application exit code -

i trying set , application exit code . i trying following : protected override void onstartup(startupeventargs e) { base.onstartup(e); if ( e.args.length != 0) { } else { new mainwindow().showdialog(); } environment.exitcode = 110; this.shutdown(); } and trying in cmd echo %errorlevel% but result 0 , idea issue ? for wpf, try application.current.shutdown(110); note application needs running console app. this answer easiest way know of; accepted answer looks more difficult. an easy test tell if you're running in console mode: call app command line (make sure code doesn't shut down right away). main window should showing. if can type command in console, app not running in context. command prompt should locked, waiting close window.

php - setcookie doesnt work -

after set cookie doesn't work. when leave domain part away , test on localhost, can echo cookie though: setcookie("email",$email,0, "/", ".domainname.com"); if want test on localhost , make domain localhost . you wouldn't expect setting google.com allow set cookies google.com you?

php - Merging multiple HTML files into one and return output -

i trying find cleanest way merge multiple html files 1 html file. way can change parts of html or show them on pages. file list followed: page.tpl (header, footer, head info) sidebar.tpl (contains sidebar , sidebar blocks) nav.tpl(contains navigation links in nested ul) the page.tpl file looks this: <!doctype html> <html> <head> <title>page title</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="author" content="brandon" /> <meta name="robots" content="noindex,nofollow" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <?php print $stylesheets; ?> <?php print $scripts; ?> </head> <body> <section id="wrapper"> <header>header title</header> <nav><?print $nav; ?...

Learning pyramid (python) and am struggling with the @view_config decorator. Should it just work out of the box? -

i still learning pyramid, , @ point trying learn how use decorators. below copy of test view callable. from pyramid.response import response pyramid.view import view_config pyramid.renderers import render_to_response def my_blog(request): return {'project':'tricky'} @view_config( renderer='templates/foo.pt' ) def foo_blog(request): return {'name':'tricky'} from can understand view_config decorator, can used set application configurations without setting them in config file. in case of example, setting renderer templates/foo.pt. not ever work. however, if set renderer in config file ( init .py) such: config.add_route( 'foo_blog' , '/blog/{foo}' , view='tricky.views.blog.blog.foo_blog' renderer='tricky:templates/mytemplate.pt' ) it work. am doing wrong preventing me being able use decorator. thanks! in order configurations added via @view_config work, need call config.scan() @...

java - synchrozie get method from map? -

in order synchrozie map method use myobj = mymap.get("aaa"); if (myobj==null) synchronize (someobject){ myobj = mymap.get("aaa"); if (myobj==null){ myobj = createnew(); mymap.put(myobj); } } return myobj; is besdt way. asking null condition twice? synchronizing get isn't useful. get not change state of map. have synchronize put (with same object monitor). , can use collections.synchronizedmap(..) or concurrenthashmap that update: get & put can use concurrenthashmap.putifabsent(..)

javascript - how can i find closest span? -

let's having fallowing html structure- <div data-theme="a" class="ui-btn ui-btn-icon-right ui-btn-corner-all ui-shadow ui-btn-up-a"> <span class="ui-btn-inner ui-btn-corner-all"> <span class="ui-btn-text">select one</span> <span class="ui-icon ui-icon-arrow-d ui-icon-shadow"> </span> </span> <select onchange="selectstate(this,'addr_ship_state')" id="addr_ship_state" name="addr_ship_state"> <option>hi</option> <option>hello</option> <option>how</option> <option>are</option> <option>you</option> </select> </div> what trying on change of select box, take text of selected option , place inside span(replace select one data) having class name ui-btn-text below code ahve tried without luck...

c# - How can I extract just text from the html -

i have requirement extract text present in <body> of html. sample html input :- <html> <title>title</title> <body> <h1> big title.</h1> how doing you? <h3> fine </h3> <img src="abc.jpg"/> </body> </html> the output should :- this big title. how doing you? fine i want use htmlagility purpose. no regular expressions please. i know how load htmldocument , using xquery '//body' can body contents. how strip html have shown in output? thanks in advance :) you can use body's innertext : string html = @" <html> <title>title</title> <body> <h1> big title.</h1> how doing you? <h3> fine </h3> <img src=""abc.jpg""/> </body> </html>"; htmldocument doc = new htmldocument(); ...

c++ - static_assert - a way to dynamically customize error message -

is there way make static_assert's string being dynamically customized , displayed? mean like: //pseudo code static_assert(check_range<t>::value, "value of " + typeof(t) + " type not ;)"); no, there not. however not matter much, because static_assert evaluated @ compile-time, , in case of error compiler not print out message itself, print instanciation stack (in case of templates). have @ synthetic example in ideone : #include <iostream> template <typename t> struct isinteger { static bool const value = false; }; template <> struct isinteger<int> { static bool const value = true; }; template <typename t> void dosomething(t t) { static_assert(isinteger<t>::value, // 11 "not integer"); std::cout << t; } int main() { dosomething("hello, world!"); // 18 } the compiler not emits diagnostic, emits full stack: prog.cpp: in function 'void dosomething(t) [with ...

networking - Connect to server in vmware player while host is not connected to a network -

i using vmware player 3.1.0 on host os windows 7 professional 64-bit. guest is suse linux es 10. guest os (suse) runs jboss app server access host using http. used "bridged" connection set this. my problem: when connected network on host (using wired network adapter) can connect http server on guest os , browse application. however, when disconnected network on host (unplugged wire), cannot access guest os app server , browse application. use guest os ifconfig command find out ip address of guest os. ip address not change whether connected or disconnected. have tried using wireless data card, not work either. i have tried "nat" "host only" connection , rebooted guest not work either. think reason guest os can recognize physical network card (which disconnected). i need run machine (my laptop) independently of network because use demo , need able connect host os guest os. i not sure understand trying do, know setting working nat config...