Posts

Showing posts from September, 2013

java - Unit testing with mockito for constructors -

i have 1 class. class first { private second second; public first(int num, string str) { second = new second(str); this.num = num; } ... // other methods } i want write unit tests public methods of class first. want avoid execution of constructor of class second. i did this: second second = mockito.mock(second.class); mockito.when(new second(any(string.class).thenreturn(null); first first = new first(null, null); it still calling constructor of class second. how can avoid it? once again problem unit-testing comes manually creating objects using new operator. consider passing created second instead: class first { private second second; public first(int num, second second) { this.second = second; this.num = num; } // other methods... } i know might mean major rewrite of api, there no other way. class doesn't have sense: mockito.when(new second(any(string.class).thenreturn(null))); first of mockito ...

javascript - play pls file in browser -

i need play pls file in website, each user can listen it. 1 way use flash , actionscript, i've been searching way play in browser using javascript or html5. is there way play pls files in browser using html5 or javascript? a pls file has format: [playlist] numberofentries=x file1=http://80.86.106.136:80/ file2=http://80.86.106.136:80/ ... so need read content , this var content = readpls(); var data = content.split('\n\r'); var number_of_files = data[1].replace('numberofentries=',''); var files = []; for(var i=0;i<number_of_files;i++){ files.push(data[2+i].replace("file"+(i+1),'')) } code needs work, way go (in js/as)

ruby on rails 3 - How to tell if reads are being redirect to MySQL slave on Rails3 -

[update] may use (or misuse) of seamless_database_pool gem. i setup master/slave setup on rails3 using seamless_database_pool . mean reads not being redirected slave? how can check @ mysql level? hoping show processlist this, i'm not seeing processes. [update] running show processlist on master displays queries being run, guess reads not being passed slave. the bin_log file has following (9's , x's added): /*!40019 set @@session.max_insert_delayed_threads=0*/; /*!50003 set @old_completion_type=@@completion_type,completion_type=0*/; delimiter /*!*/; \# @ 4 \#xxxxxxx 99:99:99 server id 2 end_log_pos 106 start: binlog v 4, server v 5.1.52-log created xxxx 99:99:99 @ startup rollback/*!*/; binlog ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx '/*!*/; \# @ 106 \#xxxx 99:99:99 server id 2 end_log_pos 125 stop delimiter ; \# end of log file rollback /* added mysqlbinlog */; /*!50003 set completion_type=@old_completion_type...

Ruby gem for text comparison -

i looking gem can compare 2 strings (in case paragraphs of text) , able gauge likelihood similar in content (with perhaps few words rearranged, changed). believe uses similar when users submit questions. i'd use diff::lcs: >> require "diff/lcs" >> seq1 = "lorem ipsum dolor sit amet consequtor".split(" ") >> seq2 = "lorem ipsum dolor amet sit consequtor".split(" ") 1.9.3-p194 :010 > diff::lcs.diff(seq1, seq2).length => 2 it uses longest common subsequence algorithm (the method using lcs diff described on the wiki page ).

Newbie Programming: HTML5 Display Image - button onclick= -

first time programmer here, writing simple program on html5. can't seem image display when button clicked. here code: <p> <center> <button onclick="deadtest()"> <img src="begintest.gif"/></button></center></p> <script language="javascript" type="text/javascript"> function deadtest() { <img style="border-width: 0px;" src="white.jpg" width="768" height="1280" /> } </script> have looked through countless sites , forums can't seem work. have tried alert() function , working. think must code call on image. first time programmer might idiotic. teach me, oh guru's... learn basics first on how call javascript function , how change properties. see sample demo. hope learn it. http://jsfiddle.net/ngrym/1/ <script type="text/javascript"> function...

c++ - Is it a good idea to shut down a class's thread member in the class's destructor? -

what's best way shut down boost thread managed c++ class when it's time object of class destroyed? have class creates , starts thread on construction , provides public wake() method wakes thread when it's time work. wake() method uses boost mutex , boost condition variable signal thread; thread procedure waits on condition variable, work , goes waiting. at moment, shut thread down in class's destructor, using boolean member variable "running" flag; clear flag , call notify_one() on condition variable. thread procedure wakes up, notices "running" false, , returns. here's code: class worker { public: worker(); ~worker(); void wake(); private: worker(worker const& rhs); // prevent copying worker& operator=(worker const& rhs); // prevent assignment void threadproc(); bool m_running; boost::mutex m_mutex; boost::condition_variable m_condition; boost::scoped_p...

httpclient - Tapestry, request processing from another application -

i'have 2 web appli, tapestry appli , simple web appli(servelt). in tapestry appli , have form, , when it'll sent, call httpclient sending informations author appli using apache's httpclient. void onsubmitfromform() { try { httpclient client = new defaulthttpclient(); httppost post = new httppost("http://localhost:8080/appli2/recep"); post.setheader("referer", "http://localhost:9090/app1/start"); list<namevaluepair> param = new arraylist<namevaluepair>(); param.add(new basicnamevaluepair("_data", getdata()); post.setentity(new urlencodedformentity(param)); httpresponse response = client.execute(post); response ????? } catch (exception e) { e.printstacktrace(); } } and in servelt recep of simple web appli(2) same below protected void dopost(httpservletrequest request, httpservletresponse re...

ruby on rails - Accessing Devise Config Variables -

in rails app, way access devise config variable directly view? i want show config.allow_unconfirmed_access_for devise's :confirmable module. variable set in devise.rb initializer: devise.setup config.allow_unconfirmed_access_for = 3.days end thanks! the configurations on devise.rb file replicated on devise model, if devise resource user , should able access through user.allow_unconfirmed_access_for . so, create instance variable on controller , assign value it, , you'll able show on view.

What is the best way to access the last entered key in a default dict in Python? -

i have default dict of dicts primary key timestamp in string form 'yyyymmdd hh:mm:ss.' keys entered sequentially. how access last entered key or key latest timestamp? use ordereddict collections module if need access last item entered. if, however, need maintain continuous sorting, need use different data structure entirely, or @ least auxiliary 1 purposes of indexing. edit: add that, if accessing final element operation have rarely, may sufficient sort dict's keys , select maximum. if have frequently, however, repeatedly sorting become prohibitively expensive. depending on how code works, simplest approach maintain single variable that, @ given point, contains last key added and/or maximum value added (i.e., updated each subsequent addition dict). if want maintain record of additions extends beyond last item, however, , don't require continuous sorting, ordereddict ideal.

c# - Invoke Javascript method from code-behind based on a condition. -

this javascript method in .aspx file. want invoke method code-behind based on condition: function confirmboxandhidemessage() { //hidemessage(); var response = confirm("are sure?."); if (response == true) { document.getelementbyid("<%=chkvalidated.clientid%>").checked = true; hidemessage(); } else { hidemessage(); return true; } } the condition upon want invoke this: if (obj.fkvalidationstatusid.hasvalue && obj.fkvalidationstatusid.value.equals(1)) { btnproceedaddnewrecords.attributes.add("onclick", "javascript:return confirmboxandhidemessage();"); } else { btnproceedaddnewrecords.attributes.remove("onclick"); } this condition being exercised in method called in pageload event inside if (!ispostback) { /* condition */ } it not working , guess way adding method in button attribute ...

exif - How to manipulate diverse meta-infomations of image files in PHP -

there diverse formats add meta-information image (and video) files. every digitalcamera add them fotos. , people don't want them published. the standards found far are: exif iptc-naa xmp are there more? (e.g. not image specific, general meta standard, can attached end of every file) reading information saved, using php seems possible 3 named formats. for xmp: how can read xmp data jpg php? for exif php provides functions: http://de2.php.net/manual/de/function.exif-read-data.php (but jpeg , tiff, or can exif data attached image formats? ) also iptc: http://de2.php.net/manual/de/function.iptcparse.php but how can data manipulated (changed, added) how can delete possible meta-data using php? (i.e. infomation not belong image itself) open , save image gd . should remove meta data because gd lib cannot handle it. if doesn't cut it, try of http://lsolesen.github.com/pel/ http://ozhiker.com/electronics/pjmt/ http://php.net/iptcembed

excel - How do I combine two private Worksheet_Change subs into one in VBA? -

i have code : private sub worksheet_change(byval target range) dim lastrow long dim rnglist range lastrow = cells(rows.count, "a").end(xlup).row set rnglist = range("ab3").currentregion if target.cells.count > 1 exit sub on error resume next if not intersect(target, range("b18:b19")) nothing ' user in column-a target.value = application.worksheetfunction.vlookup(target.value, rnglist, 2, false) end if set rnglist = nothing end sub and private sub worksheet_change(byval target range) dim lastrow long dim rnglist range lastrow = cells(rows.count, "a").end(xlup).row set rnglist = range("ac3").currentregion if target.cells.count > 1 exit sub on error resume next if not intersect(target, range("b10:b11")) nothing ' user in column-a target.value = application.worksheetfunction.vlookup(target.value, rnglist, 2, false) end if set rnglist = nothing ...

xpages - How can I allow selection of a date using the calendar button but disable typing of date in Dojo Date Textbox? -

how can allow selection of date using calandar button disable typing of date in dojo date textbox? is there way this? if how? basically want users able select date using calendar button don't allow them manually enter date. create client-side onfocus event: thisevent.target.blur(); that doesn't prevent field's value being programmatically populated via date helper, if try manually focus (i.e. click or tab into) field, kick them out again.

c++ - Using OpenSSL in a multi-threaded application -

i have been writing soap client application in c++ on ubuntu using openssl https transport , pthreads threading. have number of threads - 1 central data acquisition thread periodically gets worker threads make soap requests via shared mutex protected queues. reading documentation openssl found is openssl thread-safe? in openssl faq describes mechanisms required ensure thread safety when using openssl. implemented , works fine. the reason question conceptual difficulty really. thinking implementing same functionality application has already, instead of using threads, create 2 seperate applications : 1 worker thread (of multiple copies running) , main data acquisition thread. use tcp sockets communicate between 2 rather mutex protected queues. may bad idea not important - confusing me would have implement same functions required ensure openssl thread safety in second approach or not? my guess not have , treated independent (indeed surely must many applications use openssl) re...

layout - view not rendered properly in rails -

i have model - products, productscontroller , layout product. declared layout inside controller. added css/js/images app assets folder. did rails guide told me when want have custom layout. still doesn't show layout declared shows me default page without formatting , settings. my files follows products controller class productscontroller < applicationcontroller layout "product" # /products # /products.json def index @products = product.all respond_to |format| format.html # index.html.erb format.json { render json: @products } end end end and layout file <!doctype html> <html> <head> <title>cool amazon products</title> <%= stylesheet_link_tag "application" %> <%= stylesheet_link_tag "bootstrap" %> <%= stylesheet_link_tag "bootstrap-responsive" %> <%= javascript_include_tag "application" %> <%= csrf_meta_...

asp.net - How do I change the image on a <asp:buttonField type="Image" /> in code behind? -

i have <asp:gridview > <asp:buttonfield buttontype="image"> 1 of columns. here's problem: have dynamically change image of buttonfield during gridview_rowdatabound(...) event based on data found in particular gridview row. the real question is, how access particular buttonfield inside gridview_rowdatabound(...) event can change image in c# code? i can't use image imgctrl = (image)args.row.findcontrol("ctrlid"); because <asp:buttonfield> won't allow id set (get parser error when try run webpage). , can't use args.row.cells[0].controls[0]; because zeroth index of .controls[0] doesn't exist (i boundry overflow error). there's got simple, slick, easy way this! quick example : protected void gridview1_rowdatabound(object sender, gridviewroweventargs e) { datarowview drv = (datarowview)e.row.dataitem; if (e.row.rowtype == datacontrolrowtype.datarow) { ...

gnu make - stop on error when target of makefile rule is a foreach function -

i have makefile defines several rules target foreach function. $(foreach var,$(list), $($(var)_stuff) $($(var)_more_stuff)): @echo building $@ $^... $(cc) $(flags) ... is there way make quit when encountering error without going through entire list. the foreach evaluated , substituted before any of rules executed. behaviour of should identical if had hardcoded rule without using foreach . in other words, it's not directly relevant problem. there few possible explanations you're seeing, described in manual here : you running make -k or --keep-going you running make -i or --ignore-errors your targets defined prerequisites of special .ignore target your recipe starts - your recipe isn't returning non-zero exit status

xaml - How to show focus rectangle when the item in list is selected in WPF -

i want show focus rectangle of item when selected. because isfocusedproperty read-only, can't xaml. how can show focused rectangle... any appreciated. the focus rectangle part of keyboard focus, , displayed when user uses keyboard set focus input element. tested out manually setting keyboard focus (using keyboard.focus()), doesn't seem work. so i'd recommend creating custom style simulate focus rect when listboxitem selected. came style below seems work. matches focus rect's dash array doesn't strange when real focus rect displayed. <controltemplate targettype="{x:type listboxitem}"> <grid> <border background="{templatebinding background}"> <contentpresenter margin="{templatebinding padding}"/> </border> </grid> <controltemplate.triggers> <trigger property="isselected" value="true"> <setter property="backg...

binding - Jquery.Hotkeys behaviour -

i decent javascript programmer, not have deep understanding of dom, question should simple programer, hope. i trying use jquery.hotkeys lib. here's noticed: if do: $(document).ready( function(){ $(document).bind('keydown', 'ctrl+q', alertworld); }); it works perfectly. when do $(document).bind('keydown', 'ctrl+q', alertworld); it binds every single keydown press alertworld function. want understand why behaves so. imagined should work fine in second code example. please help. thanx in anticipation

java - Build timestamp using Hudson and Maven? -

from build time set in project built maven , hudson? use plugin: <plugin> <groupid>com.keyboardsamurais.maven</groupid> <artifactid>maven-timestamp-plugin</artifactid> <version>1.0</version> <configuration> <propertyname>timestamp</propertyname> <timestamppattern>dd.mm.yyyy hh:mm</timestamppattern> </configuration> <executions> <execution> <goals> <goal>create</goal> </goals> </execution> </executions> </plugin>

silverlight - Strange behaviour when not using dispatcher -

i know must use dispatcher whenever try access ui element different thread, today encountered want ask about. have list populated objects of class row ( custom class) , each row populated cell(custom class). each cell has property cellwidth. populate list inside viewmodel , pass view make observablecollection out of list. grid's width bound cellwidth in ui. so, if set width not using dispatcher ( inside viewmodel), grid ignores binding, if use , works fine. (note: exception not raised when don't use dispatcher) the question is: why happening? thought issue dispatcher addresses threading... public mainpageviewmodel() { idatatablemodel table1 = new observablecollection<row>(); setcellwidth(table1); } private void setcellwidth(idatatablemodel model) { list<double> widths = new list<double>(); //initializing widths values <...> deployment.current.dispatcher.begininvoke(() => { foreach(var item i...

c# - Debugging Stopping a Windows Service -

i'm debugging windows service in vs2010 with: static void main() { #if (debug) var s1 = new service1(); s1.start(); thread.sleep(timeout.infinite); #else servicebase.run(new servicebase[] { new service1() }); #endif } this lets me run service in debugger. problem on starting, service opens wcf channel seems tie socket after kill process stopping debugging. how close socket when stop debugging or if service stopped. tried setting breakpoints in service destructor, , both onstop , onshutdown methods, these aren't called. as far know when end debugging in visual studio, process killed without calls finalizers , code located finally blocks not executed.

eventbrite - Searches with complex keyword sets -

i'd make more robust searches including keyword variants. api doesn't appear support wild cards or automatically include variants. can @ eventbrite explain how out of keyword parameter? also, how multiple keywords handled? can search handle doublets or longer sets? can search done boolean operators? so far, have seen simple searches (single word) working. can more this? eventbrite uses apache lucene / solr it's search back-end. provides basic keyword stemming features , full-text search on event title , description. by default, multiple keywords handled 'and' operator: searching 'bikes' , 'tacos' (keywords=bikes%20tacos), should return events mention "taco" or "tacos" , "bike" or "bikes". keyword stemming support allows automatically match on english-language pluralizations. if want find events mention either 'bikes' or 'tacos', can separate keywords 'or' clause (k...

.htaccess - PyroCMS - Assets class doesn't minify and combine -

i have problem assets class minify , combine css , js. have plugin ad seems work without problem: class plugin_theme_assets extends plugin { /** * combine , insert multiple js files * * usage: * { theme_assets:js_files files="file1.js,file2.js" } */ function js_files() { $files = $this->attribute('files'); preg_match_all('/[\w-\.]+\.js/i', $files, $files_a); foreach($files_a[0] $file) { asset::js($file); } return asset::render_js(); } /** * combine , insert multiple css files * * usage: * { theme_assets:css_files files="file1.css,file2.css" } */ function css_files() { $files = $this->attribute('files'); preg_match_all('/[\w-\.]+\.css/i', $files, $files_a); foreach($files_a[0] $file) { asset::css($file); } return asset::render_css(); ...

iphone - Show recorded audios in tableview -

i have view responsible recording audio. how can record several audios , show them in table view? i'm trying use docs directory save recorded audios: nsarray *folders = nssearchpathfordirectoriesindomains(nsdocumentdirectory,nsuserdomainmask, yes); nsstring *documentsfolder = [folders objectatindex:0]; nsstring *recordedaudio = [documentsfolder stringbyappendingpathcomponent:newaudio]; newaudio string contains new audio name typed user suffix .m4a. retrieve saved audios i'm trying this: nsarray *folders = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsfolder = [folders objectatindex:0]; nsarray *foldercontents = [[nsarray alloc] initwithcontentsoffile:documentsfolder]; i expected foldercontents have audios stored @ documentsfolder load table, count 0. i'm new in docs directory, i'm missing something, or doing wrong. what wrong, or there way accomplish that? you getting contents of documents ...

linux - How should I batch make thumbnails with the original images located in multiple subdirectories? -

i have original images in directory structure looks this: ./alabama/1.jpg ./alabama/2.jpg ./alabama/3.jpg ./alaska/1.jpg ...the rest of states... i wanted convert of original images thumbnails can display them on website. after bit of digging / experimenting, came following linux command: find . -type f -iname '*.jpg' | sed -e 's/\.jpg$//' | xargs -i y convert y.jpg -thumbnail x100\> y-small.jpg it recursively finds jpg images in subdirectories, removes file type (.jpg) them can rename them later, makes them thumbnail , renames them '-small' appended before file type. it worked purposes, tad complicated , isn't robust. example, i'm not sure how insert 'small-' @ beginning of file's name (so ./alabama/small-1.jpg ). questions: is there better, more robust way of creating thumbnails images located in multiple subdirectories? can make existing command more robust (for example, using sed rename outputted thumbnail before...

camera - How to make a blur (tilt shift like) effect in android? -

i'm trying blur(tilt shift like) effect make pictures this , guess adding blur top , bottom of image. i wonder if effect in real-time when user looking @ camera view or worst case senario on bitmap after taking picture. if know how basic blur, effect you're looking shouldn't hard. basically, increase blur strength closer top/bottom edges of image. increasing contrast/saturation common 'tilt-shift' effects. for ideas on how fast blur in first place, check this question . as speed, i'm sure real-time, log you're doing on preview-sized bitmap since small, comparatively. run function again on actual size image once it's taken.

PHP, MySQL - My own version of SALT (I call salty) - Login Issue -

ok wrote own version of salt call salty lol don't make fun of me.. anyway registration part of script follows working 100% correctly. //generate salty own version of salt , likes me salt.. lol function rand_string( $length ) { $chars = "abcdefghijklmnopqrstuwxyzabcdefghijklmnopqrstuwxyz1234567890"; $size = strlen( $chars ); for( $i = 0; $i < $length; $i++ ) { $str .= $chars[ rand( 0, $size - 1 ) ]; } return $str; } $salty = rand_string( 256 ); //generate salty pw $password = crypt('password'); $hash = $password . $salty; $newpass = $hash; //insert data in database include ('../../scripts/dbconnect.php'); //update db record salty pw ;) // tested , without salty //hence $password , $newpass mysql_query("update `register` set `password` = '$password'...

design - writing java doc, validation, test when coding or after coding. what's better -

somebody told me should writing java doc,parameter validation,testing when coding. in fact, write them after basic code completed. question what's better? by writing tests/docs/validation first, gain concerete idea of what code needs accomplish before moving on how so. may want check out this article on benefits of writing unit tests first. testing first part of extreme programming , test driven development methodologies. may wish explore them see how fits overall software development process. keep in mind there lot of other elements these methodologies well, adopting them wholesale may not best decision depending on specifics of project.

java - Android - Get keyboard key press -

i want catch press of key of softkeyboard. don't want editview or textview in activity, event must handled extended view inside activity. i tried this: 1) override onkeyup(int keycode, keyevent event) activity method. don't work softkeybord catch few hardkeyboard. 2) create onkeylistener , register in view contains registered , working ontouchlistener . not work @ softkeyboar. 3) override onkeyup(int keycode, keyevent event) view method. not work @ niether if set onkeylistener nor if don't set it. 4) inputmethodmanager object call method showsoftinput , passing view. don't work neither raise keyboard, indeed have call togglesoftinput ; nor catch key events. i tested in emulator think it's enough. why it's complicate take simple key event keyboard ? try using dispatchkeyevent(keyevent event) in activity @override public boolean dispatchkeyevent(keyevent event) { log.i("key pressed", string.valueof(event.getkeyco...

Can Environment.getExternalStorageState() be not mounted on Android ICS? -

i have following code previous projects android 2.1-2.3 checks if sd card mounted , writable or not. @override protected void onresume() { super.onresume(); checksdcard(); } private void checksdcard(){ string state = environment.getexternalstoragestate(); if (environment.media_mounted.equals(state)) { log.d(tag, "sd card mounted , writable."); } else if (environment.media_mounted_read_only.equals(state)) { log.d(tag, "sdcard mounted readonly"); } else { log.d(tag, "sdcard state: " + state); mwarningsdcarddialog = new alertdialog.builder(this) .settitle("warning") .setmessage(r.string.warning_sdcard_message) .setpositivebutton(getstring(android.r.string.ok), mwarningsdcarddialogclicllistener) .setcancelable(false) .create(); mwarningsdcarddialog.show(); } } now i'm ...

c# - is there any difference between return void and not return in a void function -

here's situation: call void function in program, provide messagebox ok , cancel, function encapsulated. need know user click on. so there anyway hijack function know user choice? or think when programmer write function, must return void when user click cancel, , didn't return when user click ok. possible can differentiated these 2 actions - return void , not return anything? i know seems impossible, why come stackoverflow asking guys. thank you a function returns void has 1 return - nothing - , there no difference between returning nothing or returning void . if you're unable change existing function , display messagebox, i'd scrap , start again if you. what want like: public dialogresult getdialogresult(string message, string caption) { return messagebox.show(message, caption, messageboxbuttons.okcancel); } call message want , caption, , you'll return of either dialogresult.ok or dialogresult.cancel if more display messagebox, op...

windows phone 7 - How to color fill a country on a map outline -

is possible in bing or nokia maps display blank map of world each country outlined border, , fill countries solid color? thanks! you can render arbitrary polygons on top of bing maps, there's no built in functionality render regions provinces, states, counties, etc. in order highlight region need provide points of polygon , overlay on region on map. here's great article discusses drawing "advanced" polygon shapes version 7 of bing maps ajax control. “advanced shapes” (i.e. donut polygons) on bing maps a possible duplicate question in regards bing maps api bing map - highlight country polygon on hover

joomla - Start Akeeba Backup Using a Cron Job -

we using akeeba backup backing our joomla website. possible start backup calling url described here: https://www.akeebabackup.com/documentation/quick-start-guide/automating-the-backup.html . automate backup of our site want call url using daily executed cron job. our web hoster supports creation of cron jobs, cannot use shell scripts or something. execution of php script supported. have call url using php script. created script , works fine when calling directly using browser. when try execute using cron job receive error 302, means, document has temporarily moved. don't know that. script want execute: <?php $result = file_get_contents("http://www.mysite.net/index.php?option=com_akeeba&view=backup&key=topsecret&format=r"); ?> i not experienced cron jobs or php nice. thanks time. it suffices read the documentation . tells how use wget or curl use cron job. moreover, there section called "a php alternative wget". write docu...

windows phone 7 - Push Pin not locating in bing maps -

the push pin tool not finding location when provide value manually (latitude , longitude). here code: double dbllat = 13.060407; double dbllong = 80.249562; pushpin mypin = new pushpin(); watcher = new geocoordinatewatcher(geopositionaccuracy.high); watcher.movementthreshold = 40; watcher.start(); watcher.position.location.latitude = dbllat; watcher.position.location.longitude = dbllong; mypin .location.latitude = dbllat; mypin .location.longitude = dbllong; //credentialsprovider cp= map1.center = new geocoordinate(mypin.location.latitude, mypin.location.longitude); map1.setview(mypin .location, 5.0); push.tag = "location"; push.content = "i'm here"; map1.children.add(mypin); watcher.stop(); what doing wrong? if thats error: one or more waypoints can't routed because far ro...

Best practice of testing django-rq ( python-rq ) in Django -

i'll start using django-rq in project. django integration rq, redis based python queuing library. what best practice of testing django apps using rq? for example, if want test app black box, after user makes actions want execute jobs in current queue, , check results in db. how can in django-tests? i found django-rq , allows spin worker in test environment executes tasks on queue , quits. from django.test impor testcase django_rq import get_worker class mytest(testcase): def test_something_that_creates_jobs(self): ... # stuff init jobs. get_worker().work(burst=true) # processes jobs stop. ... # asserts job stuff done.

encryption - En/decrypt between php and j2me app -

i have blackberry app (j2me) encrypt data , sends server, php page, , again. app use lcrypto-j2me-147 (bouncy castle) , mcrypt php part. problem encrypting same text , producing different results. 2 can't send encrypted data 1 another. my test system: php code: <?php function printstringtohex($text) { $size = strlen($text); for($i = 0; $i < $size; $i++) { echo dechex(ord($text[$i])) . " "; } } function encrypt($key, $input) { echo "<pre>*** encrypt *** </pre>"; echo "<pre>raw input: " . $input . "</pre>"; $size = mcrypt_get_block_size('twofish', 'ecb'); echo "<pre>block: " . $size . "</pre>"; $input = pkcs5_pad($input, $size); echo "<pre>pkcs#5 padding: "; echo printstringtohex($input); echo "</pre>"; $td = mcrypt_module_open('twofish', '', ...

c# - Connecting to OLAP Cube via Silverlight -

i want create silverlight app extract , manipulate data existing olap cube . it's first time ms technologies , want know best way that. should use libraries? ones? can directly without external dependencies? i found articles talking web services ms analysis services ... should avoid connecting directly olap cube , make web services ? i have searched on google haven't found tutorials , libraries found not free. // ps : have telerik license, in case helps. what best way this? progress : the cube deployed on ssas , have access , tested many mdx query ms sql server management studio . can give example how launch mdx query silverlight page , display result ? don't need library, need query result , display self ... i can speak ssas. if connecting sql server analysis server, can use ado md.net objects. ( http://msdn.microsoft.com/en-us/library/ms123483.aspx ). or can use http pump. ( http://technet.microsoft.com/en-us/library/cc917711.aspx ...

Android - writing/saving files from native code only -

i'm trying build android app makes use of nativeactivity facility of ndk. i'm having following structure: a bunch of native shared libraries installed in /system/vendor/<company> ; i'm working custom built android image there's no problem having libraries there proper permissions , everything a couple of applications using nativeactivity depend in turn on libraries mentioned above the libraries installed in /system/vendor , applications use couple of configuration files. there's no problem reading them using standard c api fopen/fclose . libraries , application need store files result of operation, configuration, run-time parameters, calibration data, log files etc. storing of files there slight issue i'm not allowed write /system/vendor/... (as file system under "/system/..." mounted read-only , not want hack on that). so best way create , store files , best "conforming android" storage area ? i've been reading co...

php - Solr: Check if a document exists without retrieving the document -

i need find out if document exists documents saved in solr server pretty big if classic search retrieve document specified id , document returned takes time process. there possibility return example number of matching documents without retrieving actual documents ? yes, possible. can set rows=0 when submitting query, execute it. no actual documents returned. in response, can read numfound attribute response. if numfound=1 (since id), document found.

FF Addon-sdk: easy way to avoid server scripts -

i'm trying to, given target website, avoid server-scripts. in order that, first downloaded contents of page , created pagemod detects url. problem that, then, want load stored contents don't know how easily. example, i've tried: new pagemod({ include: /(http:\/\/)?(www.google)(.([a-z]){2,3}){1,2}(\/)?/, contenturl: data.url('google.html'), contentscriptwhen: 'end', contentscriptfile: [data.url('contentscripts/jquery.js'), data.url('contentscripts/handlequery.js')], contentscript: 'alert("' + data.load('contentscripts/google.html') + '");', onattach: function getquery(worker) { ... } where google.html google's main page. gives me lot of errors... does know better solution? edit : goal to, somehow, avoid scripts server can execute when go website (php, c#, etc). thought if download page client-code (html, css, javascri...

reporting services - In SSRS, is it possible to set the AutoRefresh value to an expression? -

i've set report using ssrs , autorefresh data continuously added. simple solution set value constant easy enough. however, report error log user able shut off or delay refresh while read messages. i've tried adding parameter refresh integer cannot set autorefresh value expression via =parameters!refresh.value and =[@refresh] ssrs yells @ me saying "property value not valid. param not valid value int32." i appreciate help. yes, autorefresh can use expression in ssrs 2012. i able set correctly on ssrs 2012 , make work. data type of parameter must integer. data type using? version of ssrs using? edit: have confirmed not work in ssrs 2008. however, if using ssrs 2008 r2, change project property targetserverversion sql server 2008 r2, , work. have working in test environment.

android - Dialog displays differently on ICS devices that it does with older versions -

Image
when display dialog on ics device in landscape mode dialog shows in same width did in portrait mode. but on device running gingerbread when dialog in landscape mode displays width across screen not having compact did change how dialog display's in ics not display across screen in second picture? how can show second picture not compact first one? also targeted api application 2.2 cant use ics api's or anything edit this how call dialogs incdialog = new messagedialog(this, r.style.fullheightdialog); incdialog.popupmessage(this, omessage); dialogs in separate class extends dialog this popupmessage method shows daialog public void popupmessage(final context context, clsmessagerecord omessage) { mainactivity.lastmessageclicked = omessage; mocallingcontext = context; momessage = omessage; mainactivity.mishowndialogtype = dialogid; mainactivity.setshownmessage(momessage); mainactivity.mbintentwasshown = true; log.i(classname +...

java - How to inject a Spring bean id into another Spring Configured Bean? -

i want able pass bean id bean reference. if have this: <bean id="specialname" class="my.specialbean"/> <bean id="referencebean" class="my.referencebean"> <property name="refid" value="<specialname.name>"/> </bean> public class referencebean { // spring injected value of should 'specialname' public string refid; // getter & setter refid } the reason need this, referencebean route builder in camel , directs messages specialbean through spring registry. i'm new spring , camel, if ill conceived questions, apologies. you can use spring-el - <bean id="specialname" class="my.specialbean"/> <bean id="referencebean" class="my.referencebean"> <property name="refid" value="#{specialname.name}"/> </bean>

Calculate.h file not found in Xcode -

i'm learning how use xcode , i'm using book called "beginning max os x programming". i'm working on 1 of first exercises. , told me save c file called "calculate.h" in same file main.c , calculate.c. right away, debugger giving me error saying "calculate.h file not found." here's code main.c: #include <stdio.h> #include <stdlib.h> #include <calculate.h> int main (int argc, const char * argv[]) { int a, b, count, answer; char op; // pringt prompt printf("enter expression: "); // expression count = scanf("%d %c %d", &a, &op, &b); if (count !=3) { printf("bad expression\n"); return 1; } // perform computation answer = calculate(a, b, op); // prin answer printf("%d %c %d = %d\n", a, op, b, answer); return 0; } here code calculate.h: int calculate(int a, int b, char operator); here code calculate.c: #include <stdio.h> #include <stdli...

C++: how to check if a string is all lowercase and alphanumerics? -

is there method checks these cases? or need parse each letter in string, , check if it's islower(letter) , number/letter? thanks! you can use islower() , isalnum() check conditions each character. there no string-level function this, you'll have write own.

javascript - knockout throws Message: TypeError: <xxx> is not a function. What does it mean? -

i have code: <ul id="chats" data-bind="foreach: chats"> <li> <div class="chat_response" data-bind="visible: commentlist().length == 0"> <form data-bind="submit: $root.addcomment"> <input class="comment_field" placeholder="comment…" data-bind="value: newcommenttext" /> </form> </div> <a class="read_more_messages" data-bind="visible: morechats, click: showmorechats">read more messages...</a> </li> </ul> function chatlistviewmodel(chats) { // data var self = this; self.chats = ko.observablearray(ko.utils.arraymap(chats, function (chat) { return { courseitemdescription: chat.courseitemdescription, commentlist: ko.observablearray(chat.commentlist), courseitemid: chat.courseitemid, username: chat.username, chatg...