Posts

Showing posts from January, 2013

java - Is possible to change the summary of EditTextPreference dynamically in Android? -

i set preferencescreen edit settings in application. insert edittextpreference contains title "set name" , summary containing name entered. is possible? thank in advance! sure, here short example: edittextpreference etp = (edittextpreference) findpreference("the_pref_key"); etp.setsummary("new summary"); this requires display preferences either preferenceactivity or preferencefragment , since findpreference() method of these classes. already. to change summary every time user changes actual preference, use onpreferencechangelistener , check if relevant key changed in callback. after has changed, edit summary above.

Android Eclipse: Customizing the build process -

i have many graphic resources in application , support different screen sizes differently sized graphic resources. however, app large if include 3 different versions of every graphic resource in final apk (i.e. res/drawable-hdpi, res/drawable-ldpi, res/drawable-mdpi). able generate 3 different apks testing--and deployment--purposes (see using mulitple apks ), each relevant graphical resources included. is there way customize android build process (i'm using eclipse) make possible? if not possible in eclipse possible command line? my searching indicates many people using build tools ant , maven type of problem, , android-sdk has tool support ant out of box . notes on answer: after performing tutorial below follow these steps (they clear after tutorial , reading ant manual ant main_rules.xml comes android-sdk): copy contents of main_rules build.xml (as specified in build.xml comments) make 3 new tasks follows: <property name="my.custom_res_folder" val...

php - What is the difference between echo('exit'); die; and die('exit');? -

i have seen code this: if(something){ echo 'exit program'; die; } ...more code and others use die : if(something) die('exit program'); ...more code is there inherent difference in when end program, should aware of code comes after it? etcetera update i asking mainly, if coding style, or if there real reason why coded 1 way versus another. not asking difference between exit , die is. no, there no difference; both write "exit" stdout , terminate program. i prefer die("exit") method it's less typing, easier comment out , semantically clearer. as far "speed", why care faster? need program die quickly? re: update ... inherent difference in when end program ... there no difference, inherent or otherwise. they're identical. second option, die('exit') , single statement, , requires no braces when used if statement; has nothing die , blocks , flow control in c-style languages. ...

codeigniter - How to use mobile layouts in PyroCMS -

i'm trying use mobile layouts pyrocms choose correct layout automatically if user visiting mobile device. i have mytheme/views/web , mytheme/views/mobile . web views loaded should, mobile views not. when use android or iphone simulator don't mobile-views, web-views. why? there have enable, or there somewhere can go perhaps error message , see why? mobile safari not added mobile user agents, why wasn't registered

ruby on rails - How to drop DB indices before bulk loading in seeds.rb? -

in rails app have seeds.rb script inserts lots of records. in fact i'm trying load 16 million of them. it's taking long time. one thing wanted try speed up, drop table indices , re-add them afterwards . if sounds i'm doing insane, please let me know, seems 1 recommendation bulk loading postgres i use add_index , remove_index commands in migrations, same syntax doesn't work in seeds.rb file. possible outside migration in fact? (i'm imagining might not best practice, because represents schema change) rails v2.3.8, postgres v8.4.8 one possibility indulge in little raw sql within seeds.rb activerecord::base.connection.execute("drop index myindex on mytable") at 16 million records, recommend managing whole thing via raw sql (contained within seeds.rb if like). 16 million records go single table? there ought postgresql magic bulk import file (in postgresql specific format) table.

Ruby MongoDB drop GridFS collection -

how drop grid object ruby mongo driver? drop shell, because treats gridfs collections, how do ruby? are trying remove single file or entire gridfs collections? grid_file_system supports deleting filename. otherwise can manually drop collections (i think fs.files , fs.chunks default)

ECONNRESET (Whois::ConnectionError) - Error Trying to Query Whois in Ruby -

i'm writing simple program in ruby check if list of domains taken. cycles through list, , uses following function check. require 'rubygems' require 'whois' def check_domain(domain) c = whois::client.new c.query("google.com").available? end the program keeps erroring out (even when hardcode in google.com), , prints message below. given how simple program is, i've run out of ideas - suggestions? /library/ruby/gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:165:in `query_the_socket': errno::econnreset: connection reset peer (whois::connectionerror) /library/ruby/gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/verisign.rb:41:in `request' /library/ruby/gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:113:in `query' /library/ruby/gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:150:in `buffer_start' /library/ruby/gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:112:in `query...

android - how to split a string of data into different list views? -

would able split string of data starting <newdata> several different objects inside such <schedule> ending in </schedule> , ending on </newdata> . split several list views each schedule in different list view? quite difficult explain thing i've missed say... umm i'll give hint, string stuff = "<schedule> save kittens </schedule> " + "<schedule> , puppies </schedule>" ; string [] result = stuff.split("<schedule>"); for(int = 0; < result.length; i++) { if(result[i].length() > 0) log.d("todo", " - " + result[i].substring(0, result[i].indexof("<"))); }

Is it possible to know if a default argument was supplied as an actual parameter value (when they are equal) in Scala? -

is possible know if default argument supplied actual parameter value? in other words, assume defined method: def mymethod(x: int = 1) = x + 1 then possible distinguish between these 2 calls (which return identical results because parameter in second method call has same value default value in method definition) within method body: mymethod() mymethod(1) in other words, want know if there technique achieve effect similar -supplied-p feature in common lisp function definitions (see http://www.gigamonkeys.com/book/functions.html , http://www.psg.com/~dlamkins/sl/chapter21.html details , more context). no, can't directly know this. here's ugly workaround relies on fact default parameter can method call. comes many caveats, biggest of is not thread-safe. private var useddefault = false private def default = { useddefault = true 1 } def mymethod(x: int = default) = { if (useddefault) { println("default") } else { println("s...

ios4 - ios manipulating a views elements programmatically -

i want change hidden property of elements programmatically based on button click. in javascript document.getelementbyid('element').display = 'block'. there way of doing ios like: self.'element'.hidden = no; uiview has boolean property called hidden , no default, can set yes hide view. retrieve views, possible assign tags, merely integers (default 0): [myview settag:10]; so.. [[myparentview viewwithtag:10] sethidden:yes]; this pretty similar js, otherwise can iterate on subviews: nsarray *viewsarray = [parentview subviews]; (uiview *view in viewsarray) { // ... }

memory management - iPhone tableview pagination -

first, please believe me when did search answer first... lot. found many examples, none performing need. though have been searching using wrong key words, don't believe so. here issue: i have table view being populated query returning huge amount of data. data list of restaurants, price rating, , id. there many restaurants in database fills memory , crashes app time. (i assuming going on, code works fine if query limited, , has worked on other pages query things don't have data returned.) what make pagination application's table view page. don't see how use "show more" method, or auto load when scrolled bottom, because if scroll down end of list, still have same issue: filling memory. there way web-like pagination (if not on first page) have "previous" cell @ top , (if not on last page) "next" cell @ bottom? these have clear cells out in current view , drop data we're not adding data cause same issue, new query popula...

sql server - SQL: Update table where column = Multiple Values -

i created sql query updates table column column = value code: update products set productname = 'shoes' productid = (1,2,3,4,5,6,7,8) the problem productid . how can make update column id's ? regards. replace productid = productid in update products set productname = 'shoes' productid in (1,2,3,4,5,6,7,8)

javascript - Does 'this' refer to the element that called this function? -

in snippet below use $(this) refer element in function being called from. know not correct because printed out values , gave me 'undefined'. how refer input element? $(function() { $( ".datepicker" ).datepicker({ onselect: function (date, obj){ if(confirm('is correct?: '+ date )) { $.post('edit.php', { "row": $(this).data('id'), "date":date, "field":$(this).name, "ajax":'true' }); } } }); }); here html element: <input name="appvacadvp" data-id="someid" class="datepicker" size="10" type="text" placeholder="someholder" > i appreciate help. sorry being such javascript noob ._. jquery sets this itself,...

Matlab: In function "fminsearch(fun,x0)" x0 not getting accepted as matrix -

in matlab documentation function fminsearch(fun,x0) , x0 can scalar, vector, or matrix. trying call function : weight=2; delta_obj=@(k_to_perturb_annealing) gibbs_sampling_sisim_well_testing(k_to_perturb_annealing); k_to_perturb_annealing=fminsearch(delta_obj,k_to_perturb_annealing_initial); where, k_to_perturb_annealing_initial 101x82 matrix. getting stuck error on line k_to_perturb_annealing=fminsearch(delta_obj,k_to_perturb_annealing_initial); error message: ??? subscripted assignment dimension mismatch. error in ==> fminsearch @ 195 fv(:,1) = funfcn(x,varargin{:}); error in ==> optimizing_by_perturbing_sisim_perm @ 31 k_to_perturb_annealing=fminsearch(delta_obj,k_to_perturb_annealing_initial); the function gibbs_sampling_sisim_well_testing(k_to_perturb_annealing) calling above is: function[obj_fun]=gibbs_sampling_sisim_well_testing(k_to_perturb_annealing) %% parameters ncell=40000; a=((sqrt(ncell)*500*sqrt(ncell)*500))/43560; % area of reservoir in acres...

javascript - jQuery toggle .click() function -

i unsure if "callback' need or not, trying emulate reversal of function on .hover() effect .click() effect. possible. basically, if user clicks again on link, reverse of happened, ie div closing opposed opening, happen. possible .click()? $(document).ready(function(){ $('.content_accrd').css({"height":"0px"}); $('.paneltop').click( function() { $(this).css({"background-position":"0px -21px"}) .siblings().animate({"height":"100px"}, 200) }, function() { $(this).css({"background-position":"0px 0px"}) .siblings().animate({"height":"0px"}, 200); }) }) use .toggle() , not .click() . description: bind 2 or more handlers matched elements, executed on alternate clicks.

Google Keyword Tools API -

is there anyway developer test google keyword tools api free? you can test against sandbox without charge don't real results live system. testing against live api uses api units. however, find need pull down few keywords testing , many testing cycles doesn't cost much. one thing can reduce costs tool working sandbox make sure there aren't errors etc. then, once it's working, run few tests in production check data looks correct.

javascript - Regex for alphanumeric with at least 1 number and 1 character -

i have regex /^([a-za-z0-9]+)$/ this allows alphanumerics if insert number(s) or character(s) accepts it. want work field should accept alphanumeric values value must contain @ least both 1 character , 1 number. why not first apply whole test, , add individual tests characters , numbers? anyway, if want in 1 regexp, use positive lookahead: /^(?=.*[0-9])(?=.*[a-za-z])([a-za-z0-9]+)$/

javascript - How can I make a popup form? -

Image
i want password protect page doing using ldap bind authentication. whole process , script fine. have form submits script , script checks whether user has authentication or not, if don't kicks them out. what trying here this. http://jsfiddle.net/s5jyr/ form have there, make popup login instead user goes url of site blank page popup screen asking login. how can make popup? if user clicks cancel should display error. access denied. or if user inputs wrong login credentials display same error message. error messages don't need popup, can displayed on different blank page. forms have looked around google have popup button isn't want.. i trying make this: in javascript can opening new window window.open() method, opening url form , capturing information outside. might fail in platforms not supporting it. another method can showing form in floating box, still javascript dependant. maybe want http login form, not javascript ask for. though have handle server...

jQuery events on iOS 5 -

i'm having issue jquery 1.6.4, ios 5 , registration of touchstart/touchend events (as stated in title, obviously). take following code: <!doctype html> <html lang="fr"> <head> <meta charset="utf-8" /> <script type="text/javascript" src="mmpa/jquery-1.6.4.min.js"></script> <script type="text/javascript"> $(document).ready(function() { var $body = $('body'); $('<button>').html('test jquery').bind('touchstart', function() { alert('touchstart'); }).appendto($body); }); </script> </head> <body> <button ontouchstart="alert('touchstart');">test pure js</button> </body> </html> the "pure js" button shows alert in ios 4.3 , ios 5, "jquery" button works on ios 4.3. tested on ipad/iphone simulator, 4.3 , 5 ; t...

streaming - Problem playing media from RTSP URL in Android -

i have made android streaming application plays media online url's. playing media, using standard mediaplayer class playing media. as per android documentation, supports rtsp protocol audio & video playback http://developer.android.com/guide/appendix/media-formats.html but when trying play media rtsp url, gets connected not able hear media following 1 of rtsp url - rtsp://sfera.live24.gr/sfera4132 does media have idea of playing rtsp url's through android mediaplayer thanks that link provided has 3 audio tracks, first , last tracks appearing silent , don't contain valid audio. middle track has audio (as per vlc). don't know how android deals multiple audio tracks. imagine may better results if use links contain 1 audio , 1 video track @ most. expect rtsp stream multiple audio tracks, android going play first 1 there no user interface select specific audio stream, hence why aren't hearing audio. if stream own server, hear audio should a...

linux - Spliting file by columns -

i know cut command can cut column(s) file, can use split file multiple files each file named first line in column , there same number of produced files there columns in original file example (edit) columns separated tab , can of different length. first file have names of rows. probe file1.txt file2.txt file3.txt "1007_s_at" 7.84390328616472 7.60792223630275 7.77487266222512 ... also thing original file extremely huge, want solution split in 1 run. not calling cut repeatedly can 1 line of awk: $ cat test.tsv field1 field2 field3 field4 asdf asdf asdf asdf lkjlkj lkjlkj lkjlkj lkjlkj feh feh feh bmeh $ awk -f'\t' 'nr==1 { for(i=1;i<=nf;i++) { names[i] = $i }; next } { for(i=1;i<=nf;i++) print $i >> names[i] }' test.tsv $ ls field1 field2 field3 field4 test.tsv $ cat field4 asdf lkjlkj bmeh edited include tab separator courtesy of glenn jackman addition removing double quotes fields: ...

c# - How-to: Mapping (NHibernate) multiple classes with different business logic from the same table? -

i working brownfield database contains table holds data 3 different sorts of business. has salesorders , orderlines. in old application, able add 3 types of orderlines each salesorder: products, hourly rates , text lines. 15 years ago, quick , dirty solution easy queries in delphi lines in 1 datagrid. every now trying build object model in c# using nhibernate. i've made 3 seperate entities without base class, due fact these 3 line types have no real business logical connection. however, want these 3 types 1 list can order them. i've considered using inheritence, table per class, table meets requirements (no columns not-null restraint). isn't logical step though, since business per type different (only things in common userid, description , remarks). perhaps component? how map properties 3 different classes without base class or kind of link except table name? i hope guys understood wrote. have no real code yet, sketching stuff on paper on how deal code. anyone h...

objective c - Can't read Root.plist with NSUserDefaults -

i've problem. have file root.plist many preferences but, when use: nsuserdefaults standarduserdefaults to read it, nothing happened. why? can me? thanks why read file? user defaults aren't stored in plist in application bundle. if file contains "first-run" preferences set users need read file , copy values defaults using standard methods.

ruby on rails 3 - Altering nested messages helper from div to unordered list -

i using helper method ryan bates railscasts on ancestry display nested messages(code below works perfectly). def nested_messages(messages) messages.map |message, sub_messages| render(message) + content_tag(:div, nested_messages(sub_messages), :class => "nested_messages") end.join.html_safe end the above bit of code nests individual divs in tree structure. i make unordered list, have done this: def nested_messages(messages) messages.map |message, sub_messages| content_tag(:ul, :class => "") render(message) content_tag(:li, :class => "nested_messages") nested_messages(sub_messages) end end end.join.html_safe end the generated html looks fine, list items contain no values. doing wrong? update i generated html this: <ul> <li>main message</li> <!-- first message --> <li> <b>message 1</b> ...

objective c - When will UITableView reloadData have updated the visibleCells? -

i have uitableview instance tableview displays data server. the tableview have wait until data received, , gets call it's reloaddata method. fine, works great. now have particular method want perform right after tableview finishes creating first set of visiblecells . example i'll call method performfancyactiononvisiblecells . seems however, reloaddata action asynchronous, can't do [tableview reloaddata]; [self performfancyactiononvisiblecells]; because visiblecells still empty when second line executed, have wait bit before calling it. brings me question. to knowledge there no delegate method tableview:didfinishreloadingdata . if i'd want call performfancyactiononvisiblecells certainty reloaddata has finished updating visiblecells property, be? cheers, ep. to answer question directly, not aware of delegate callback you're looking for. but, reloaddata call [tableview cellforrowatindexpath] on each of visable rows put call @ bottom ...

android - zxing barcode is not decoding in portrait mode -

Image
i using zxing src , resource android application. it reading qr code not barcode in portrait mode working fine in landscape mode . problem .. have idea. the original zxing scanning mode in landscape requirement in portrait mode changed landscape design in portrait. <activity android:name="com.google.zxing.client.android.captureactivity" android:screenorientation="landscape" android:configchanges="orientation|keyboardhidden" android:theme="@android:style/theme.notitlebar.fullscreen" android:windowsoftinputmode="statealwayshidden"> above given manifest content. i'm developer of barcode scanner. yes, takes lot more make scan in portrait mode. have "rotate" image data, , account orientation of device, default orientation, , sensor's orientation. barcode scanner+ scans in portrait mode, , can integrate via intent in same way integrate barcode scanner . (however it's for-pay app.)

Javascript age calculation on IPad -

on every regular browser, date calculated .. 38 year old. on ipad not number (nan) error... why? function getage(date) { var today = new date(); var birthdate = new date(date); var age = today.getfullyear() - birthdate.getfullyear(); var m = today.getmonth() - birthdate.getmonth(); if (m < 0 || (m === 0 && today.getdate() < birthdate.getdate())) { age--; } return age; } edit: nan @ ipad, ie8 , correct working @ firefox&chrome you need following transformations on input date string work on ipad/iphone. function getage(date) { date = date.replace(/-/,"/").replace(/-/,"/"); //substitute - / var today = new date(); var birthdate = new date(date); var age = today.getfullyear() - birthdate.getfullyear(); var m = today.getmonth() - birthdate.getmonth(); if (m < 0 || (m === 0 && today.getdate() < birthdate.getdate())) { age--; } return age; } ...

php - How to get popular friends from Facebook API? -

i know can friends using https://graph.facebook.com/me/friends know can friends fql so: select uid,username user uid in ( select uid2 friend uid1 = me() limit 20 ) need order these friends interact often, i.e. close friends. is possible? you search user's defined lists.. list "close friends" may contain such information though manually edited user himself (so might empty or not accurate)

php - Password validating -

i trying validate confirm passwords in php using javascript code: if($_post['passwordfield']== $_post['confirmpassword'] && $_post['passwordfield']>='8') { echo "succed <br>"; } else { echo "filed <br>"; } it works matching 2 passwords, length of password not working. if enter password less 8 character succeeds - why this? also, how can check password strength using javascript not using regular expressions? you should use strlen() method length of string contained in $_post['passwordfield']. , should not check string '8'. needs like: <?php function ispasswordvalid($password1, $password2){ if(strlen($password1) >= 8) if($password1 == $password2) return true; return false; } ?> call method 2 values post. also, use trim() strip whitespaces. ohw...and has nothing javascript.

Maven built swf(flex project) throwing errors at application start -

i'm getting following error @ start of application: referenceerror: error #1065: variable mx.messaging.config::configmap not defined. at _abc_flexinit$/init() @ mx.managers::systemmanager/http://www.adobe.com/2006/flex/mx/internal::kickoff() @ mx.managers::systemmanager/http://www.adobe.com/2006/flex/mx/internal::preloader_completehandler() @ flash.events::eventdispatcher/dispatcheventfunction() @ flash.events::eventdispatcher/dispatchevent() @ mx.preloaders::preloader/timerhandler() @ flash.utils::timer/_timerdispatch() @ flash.utils::timer/tick() i have gone through lot of posts on various forums. of them error occurs in cases like: not declaring classes 'public' trying refer isn't there syntax error when run application, runs fine. when try run swf generated maven install on application, when error occurs. can safely above mentioned cases not reason error. why maven built swf throwing error. appreciated....

java - Network of Brokers - ActiveMQ - Any other alternatives? -

we setting pool/network of activemq brokers. issue having every broker instance should know else on network. i.e need update configuration(uri) xml when new broker gets added pool , release brokers. time consuming process , seems on kill. is there better approach? thought of dynamic discovery, needs multicast (not sure, whether supported) is there 1 place can update in network, rather in every broker instance? any appreciated. network of brokers dynamic discovery using multicast standard example, please see network of brokers docs . also, dynamic rebalancing , updating of clients supported (amq version >= 5.4) ( updateclusterclients , rebalanceclusterclients ), please refer failover docs .

mod rewrite - How to use .htaccess to redirect a url which has a # character -

i've been looking @ couple of days, had guys @ work try , figure out didn't far. i have url my.website.com/index.php#!lightbox[gallery]/0/ want redirect my.website.com. can fine index.php, it's parts aren't working. i've tried: rewritecond %{http_host} ^my.website.com$ [nc] rewriterule (.*) http://my.website.com/index.php#!lightbox[gallery]/0/? [r=301,l] and cpanel generated following redirect: rewritecond %{http_host} ^my.website.com$ [or] rewritecond %{http_host} ^www.my.website.com$ rewriterule ^/?$ "http\:\/\/my\.website\.com\/\#\!lightbox\[gallery\]\/0\/" [r=301,l] both output my.website.com/%23!lightbox[gallery]/0/ url - can see hash isn't being processed. if has ideas i'd love hear! thanks :) have rules this: options +followsymlinks -multiviews rewriteengine on rewritecond %{http_host} ^(www\.)?my\.website\.com$ [nc] rewriterule ^/?$ http://my.website.com/index.php#!lightbox[gallery]/0/ [r=301,l,ne] you need...

php - PHPVideoToolkit Execution error -

when try convert video flv using phpvideotoolkit following errors(output of geterrors() method): array ( [0] => phpvideotoolkit error: execute error. output file "" not found. please check server write permissions and/or available codecs compiled ffmpeg. can check encode decode availability inspecting output array phpvideotoolkit::getffmpeginfo(). [1] => phpvideotoolkit error: input file "/home/nik/video1.mp4" not exist ) phpvideotoolkit::getffmpeginfo() contains flv format. i tested ffmpeg command line , works. set permissions both input , output directory , files 777 still getting same errors. what's wrong? well 1 part of says file trying input doesn't exist. secondly, appears output filename empty string.

c++ - Using QLineEdit for passwords -

Image
how can make qlineedit suitable entering passwords (i.e. doesn't show what's entered): setechomode ( documentation) object. example code: ui->lineeditpassword->setechomode(qlineedit::password); you can qt designer:

web - Design pattern for permissions -

i want build web site has few different kinds of users, e.g.: administrator - can on site registered user - can on page. unregistered user - can view website. is there design pattern appropriate situation, , how apply scenario? design patterns aren't magic bullet solving problems. tried , tested means of applying sensible software engineering practice code design.

Silverlight/XAML - How to get parent name of element after MouseLeftButtonUp event? -

i setup simple chessboard (i have hardcoded in xaml) this: <border name="s0" grid.column="0" grid.row="7" background="black"> <image mouseleftbuttondown="image_mouseleftbuttondown" mouseleftbuttonup="image_mouseleftbuttonup" mousemove="image_mousemove" source="/silverlightapplication4;component/all_chess_pieces_png_by_abener.png" canvas.zindex="1" /> </border> each border on board have name s0, s1, s2, etc. on dragging element i'm getting name of starting square, working fine. what want name of end square after droping element square. instead i'm still getting name of square start dragging from. private void image_mouseleftbuttonup(object sender, mousebuttoneventargs e) { image image = (image)sender; canvas border = (canvas)image.parent; image.releasemousecapture(); _isdragging = false; string...

C# Winforms difference between DoubleClick event and MouseDoubleClick event -

quick question here: title says, what's difference between 2 events? as far can tell, mousedoubleclick inherited control , while doubleclick inherited component , there functional difference between two? thanks from msdn documentation : doubleclick events logically higher-level events of control. may raised other user actions, such shortcut key combinations.

php - How can I define scripts in CakePHP? -

whenever trying define 2 scripts way: echo $this->html->script(array('jquery', 'prototype')); only prototype working. when way: echo $this->html->script(array('prototype', 'jquery')); only jquery working. how fix both working? that because both use $ variable, , second script overwrites first. try creating script middle contains: $j = $.noconflict(); //sets `$j` jquery variable then do: echo $this->html->script(array('jquery', 'middlescript', 'prototype'));

Spring Security 3: Method Level Access Failure -

i have url-level security in placed, , also, method level. method level security bypassed once user has been authenticated @ url-level! looked @ further , seems following url-level security: intercept-url pattern="/**" access="role_user" would override of method level security (like below code snippet). @preauthorize("hasrole('role_supervisor')") public string supervisorroleonly() { return "success!!!" ; } i think method throw access-denied error, no, role_user can access method once authenticated @ url-level. i have in security-config.xml : <global-method-security pre-post-annotations="enabled" > <expression-handler ref="expressionhandler"/> </global-method-security> what missing? i guess applies more future readers, when set debug logging spring security see similar following: looking pre/post annotations method 'supervisorroleonly' on target class ...

Nested query microsoft access -

i have table of transactions. table multiple vendors multiple transactions multiple transaction amounts. need update table if vendors transaction more double transaction amount average vendor. far came following code wrong: update tbltransaction set variabilityindicator = 1 transactionnumber in (select transactionnumber tbltransaction group vendorname having transactionamount >= avg(transactionamount*2)) the code above wrong. came statement possibly nested: select avg(transactionamount) vendorname tbltransaction group vendorname this should return vendornames average transaction amounts. how can nest can compare transactionamount average vendor names match?? update tbltransaction set variabilityindicator = 1 transactionnumber in ( select t.transactionnumber tbltransaction t t.transactonamount > 2 * ( select avg(transactionamount) tbltransaction a.vendorname = t.vendorname ) ) you may want check business logic exclude transa...

windows phone 7 - Pause WP7 HyperlinkButton? -

i'm trying 'pause' hyperlinkbutton in wp7 app user can confirm whether or not leave app , follow link. series of events like: the user clicks hyperlinkbutton messagebox pops confirm want leave app , visit external site if user agrees, webpage loads; if not, user returned app my question is: can get hyperlinkbutton to wait user's response? at moment, i've hacked solution below: <hyperlinkbutton tag="http://www.google.com/" tap="confirmbeforeloading()"/> confirmbeforeloading prompts user and, if agree, creates new webbrowsertask using address in tag property. this works, seems 'hackish'. there way can use normal hyperlinkbutton navigateuri , have wait user's response? many in advance! try one,maybe helpfull you, popup mypopup; //golbal variable private void hyperlinkbutton1_click(object sender, routedeventargs e) { layoutroot.opacity = 0.6; mypopup = new pop...

Ruby / Rails calculation -

i have rails 3 application , following problem. need calculate price based on following: term range 1 365 days (1 year). tariffs in tables presented in 2 sections: 1 day , half month (15 days) example 1: prices: 1 day price = 0.5 , 15 days = 6 term : 45 days. price: price devide number of days 15 (45/15 = 3) , multiply result tariff 15 days (3*6 = 18). final price 18. example 2: prices: 1 day price = 0.5 , 15 days = 6 term : 79 days. price: price find half month period in case 45 , again devide number 15 (75/15 = 5) , multiply result tariff 15 days (5*6 = 30). there 4 more days account for, multiple them price day (4*0.5 = 2). sum of 2 results forms final price (30+2 = 32). the period submited through , can 1 day 365 days, prices per day , 15 days stored in database. question how make calculations in ruby/rails, code calculates half month , reminder if any? appreciated. use modulo operator: 79 / 15 # dividing integers performs euclidian division =...

c# - Extending a WebControl using a partial class -

is possible extend, instance, hyperlink control using partial class? i'd define custom properties on control, without having extend class... so... <asp:hyperlink runat="server" custompropertya="a" custompropertyb="b" /> and able use them on oninit/onpreload etc. no. partial types only allow specify code type within multiple source files within same project. that's all. they're compile-time change - don't affect object model, or can types exist etc. it sounds may want create new class derived hyperlink instead.

objective c - Got warning "Incorrect decrement of the reference count of an object that is not owned at this point by the caller" -

when 'analyse', got warning "incorrect decrement of reference count of object not owned @ point caller" in this. (xcode 4.1+) i can understant it's better "kill" object it's proper class, there way outside without warning? thanks! nslog(@"--[%s:%d]",__pretty_function__, __line__); myappdelegate* appdelegate = [[uiapplication sharedapplication] delegate]; if (appdelegate.referencespopup != nil) { [appdelegate.referencespopup release]; // warning appdelegate.referencespopup = nil; } } most likely, way in acquiring object being stored in referencespopup , did not allocate or retain it. in case, not responsible releasing it. can set ivar nil.

c# - Does IF perform better than IF-ELSE? -

Image
which 1 of these blocks of code performs better, , 1 of them more readable? i'd guess gain negligible, particularly in second block. curious. block #1 string height; string width; if (myflag == 1) { height = "60%"; width = "60%"; } else { height = "80%"; width = "80%"; } block #2 string height = "80%"; string width = "80%"; if (myflag == 1) { height = "60%"; width = "60%"; } updated the results when tested above code both blocks performed same block #1 myflag = 1: 3 milliseconds myflag = 0: 3 milliseconds block #2 myflag = 1: 3 milliseconds myflag = 0: 3 milliseconds but 1 important thing noticed here(thanks matthew steeples answer here ) since block of code have tested has not used variables height , width except assignment in if-else , if blocks of code block-1 , 2 respectively, the compiler has optimized il code removing if , if-else blocks ...

linux - Doesn't work diff command (arguments troubles) -

trying diff typing next: $ diff -c $(rpm -qpr prev/p.src.rpm 2>/dev/null) $(rpm -qpr curr/p.src.rpm 2>/dev/null) diff: operand `<=' diff: try `diff --help' more information. how can change arguments normal script working? can try executing script way: $ diff -c <(rpm -qpr prev/p.src.rpm 2>/dev/null) <(rpm -qpr curr/p.src.rpm 2>/dev/null) this should substitute command between "<()" process. create named pipe , given diff file compare. allowing execute above directly in script.

iphone - Class variable memory lifecycle in objective-c -

if declare class variable in .m file (contrast instance variable) , access setter & getter e.g. [myclass setvalue], [myclass value] when variable memory allocated , when freed? just new questions thought of previous question: how store relatively static configurable information assuming you’re realising class variable variable file scope (a global variable ), i.e., variable declared outside of function or method, like: #import "myclass.h" sometype someclassvariable; @implementation myclass … @end then variable said have static storage duration. means that, prior program startup, memory variable allocated , variable initialised. corresponding memory address constant , lifetime entire execution of program. if variable objective-c object, e.g. #import "myclass.h" nsstring *somevariable; @implementation myclass … @end it initialised nil prior program startup. you’ll want assign object, e.g. in +[myclass initialize] or in +[myclass...

ios - UINavigationController scrolls down on back button click -

i'm working on iphone / ipad app several navigation controllers. when click button of view while device in landscape mode, previous view scrolls vertically screen, instead of scrolling horizontally usual. push animations work horizontally, should be. what causing weird problem? thanks, adrian are sure view controller, you're getting to, set deal rotation ? i had similar issue using monotouch.dialog until added autorotate = true; every (non-leaf) dialogviewcontroller inside application.

Scala Map, ambiguity between tuple and function argument list -

val m = scala.collection.mutable.map[string, int]() // doesn't work m += ("foo", 2) // work m += (("foo", 2)) // works val barpair = ("bar", 3) m += barpair so what's deal m += ("foo" , 2) not working? scala gives type error: error: type mismatch; found : java.lang.string("foo") required: (string, int) m += ("foo", 2) ^ apparently scala thinks trying call += 2 arguments, instead of 1 tuple argument. why? isn't unambiguous, since not using m.+= ? unfortunately a b (c, d, e, ..) desugars a.b(c, d, e, ..) . hence error.

javascript - Hijacking onchange event without interfering with original function -

im writing on library want include on different pages might use onchange event - there way attach event onchange without removing original one? edit: onchange on window obj. not single element - onchange in hash change in url etc. sorry if confused them! if i'm correct sounds want inject new code existing event. may if want pure javascript solution , here fiddle demonstrating feature. http://jsfiddle.net/vzcve/1/ var element = document.getelementbyid("myelementid"); element.onchange = (function (onchange) { return function(evt) { // reference event pass argument evt = evt || event; // if existing event existed execute it. if (onchange) { onchange(evt); } // new code "injection" alert("hello2"); } })(element.onchange); edited: tags changed , reference jquery in question jquery continue bind new functions using jquery.change(). note following execute change functions assigned $(docum...

php - Why does fgets read the same lines over and over in wrong order? -

i have been using fgets read list of (20,000) words in file. working fine yesterday, somehow reads text file, list - out of order, reads of same sections on multiple times. it's 1 word per line. simple problem, enough stop workflow in tracks. $fh = fopen('newsymbols.txt','r') or die($php_errormsg); while (! feof($fh)) { if ($s = fgets($fh,1024)) { curious if encountered strangeness fgets . using instead of file_get_contents because particular script used dom objects eat memory in foreach loops. well not iterating through lines because while condition have setted fgets $fh = fopen('newsymbols.txt','r') or die($php_errormsg); while ($s = fgets($fh,1024)) { if ( feof($fh)) {

c# - HTML layout in .NET -

i new htmlayout , know nabu library, , dont know how create html based forms using nabu library, provide example or opensource application uses htmlayout in .net setup? this example find in bit of googling, looks promising.

webview - QNXStageWebView on top of all containers -

i developing application blackberry playbook using flex hero , html contents displayed using qnxstagewebview.but problem when add webview stage coming on top of other display objects.i not able control it.i need solve can continue work. can me solve issue??? import mx.core.flexglobals; import mx.events.flexevent; import qnx.media.qnxstagewebview; public var webview:qnxstagewebview = new qnxstagewebview(); protected function view1_creationcompletehandler(event:flexevent):void { var rect:rectangle = new rectangle(0,0,200,400); webview.stage = stage; webview.viewport = rect; webview.zorder = 1; } ]]> </fx:script> <fx:declarations> <!-- place non-visual elements (e.g., services, value objects) here --> </fx:declarations> <s:button id="buttn" x="0" y="0"/...

c++ - undefined reference to `__gxx_personality_sj0 -

with gcc 4.6 when trying execute code: #include <iostream> using namespace std; #include <bitset> int main() { //int<> a; long long min = std::numeric_limits<int>::min(); unsigned long long max = std::numeric_limits<int>::max(); cout << "min: " << min << '\n'; cout << "max: " << max << '\n'; cout << (min <= max); std::bitset<64> minimal(min); cout << "minimal: " << minimal; return 0; } i'm getting following error: 1. undefined reference __gxx_personality_sj0 2. undefined reference to _unwind_sjlj_register' 3. undefined reference _unwind_sjlj_unregister' 4. undefined reference to _unwind_sjlj_resume' what on hell going on?! these functions part of c++ exception handling support gcc. gcc supports 2 kinds of exception handling, 1 based on calls setjmp , longjmp (sjlj exception h...

iphone - Apple Push Notifications to specific Users -

as far understand apn's can send them app not specific user uses app. is there way of sending apn's specific users use app? can't think of way of doing this... greetz apns not broadcast medium. as says in documentation : apple push notification service transports , routes notification given provider given device. when send notification server, 1 of paramters device id.

why git-completion.bash is not autocompleting show-ref? -

the git autocompletion has show , show-branch not show-ref . because autocompletion list not complete? or there other reason? [note] using latest git source (git version 1.7.5.128.g50d30) come think of it, asnwer, of course: i think show-ref plumbing, not porcelain porcelain can used in various contexts including non-standard (overriden git_dir, git_work_tree, temporary directories, locks, whatnot). ill-advised use completion scripts indiscriminately during such operations, because invariably rely on other git subcommands, may not valid @ time this theory, people welcome supplement :)

c++ - Array of template objects -

i don't know how resolve problem templates , inheritance. in code there templated class looks more or less like: template<typename t> class derived : public base{ t value; public: derived(t arg) { value=arg; }; t getvalue() { return value;}; }; class base{ }; the purpose of base class group array of objects of derived class. parameter t double, float or complex, although int , structs might become useful. (there should several more similar derived classes few additional functions, later.) i can create such group base** m = new base*[numelements]; and assign elements of derived class them, e.g.: m[54] = new derived<double>(100.); but how can find out 55th element has value 100 later? need like virtual t getvalue() = 0; but t typename of derived class , may different 2 elements of array. the visitor pattern best bet here. code iterating array has provide "visitor" object knows how handle each of various types. ...

clojure.contrib.duck-streams FileNotFoundException, why? -

user=> (use '[clojure.contrib.duck-streams]) java.io.filenotfoundexception: not locate clojure/contrib/duck_streams__in it.class or clojure/contrib/duck_streams.clj on classpath: (no_source_file:0) clojure.contrib in classpath still throwing exception. need other jar? i highly recommend using leiningen sort out. try lein repl command quick repl working classpath. according message: http://osdir.com/ml/clojure/2010-10/msg00834.html clojure.contrib.duck-streams has been deprecated.

jQuery Show/Hide Div -

i'm using show/hide div expander, working fine, however, html entities aren't being outputted. $(document).ready(function() { $('.slickbox').hide(); $("#slick-toggle").toggle(function() { $(this).text("&#9650; see less"); $('.slickbox').slidetoggle(500); }, function() { $(this).text("see more &#9660;"); $('.slickbox').slidetoggle(500); }); }); instead of showing or down arrow entities, outputs &#9660; how can make it'll output entities? .text conversion "text" "html" itself. from the documentation : we need aware method escapes string provided necessary render correctly in html. so, calls dom method .createtextnode(), replaces special characters html entity equivalents (such < <). so text being converted &amp;#9650; , being rendered, point-of-view, verbatim . you can encode literal di...

css - Vb.net 8.5 x 11paper to webform -

basically have vb.net form when user clicks submit button going store values in sql database. have done already. what know best way approach after user clicks submit submit form database should use separate button call values crystal report or report designer? or there css template mimic size of piece of paper on web , print seen on screen. i tried create website 612 x 792 googled size of 8.5 x 11 sheet of paper although looked great on web when printed decided print 4 pages when should have been 2 pages. little confused , thinking maybe approaching wrong way advice appreciated. thanks here part of css code trying make size of paper body { background: #b6b7bc; font-size: .70em; font-family: arial; margin: 0px; padding: 0px; color: #696969; } firstpagecontainer { width: 612px; height: 792px; background-color:#ffffff; margin-top: 50px; margin-bottom: 50px; margin-left: auto; margin-right: auto; padding: 0px; bo...

android - How can I refresh the ActionBar when onPrepareOptionsMenu switched menu entries? -

within apps enable/disable menu entries , make them visible onprepareoptionsmenu. today started add android:showasaction menu attribute of android 2.x apps show menu entries used on actionbar. the actionbar not reflect enable/disable , visibility immediately. need click on menu dropdown on right see change happen. ok, understand menu fires onprepareoptionsmenu. need refresh actionbar? think change needs applied within onoptionsitemselected don't know should call. here's menu: <item android:icon="@drawable/ic_menu_mapmode" android:id="@+id/men_mapview" android:showasaction="ifroom|withtext" android:title="@string/txt_mapview" /> <item android:icon="@drawable/ic_menu_mapmode" android:id="@+id/men_satelliteview" android:showasaction="ifroom|withtext" android:title="@string/txt_satelliteview" /> here's onprepareoptionsmenu: @override pub...

javascript - Find and Replace for Textarea Problems -

i'm trying add cool little find , replace system. wan't make highlights found items(which code doesn't right now). wan't add find next button (right replaces found). my javascript is: function replacecharacters() { var inchar = document.form1.inc.value; var outchar = document.form1.outc.value; var newstring = document.form1.cool.value.split(inchar); newstring = newstring.join(outchar); document.form1.cool.value = newstring; } and html is: <form name="form1" method="post" action=""> <textarea class="code" name="cool" type="text" id="cool"> little text testing. </textarea> <br> replace instances of: <input name="inc" type="text" id="inc" value="tr" size="4"> with: <input name="outc" type="text" id="outc" value="w" size="4"> <br> <input type=...

sql - Oracle select for update behaviour -

the problem try solve looks this. we have table full of rows represent cards. purpose of reservation transaction assign card client a card can not belong many clients after time (if not bought) card has returned pool of available resurces reservation can done many clients @ same time we use oracle database storing data, solution has work @ least on oracle 11 our solution assign status card, , store it's reservation date. when reserving card using "select update" statement. query looks available cards , cards reserved long time ago. however our query doesn't work expected. i have prepared simplified situation explain problem. have card_numbers table, full of data - of rows have non-null id numbers. now, let's try lock of them. -- first, in session 1 set autocommit off; select id card_numbers id not null , rownum <= 1 update skip locked; we don't commit transaction here, row has locked. -- later, in session 2 set autocommit off;...