Posts

Showing posts from July, 2011

user interface - Reference documents for GUI implementation -

i'm writing gui library opengl project i've been working on- basic stuff @ point, handling position of text on screen. i've spent time looking documents refer while designing thing, seem find notes on gui theory, rather implementation. i'm not interested in things usability heuristics , rather statements "the decorator design pattern useful when designing guis". things talk particular implementation details, how efficiently handle relative positioning, or ways structure gui screen transitions possible. i'll keep doing googling, , post links particularly useful find, thought i'd reach out community advice on books, blog entries, tutorials, etc. so far, i've found 1 result: martin fowler's overview of gui architectures provides nice overview of different design patterns. topics covered include mvc, mvp, , few other similar methods. still looking. i'll update when find more.

preg replace - How to do preg_replace on a long string -

i want able find , replace long line javascript code. code has lot / , \ in too. is possible? you can modify limit manually php allow handle long strings. put following line somewhere before calling preg_replace. ini_set('pcre.backtrack_limit', 99999999999); even better, if can modify php.ini file, can change value of pcre.backtrack_limit there new limit globally available.

How can I log the outgoing request of urlfetch in google app engine python? -

i'm having trouble getting oauth work linkedin in gae python , suspect it's format of outgoing request. how can log or somehow view outgoing request devserver making oauth provider? you can registering api call hook urlfetch requests. can see complete contents of request or response object logging request.toascii() or response.toascii()

problem with .blur function using jquery -

i have application zooms in image on focus() , zooms out on blur() . have read original image size , added 15px in order create zoom in effect, works fine. problem zoom out effect i'm trying pass original image size have read .blur() no luck. 1 me solve issue? here working demo of following code. first, weren't calling $.data() method on orgw , orgh in .blur() function. also, i've altered .blur() function have similar implementation .focus() function in order zoom out work: $('button:has(img)').blur(function() { if (timer !== null) cleartimeout(timer); var $image = $(this).find('img'); $image.each(function() { $(this).animate({ 'width': $.data(this, 'orgw') + 'px', 'height': $.data(this, 'orgh') + 'px', }, 500); }); });

inheritance - Django: app_label problem when declaring base models outside models.py -

i have abstract container class allows derived models hold content blocks such images, text, etc., separate models. db tidiness, want tables models labeled content_block_image, content_block_text, etc. but when specify app_label = 'content_block' in meta class of content model, getting error during syncdb: content.event: 'content' has m2m relation model content, has either not been installed or abstract. i declaring following base classes follows: # base.py class content(models.model): tags = models.textfield(_('tags'), blank=true) user = models.foreignkey(user) content_type = models.foreignkey(contenttype, related_name='%(class)s_content_set') container_type = models.foreignkey(contenttype) container_id = models.positiveintegerfield() container = generic.genericforeignkey('container_type', 'container_id') class meta: app_label = 'content_bloc...

ruby on rails - git reverse cherrypick -

