Posts

Showing posts from June, 2012

C - differentiate between 0 and \0 in integer array -

possible duplicate: nul terminating int array i'm trying print out elements in array: int numbers[100] = {10, 9, 0, 3, 4}; printarray(numbers); using function: void printarray(int array[]) { int i=0; while(array[i]!='\0') { printf("%d ", array[i]); i++; } printf("\n"); } the problem of course c doesn't differentiate between 0 element in array , end of array, after it's 0 (also notated \0). i'm aware there's no difference grammatically between 0 , \0 looking way or hack achieve this: 10 9 0 3 4 instead of this 10 9 the array this: {0, 0, 0, 0} of course output still needs 0 0 0 0. any ideas? don't terminate array value in array. you need find unique terminator. since didn't indicate negative numbers in array, recommend terminating -1 : int numbers[100] = {10, 9, 0, 3, 4, -1}; if doesn't work, consider: int_max , or int_min . as last resor

authentication - CakePHP auth and validation -

i have app uses auth component. logedin members can alter data long have no validation rules in users model. when add array $validate in model logedin users cannot submit data database. i use 1 mysql table named users. in other words works don't have validation in signup view <?php class user extends appmodel { var $name = 'user'; ?> but when add validation this: <?php class user extends appmodel { var $name = 'user'; var $validate = array( 'email' => array( 'email' => array('rule' => 'email','required'=>true,'message' => 'enter proper mail') ) ); } ?> validation in signup view works users in secret area cannot enter data database. my guess is: happening because have set required true . this enforces rule when submitted data of user model, email key needs set. therefore, works in sign form has email key. on other hand, form you're using in se

Pulling in photos via Facebook Graph API -

i'm trying pull in tagged photos of current logged in profile. got session id appears it's empty array. <?php $photos = $facebook->api('me/photos'); $number_of_photos = count($photos[data]); ?> <?php ($i=0; $i < $number_of_photos; $i++) :?> <img src="https://graph.facebook.com/me/photos/<?php echo $photos[data][$i][url]; ?>"/> <?php endfor; ?> i'm aware code awful, i'm new php , trying few things. as stated documentation available here (scroll down 'connections'), in order user's photos must have explicitly given 1 of following permissions: user_photo_video_tags friend_photo_video_tags user_photos friend_photos permissions

html - CSS: Sidebar with folded header ribbon -

Image
now i've see various ways accomplish effect: i used accomplish table, i've since decided not use tables that. what's best way this? keeping in mind there's right border... <style> .left{ float:left; } .ribbontitle{ background:transparent url(/images/solid.png) repeat-x; height:20px; width:auto; } .ribbonend{ background:transparent url(/images/end.png) no-repeat; height:20px; width:10px; } .clear{ clear:both; } </style> <div class='left ribbontitle'>title</div> <div class='left ribbonend'>&nbsp;</div> <br class='clear'/> take 2 elements, float them left abutted each other. set repeating background of ribbon without end in div 1. set non-repeating background of ribbon "end" in other div

objective c - Cannot understand getter/setter with object -

it easy understand concept of setter/getter simple data, nsinteger example. if say: nsinteger a; the setter "a" changes value of a, , getter gets (returns) value. easy understand atomic/nonantomic concept since atomic guarantee reading "a" when being chnaged return whole value (getter , setter synchronized). but not understand setter , getter properties pointers objects (nsdata*, nsstring* example). let's example nsmutabledata: if say: nsmutabledata *m_my_mutable; imagine have setter setmymutable , getmymutable property belongs object myobject. if this, call getter (since object before appending data): [[myobject getmymutable] appenddata....] but appendingdata modify it, sould not seen setter action instead ? or setter refer fact of initiliazing value (which can retained example). there must missing in concept. thanks apple92 a setter sets value of property. when set integer property, new integer value stored. when set object prope

open source - Windows share indexing -

i'd index windows share workgroup of win7 clients using open-source technologies. users should able run full-text queries against contents of .doc, .xls, .ppt, .pdf, .txt, .rtf, etc. files added through unc path via drag-n-drop, no need manually trigger index update. what's software stack this? trying not use win indexing here. there various open source tools indexing documents, tend require tuning. i'd recommend at: solr lucene lucene.net although solr uses java, can run on windows . in cases need trigger indexing process or schedule it. might able use filesystemwatcher .net trigger indexing of new files depends on how need visible in search results.

generics - Data.Data -- producing dataCast1 for an arity 2 type constructor (partially specialized) -

so data.map has datacast2 defined, makes sense, has arity 2 type constructor. datacast1 defaults const nothing . datacast2 defined gcast2 . for reference: class typeable => data datacast1 :: typeable1 t => (forall d. data d => c (t d)) -> maybe (c a) datacast2 :: typeable2 t => (forall d e. (data d, data e) => c (t d e)) -> maybe (c a) ... gcast1 :: (typeable1 t, typeable1 t') => c (t a) -> maybe (c (t' a)) gcast2 :: (typeable2 t, typeable2 t') => c (t b) -> maybe (c (t' b)) the question @ hand this: given in data.data , data.typeable , etc., , given arity 2 type constructor datacast2 defined (say, map , or (,) ), possible write version of datacast1 right thing partial specialization of type constructor, either 1 specific constructor @ time, or in general? intuitively, think there should solution, first few tries crashed , burned. i'm not sure if want, might steer in right direction if it's

c - Is there a way to read HD data past EOF? -