my question is, there way mark specific commit(s) either won't merged branch, or ignored when issue "git push" or fetch repository? my understanding can cherry-pick specific commits merge current branch; there way mark commit 'local' specific machine/repository/branch? the problem question grew out of, solving different way. specifically, there specific version of sqlite3-ruby (1.2.5) require work on rails application on 1 osx machine don't have root access. right i've made commit specify version in gemfile on local branch called "mac-bundle", , plan switch branch , merge necessary changes before run bundle if need install ruby gem. which minor live-withable annoyance. seems possible similar situation might arise same workaround won't quite acceptable, thought ask ideas on different solution. (question similar one: committing machine specific configuration files , , current solution similar greg hewgill's answer.) ...

Accessing SQL database from Cocoa application -

i want connect table have created in sql developer code i've written in xcode. table contains usernames , associated passwords "would be" users of application. want use table validate user entry @ login page. please guide me how connection made. small application i'm creating in attempt understand cocoa concepts (alongwith database). in advance.. there's no built-in cocoa framework accessing sql databases. if database in sqlite format, may want use fmdb .

Authorize.net - How to increase "Product Name Maximum character limit"? -

i have integrated authorize.net, got error message "line item 1 invalid", understood reason, product name maximum character limit 31, when submit short product name works fine..., how increase "product name maximum character limit" please me!!!! it's called "limit" because that's maximum number of characters can use no matter what. can't increase it. if have products long names should increase abbreviation meets 31 character limit.

flash - air android app always launches in portrait mode irrespective of the way the android device is held ( landscape/portrait) -

i have air android app running on android device ( samsung tab ). want app laid out in landscape mode when user starts app holding device in landscape ( same goes portrait ). but air app gets started in portrait mode irrespective of way device held. i tried following ways - use stage.deviceorientation (but when app starts (after applicationcomplete notification ) value unknown) use stage resize event. (this gets triggered @ start itself, manual resize not required - values based on portrait mode though - width 600 , height 1024 (should have been otherway) ) i correct values when try changing orientation of device, @ startup see problem required values. could please advice on problem ? thanks use getresources().getconfiguration().orientation . link here if(mycurrentactivity.getresources().getconfiguration().orientation == configuration.orientation_portrait) { // code portrait mode } else { // code landscape mode }

asp.net - Call an asmx webservice without extending user session -

in asp.net 3.5 application i'm calling asmx webservice part of application. calling webservice entends user's session timeout, undesirable in case. how can call webservice on server without extending session timeout? there way in iis designate being outside of session scope? (apologies if i'm using incorrect terminology) can designate directory in asp.net web.config file being outside session? thanks. problem solved! you can create new application in iis root directory underneath original application. done in iis mms snap-in in properties pane of directory want new root. click "create application" , you're done. new application inherits parent application's web.config, seemingly, little no configuration needs done.

java - JLabel doesn't change back color -

part of function looks jlabel2.setbackground(color.yellow); jlabel2.settext("status : idle"); boolean ok=cpu21.restartssh(); if(ok){ jlabel2.setbackground(color.green); jlabel2.settext("status : run"); } before enter in function label green , run, when come in function doesn't chabge color yellow ( function restartssh executing 5-6 sec, during time labels doesn't change colors , captures ). make mistake in painting ? make jlabel opaque can set background colour. perform restartssh in separate thread, or gui won't respond events. example: final jlabel jlabel2 = new jlabel("hello"); jlabel2.setopaque(true); jlabel2.setbackground(color.yellow); jlabel2.settext("status : idle"); //perform ssh in separate thread thread sshthread = new thread(){ public void run(){ boolean ok=cpu21.restartssh(); if(ok){ //update gui in event dispatch thread swingutilities.invok...

Company profile API:LinkedIn -

can 1 tell how company company,name,title,email address,physical address,company type, , more linkedin through api linkedin has added company api of may 2011. https://developer.linkedin.com/documents/company-lookup-api-and-fields i'm using company api through python , getting results. let me know if have more questions.

forcing firefox skip "text nodes" in DOM parsing by javascript -

hi i'm writing javascript code traverse html dom , highlight elements. problem firefox returns whitespaces text node. there solution force return tags? example need "firstchild" return first tag , not text! thanks you can check if node element node.nodetype === 1 . you can implement new dom travelsal api functions. var dummy = document.createelement("div"); var firstelementchild = ('firstelementchild' in dummy) ? function (el) { return el.firstelementchild; } : function (el) { el = el.firstchild; while (el && el.nodetype !== 1) el = el.nextsibling; return el; } usage firstelementchild(el)

php - Database structure for social login implementation? -

in application, have "user" table have following structure. create table if not exists `users` ( `userid` int(10) unsigned not null auto_increment, `username` varchar(128) not null default '', `password` varchar(32) not null default '', `email` text not null, `newsletter` tinyint(1) not null default '0', `banned` enum('yes','no') not null default 'no', `admin` enum('yes','no') not null default 'no', `signup_ip` varchar(20) not null default '', `activation_key` varchar(60) not null default '', `resetpassword_key` varchar(60) not null default '', `createdon` datetime not null default '0000-00-00 00:00:00', primary key (`userid`) ) engine=myisam default charset=latin1 auto_increment=27 ; i want implement social login via facebook, twitter , openid in application, statckoverflow did. please suggest me change require in db , how logic implemente...

SQL VarChar to Date -

hi trying convert varchar date field (e.g. 20100320) real date field 'dd/mm/yyyy' (e.g. 20/03/2010). i have tried 2 ways: a) (select min(cast(a.dateofaction date)) expr1 resadm.action (a.personid = p.personid)) 'period from', b) (select min(convert(date, a.dateofaction, 103)) expr1 resadm.action (a.personid = p.personid)) 'period from', both producing result yyyy-mm-dd (e.g. 2010-03-20) but want result dd/mm/yyyy (e.g. 20/03/2010) any appreciated. thanks. try this: select convert(varchar(8), convert(datetime, min(a.dateofaction), 112), 103) your problem once have date format, sql server dump out in default date format, you've discovered yyyy-mm-dd . need convert date varchar format want. convert date, need first convert date! 112 format yyyymmdd , , 103 format dd/mm/yyyy , why need these formats. ( books online reference dat...