is there way read file's data continue reading data on hard drive past end of file? normal file i/o use fread(), but, obviously, read end of file. , might beneficial if add need on windows computer. all googling way instead coming results unrelated topics concerning eof, such people having problems normal i/o. my reasoning accidentally deleted part of text in text file working on, , entire day's worth of work. googled bunch of file recovery stuff, seems recovering deleted files, problem file still there without of information, , i'm hoping of data still exists directly after marked end of file , neither fragmented elsewhere or claimed or otherwise overwritten. since can't find program helps specifically, i'm hoping can make (i understand that, depending on involved, might not feasible redoing work, i'm hoping that's not case). as far can foresee, though might not correct (not sure, why i'm asking help), there 3 possibilities. worst of three:

javascript - output all set attributes of an element -

Image
this question has answer here: get attributes of element using jquery 4 answers i have jquery object represents input button element on page. how can jquery output via console.log properties/attributes of element? assuming html of page is <body> <img id="smile" class="big" alt="smile" madeupattribute="yep" src="http://mikegrace.s3.amazonaws.com/forums/stack-overflow/smile.png"/> </body> you do var domelement = $("img")[0] // [0] returns first dom element jquery found $(domelement.attributes).each(function(index, attribute) { console.log("attribute:"+attribute.nodename+" | value:"+attribute.nodevalue); }); example page => http://mikegrace.s3.amazonaws.com/forums/stack-overflow/example-get-element-attributes-jquery.html example page console outpu

Problem in creating xml file from php -