flex - Actionscript tricks -

there many ways improve actionscript performance , reduce code size. let share tricks can come with. if search on google as3 tips can find lot. first check pages on kirupa forum. kirupa tricks , tips grant skinner made nice performace tips , tricks flash 10(.1) then if want profile self , see deep going optimization's go visit jpaucliar's blog

android - Which markup language to use for the new Web site? (Desktop & Mobile) -

i need redesign old site , thinking best web markup language use. here 2 questions. please me find right answer both or of them: what's optimal web standard desktop users? html? xhtml? else? version of (e.g. "xhtml 1.0 transitional")? what optimal markup language mobile users? site i'm going redesign applications mobile devices. so, naturally have lot of mobile visitors. of devices android-based, ios-based blackberries, palm os , symbian devices. markup language should stick when i'll developing mobile version of site? thanks great answers! i avoid xhtml. xhtml has become dead end , in no way "better" or "stricter" html, plus ie still doesn't support properly. see example: http://www.webdevout.net/articles/beware-of-xhtml the best supported standard html 4.01 strict. there no need transitional newly created site. you use "backwards compatible html5", 4.01 markup html5 doctype, in order ready if want use h...

Google Search optimisation for ajax calls -

i have page on site has list of things gets updated frequently. list created calling server via jsonp, getting json , transforming html. fast , slick. unfortunately, google isn't able index it. after reading on how done according google's ajax crawling guide , bit confused , need clarification , confirmation: the ajax pages need implement rules only, right? have rest url like [site]/base/junkets/browse.aspx?page=1&rows=18&sidx=scoreall&sord=desc&callback=jsonp1295964163067 this need become like: [site]/base/junkets/browse.aspx#page=1&rows=18&sidx=scoreall&sord=desc&callback=jsonp1295964163067 and when google calls this [site]/base/junkets/browse.aspx#!page=1&rows=18&sidx=scoreall&sord=desc&callback=jsonp1295964163067 i have deliver html snapshot. why replace ? # ? creating html snapshots seems cumbersome. suffice serve simple links? in case happy if google index things pages. it looks you've mis...

asp.net - Is there a solution for a BitTorrent Uploader? -

i have requirement client able upload extremely large files. i'm talking 7 gb files. website running on asp.net 4.0 app, standard upload scheme web app not going work. i'm tossing around multiple options trying figure out best route go be. one option i'm thinking seeing if can have bittorrent uploader. end users app typically have same file on hand, idea end user go site, wanted upload file. @ point, pick file, , server mark person seed file. then, web app go preconfigured leech on our side, , instruct leech download file. expect @ point during or after process torrent magic find other seeders on client's network, or wherever, that's idea. is there technology out there this? or describing i'm going have build ground up? it doesn't sound it's going easy bittorrent. in order bt work, need torrent files. in order create torrent file particular file, need file (the torrent file contains hash of file). in general torrent, need ...

ASP.Net: Load Advertise after load page? // performance Issues -

i have big performance issue in asp.net page. have around 10-15 database querys on every page load, page load done in ~0,x seconds (very fast think). since add advertisment: <script type="text/javascript"> adscale_slot_id = "xxxxx"; </script> <script type="text/javascript" src="http://js.adscale.de/getads.js"></script> my site-performance very high, around 1-2 seconds every page. how make faster? a idea load advertise after page ready , loaded. do-able? defer 1 way load ads after page has loaded. other way use aswift way uses iframe load ads parallel. google uses way speed page loading. has few gotchas worth try. check out presentation them on velocityconf. don't let third parties slow down --sai

java - MySQL & NetBeans problems -

im doing faculty homeworks , have problem 1 i'm suppoused run tapestry application nb , input values , values should in db , print in table on other page. installed mysql server , run nb aplication still gives me response "an unexpected application exception has occurred. error invoking service builder method org.apache.tapestry5.hibernate.hibernatemodule.buildhibernatesessionmanager(hibernatesessionsource, perthreadmanager) (at hibernatemodule.java:87) (for service 'hibernatesessionmanager'): cannot open connection" if know whats problem please feel free share... in advance.. probably, connection mysql database not stablished, try in configuration file , sure mysql user/password , mysql permissions user. try re-connect.