i need in creating xml file php code. created function forms xml want it, dont know how save formed xml in file. also if tell me, next time, how can update created xml file. my code looks below: public function create_xml() { $output = "<?xml version=\"1.0\" encoding=\"utf-8\" ?> "; $output .= "<data>"; $output .= "<news>"; $news_articles = new c7_news(); $db = c7_bootstrap::getdb(); $foxsport_sql = "select headline, link c7_news source = 'foxsports' , category = 'breaking news' limit 0,4"; $foxsport_rowset = $db->fetchall($foxsport_sql); $data = array(); foreach($foxsport_rowset $foxsport_row) { $output .= "<title>"; $output .= "<description>"; $output .= "<![cdata["; $output .= $foxsport_row['headline'];

.net - Is it possible to execute an efficient multiple row DELETE or UPDATE using EF4? -

i'm developer still learning intricacies of ef4. aware of how pull down list of objects , iterate through deleting them in loop can't bring myself write code execute n statements (and database round-trips) n records when doing mass update or delete. a classic case deleting child records prior deleting related parent record maintain referential integrity... (yes, employ soft deletes default humor me) in stored procedure i'd execute sql, so: delete somechildtable foreigntableid = @keytogo delete parenttable id = @keytogo in linq sql this: datacontext.childrentable.deleteallonsubmit(from c in datacontext.childrentable c.parenttableid == keytogo select c); datacontext.parenttable.deleteonsubmit(parenttogo); datacontext.submitchanges(); in nhibernate this: nhsession.createquery("delete childrentable parenttable.id = :keytogo") .setint32(&q

ruby on rails - How to verify a user's password in Devise -

i'm having problem matching user password using devise gem in rails. user password stored on db encrypted_password , trying find user password, don't understand how match password form , encrypted_password in db. user.find_by_email_and_password(params[:user][:email], params[:user][:password]) i think better, , more elegant way of doing it: user = user.find_by_email(params[:user][:email]) user.valid_password?(params[:user][:password]) the other method generate digest user instance giving me protected method errors.

.obj files in Opengl with Textures -

so trying load .obj file c program using opengl graphics library. works fine, until add textures. image renders in black , barely visible, , because there white axis in center of window blocked object. i've narrowed down , think has .mtl file. if delete it, object @ least renders in white, normals lighting, , work fine. there no textures. i have been told meddle .mtl file, double check lighting numbers , such, don't know how or know reasonable numbers like. what problem/how fix it? thanks! opengl has no concept of .obj or .mtl , in fact has no idea file is. using separate third party library this, , problem lies there (or forgot add lights , texture coordinates)

c# - textbox_leave event fires twice when click on combobox -

hi have used textbox_leave method in order validate textbox , if mouse clicked on control want show message box. code shown below. private void txtbox_leave(object sender, eventargs e) { if(textbox.text != "this") { messagebox.show("not valid"); textbox.focus(); } } the issue when click on combobox in form messagebox pop twice. if click on other control works fine. how can solve problem? thanks in advance.. it more appropriate use combobox.selectedindexchanged or combobox.selectedvaluechanged validate value selected user combobox.

c# - DataGridVIew populated with anonymous type, how to filter? -

i've populated datagridview linq query returns anonymous type. question : chance filter datagridview data source anonymous? // setting datagridview data source rawdocumentsdatagridview.datasource = rawtopics .selectmany(t => t.documents) .select(d => new { documentid = d.id, rilevante = d.isrelevant, topicid = d.topic.id // foreign key }).tolist(); // make not visibile, waiting master change rawdocumentsdatagridview.visible = false; // when master selection changed... void rawtopicsdatagridview_selectionchanged(object sender, system.eventargs e) { if (rawtopicsdatagridview.currentrow == null) return; // selected topic id int tid = (int) rawtopicsdatagridview.currentrow.cells["topicid"].value; // filter rawdocumentsdatagridview based on topic id // warning: pseudo code var olddatasource = (list<anonymoustype>)rawdocumentsdatagridview.datasource;

javascript - How do I lay my DIVs in a unique grid? -

Image
currently, divs laid out this. it's basic float:left . easy but if want turn of square divs 1 twice wide/long? randomly selected, of course. how generate html/javascript , this? what's math behind this? float:left still work? can please give example of how can achieved easily? jquery masonry works this: http://desandro.com/resources/jquery-masonry/ ( demo )

wampserver - .htaccess not working on WAMP -

i have installed wamp on windows. found .htaccess files not working here. there way work .htaccess? click on wamp icon , open apache/httpd.conf , search "rewrite_module". remove # below , save it loadmodule rewrite_module modules/mod_rewrite.so after restart service.

iphone - Clear all Text Fields using a for loop? -

i've used: iboutlet uitextfield *text1, *text2; for referring textfields. and clear each 1 using: [text1 settext:@""]; [text2 settext:@""]; if wanted clear @ once using loop, how should write code ? u should assign tag each textfield(say 1,2) then ur code should follows, for(int i=1; i<=2;i++) { uitextfield *tf=(uitextfield *)[self.view viewwithtag:i]; [tf settext:@""]; }

Overview of Grails project structure -

i'm trying find overview grails project structure, possible. see, not projects used default structure generated "grails create-app" %project_home% + grails-app + conf ---> location of configuration artifacts + hibernate ---> optional hibernate config + spring ---> optional spring config + controllers ---> location of controller artifacts + domain ---> location of domain classes + i18n ---> location of message bundles i18n + services ---> location of services + taglib ---> location of tag libraries + util ---> location of special utility classes + views ---> location of views + layouts ---> location of layouts + lib + scripts ---> scripts + src + groovy ---

Finishing (or Accessing) a specific Activity in Android -

as activities opened user, they're stacked on view stack. , user finishes activity means, popped out of view stack. now, have situation user has opened app's home screen, , has successively opened multiple activities, on top of home screen. in each activity, there's control lets user see home screen again. as can think, there can 2 approaches this: on press of control, pop home screen bottom of view stack , push on top of it. as control pressed, start popping each of current screen until home screen becomes current screen. i know there's way in android @ least 1 of this, or this. can't remember it. please me choose better approach, , let me know way (the code, specifically) it. thanks lot :) (please edit title/text if isn't appropriate) try this intent = new intent(); i.putextra(extra_key_artist, id); i.setclass(this, artistactivity.class); i.addflags(intent.flag_activity_single_top); startactivity(i); that's

c# - Copy permissions from one Windows Folder to another -

i need create small c# windows app copies security permissions 1 folder another. includes copying group permissions too. best way approach such challenge? yosief kesete first out folder directoryinfo out instance of directorysecurity class using getaccesscontrol method. you'll able call getaccessrules , addaccessrule should started.

Control menu display and page level security using Active directory for an ASP.NET website -

i control menu display (show/hide menu items) in asp.net 3.5 website based on user's ad group , control functionality within page using user's active directory group membership. how this? menu stored in xml file , bound control. all examples see on web related forms authentication. intranet website integrated windows authentication , both authentication , authorization should controlled using user's active directory groups. in advance. i got answer in asp.net forums same question, posting here if interested. http://forums.asp.net/p/1628890/4193568.aspx#4193568 .

linq - Using an SPMetal entity class -

i'm executing code below information page via linq . works fine, how convert , using entity class generated spmetal command? guid siteguid = spcontext.current.site.id; using (spsite site = new spsite(siteguid)) { using (spweb web = site.openweb()) { splist lespages = web.lists["pages"]; var resultat = splistitem page in lespages.items page.contenttype.name.equals("pagenews") && page.moderationinformation.status.equals(spmoderationstatustype.approved) select page; foreach (splistitem r in resultat) { contenu += "_moderationstatus: " + r["_moderationstatus"] + "<br>"; contenu += "fileleafref: " + r["fileleafref"] + "<br>"; contenu += "publishingpagecontent: " + r["publishingpagecontent"] + "<br>";

mysql - Reuse expression in SQL sentence -

i'm using mysql , i'm going mad trying simplify bit complex sql sentence. the query this: select `provider`.*,`products`.`placement`,`price`.`price`+ ifnull((select `price` `price` `handle`= (select `group` `group_provider` `provider_id`=`provider`.`id`)),'0') `price` `provider` left join `products` on `provider`.`id`=`products`.`web` left join `price` on `price`.`handle`=`provider`.`id` `products`.`type`='$product_type' , `price`.`price`+ ifnull((select `price` `price` `handle`= (select `group` `group_provider` `provider_id`=`provider`.`id`)),'0')>0 this query working perfect, problem have repeated item , don't know how simplify it. repeated item i'm talking is: `price`.`price`+ ifnull((select `price` `price` `handle`= (select `group` `group_provider` `provider_id`=`provider`.`id`)),'0') any idea simplify it? thanks create view of data includes column , query view. once have creat

.net - NHibernate - When adding an object to a many-to-many collection, existing objects are removed and reinserted -

i'm using many-to-many mapping table maps fields objects. relevant db structure... objects: table (pk) objectid [ rest irrelevant ] fields: table (pk) fieldid [ rest irrelevant ] objectfields: table (pk) fieldobjectid (fk) fkobjectid -> objects (fk) fkfieldid -> fields my mapping looks this: <bag name="fields" table="objectfields" lazy="true" cascade="all"> <key column="fkobjectid"/> <many-to-many class="field" column="fkfieldid" /> </bag> now, collection operations work expect - retrieving, adding , deleting. however, there odd thing happening. if add object "fields" collection, nhibernate deletes there , reinserts it. here log4net dump: debug nhibernate.sql [(null)] - select this_.objectid objectid6_0_, this_.name name6_0_, this_.description descript3_6_0_, this_.rootelement rootelem4_6_0_, this_.childelement childele5_6_0_, this_.imageurl im

asp.net - Wrong encoding when getting response from Google's translate API? -

i using google translate api translate text english german. code using is: string url = string.format("http://www.google.com/translate_t?hl=en&ie=utf8&text={0}&langpair={1}", txtenglish.text, constants.languagepair); webclient webclient = new webclient(); webclient.encoding = system.text.encoding.utf8; webclient.downloadstringcompleted += new downloadstringcompletedeventhandler(texttranslation_downloadstringcompleted); webclient.downloadstringasync(new uri(url)); on receiving response in e.result ....... original text: can me? translated german text on translator page: können sie mir helfen result in e.result : k�nnen sie mir helfen so, plz me know why "�" special character coming , how can fix issue?? use fiddler check response headers , find encoding in there. the way being shown unrelated data receive , related way representing in ui code. share , have look.

c# - What is the minimum memory requirement for splitting a TIFF file to multiple TIFF files? -

i have query minimum memory requirement splitting tiff file multiple tiff files. running less 2gb memory or not. have suggestion. please reply urgent. thanks dinesh kumar it depends, obviously, on how big input tiff file is, , how going split up. did try calculations? or perhaps try out?

javascript - Change current element background in jQuery -

<label class="default" for="checkbox1"><input id="checkbox1" name="checkbox1" type="checkbox" style="display:none" /> text</label><br /> <label class="default" for="checkbox2"><input id="checkbox2" name="checkbox2" type="checkbox" style="display:none" /> text</label><br /> <label class="default" for="checkbox3"><input id="checkbox3" name="checkbox3" type="checkbox" style="display:none" /> text</label><br /> how should change clicked checkbox's label background color using jquery? example when second checkbox checked it's style should changed "checked": <label class="checked" for="checkbox2"><input id="checkbox2" name="checkbox2" type="checkbox" style=&quo

embed - Question about embedding Flash: swfObject vs < Object > -

i noticed flash cs5 ide publishes lean html code (see below) appears utilise < object > tag. seems work - although have nagging feeling should using swfobject .. how swfobject different < object > tag? i've tested code on browsers (ie6 included) no problems. is time ditch swfobject? or there features i'm overlooking? if swfobject "standard" why doesn't latest flash ide utilise it? <object id='myswf' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='100%' height='100%'> <param name='movie' value='index.swf'> <param name='allowfullscreen' value='true'> <param name='bgcolor' value='#919191'> <!--[if !ie]>--> <object type='application/x-shockwave-flash' data='index.swf' width='100%' height='100%'> <param name='allowfullscreen' value='true'> <p

c# - Entity Framework Contains/In Clause with SQLCE -

i trying select items sqlce table, field exists in string array. easy in sql with: select * tablex somefield in ([comma delimited array values]); i having difficult time transposing linq. following logically work, receiving error: linq entities not recognize method 'boolean contains[string](system.collections.generic.ienumerable`1[system.string], system.string)' method, , method cannot translated store expression. var result = c in db.tablex somestringarray.contains(c.somefield) select c; please let me know if has ideas or advice. thanks! update: the following, reccomended below, throws notsupportedexception, error message, class x class calling enumeration: unable create constant value of type 'namespacex.classx'. primitive types ('such int32, string, , guid') supported in context . var result = c in db.tablex somestringarray.any(s => s == c.somefield) select c; try var r

default resoultion for android launcher icon -

android icon guidelines says use icon of size 36*36pixels ldpi , 48*48 mdpi 72*72pixels hdpi (http://developer.android.com/guide/practices/ui_guidelines/icon_design.html). value should give pixels per inch while creating icon?(photoshop shows 72 pixels/inch default value while creating new icon) i quite sure not matter @ all. far reckon, dpi in photoshop , other (non vectorial) image editing software used when want print image. if not convinced, try different settings image's dpi , check whether changes anything.

eclipse - Sending and receiving text using android emulator -

i'm developing android application includes text messaging. possible send , receive text messages using android emulator? if yes, how can it? it's quite easy: open console connect via telnet running emulator: telnet localhost 5554 (you can find portnumber in title of emulator) type this: sms send senderphonenumber textmessage

web services - native C++: WSDL proxy generation library -

it necessary communicate webservice c++ mfc application. can add reference service, wsdl generated if simple types used only. attempt generate proxy methods complex types returns error: does not support extension of complextype here suggestions fix that: http://support.xignite.com/entries/168861-getting-around-the-sdl1030-sproxy-exe-does-not-support-extension-of-complextype my intention generate wsdl proxy generation library. question: please advise library wsdl proxy generation? on linked page http://ws.apache.org/axis/ advised library suggested. did used it? fine? is gsoap looking for? can generate both client , server sides of web service in c or c++.

linux - How to tar a fifo -

i want tar output of program writes stdout , fifo @ fd=3. here first attempt: #!/bin/bash #create fd=3 exec 3> >(cat) #start tar tar -cvzf ha.tgz /dev/fd/1 /dev/fd/3 #write data echo stdout echo 'fd=3'>&3 #close exec 3>&- it created ha.tgz , contents /dev/fd/1 , /dev/fd/3. when extract files, creates symlinks /dev/fd/1 , /dev/fd/3 (which broken). hoping files regular files content echo'd in script. there way this? is there way this? no. entries under /dev not real files, file-like interfaces device drivers. if want regular files, use regular files.

c - Resolving ambiguous grammar without resorting to GLR-Parser -

i have grammar has 2 different possibilities when parsing 'if' expr 'then' . there's simple "assignment", such if foo bar=1; else bar=0; there's i'm calling "if_block" of code can contain 1 or more "assignments": if foo { bar = 1; if xyz abc = -1; } else { bar = 0; if xyz { abc = 0; } } i'm handling nested if_blocks way of dangling else matched/unmatched block. my ( very simplified) grammar basically: program : if_blocks if_blocks : if_block | if_block if_blocks if_block : assignments assignments : assignment | assignment assignments assignment : simple_assignment | if_assignment so predicament assignment followed if_block. example: foo = bar; if foo { foo = foo + 1; } foo = bar; assignment that, in case, should reduced if_block. if foo { ... } if_block. whole code if_block+if_block (reduced if_blocks). after foo = bar; reduced assignment, there's not enough look

vb6 - Deploying apps created using QuickBooks SDK -

i have written application interfaces qb pro in vb6. deploy client's system. dlls and/or msms should include in installer? i using visual studio installer create msi. thank in advance advice. you don't want install copies of intuit sdk dlls. merge modules need in sdk, in path program files\intuit\qbsdk\tools. in directory find both stand-alone installation executables , merge modules. in mergemodules directory, find merge modules both qbfc , qbxmlrp2. if using visual studio create msi best way add correct merge modules add intuit sdk mergemodules directory search path of setup project. this, select project in project explorer, click property pane or hit f4. should bring setup project properties should able see searchpath property. once have added mergemodules directory searchpath, should see merge modules added automatically in detected dependencies folder of setup project. see both intuit module (either qbfc or qbxmlrp2) , xerces parser merge module (the

sql - Resolving an ADO timeout issue in VB6 -

i running issue when populating ado recordset in vb6. query (hitting sqlserver 2008) takes 1 second run when run using ssms. works fine when result set small, when gets few hundred records takes long time. 800+ records requires 5 minutes return (query still takes 1 second in ssms), , 6000+ takes on 20 minutes. have "fixed" exception increasing command timeout, wondering if there way work faster since not seem actual query requires time. such compressing results doesn't take long. recordset opened follows: myconnection.commandtimeout = 2000 myconnection.connectionstring = "provider=sqloledb;" & _ "initial catalog=db_name;" & _ "data source=server_name" & _ "network library=dbmssocn;" & _ "user id=user_name;" & _ "password=password;" & _ "use encryption data=true;" myconnection.open myrecordset.open stored_proc_query_stri

Jquery and Regular Javascript Interference -

im building site in joomla , purchased content slider built in plain old javascript, built content boxes have animation on them provided jquery. right animations work, slider doesn't. wondering how page work using both. here's code <script src="http://code.jquery.com/jquery-1.4.4.js"></script> <script>jquery.noconflict(); $(document).ready(function() { //settings var opacity = 0.5, toopacity = 1, duration = 350; //set opacity asap , events $('.opacity').css('opacity',opacity).hover(function() { $(this).fadeto(duration,toopacity); }, function() { $(this).fadeto(duration,opacity); } ); }); </script> try calling after libraries loaded: jquery.noconflict(); also, try replacing jquery ready function this: jquery(document).ready(function($){ this passes $ shortcut jquery code block, should still avoid conflicts outside it. you can read on subject here in jquery docs.

jquery, set focus on the first enabled input or select or textarea on the page -

it's straightforward. want set focus first enabled , not hidden control on page. for textbox, have $("input[type='text']:visible:enabled:first").focus(); but want "all" form input controls: textbox, checkbox, textarea, dropdown, radio in selector grab first enabled , not hidden control. suggestions? $(':input:enabled:visible:first').focus();

design patterns - Use Local Storage as an autosave proxy - good or bad? -

we developing web app uses auto save save pattern. feature came quite unexpected ui problems. in order enhance user understanding of concept, wanted make autosave instant, not periodic visual feedback everytime document saved. we thought using local storage temporary data cache, , set slower interval synchronizes user data web server in background. might have bad side-effects when dealing possible revision conflict scenarios. has had experience autosave patterns and/or using local storage data proxy, , can share valuable information i assume instant mean after every user edit action (or keypress or whatever)? depends on data have here. if have text documents see no reason why not directly interact server add sleep time example: if user edits set switch edited = true, if last commit longer 10 seconsd ago, commit current state (the document may have changed in time, use current state) set last commit switch current time. i think local buffer complicated , brings

c# - Marshalling double parameters with P/Invoke -

i have problem p/invoke call i'm trying do. have call c++ class c# program. have source of class did put in dll project , create export functions access it's main method. should enough need , keep things simple. my export method looks : extern "c" _declspec(dllexport) void inference(double *c1, double *c2, double *c3, double *result) { /* somecode */ } this compiles, , can see export in dumpbin output. now problem is, can't call method c# code because pinvokestackinbalance exception, telling me this because managed pinvoke signature not match unmanaged target signature. i tried calling method : [dllimport("inferenceengine.dll")] extern static unsafe void inference(double *c1, double *c2, double *c3, double *result); i tried : [dllimport("inferenceengine.dll")] extern static void inference(ref double c1, ref double c2, ref double c3, ref double result); ... both possible ways documented on msdn no luck. have

iphone - How do faces in .obj work? -

when parsing .obj-file, vertices , vertex-faces, easy pass vertices shader , use gldrawelements using vertex-faces. when parsing .obj-file, vertices , texture-coordinates, type of face occur: texture-coordinate faces. when displaying textures, apart loading images, binding them , passing texture coordinates parser, how use texture-coordinate faces? differ vertex-faces , suppose texture-coordinate faces have purpose when displaying textures? regards niclas not sure you're asking, if understand correctly, you're wondering how store data texture coordinates render textured 3d object. if so, store vertex-normal-texturecoordinate data in interleaved format, below: vertexx vertexy vertexz normalx normaly normalz texturex texturey texturez once have array of these, create pointers different parts of array , render below: glenableclientstate(gl_vertex_array); glenableclientstate(gl_normal_array); glenableclientstate(gl_texture_coord_array); glvertexpointer(3,

iphone - NSPredicates beginsWith -

i have nsarray contents strings format similar to: [a-z]{+}-[0-9]{+} so bunch of repeating alpha characters, separator, , 1 or more digits i want filter values in array match separator can't seem explicitly specify in predicator's format: nspredicate *apredicate = [nspredicate predicatewithformat:@"self beginswith %@", avalue]; nsarray *filtered = [entries filteredarrayusingpredicate:apredicate]; how constrain filtering such case? you use "matches" operator regular expression search, so: nspredicate * p = [nspredicate predicatewithformat:@"self matches %@", @"[a-z]+-.*"]; nsarray * s = [nsarray arraywithobject:@"abc-123"]; nslog(@"%@", [s filteredarrayusingpredicate:p]); there caveat, though. regular expression matched across entire string. if want find elements begin 3 letters, expression can't "[a-z]{3}". has "[a-z]{3}.*". first fail that's not 3 letters, wher

uigesturerecognizer - UITapGestureRecognizer waiting for second tap, buttons slow -

i have uitapgesturerecognizer waiting doubletap zoom out scrollview original level. there situation add couple of buttons on top of scrollview. these buttons react slow (sluggishly) because once tap button, app waiting second tap. if not come, button pressed. anyone have idea on how buttons respond quickly? can temporarily disable gesturerecogniser while buttons up? cheers nick what filtering touches on buttons so: - (bool)gesturerecognizer:(uigesturerecognizer *)gesturerecognizer shouldreceivetouch:(uitouch *)touch { // don't recognize taps in buttons return ((! [self.button1 pointinside:[touch locationinview:self.button1] withevent:nil]) && (! [self.button2 pointinside:[touch locationinview:self.button2] withevent:nil])); } ?

firefox - Get unobfuscated source from browser after click -

a webpage has contents obfuscated in sophisticated way (at least me). i'm unable decipher page source. anyway, when clicking link on page, onclick java function gets called , page becomes readable. @ point, generated source in browser readable. is there programming tool (like mechanize or sth., preferrably perl) load page in firefox, click link , unchipered html? any suggestions how attack problem? try using chrome , check deobfuscate source option, in developer tools, javascript viewer.

c# - Soap server address in silverlight -

in silverlight light apps im connecting asmx or wcf web service. i wonder best way of holding url in app of soap client should looking at. this fine in debug because sort of knows, in release , depending using ip or swaps production servers keep getting tripped up. i love there sort of client config bit web config your service endpoints can go in servicereferences.clientconfig file. xml file , can changed @ point needed; ie..at deployment, etc...

Centering elements in jQuery Mobile -

does jquery mobile framework have way of centering elements, buttons? looks defaults left-aligning , can't find way (within framework) this. jquery mobile doesn't seem have css class center elements (i searched through css). but can write own additional css. try creating own: .center-button{ margin: 0 auto; } example html: <div data-role="button" class="center-button">button text</div> and see happens. might need set text-align center in wrapping tag, might work better: .center-wrapper{ text-align: center; } .center-wrapper * { margin: 0 auto; } example html: <div class="center-wrapper"> <div data-role="button">button text</div> </div>

More efficient way to merge arrays in PHP? -

here's i'm doing: $daterange = array('2010-01-01', '2010-01-02', '2010-01-03', ...); $data = array('2010-01-01' => 5, '2010-01-03' => 7); foreach ($daterange $date) { $values[$date] = $data[$date]; } $values results in: array ( '2010-01-01' => 5 '2010-01-02' => null '2010-01-03' => 7 ... ) seems efficient, wonder if there's simple php function that'll handle this. $values = array_merge(array_fill_keys($daterange, null), $data); whether that's more efficient can found out through testing, i'd it's more concise, easy understand, , it doesn't throw errors non-existent keys in $data . :)

java - JOptionPane.showMessageDialog truncates JTextArea message -

Image
my java gui application needs show text end-user, joptionpane utility methods seem fit. moreover, text must selectable (for copy-and-paste) , long (~100 words) must fit nicely window (no text off screen); ideally should displayed @ once user can read without needing interact, scrollbars undesirable. i thought putting text jtextarea , using message in joptionpane.showmessagedialog easy appears truncate text! public static void main(string[] args) { jtextarea textarea = new jtextarea(); textarea.settext(gettext()); // string of ~100 words "lorem ipsum...\nfin." textarea.setcolumns(50); textarea.setopaque(false); textarea.seteditable(false); textarea.setlinewrap(true); textarea.setwrapstyleword(true); joptionpane.showmessagedialog(null, textarea, "truncated!", joptionpane.warning_message); } how can text fit entirely option pane without scrollbars , selectable copy/paste? import java.awt.*; import javax.swing.*; public class te

java - javac -Xlint:overrides not working -

i'm trying java build fail when have class overrides superclass method without specifying @override annotation. the build being done via ant, , i've added following elements <javac> task: <compilerarg value="-werror"/> <compilerarg value="-xlint:unchecked,overrides"/> the unchecked option being followed, overrides option being ignored. tried separating 2 xlint options 2 separate <compilerarg> elements, no avail. misunderstanding option does? one note: jdk6 on macosx (10.6). running osx-specific bug? i believe misunderstanding xlint:overrides behaviour. to knowledge, enabling check cause compiler emit warnings (or maybe errors) when encounters method annotated @override not override superclass method. not, however, check overridden methods annotated correctly. edit: tested it. compiler emit error when specify @override on method not override superclass method, or without xlint option. the document

forms - jQuery - Multiple Triggers for the Same Function -

i'm developing jquery, i'm beginner it's little bit bloated , not elegant. basically, want cookie value nullified when either 1 of 2 forms submitted or submit buttons clicked. don't know how consolidate conditions of function have write out function once, best can this: $('form#searchform-basic').submit(function() { $.cookie('tab_cookie', null); }); $('form#searchform-basic a.search').click(function() { $.cookie('tab_cookie', null); }); $('form#searchform-advanced').submit(function() { $.cookie('tab_cookie', null); }); $('form#searchform-advanced input#search-button-submit').click(function() { $.cookie('tab_cookie', null); }); there's got better way, right? and before asks, yes, think you'd need know when forms being submitted. leaving out click events means function doesn't run when submit buttons clicked. don't know why that, is. give function name, so:

c# - MVC + How can i alert prompt user before Controller action -

mvc newbie here. i want user confirmation before controller action (update record) my code: [httppost] public actionresult jobhandlerupdate(int jobscheduleid, jobhandlerlist jobhandlerlist) { var updatejobhander = new mainjobhandler(); var item = updatejobhander.getbyid(jobscheduleid); if (modelstate.isvalid) { list<string> days = jobhandlerlist.jobprocessdayofweek.split(',').tolist(); updatejobhander.update(item, days); if(jobhandlerlist.maxinstances == 0) { // here need prompt user if maxinstances entered zero- job disabled want processs (y/n) if yes update else nothing or redirect edit screen } return redirecttoaction("jobhandler"); } return view(item); } do need using javascript alert? or there way. you can onclick event handler: <input type="

qt - QGraphicsItem validating a position change -

i have custom qgraphicsitem implementation. need able limit item can moved - i,e. restrict area. when checked qt documentation suggested: qvariant component::itemchange(graphicsitemchange change, const qvariant &value) { if (change == itempositionchange && scene()) { // value new position. qpointf newpos = value.topointf(); qrectf rect = scene()->scenerect(); if (!rect.contains(newpos)) { // keep item inside scene rect. newpos.setx(qmin(rect.right(), qmax(newpos.x(), rect.left()))); newpos.sety(qmin(rect.bottom(), qmax(newpos.y(), rect.top()))); return newpos; } } return qgraphicsitem::itemchange(change, value); } so basically, check position passed itemchange, , if don't it, change , return new value. seems simple enough, except doesn't work. when checked call stack see itemchange being called qgraphicsitem::setpos, doesn't @ return

C# HttpWebRequest and Javascript based form submittion actions -

i trying make simple web crawler learning experience , have hit wall. able set cookies, cookies, , keep cookies on session stuck when attempting submit login information. looking @ source of website see login form has username , password field submit button who's action javascript call. if post call wouldn't have problem can't figure out how handle logging in using httpwebrequest. possible? if not how can go doing this? (can i?) just because javascript call doesn't mean can't post. read javascript , see does, similar.

ExpressionEngine templates: pass a plugin/module's output as parameter to another plugin/module -

here's want accomplish: {exp:plugin1:method arg="{exp:plugin2:method}"} i’ve tried number of different approaches. approach 1: {exp:plugin1:method arg="{exp:plugin2:method}"} result: plugin1->method ’s arg parameter value string, {exp:plugin2:method} , , it’s never parsed. approach 2: my understanding of parsing order suggests might have different results, apparently not. {preload_replace:replaced="{exp:plugin2:method}"} {exp:plugin1:method arg="{replaced}"} result: arg parameter has same value approach 1. approach 3: first define snippet ( snip ), content is: {exp:plugin2:method} then in template: {exp:plugin1:method arg="{snip}"} result: same approaches 1 , 2. approach 4: noting plugins processed in order appear, have tested placing instance of {exp:plugin2:method} before {exp:plugin1:method} call. thinking wrap first call in regex replacement plugin in order suppress output, trigger

php - Don't store variable if not set -

function append_url( $link, $sort ) { $sort = $_get['sort']; if ( isset($sort) ) { $link = add_query_arg( 'sort', $sort, $link ); } return $link; } i notice undefined index: sort when no sort parameter exists. best way check if sort param exists before creating $ sort variable? $sort = array_key_exists('sort', $_get) ? $_get['sort'] : null; also, if you're setting $sort value $_get, why pass in argument function? seems redundant.

converting jar to native dll -

this first post here. please let me know if doing wrong in posting. coming question, have jar(bundled collection of jars one) , jar doesnt have main method. have convert jar dll , write c code using dll. (native language bindings). so, there tools convert jar native dll? googling , came across ikvmc converts jar .net dll. difference between normal dll , .net dll? can use ikvmc work? or there other tools converts jar native dll? see many tools can covert jar exe not jar dll. please me.thanks.. look @ instantiating jvm in c , wrap code in new dll required. how call java functions c++?

c# - In ASP.NET 3.5, what is the .Tag Namespace? -

i using textbox1.tag + textbox1.text calculator tag part not accepted. namespace must use accepted in asp.net 3.5 application? you might thinking windows forms rather asp.net the tag property property on system.windows.forms.control isn't web control. have @ system.web.ui.webcontrols.textbox information on available properties.

iphone - Finding details of the NSError webkit domain -

i unable find details of nserror webkit domain, including definition of error codes in domain. search in ios docs yields nothing, nor search here on so, or in ios forums. think ought in header file, i'm unsure how find it. can find info? how webkit constants reference the header file looking cunningly named webkiterrors.h

php - Finding all possible ways to swap cards -

i working on php application finds possible ways swap cards. each user has @ least 1 card. when user request card, application shows him possible ways swap card in excange card requested. lets that: user 1 has card type user 2 has card type b user 3 has card type c and lets assume that: user 1 wants card type c user 2 wants card type user 3 wants card type b if user 1 requests card c, solution that: user 1 gives user 2 card user 2 gives user 3 card user 3 gives user 1 card but if there 2 other users: user 4 has card type b & wants card type user 5 has card type c & wants card type b now, if user 1 requests card c, there 1 other solution besides 1 above : user 1 gives user 4 card user 4 gives user 5 card user 5 gives user 1 card there no limit in terms of how many cards user may have or request. far, created 2 sql tables. table "cards" keeps track of each userid , cardid. table "requests" keeps track of each userid , desired cardid

swapfile - Change Vim swap/backup/undo file name -

is possible change way vim names swap/backup/undo files? to avoid clutter, i've set options in ~/.vimrc dump these files in ~/.vim/tmp/{swap,backup,undo} ; however, routinely edit files in different directories same name, end lots of otherwise indistinguishable files , vim has trouble recovering. ideally, i'd use naming scheme persistent undo has ( %path%to%file.undo ) these auxiliary files; there's no obvious way set it, can done buf{read,write} macros? i have in .vimrc , names swap files full path names , percent signs describe: " store swap files in fixed location, not current directory. set dir=~/.vimswap//,/var/tmp//,/tmp//,. the key // @ end of directories. see note :help dir : for unix , win32, if directory ends in 2 path separators "//" or "\\" , swap file name built complete path file path separators substituted percent '%' signs. ensure file name uniqueness in preserve direc

c# - MethodAccessException with Reflection on Windows Phone 7 -

while working reflection, got point wanted access object (in fact, static instance of object). the object defined internal class, therefore there no other way access it. instead of directly getting parametrized constructor, can access static instance via instance property. of reflection, able property , set propertyinfo instance - detected correctly. however, not able value of property via getvalue (since called via get_instance() in internal class itself) , set object because getting methodaccessexception . the internal class marked securitysafecritical , believe shouldn't problem. any ideas on why getting exception? have @ methodaccessexception . it says this exception thrown in situations such following: * private, protected, or internal method not accessible normal compiled code accessed partially trusted code using reflection. * security-critical method accessed transparent code. * access level of method in class library has change

iphone - How to improve performance while using UIWebView in cells of table view? -

i creating application uses web service.and retrieves list of users , there details images, user id , there names.i displayed information related users in table view, each of cell in table view has image tables in it. using custom cell class create individual cells. selecting row in table presents detail view (using navigation) show larger image , details related particular user selected. in customcell , detail view class using web view display image. when run app images gets bit of delay display , same happens detail view. is there alternative can improve performance of table view can have smooth scrolling of table view out delay in image loading , detail view?? here code... - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *customcellidentifier = @"customcellidentifier "; customcell *cell = (customcell *)[tableview dequeuereusablecellwithid

iphone - Guide me on iOS Developer Program -

Image
i have ios developer program membership paid $99. have installed certificate in 1 system, , i'm able run application on real device. is possible install certificate on system, such can run application on real device? when try install same certificate on system, i'm not able working. read submitting iphone apps apple app store – step step guide —in particular, last paragraph, "managing digital identities": also read: ios development workflow guide: managing devices , digital identities

css - How to use seleniumRC in Junit framework on dynamically changing elementids -

i trying automate work flow process .in this,i need click on link positioned in of rows of table.thing links available in rows have same element id , in source code have java script " ("element id" @ onclick.. java script **** :).....so here after clicking connecting 1 form form inputting value in java script code , 1 value in java script dynamically changes.how click on link now?is there solution using xpath or so...to click on link based on css classid or so...please me out..main problem is...all links in rows have same element id , dynamically changing java script . trying use selenium.focus() , selenium.clickandwait().but these helpless.as not able identify link id only. the best way xpath. something //*[@onclick='javascript'] work can make tests extremely flaky because if inline javascript changes or if removed in preference of addeventlistener element. something //*[@class='cssclass'] work. think need speak developers , ask them

heartbeat - Heatbeat 2.13 for solaris 10 -

i setting high availability cluster server using heartbeat in solaris 10. have compiled , add package after couple of hours tried. however not find documentation online solaris 10 configuration in 2 nodes. linux system(since heartbeat linux openware) have ever configure in solaris 10 , make work? thanks in advace if helpful tips a more usual configuration 2 cluster nodes , quorum server. have never had develop heartbeat software describe in order solaris cluster going. solaris has own version, , meant geo cluster. geo cluster == geographically spread out cluster this explains using heartbeat geo cluster: http://docs.sun.com/app/docs/doc/821-1416/6nmdd2phk?l=en&a=view

ios - Sending release after [[NSString alloc] init] causes EXIT_BAD_ACCESS -

i think there did not understand in memory management in xcode , when or not release objects avoid memory leaks. have been reading presentation, since there no audio dont understand sides: http://www.slideshare.net/owengoss/finding-and-fixing-memory-leaks-in-ios-apps-5251292 here simple code of app issue: // implement viewdidload additional setup after loading view, typically nib. - (void)viewdidload { [super viewdidload]; nsstring *mybundlename = [[nsstring alloc] init]; nsstring *mybundleversion = [[nsstring alloc] init]; nsstring *mybundlebuild = [[nsstring alloc] init]; nsstring *myiosname = [[nsstring alloc] init]; nsstring *myiosversion = [[nsstring alloc] init]; mybundlename = [[nsbundle mainbundle] objectforinfodictionarykey:@"cfbundlename"]; mybundleversion = [[nsbundle mainbundle] objectforinfodictionarykey:@"cfbundleshortversionstring"]; mybundlebuild = [[nsbundle mainbundle] objectforinfodictionarykey:@"cfbundleversion"];