jquery - Is there a way to reference an input element immediately before a javascript function WITHOUT using its ID? -

when calling function page in javascript, there way reference element before function without id? example, <select>...</select> <script type="text/javascript"> my_function(previous_element); </script> is there way send select element my_function() without using id of select element? thanks in advance. edit: more information on trying do. i'm using rails plugin generates copy of group of form elements unique id each element. i'm trying call function particular form (select) element within group - ideally add onload select element, doesn't exist form elements. calling function within page best can come with. since elements copied using ajax (iow "add new address" kind of thing), if added element known id copied (and create multiple elements same id, , confusion). know it's messy i'm having difficulty coming solution, , plugin integrated project. since using nested_forms gem, , want access specifi...

html - Running XSLT on servers? -

currently working on project client compares difference between 2 xml files, generates xml lists differences (i.e. if part in inventory <added>, <deleted>, or <modified> ) , displays report in html. i have 3 transforms transform large vendor-specific xml files simple generic xml files (schema defined). these generic xml files transformed 1 generic xml file shows differences , transformed report.html display user. presently testing, invoke .bat file run 3 transforms (using saxon8.jar). question is, possible put these transforms on server , create html page one-click action let user upload vendor-specific xml files, transform them, , display generated html file user? you haven't specified whether you'll using php, java or asp.net, however, functionality you're looking possible in 3 cases. backend web app should have necesssary mechanism accept file uploaded user, save in work folder, run necessary transformation using chosen language, jav...

How do you use bcrypt for hashing passwords in PHP? -

every , hear advice "use bcrypt storing passwords in php, bcrypt rules". but bcrypt ? php doesn't offer such functions, wikipedia babbles file-encryption utility , web searches reveal few implementations of blowfish in different languages. blowfish available in php via mcrypt , how storing passwords? blowfish general purpose cipher, works 2 ways. if encrypted, can decrypted. passwords need one-way hashing function. what explanation? bcrypt hashing algorithm scalable hardware (via configurable number of rounds). slowness , multiple rounds ensures attacker must deploy massive funds , hardware able crack passwords. add per-password salts ( bcrypt requires salts) , can sure attack virtually unfeasible without either ludicrous amount of funds or hardware. bcrypt uses eksblowfish algorithm hash passwords. while encryption phase of eksblowfish , blowfish same, key schedule phase of eksblowfish ensures subsequent state depends on both salt , key (user ...

svn:externals : Having more than one external repository in a local directory -

is possible have 2 (or more) external repositories linked local directory ? for example, have file named externals , containing : http://somewhere/dev/trunk/f01common.lib include i declare property : svn propset svn:externals -f ../external . if try use file 1 after, last line taken : http://somewhere/dev/trunk/f01common.lib include http://somewhere/dev/trunk/f04logger.lib include is want possible or not ? answers. the doc says it's possible: http://svnbook.red-bean.com/en/1.7/svn.advanced.externals.html each external must written on line: because svn:externals property has multiline value, recommend use svn propedit instead of svn propset.

itunesconnect - Invalid Binary Itunes Connect -

possible duplicate: invalid iphone application binary im ripping hair out on this!!! i have tried , evertime submit app itunes connect allways says: upload received (2 minutes later) invalid binary its driving me mad , have already: cleaned builds made new entitlement.plist checked built distribution profile. check mailbox associated apple developer account, apple send email mailbox diagnose information , how solve problem. for me, apple send following diagnose information. have never touched icound, confusing. after all, created new app id without wild-card character, new distribution profile, , sign app, summit apple, turn out successful. invalid code signing entitlements - signature app bundle contains entitlement values not supported. com.apple.developer.ubiquity-container-identifiers entitlement, first value in array must consist of prefix provided apple in provisioning profile followed bundle identifier suffix. bundle ident...

Viewing an XPS document with malformed URI's in WPF -

i'm trying use documentviewer (or, more specifically, documentviewer's documentpageview) load presentation saved powerpoint xps. however, author of slides being clever , entered 1 of urls pseudo-regex (e.g. http://[blog|www]mywebsite.com ). built in xps viewer able load document without problem. however, documentviewer throws exception because tries validate uri: failed create 'navigateuri' text 'http://[blog|www]mywebsite.com' i of course go slide , fix uri document displays. however, since can't control documents used application, i'd prefer find way display document in spite of invalid uri's (like xps viewer). any thoughts? the documentviewer trying create uri instance provided url. if url isn't valid, operation fail. you can prevent happening performing validation on urls provided author. (writing without testing, there may syntax errors) public static bool isvalidurl(this string url) { if(string.isnullorwhitespa...

c# - Linq -- How to perform Join in ForEach statement? -

the linq join examples i've seen illustrate hot ti join when creating anonymous type. how do the join in foreach statement. e.g. foreach (item in mycontext.someentity.include("navigationproperty1").include("navigationproperty2").join(mycontext.someentity2 on id == id) { } thanks! well, you're trying mix query syntax calling extension methods directly here - that's not going work start with. but result of join sequence of pairs , - pairs have property in common. it's not clear "item" comes - how want each pair someentity , someentity2 transformed item ? your call end looking like: ...join(mycontext.someentity2, x => x.id, y => y.id, (x, y) => !!!) where !!! projection pair of entities single useful value. see part 19 of edulinq blog series more information how join method works.

Rookie PHP, receiving an undefined variable error -

Image
i reading book , going through examples, unfortunately keep getting error if leave field empty when submit form. checked errata , there nothing, tried posting on books forums didn't responses. i believe maybe have declare variables first take away variables being automatically generated. any appreciated, rookie trying learn php. per request, here $required , $expected. thanks! $expected = array('name', 'email', 'comments'); $required = array('name', 'email', 'comments'); <?php foreach ($_post $key => $value){ //assign temporary variable , strip whitespace if not array $temp = is_array($value) ? $value : trim($value); //if empty , required, add $missing array if (empty($temp) && in_array($key, $required)){ $missing[] = $key; } elseif(in_array($key, $expected)){ //otherwise, assign variable of same name $key ${$key} = $temp; } } <?php include('./include...

android - How to make a ListActivity with custom List Item with nested clickable Button -

now have activity, shows list of usernames. ok works. need show custom listview item username @ left , button @ right (this button call programatically given phone number). i know have custom adapter, skills low. , dont know how use when have done. can me making easy custom adapter manage listitem 1 textview , 1 button , giving me code use custom adapter? the adapter should able use new list_item2.xml: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content"> <textview android:id="@+id/friendname" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:padding="10dp" android:textsize="16sp"/> <button android:id="@+id/callbutton...

.net - Asp.Net MVC 3 Partial Page Output Caching Not Honoring Config Settings -

i have simple partial view i'm rendering in main view with: @html.action("all", "template") on controller have this: [outputcache(cacheprofile = "templates")] public actionresult all() { return content("this stinks."); } and in config this: <caching> <outputcachesettings> <outputcacheprofiles> <clear/> <add name="templates" duration="3600" varybyparam="none"/> </outputcacheprofiles> </outputcachesettings> <outputcache enableoutputcache="false" enablefragmentcache="false" /> </caching> this fail @ runtime exception: error executing child request handler 'system.web.mvc.httphandlerutil+serverexecutehttphandlerasyncwrapper and inner exception: duration must positive number now it's not picking web.config settings, because if change to: [outputc...

diagramming customizable api java -

hi wondering if exists java library or api can me achieve this: i have gui user can construct diagram (states or workflow) , in end save picture , representation of diagram in xml file. have advance if can tell me library or api great thanks you need jgraph or jgraphx version 1.5.0.2! link: jgraph jgraphx free version. can sorts of diagrams , mathematical graphs. interactive. blends swing , robust.

.net - How to organize classes in a C Sharp application? -

let's have visual studio project needs make use of binary search tree data structure. since .net not have built-in bst data structure have add classes myself (like this article ). involve several classes: node, nodelist, binarytree, etc....so question better add these classes 1 .cs file i.e. nest them, or should each class it's own separate file? seems bit cleaner , possibly easier reuse classes if in 1 file, no? i'm trying understand best practices organizing , designing projects. advice or direction point me appreciated. i recommend using 1 file per type. there's no economy in restricting number of files , 1 file per type helps finding type in solution. quite often, files organised in folders levels of organisation (the folders named along namespace lines these provide natural groupings of types) although not done.

java - Accessing variables from inner class -

i've got code defines anonymous inner class callback handler. handler needs assign local variable, see below. need assign resp in callback , refer towards end of function. getting error in eclipse however: the final local variable resp cannot assigned, since defined in enclosing type how can fix this? doorresult unlockdoor(final lockabledoor door) { final unlockdoorresponse resp; final boolean sent = sendrequest(new unlockdoorrequest(door), new responseaction() { public void execute(session session) throws timedoutexception, retryexception, recoverexception { session.watch(unlock_door); resp = (unlockdoorresponse)session.watch(unlock_door); } }); doorresult result; if (!sent) { return doorresult.comms_error; } else { return doorresult.valueof(resp.getresponsecode()); } } here hack work in case: doorresult unlockdoor(final lockabledoor door) { ...

xml - Strategies for complex page numbering in PDF's -

i have question custom page numbering ("point pages") when creating pdf. i'm using xslt create xsl-fo xml instance. xslt processor saxon 9 , xsl-fo processor renderx (4.18). what need able change page numbering once reaches point. (the page number in footer (static-content).) lets have book has multiple chapters in it. each 1 of these chapters has chapter number. chapter number page numbering based on. for example, if chapter number 2000, first page of chapter 2001. this fine until 998'th page (the chapter has end on page). example, if chapter 2000 had 1,002 pages page numbering of last 6 pages be: 2997, 2998, 2999, 3000, 3001, 3002 this incorrect since there might chapter 3000. what need able change page numbering after 998'th page. using chapter 2000 1,002 pages example, numbering should be: 2997, 2998, 2998.1, 2998.2, 2998.3, 2998.4 . this i'm doing now: i'm using <fo:page-number> in fo:static-content . i'm setting s...

iphone - Hide status bar on initial load screen? -

i'm trying hide status bar (top bar time , signal strength etc) while inital load screen displayed. sorry if obvious, i'm new @ this. by setting uistatusbarhidden on info.plist can control starting status (hidden, or shown). to hide (or show it) within application, need use: -setstatusbarhidden:withanimation: on uiapplication (docs here )

xpath - Pagination in XSLT -

my request below . empnumberlist have 250 empnumbers separated space. <soapenv:body> <v1:mrrequestparam> <v1:empnumberlist><v1:empnumber> 9989071005 2004421004</v1:empnumber></v1:empnumberlist> </v1:mrrequestparam> </soapenv:body> the xslt need write should count empnumbers empnumberslist need call stored procedure in xslt such make 5 calls . in 1 call pass 50 empnumbers. make 5 calls in total first call have $empnumber1 such contains 50 empnumbers $empnumber1 = 9989071005 2004421004 (so on 50 empnumbers) <argument type="sql_varchar" mode="input" nullable="true" precision="0" scale="0" isnull="false"><xsl:value-of select="$empnumber1" /> </argument> when send response need club 5 result set , send @ time. please let me know if have suggestions this 1 easy: use : string-length(transla...

performance - timing code in ruby/rails -

i have rake task/batch job taking long , im trying track down in production time being spent. have started adding: start_time = time.now # logic end_time = time.now elapsed_time = end_time - start_time puts "elapsed time #{elapsed_time} logic" is best way this? dont want install external tools in production. need finer grained timings method levels, because need know data being used each method/section etc. i think you'll bang buck using profiler (like ruby-prof ). show time being spent.

PHP arrays - simple way to change value of relative location in deep associative array -

i have script handling array in $_session, want change 1 specific value within array. go nested foreach route, think missing simpler solution. the branch of array want change looks like $_session['roles'][$group][$role]['status'] = 'disabled'; this of course easy change if know $group , $role variables, script trying write want change first instance of ['status'] 'active'. (that status of first $role in first $group of $_session['roles'] array i tried $_session['roles'][key($_session['roles'])][key(current($_session['roles']))]['status'] = 'active'; which works, seems clumsy. missing simple function here? there's no better solution. "relative/sequential access" , "associative arrays" don't fit anyway. btw, depending on did array before you'll have reset() so key()` returns first key. edit: first part replace $_session['roles'][key(...

android - Forcing Portrait mode OOM bitmap resize -

whenever force portrait mode in oncreate setrequestedorientation(activityinfo.screen_orientation_portrait); i error what portrait mode have oom vm budget on image scale? private void scalefrom(bmpwrap image, bitmap bmp) { if (image.bmp != null && image.bmp != bmp) { image.bmp.recycle(); } if (mdisplayscale > 0.99999 && mdisplayscale < 1.00001) { image.bmp = bmp; return; } int dstwidth = (int)(bmp.getwidth() * mdisplayscale); int dstheight = (int)(bmp.getheight() * mdisplayscale); image.bmp = bitmap.createscaledbitmap(bmp, dstwidth, dstheight, true); } private void resizebitmaps() { scalefrom(mbackground, mbackgroundorig); (int = 0; < mborig.length; i++) { scalefrom(mb[i], mborig[i]); } (int = 0; < mblind.length; i++) { scalefrom(mblind[i], mblindorig[i]); } (int = 0; < mfrozen.length; i++) { scalefrom...

qt - QNetworkReply - connection established, first byte written, etc -

i'd log lifetime of qnetworkreply object. includes: when underlying socket connection established when first byte of request sent when first byte of response received when last byte of response finished (3) , (4) can determined listening downloadprogress signal, i'm not sure how (1) , (2). there way listen on underlying socket of qnetworkreply? uploadprogress signal doesn't seem triggered requests. i have no idea if (1) possible others easy. have seen network trace example? not work case?

Is there a programming language for contests? -

is there programming language measures everything? for instance, measure how memory allocated, number of operations used (in terms of cycles), , time spent on io. such language great running programming contest. you might consider running program compiled/interpreted existing language under tool valgrind, can report on these kinds of factors. extend valgrind further if necessary.

algorithm - Video Scene Detection Implementation -

i looking video scene detection algorithm implementation. programming language used implementation acceptable. found implementation sensitive small changes , inaccurate. finally did simple implementation, comparing 2 consecutive frames: resize current frame: computation time + memory generate color histogram resized frame calculate euclidean distance of current frame previous frame's. if euclidean distance greater given threshold, have scene change. the threshold varies video ... got acceptable results.

performance - Efficient file buffering & scanning methods for large files in python -

the description of problem having bit complicated, , err on side of providing more complete information. impatient, here briefest way can summarize it: what fastest (least execution time) way split text file in (overlapping) substrings of size n (bound n, eg 36) while throwing out newline characters. i writing module parses files in fasta ascii-based genome format. these files comprise known 'hg18' human reference genome, can download ucsc genome browser (go slugs!) if like. as notice, genome files composed of chr[1..22].fa , chr[xy].fa, set of other small files not used in module. several modules exist parsing fasta files, such biopython's seqio. (sorry, i'd post link, don't have points yet.) unfortunately, every module i've been able find doesn't specific operation trying do. my module needs split genome data ('cagtacgtcagactatacggagcta' line, instance) in every single overlapping n-length substring. let me give example usi...

java - Bitmap/Canvas use and the NDK -

i've found out there no hard limit amount of memory ndk code can allocate in contrast heavily limited amount of memory (~25mb on devices) can allocate on java side. i want write image processing app (something photoshop) needs keep several large bitmaps in memory @ once bitmap data take ~20mb of memory. doing in java makes app prone out of memory exceptions on many devices i've tried. all current code makes use of bitmap , canvas class doing image manipulations. can suggest way allows me allocate of memory on c side , still make use of bitmap+canvas performing drawing operations (using android 2.1 , above)? as example, if image composed of 6 bitmap layers , user painting on 3rd layer, need draw paint blob bitmap 3rd layer , update screen show result of flattening layers on top of each other in real time. i've considered along lines of allocating 6 bitmaps in c int arrays , performing painting operation on java side canvas using copy of layer being edited stored in...

asyncore.dispatcher python module error -

i started learning asyncore.dispatcher module , when run first example program gives below error. python version 2.6 asyncore module installed , there dispatcher class inside it. may problem ! error : attributeerror: 'module' object has no attribute 'dispatcher' example code : import asyncore, socket class httpclient(asyncore.dispatcher): def __init__(self, host, path): asyncore.dispatcher.__init__(self) self.create_socket(socket.af_inet, socket.sock_stream) self.connect( (host, 80) ) self.buffer = 'get %s http/1.0\r\n\r\n' % path def handle_connect(self): pass def handle_close(self): self.close() def handle_read(self): print self.recv(8192) def writable(self): return (len(self.buffer) > 0) def handle_write(self): sent = self.send(self.buffer) self.buffer = self.buffer[sent:] client = httpclient('www.python.org', '/'...

cocoa - NSButton's images lose transparency on selection -

i have edited nsbuttons in mac os x application , set custom image them. images in png format transparency. when select button, background of image goes white. does know of way fix this? the issue was customising 'bevel' button. changed button bezel 'square' , changed button type 'momentary change'. hope helps people in future!

sql - MYSQL nested query newbie question -

i trying increment 'sellingdate' field that's in 'company' table. update company set sellingdate = ((select date_add((select sellingdate company cid = '35'), interval 1 day))) cid = '35'; this query gives me error saying: error code: 1093 can't specify target table 'company' update in clause what doing wrong here? use: update company set sellingdate = date_add(sellingdate, interval 1 day) cid = '35' mysql doesn't allow subquery in update statement against same table, subquery unnecessary example. odd reason self-join in update statement won't return 1093 error though it's same logic.

c++ - Avoiding virtual functions -

so suppose want make series of classes each have member-function same thing. let's call function void doyourjob(); i want put these classes same container can loop through them , have each perform 'doyourjob()' the obvious solution make abstract class function virtual void doyourjob(); but i'm hesitant so. time-expensive program , virtual function slime considerably. also, function thing classes have in common each other , doyourjob implimented differently each class. is there way avoid using abstract class virtual function or going have suck up? virtual functions don't cost much. indirect call, function pointer. what performance cost of having virtual method in c++ class? if you're in situation every cycle per call counts, you're doing little work in function call , you're calling inner loop in performance critical application need different approach altogether.

sqlite3 - C# Sqlite function across applications -

is possible register sqlite function in application , trigger application? example: i create trigger calls myfunction() after update application uses sqlitefunction.register register function called myfunction application b makes update fires trigger when application b makes update, receive error "function myfunction not defined". there way register function "global" scope? ps: final purpose of simulating events across applications using triggers thank you if you're trying pass event notifications between multiple applications, sqlite -- or matter, database table -- wrong tool job. if operation asynchronous might want use named eventwaithandle notify other process you've done should interested in, or if there's data involved, stuff notification , data in messagequeue other application pick up. otherwise, should use real inter-process communication mechanism sockets, named pipes, remoting, wcf, etc.

javascript - In a browser extension, how do I click a specific button of an alert? -

so... i need click [stay on page] automatically in such prompt: confirm navigation: [leave page] [stay on page] the code invokes $(window).bind('beforeunload', function() { return 'leave page?'; //click prompt code goes here. $(window).unbind(); }); if take away return 'leave page?'; iframed page overrides top frame , user struck unknown site, maybe there's way this? actually hook onbeforeunload event: $(window).bind('beforeunload', function() { return 'leave page?'; });

java - How to set alert instead of showing unhandled exception in J2ME? -

i designing application shows unhandled exception due lot of reason. want application show alert in catch block instead. you this: private alert alert; private display display; // obtain display display = display.getdisplay(this); in consturctor catch(exception e) { alert = new alert("error occurred", "message: " + e.getmessage(), null, alerttype.error); alert.settimeout(alert.forever); display.setcurrent(alert, form); } hope helps.

android - Turn off or modify recent apps list -

is there way interact recent apps list appears when long press home button? turn off or if not possible clear entries. i'm not sure if turn off completely, if want exclude app appearing there, set android:excludefromrecents="true" in manifest.xml. have @ getrunningtasks of activitymanager list of launched app. public list getrunningtasks (int maxnum) return list of tasks running, recent being first , older ones after in order. note "running" not mean of task's code loaded or activity -- task may have been frozen system, can restarted in previous state when next brought foreground. at last, question , answer provides information regarding overriding longpressed home button.

java - Informing the user that the file is being generated in a download servlet -

i have download servlet wich generates zip files, 1 of them pretty big, , sends generated file in response download. the problem generating process pretty big, , between step of generation of de zip , download step (when user see download dialog) many seconds or minute pass. inform user anyway file beeing generated. the solution i´m thinking doing several requests, 1 open modal window informs user , inside this, request automatically action wich generates file in temp location , then, when request ends, 1 wich close window (the window must closed automatically) , request download servlet generated file in last step. if understands i´m trying do, if exists better , cleaner solution. you can fire ajax request start generation process, , other ajax requests poll server if file ready. if yes - change location of browser file. otherwise, show "loading" message/image/..

MVC3 client validation not working -

i have required annotation on model: [required(errormessage = "please choose option")] public bool? anydebts { get; set; } i have enabled client validation in web.config: <appsettings> <add key="clientvalidationenabled" value="true" /> <add key="unobtrusivejavascriptenabled" value="true" /> </appsettings> i have referenced jquery scripts in layout: <script src="@url.content("~/scripts/jquery-1.4.4.min.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/jquery-1.4.4.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/jquery.validate.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script> ...