Posts

Showing posts from July, 2015

fMRI Brain Image Registration in Matlab or Python between Patients -

so, use spm register fmri brain images between same patient; however, having trouble registering images between patients. essentially, want register brain atlas patient-specific scan, can image patching. register, apply warping , transformation number of images. spm unsuccessful in such registration. cannot warp atlas in same brain shape patient brain. would software such freesurfer this?? or there better out there in either matlab or python (but preferably python)?? thanks! tylerthemiler freesurfer segments , annotates brain in patient's native space, resulting in patient-specific regions, so . i'm not sure mean patching, or other images you'd apply transformation, seems software compatible working individual patient data, rather normalized data across patients.

Android Bitmap Height and Width equaling -1 -

i have 200 x 30 png-24 image trying load application. i've imported multiple other pngs using same method , work fine. when png loaded causes bitmap returned have -1 width , height. bitmap wont draw. mgameover=bitmapfactory.decoderesource(c.getresources(), r.drawable.gameover); the line load in resource. doesn't help. have tried cleaning project , still doesn't work. tried recreating png still isn't working. any ideas? when bitmap factory returns -1,-1 in bitmap width , height of bitmap means android unable decode resource. - answer vector

textbox - AJAX options box when clicking on a word? -

is possible ? have phrase on textbox: "i went home" then when click "home" options box shows like: "i entered home" |garden| | motel| |______| sorry ugly way show it, couldn't think better lol <!doctype html> <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(function(){ $("#fieldname").focus(function(){ var el = $(this); var coords = el.offset(); var div = $("<div>").addclass("dropdown").html("<span>garden</span><span>motel</span>").css({"top":coords.top+18+"px","left":coords.left+45+"px"}); el.after(div); $(".dropdown span").click(function(){ var newtext = "i entered " + $(this).text();

string - VBA macro copies same data to each cell -

i have macro: sub stringchecker() dim string_arr() variant dim k integer dim c range set c = activesheet.[a1] end_string = array(" &", _ " tr", _ " sr", _ " defen") substring = array(" sr ", _ " jr ") while c <> "end loop" c.offset(0, 1) = c k = 0 ubound(end_string) if right(c, len(end_string(k))) = end_string(k) cleaner_string = mid(c, 1, len(c) - len(end_string(k))) end if next k clean_string = cleaner_string l = 0 ubound(substring) clean_string = replace(clean_string, substring(l), " ") next l if clean_string = "" clean_string = c end if c.offset(0, 1) = clean_string set c = c.offset(1, 0) loop end sub the problem when finds character in array matches current string iteration, ends copying string on every cell iteration thereafter. here&

ruby - How to access Firefox Extension I added in Selenium Webdriver? -

i know can load either existing firefox profile, or create 1 using ruby bindings in selenium-webdriver gem, described here: http://code.google.com/p/selenium/wiki/rubybindings and use add_extension add number of firefox extensions instance, what? window extension i'm using not appear during test. how use extension? is there way have extension open default when driver opens firefox? here code i'm using: #!/usr/bin/env ruby require "rubygems" require "selenium-webdriver" default_profile = selenium::webdriver::firefox::profile.from_name "default" default_profile.add_extension("/users/******/library/application support/firef\ ox/profiles/wvon3h99.default/extensions/{9c51bd27-6ed8-4000-a2bf-36cb95c0c947}.\ xpi") driver = selenium::webdriver.for(:firefox, :profile => default_profile) driver.navigate.to "http://google.com" element = driver.find_element(:name, 'q') element.send_keys "hello webdriver!&qu

cocoa - What elements should I include in a Mac Preferences Panel? -

i have question mac program's preferences window. have application coredata-based end. program includes feature allows users switch out database different one. not expect users often—perhaps once or twice year. now, many of options users can tweak stored in database. these options need configured once every time new database used, because specific database itself. the apple human interface guidelines on preferences state this: as possible, ensure users need reset preferences. ideally, preferences include settings users might want change once. if there settings users might want change every time open app, or every time perform task, don’t put these settings in preferences. instead, use menu item or control in panel gives user modeless access these settings. my question this: database-level settings valid candidates preferences window? "once or twice year" count "rarely"? if not, there downsides creating second panel (with many panes

css - Jquery Animate problems -

i using jquery animate change size of div when content loaded. looks when little bits of text being loaded not when lot of text being loaded. there way make them same? for example: http://www.scotwebtech.co.uk click "our services" lots of text , "portfolio" small amount of text. this can solution: use 2 wrappers content: <div class='wrapper'> <div class='content'> content here... </div> </div> and stylesheets: .wrapper {overflow:hidden;} .content {width:473px (static width)} now if animate width of wrapper fine.

iphone - Apple Mach-O Linker (Id) error -

got error first time, have looked around , cannot find solution me, have cleaned build , checked make sure compiling latest firmware. this happened after tired implementing reachability solution found on here imported 2 reachability files (.m/.h) added code .m file , delared t in . h of reachability files -(bool)reachable { reachability*r =[reachability reachabilitywithhostname:@"enbr.co.cc"]; networkstatus internetstatus =[r currentreachabilitystatus]; if(internetstatus ==notreachable){ return no; } return yes;} after called function both of viwcontrollers viewwillappear methods so.. - (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; //-- check reachability start ----> reachability *reach = [[reachability alloc] init]; if ([reach reachable]) { nslog(@"reachable"); } else { nslog(@"not reachable"); } //-- check reachability end ---->

c++ - pygtkscintilla auto indent -

i'm trying translate c++ code , can't work out "char linebuf[1000]" is, can kind sole translate python or explain linebuf is. thanks! :) taken http://www.scintilla.org/scintillausage.html if (ch == '\r' || ch == '\n') { char linebuf[1000]; int curline = getcurrentlinenumber(); int linelength = sendeditor(sci_linelength, curline); //platform::debugprintf("[cr] %d len = %d\n", curline, linelength); if (curline > 0 && linelength <= 2) { int prevlinelength = sendeditor(sci_linelength, curline - 1); if (prevlinelength < sizeof(linebuf)) { word buflen = sizeof(linebuf); memcpy(linebuf, &buflen, sizeof(buflen)); sendeditor(em_getline, curline - 1, reinterpret_cast<lparam>(static_cast<char *>(linebuf))); linebuf[prevlinelength] = '\0'; (int pos = 0; linebuf

c# - Is there a Microsoft.CSharp in mono (2.10)? -

does mono have csharpcodeprovider implemented should using instead of microsoft.csharp.csharpcodeprovider? i using class dynamically compile c# scripts compiled program mono throws error under linux: ->unhandled exception: system.componentmodel.win32exception: cannot find specified file you should use mono.csharp.evaluator class in mono.sharp.dll assembly

Is there a tool for viewing an activity stream for a TFS project? -

i looking tool displays various project activities given duration (say since yesterday) in order took place e.g. 9:40 "dev 1" committed change set 12345 9:43 "dev 1" closed work item 2145 10:05 "dev 2" added new work item 23456 "design ui customer details" 10:25 "dev 1" added comments work item 23456 10:45 "dev 3" added work item 23456 iteration 1 . . i don't think give need regards single rollup report give sidekick try. find indispensable getting view tfs.

iphone - how to use ASIHTTPRequest reachability -

i using asihttprequest send requests php scripts searching mysql server, have read in apple documentation have implement reachability when ever try send or receive data on tcp... what wanting know asihttprequest taking care of reachability me, or have implement method calls code make sure checking being done? any great... asihttprequest documentation abit light regards reachability , have not been able find notes on regards this. there google group better equipped answer asihttprequest questions. since it's reimplementation of ios functionality, it's not particularly ios relevant.

c++ - Trying to combine two similar printf style debug messages in to a single function -

i have 2 printf style debug logging functions ( debuglogfa , debuglogfb ). both operate same way 1 of logging functions takes logging level parameters , ignores low level debug messages. currently duplicate code each of these functions debuglogfb able call debuglogfa if debug level high enough without having create temporary buffer in debuglogfb. void debuglogfa( const char *lpsztext, ...) { //initialize variable argument list va_list arglist; va_start(arglist, lpsztext); char buffer[1024]; unsigned short length = snprintf_s(buffer, 1024, "[%d] ", ctime::getcurrenttimeinsec() ); length += vsnprintf (buffer+length, 1024 - length, lpsztext, arglist ); logsend( buffer, length ); } void debuglogfb ( const unsigned int level, const char *lpsztext, ... ) { if( level < 50 ) { return; // low report. } //initialize variable argument list va_list arglist; va_start(arglist, lpsztext); char buffer[1024]; un

html - CSS style for container with transparent border images -

Image
want make page layout such picture below. there 3 major components, frameleft , framemid , frameright . while framemid houses page content, other 2 components borders transparent .png files in them. question how make frameleft , frameright scale framemid ? found similar question posed earlier here , technique described answer following accepted 1 (which doesn't solve problem @ all), not apply when images in side components transparent. my solution far relies on housing these components in div , setting height manually. it's not optimal, since ideally have entire ensemble inferring height framemid . html houses 3 components inside div predefined height. <div style="height: 500px"> <div class="frameside frameleft"></div> <div class="framemid"> content </div> <div class="frameside frameright"></div> </div> css scales side images respect housing component. .f

java - Android : adb shell, no command adb found -

i trying run adb shell can kill process testing purposes. in directory platform-tools , adb executable in there. when try run shell says adb command not found. running eclipse (through ubuntu) , using emulator. not sure whats going on. lot. run ./adb shell (note ./ ) by default, local folder not in path.

leiningen - Clojure: lein task cannot find jdbc, even though application can find it fine -

i'm trying make custom lein task called migrate, can on command line: lein migrate lein finds task file under src/leiningen/migrate.clj (as per leiningen convention). in ns declaration task have require file project (ns leiningen.migrate (require [triface.migration :as mm])) (defn migrate [] (mm/run-migrations)) it finds src/triface/migration.clj fine, file requires file requires jdbc: (ns triface.db (:require [clojure.java.jdbc :as sql])) this call works fine in application, lein task fails following error: exception in thread "main" java.io.filenotfoundexception: not locate clojure/java/jdbc__init.class or clojure/java/jdbc.clj on classpath what going on here? thanks! the classpath different. use is, must define :dev-dependencies in project.clj file. for example, :dev-dependencies [[org.clojure/java.jdbc "0.0.4"] ] then, jar file loaded properly. (ns triface.migration (:require [clojure.java.jdbc :as sql])) (d

firefox addon - Browser plugin to recognize a custom image-format -

i have images in custom file-format (basically containing raw data) , and want have them viewable in browser (without converting them standard formats such jpg/png). is possible write browser plugin read my-custom-format , display images in browser (like pdf reader) ? i can using flash, trying see if can avoid having download flash swf display image. can browser plugin/extension binary data web, process , render on specific area on browser screen ? browsers possible on , ones not ? you can download binary file xmlhttprequest , display in on <canvas> element, have full control on each pixel. now if mean want browser natively recognize custom image format tricky.

RichFaces Calendar: Month and Year only display -

i using richfaces4.0; need display selection of month , year only; user chooses it. <rich:calendar id="start" value="#{reportbean.fromdate}" oncurrentdateselect="alert('hello');" popup="false" showweekdaysbar="false" showfooter="false" styleclass="special"></rich:calendar> script being used given below, hide date grid: .special tr[id] { display:none; } i following example on forum, selected month/year not being reflected in reportbean.fromdate: http://relation.to/12480.lace ; see not support oncurrentdateselected attribute. i sure missing important step, please help. thanks value attribute removed , added currentdate:

c++ - Simple OpenCV program won't run; given no errors. What now? -

i'm working on term project school , plan use opencv. i've spent past day or battling include/link errors (mostly because of dumb mistakes) , have working. or thought. i have simple program, looks this: #include <highgui.h> int main() { cvnamedwindow("window", cv_window_autosize); cvwaitkey(0); return 0; } no errors appear in eclipse, , bold-faced / looking should library functions (can't remember proper formatting name called). when compile it, succeeds. no errors. when run this, nothing happens. , it's @ point i'm stuck. i'm using opencv @ work , modeled setup @ home accordingly (nearly identically actually). include paths, library paths, , libraries added in project eclipse (at least, w.r.t work setup). dll's in same folder executable. any ideas why doesn't run? (the window doesn't display, instantly terminates) i should mention i'm using eclipse (helios), mingw, windows 7, , opencv 2.3. cheers.

How to start an ASP.NET project? -

in first handling asp.net web project. there step step procedure start it? mean best practices. thank you. http://www.asp.net/ 1 way start. there tutorials, video. go http://www.asp.net/mvc learn mvc

PHP: Condition Format - (6 == $var) or ($var == 6)? -

i browsing these php coding guidelines (a bit outdated interesting), , found this: condition format always put constant on left hand side of equality/inequality comparison. example: if ( 6 == $errornum ) ... one reason if leave out 1 of = signs, parser find error you. second reason puts value looking right front can find instead of buried @ end of expression. takes little time used format, gets useful. i have been using ($var == 6) years , idea of putting them other way around horrifying. mentioned, takes bit time used , supposed have clear benefits. writing standard @ our company if want change this, moment that. i'd hear if other have experience particular format. opinions? edit i interested in people's experience making switch. me, , others, looks big change need used to. looks interesting. question have switched: can recommend change? 6 == $var has real advantage $var == 6 not. there nothing horrifying @ all, looks differ

C# Linq DBML Class Wrapper -

i have generic class extends linq class. means can't extend linq class, need have separate generic class. public linqcake // linq class dbml { string name; frostingtype type; } public class cake<t> : linqcake t frostingtype { public bool someproperty { { return linqcake.type == frostingtype; } } // want this, // can't because code isn't valid public cake (int id) { = db.linqcakes.where(x=>x.id = id).single(); } } public void main() { cake<chocolate> chocolatecake = cake<chocolate>(7); console.writeline(chocolatecake.someproperty); } i want populate cake's inherited class linqcake information database. can implicit cast? how accomplish spirit of i'm trying do? can think of 2 ways of sort of doing this; a) add private linqcake member b) read in each property of linqcake class duplicate properties of cake class. i feel there be

eclipse workbench selections -

i have written 1 code getting source , selected of part of eclipse. if click on view or editor display object , if select displayed selected item.the same way possible dialogues , others actions. example if click on 1 dialog should dialog name or object. same way whate ever object clicked on wokbench hould whats object.including actions. following code. private iselectionlistener listener = new iselectionlistener() { public void selectionchanged(iworkbenchpart sourcepart, iselection selection) { system.out.println(sourcepart, selection); } }; i got commands. can use iexecutionlistener ever command have attached workbench. want actions,dialogues,etc.. the short answer: it's lot of work. have @ plug-in spy code (alt+shift+f1). looks @ swt events , uses widget in event starting point. has use knowledge of how various structures constructed (views, wizards dialogs, preference dialogs, property dialogs, editors, menus, toolbars) figure out if

php - Render view files on Yii framework -

i have 2 models suppose , b contain 2 separate forms. want show content of form b on view page of model a. how render content of b on a. on highly appreciable. you need pass b model view of model, if you're using code generated yii's crud example in acontroller file can modify this: public function actionview() { $bmodel = b::model()->findall(); $this->render('view',array( 'model'=>$this->loadmodel(), 'othermodel'=>$bmodel, )); } after adding 'othermodel' view function, should able access $othermodel in view.php file

javascript - How can I know a button's event handler in a html page? -

Image
possible duplicate: how debug javascript/jquery event bindings firebug (or similar tool) how inspect element's associated event handlers? sometimes,i use firebug inspect button in page, found there no onclick function. did have event handler. think used "bind" method attach event handler. now, question how can use tool , can find out event handler easily? in google chrome it's easy. there can setup debuger stop execution whenever click event fired:

How to pump message for COM STA threads in C#? -

i have main sta thread calls lot methods on com object , secondary sta thread lot work on same object too. want main thread , secondary thread work in parallel (i.e. expect interlaced output main , secondary). know need pump messages in main thread every , - calling get/translate/dispatchmessage in c++ trick. but i'm having problem getting same strategy working in c#. @ first used currentthread.join() in main thread give control second thread. didn't work. turned application.doevents() - called in main thread whenever wanted second thread run. result second thread grabs control , won't let go - main thread cannot continue until second thread done. i read documents application.doevents() process waiting events - while getmessage() retrieves 1 message. what's correct thing do? there c# equivalent of get/translate/dispatchmessage? thanks update: second thread running fast, sending lot com call messages main sta thread. added delays in second thread slow down.

Multiple Parent Keys for element/attribute in an XSD -

can refer multiple 'key' references single attribute in xsd? my requirement there attribute addressid reference 2 other attributes of addressid in physicaladdress , foreignaddress. in effect reference value can either of 2 specified primary keys. i tried 2 entries 'selector xpath' values, failed. tried separating xpaths '|' in selector xpath value (the field value remaining same in both these cases), facing error @ runtime 'identity constraint validation error: 'duplicate keys'.' thanks time. please let me know other info. regards, krish

asp.net mvc - Quick question about Ajax.ActionLink and span -

i have simple question. i have following html code <a href="#" class="purchase"> <span>purchase</span><em>@string.format("{0:c0}", model.thisitem.itemsaleprice)</em> </a> but want use ajax.actionlink make ajax post. i have following updated code @ajax.actionlink("purchase", "addtocart", "browse", new { itemid = model.thisitem.itemid }, new ajaxoptions { updatetargetid = "content" }, new { @class = "purchase" }) the question how can put tag actionlink? thank everyone. updates i got answer asp.net's forum, , easier. http://forums.asp.net/p/1702210/4518688.aspx/1?p=true&t=634468566867949718 just specify in action link text parameter: @ajax.actionlink(string.format("{0} {1}", "purchase", string.format("{0:c0}", model.thisitem.itemsaleprice)), "addtocart", "browse", new { itemid = model

java - Gilead and RequestFactory alternatives -

i began develop large gwt-project, naturally have data model. , want comfortably work entity-classes on client side. i liked gilead, this thread not news me. i not want use requestfactory, because makes writing boilerplate code , duplicate code. maybe knows alternatives gilead , requestfactory can me in project , supported developers nowadays? thanks in advance! imo, there no escape boiler plate when working gwt. think best option working data intensive apps, sophisticated data models requestfactory. can try reduce boiler plate writing code generation framework. example, take @ gwtp 's annotation based code generation facilities , can generate lot of boiler plate required work mvp. specifically, gwtp can generate action , result classes encapsulate command want sent server , result returned server. a similar code generation facility boiler-plate related requestfactory can ease burden significantly. for example, can have annotation generating entity proxie

css - alignment of background in internet explorer -

i working on website http://bookmyshirt.co.cc/help/index.html background not align in internet explorer working fine in firefox. please me out. try adding doctype. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> i had @ styles. if replace styles on #maincontainer: left: -480px; margin-left: 50%; position: relative with margin:0 auto; width: 960px; everything should line up. if doesn't, use ie's developer toolbar trace styles. firebug. edit: please note, must set width on element, otherwise margin:0 auto won't have effect.

saving html from ruby on rails output to a variable -

i have ruby on rails website. page dynamically loaded , generated using ruby , rails. however, i'd generate static .html page ease server rather calling rails page every time. in php know how capture output buffer using ob_start() , ob_get_contents() outputted text. how capture output rails page variable? edit: reason want can save page .html use on other machines. generate html using ruby , distribute others in format can view. you should use rails caching achieve result. achieves ends looking for. alternatively, can render_to_string , output result using render : #ticket_controller.rb def ticketcontroller < applicationcontroller def show_ticket @ticket = ticket.find(params[:id]) res = render_to_string :action => :show_ticket #... cache result-- may want adjust path based on needs #this similar rails caching #finally, should note rails servers serve files # /public directory without ever invoking rails proper

mvvm - Printing Multiple pages in wpf -

i have scroll viewer , inside text block multiple pages contents. how can print within scroll viewer.i'm using wpf mvvm pattern. text block right control this?or shall go other wpf controls.? thanks in advance.. documentviewer ir better control paginated printing

javascript - Limited splits without losing the rest of the string? -

say have: var str = "this string separated spaces"; and did: alert(str.split(" " , 1)); the outcome "this" whereas want outcome "this,is string separated spaces" maybe split isn't right method? what i'm trying separate string parts based on semicolons, unless semicolons in quotes. example, want randomnessstuff;morestuff;some more stuff to in 3 parts, i've been doing: var str = "randomnessstuff;morestuff;some more stuff"; var parts = str.split(";"); which has been working fine, if semicolon in quotes, want not separated part. for example, with: var str = "randomnessstuff;morestuff , semicolon in quotes : ";";some more stuff"; i want part 1 randomnessstuff , part 2 morestuff , semicolon in quotes : ";" , , part 3 some more stuff of course, if did split semicolon again, make part 3 quote. what i'm hoping have loop checks semicolons 1 one see if th

javascript - How to Remove Resize handles and border of div with contentEditable and size style -

the problem i'm having contenteditable attribute in ie. problem i'm getting resize handles, , thick border around elements when they're in focus. styles with, height , display needed. idea of how remove them? css or javascript a simple example: <html> <head> </head> <body> <div contenteditable="true" style="width: 50%; height: 50%; display: table" > <div contenteditable="true" style="width: 50%; height: 50%; display: table-cell"> <p>aaa</p> </div> </div> </body> </html> do need contenteditable="true" defined twice ? if delete first one, resize handles go away, although functionality remains. http://jsfiddle.net/2uphd/1/

Page.Title equivalent in PHP -

i want change title of php pages dynamically since headers , footer sections include files cannot use <title><?php echo $title;?></title> kind of solution. i wondering if there solution such 1 in asp.net page.title = "some title"; maybe $page->set_title('programmers palace'); many thanks... since headers , footer sections include files cannot use <title><?php echo $title;?></title> kind of solution. you can. because files included doesn't mean can't echo things there. if had page object... index.php <?php $page = new page('programmers\' palace'); include 'includes/header.php'; includes/header.php <head> <title><?php echo $page->gettitle(); ?></title> </head>

sqlite3 - Android Database creation Error - -

Image
i have written database/copy database part. push databse through file explore --> data -> package -> databse & push using "push file onto device" option.that time(emulator) when click data , showing data contents. when run through real phone, connected pc usb port, didn't allow me open data option see image: if open , can push database android app. reason should "permission denied". how can give permission? please guide me this thanks in advance.. you can't, unless phone rooted. access data folder not enabled on devices.

php - Click-to-call on BlackBerry -

i have site displays telephone numbers , email addresses. aim enable user click on tel or email complete action. currently have .php file creates uri tell or email , track actions. have following in html link user see: <a href="track.php?" target="_self">contact</a> track.php determines if call / email / website , sets $location var (either tel:1231231234 / web:www.test.com / mailto:address@test.com). if tried returning / doing redirect in following ways: 1. echo '<script type="text/javascript"> window.location="'.$location.'"; </script>'; 2. header('location: ' . $location); 3. echo '<script type="text/javascript"> header.location="'.$location.'"; </script>'; all of these methods work on iphone / android / symbian devices, not on blackberry (i've tested bb curve 8520). if hardcode links (see co

jsf 2 - <ui:param and caching -

i have following thing: <ui:param name="randomvideo" value="#{bean.randomvideo}" /> <a href="#{randomvideo.link}">#{randomvideo.text}</a&></pre> because <ui:param> not cache variable, bean.getrandomvideo() called twice, , worst part .text , .link different videos. have tried <c:set , <f:param . both not set variable, maybe because i'm facelets (jsf2). any ideas? getters supposed real getters, not containing logic. so: make bean @requestscoped initialize randomvideo field in @postconstruct let getter retrieve randomvideo field of bean.

c# - Trying to access a Microsoft web-service causes a 400 Bad Request error -

i'm trying use microsoft translator webservice in application. though when try language names according example given @ http://msdn.microsoft.com/en-us/library/ff512414.aspx , (400) bad request error when try language names. the uri use is: private const string languagestring = "http://api.microsofttranslator.com/v2/http.svc/getlanguagenames"; private string[] usablelanguages = { "en", "nl", "es", "de" }; // create uri use. string getlanguages = string.empty; getlanguages = languagestring + string.format("?appid={0}&locale;=en", appkey); uri langrequest = new uri(getlanguages); httpwebrequest req = (httpwebrequest)webrequest.create(langrequest); after use datacontractserializer , stream webrequest send request web service. when try response webrequest, (400) bad request error. webresponse response = null; try { // causes exception. response = req.getresponse(); } catch (webexception e) { messag

css - Text and Select not aliigned to same line -

i have site(www.excoflare.com/dev2011/socialnetwork) . can see in search field text , select not alligned same line . how can alligned them same line ? try add float:left input

mocking - Mock an object in a method that is not a parameter in python -

(i'm python newbie) i looking at: mocking out objects , methods and wondering if can replace object in python method not passed parameter, lets method this: def mypymethod(param1) myresult = os.path.something return myresult and wish test mypymethod wish os.path @ case return "yourmockresult" when call test method anyway can this? thanks!! you should use michael foord's mock module same. from documentation: >>> mock import mock >>> real = productionclass() >>> real.method = mock(return_value=3) >>> real.method(3, 4, 5, key='value') 3 >>> real.method.assert_called_with(3, 4, 5, key='value')

android - Activity save state problem -

i new in android application development. working on chat(im) application. activity shows contact list , activity b chat activity(conversation activity). activity when click on contact entry(from contactlist) start activity b contact entry emailaddress(by putextra in intent). want chat person , click button , go activity showing list(contact).i click 1 entry , again start activity b different emailadd(putextra in intent).after listactivity , choose previous person chating. now how can stop creating new activity , load previous activity stack previous state?????? thanks in advance. rawcoder if asking how can have multiple instances of top level activity, cannot, there 1 top level activity. activities created in stack, when create b b @ top of stack, when press button telling android top level of stack (current activity) no longer needed , gets removed. you have save state , restore if that's need when b recreated. similar question

python - Why is this code behaving differently across various distros/Unixes? -

the following (a small c program , python script calls it) behave differently across various unixes. in of them (e.g. debian stable), c app gets signal, message printed fine signal handler , script finishes. in others (e.g. 2 year-old ubuntu , openbsd) signal lost, , therefore message not printed @ all, , script waits forever... the signal delivered, if in python script, change this... mysub=subprocess.popen("./cryinabort", shell=true) into this... mysub=subprocess.popen("./cryinabort", shell=false) so appears in unixes intermediate shell "eats" sigint, while in others forwards child process (the c program). i took care call re-entrant functions in signal handler doesn't seem related c code - looks if signal handling behavior within "/bin/sh" (the default shell used python spawn things) not "stable" across unixes... am doing wrong? edit: in case wondering why used "shell=true": it's because

testing - What dataset to work on when Azure role is in staging deployment? -

afaik staging deployments intended testing azure roles implies deploy role errors in code staging. if error damages data screwed. how address that? can't stage role without reasonable data (hard test it) , can't let unstable role damage data. do have maintain separate dataset staging? how problem typically solved? afaik staging deployments intended testing azure roles implies deploy role errors in code staging. if error damages data screwed. staging designed place deployment - spinning new role instances prior instant virtual ip address swap. while can testing there - e.g. making final checks deployment valid - it's not there allow lots of testing. how address that? can't stage role without reasonable data (hard test it) , can't let unstable role damage data. i've tested on development environment fake data or deployed separate azure service fake data. however, admit has never been in situation i've needed huge amounts of data

c# - Download file and automatically save it to folder -

i'm trying make ui downloading files site. site have zip-files , these need downloaded directory entered user. however, can't succeed download file, opens temporary folder. code: private void webbrowser1_navigating(object sender, webbrowsernavigatingeventargs e) { e.cancel = true; string filepath = null; filepath = textbox1.text; webclient client = new webclient(); client.downloadfilecompleted += new asynccompletedeventhandler(client_downloadfilecompleted); client.downloadfileasync(e.url, filepath); } full sourcecode: http://en.paidpaste.com/lqemiq why not bypass webclient's file handling pieces altogether. perhaps similar this: private void webbrowser1_navigating(object sender, webbrowsernavigatingeventargs e) { e.cancel = true; webclient client = new webclient(); client.downloaddatacompleted += new downloaddatacompletedeventhandler(client_downloaddatacompl

c# - Unit Testing - best practice -

i use visual studio 2010 professional mstest framework perform unit tests. have nasty production code test. first issue problematic code in constructor. show examaple : class classtotest { public someenum upperborder; public someenum lowerborder; public int var1; private readonly someenum2 _ethnicgroup; private readonly double _age; public int datastart; public int dataend; public double[] darkreddarkyellow; public double[] darkyellowgreen; public double[] greenlightyellow; public double[] lightyellowlightred; public classtotest(someenum upperborder, someenum lowerborder, int var1, someenum2 ethnicgroup, int age) { upperborder = upperborder; lowerborder = lowerborder; bscanindex = bscanindex; _ethnicgroup = ethnicgroup; _age = age; datastart = 0; dataend = 0; darkreddarkyellow =

android - configure/customize an AVD -

in avd manager android in ubuntu can specify size of sd card storage, "skin", screen resolution, , hardware specs. but if wanted make new android rom image or build use rahter given or coming options in target, possible. is there step-by-step document describing how configure/customize avd level of detail? thanks in advance. kash download source code. make customizations. build it. run custom os on emulator. http://source.android.com/source/index.html

php - Tag based searching with MySQL -

i want write tag based search engine in mysql, don't know how pleasant result. i used like, stored on 18k keywords in database, it's pretty slow. what got table this: id(int, primary key) article_cloud(text) keyword(varchar(40), fulltext index) so store 1 keyword per row , save refering article numbers in article_cloud. i tried match() against() stuff, works fine long user types in whole keyword. want suggest search, there relevant articles popping up, while user typing. still need similar statement like, faster. , have no idea do. maybe wrong concept of tag based searching. if know better one, please let me know. i'm fighting days , can't figure out satisfying solution. reading :) match() against() / fulltext searching quick fix problem - schema makes no sense @ - surely there multiple keywords in each article? , using fulltext index on column contains single word rather dumb. and save refering article numbers in article_cloud no! stori

German characters not showing properly on csv file using php -

i trying generate csv file, gets created except german characters ä,ë,ï,etc information $data variable , tried use: utf8_encode($data); but weird text, here headers file: header("content-type: application/octet-stream"); header("content-disposition: attachment; filename=\"file1.csv\""); i have tried using iconv(); no luck far. edit just noticed $data utf-8 removed utf8_encode(); still, when try print ? and changed header to: header("content-type: text/plain; charset=utf-8"); use: header("content-type: text/plain; charset=utf-8"); and make sure $data isn't utf-8!

couchdb - Passing an argument to map.js in a CouchApp view -

i have couchapp functions social network. have button which, when clicked user, creates , saves couchdb json document fields post_id (the id of post liked), user_id (the id of user liked post), , type (value "like," indicate document like). alongside post, i'd indicate number of likes has received. map function looks this: function(doc) { if (doc.type && doc.type == 'like') { emit(doc.post_id, 1); } } and reduce, this: function(post_ids, likes) { return sum(likes); } my problem is, function returns sum of likes in posts in site. i'm thinking reduce.js fine , maybe tweak map.js accept post_id argument can retrieve likes post_id, how do that? post_id comes design document, of course, when "like" button clicked. thanks. you need group view parameter. if supply no querystring parameters, default reduce entire contents of view. once apply group=true , can use key or startkey/endkey pick out post id(s) need.

C# .Net WPF Custom User Control zIndex issue with similar user control -

user control details: have created drop down list control (like combo box), clicking on down arrow button, displays list below text box i have set zindex property of user control issue: case 1: when there user control (other custom user control), , if drop down list displayed, other user control hides behind user control. ok case 2: there 2 custom user controls, if list displayed first user control, second user control appears on list. facing issue xaml of control below <usercontrolx:class="usercontrols.autocompletecombobox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" panel.zindex="1110" lostfocus="usercontrol_lostfocus" height="auto"> <canvas name="maincanvas"> <grid> <grid.rowdefinitions> <rowdefinition></rowdefinitio

c# - UserControl's and databound values -

i have user control, in templatefield on gridview. pass in 6-7 properties it, of bound data source. here markup: <uc1:gridmenu id="gm1" runat="server" total='<%# bind("total") %>' .... haven't copied it's rather long can see how i'm passing properties in. problem however, properties end null when they're passed through, though i'm binding correct things. doing wrong? have set bindable attribute total property?

about combine ajax ,php and javascript -

i have main html file , using ajax call php file in same directory. inside php file, call external javascript functions. javascripts functions not working. not possible? i see generated source in web browser , normal. if call functions using php file (without using ajax), functions working , generated source same previous case. please me. in html file using ajax follows: xmlhttp.open("get","end_location_drop_down.php?q="+str,true); xmlhttp.send(); in php file functions follow, <?php echo '<script type="text/javascript" src="../js/pointing.js"></script>'; //external script $btn8="'btn8'"; $q=$_get["q"]; echo '<script type="text/javascript"> nextpoint('.$at_id.'); //$at_id mean variable,nextpoint() java script function </script>'; ?> in javascript function have image swapping functions.they can call nextpoint(). didn

c# - How can i export multiple dataset to an excel sheet -

hi export data dataset excel sheet. dataset consists of 2 tables how can write multiple dataset values in single excel sheet before u have create 1.using excel = microsoft.office.interop.excel;//in header,and add correct refference 2.excel.application excelhandle1 = prepareforexport(ds); //add handle in calling function excelhandle1.visible = true; public excel.application prepareforexport(system.data.dataset ds,string[] sheet) { object missing = system.reflection.missing.value; excel.application excel = new excel.application(); excel.workbook workbook = excel.workbooks.add(missing); datatable dt1 = new datatable(); dt1 = ds.tables[0]; datatable dt2 = new datatable(); dt2 = ds.tables[1]; excel.worksheet newworksheet; newworksheet = (excel.worksheet)excel.worksheets.add(missing, missing, missing, missing); newworksheet.name ="name of

JavaScript Regex Only returns one match -

i can't see went wrong here: var teststring = '+test +"testing multi" -not -"and not this" "w00t" hehe nice +\'test this\' -\'and well\''; var regex = new regexp('([\\+\\-]{0,1}([\\\'"]).*?\\1|[^\\s]+)', 'g'); var match = regex.exec(teststring); if (match != null) { (var = 1; < match.length; i++) { alert('match ' + + ': "' + match[i] + '"'); } } for reason, +test matched, followed empty match, , that's it. well, seems work ok var teststring = '+test +"testing multi" -not -"and not this" "w00t" hehe nice +\'test this\' -\'and well\''; var match = teststring.match(/([+-]?([\\'"]).*?\2|[^\s]+)/gi) if (match != null) { (var = 1; < match.length; i++) { alert('match ' + + ': "' + match[i] + '"'); } } it wasn't on p

xcode4 - Three20 error with xcode 4.0.2 -

i error: shell script invocation error env: python: no such file or directory run custom shell script "lint" phasescriptexecution lint /users/nasser/library/developer/xcode/deriveddata/abc-fgspuusakfyzczfehhbduewymfmp/build/intermediates/three20core.build/debug-iphonesimulator/three20core.build/ script-668e63ea131a42f500ace4ab.sh cd /users/nasser/documents/test2/abc/three20/src/three20core /bin/sh -c /users/nasser/library/developer/xcode/deriveddata/abc-fgspuusakfyzczfehhbduewymfmp/build/ intermediates/three20core.build/debug-iphonesimulator/three20core.build/script-668e63ea131a42f500ace4ab. sh env: python: no such file or directory you need install python. the best way use macports. download , install macports , install python via macports typing following commands in terminal: sudo port install python26 python_select sudo python_select python26

jquery - Using javascript to remove link formatting on click -

i'm using javascript (and jquery) move between 3 box descriptions. javascript <script type="text/javascript"> $(document).ready(function() {     $('#foo-box').show();     $('#bar-box').hide();     $('#bob-box').hide();   $('#bar-link').click(function() {     $('#foo-box').hide();     $('#bob-box').hide();     $('#bar-box').show();     return false;   }); }); </script> html <div id="stuff"> <a href="" id="foo-link">foo</a> <a href="" id="bar-link">bar</a> <a href="" id="bob-link">bob</a> <div id="foo-box">hello</div> <div id="bar-box">world</div> <div id="bob-box">!!!</div> </div> but after clicking on link want normal text. can't seem fig

CakePHP routing & pagination problem -

i have app i'm working on @ moment pretty strange routing involving passed args. works fine, links reverse routed correctly except pagination. i'm tearing hair out must missing something. my routes are: router::connect('/manufacturer/:manufacturer/:friendly0', array('controller'=>'categories', 'action'=>'view'), array('pass'=>array('manufacturer', 'friendly0'))); router::connect('/manufacturer/:manufacturer/:friendly0/:friendly1', array('controller'=>'categories', 'action'=>'view'), array('pass'=>array('manufacturer', 'friendly0', 'friendly1'))); router::connect('/manufacturer/:manufacturer/:friendly0/:friendly1/:friendly2', array('controller'=>'categories', 'action'=>'view'), array('pass'=>array('manufacturer', 'friendly0', 'friendly1', &

jquery - Show hide icon next to input form depending on validation -

i been asked design small login form 3 labels , input forms login button. layout pretty ready , took liberty of placing warning icons next each input forms. because knowledge of jquery limited , that's precisely format asked me, not know how write validation each form (for example nulls , minimum characters = 4) resulting in showing , hiding of warning icon next it! please me! thankyou kind regards tiago have checked out jquery validation plugin ? the demo page should started.

oracle - SQL command not properly ended -

select /*+ parallel(aae,4) */ distinct nvl(aae.voucher_group_id,-1) voucher_group_id, aae.nominal_transaction_amount unit_price, aae.original_currency_type currency_type, aae.segmentation_id air_account_events aae aae.time_hour_id >= m_start_thid , aae.time_hour_id < m_end_thid , aae.nominal_transaction_amount not null minus select vg.voucher_group_id, vg.unit_price, vg.currency_type, vg.segmentation_id wh_voucher_groups_dim vg) ahm on (whm.voucher_group_id = ahm.voucher_group_id , whm.unit_price = ahm.unit_price , whm.currency_type = ahm.currency_type , whm.segmentation_id=ahm.segmentation_id) ahm when run following pl/sql there error wh_voucher_groups_dim vg) ahm * error @ line 14: ora-0093

load - Applying loadMask() to a single element in extjs? -

Image
how apply loadmask 1 element, , not whole browser width-height? default here, 1 element masked, , messagebox in center, inside element , not whole display... ideas? edit: @molecule , thanks, when data loading source, need : { xtype:"button", text:"alert", handler: function(){ ext.msg.show({ title:'save changes?', msg: 'you closing ?', buttons: ext.msg.yes, setloading: // here somehow mask parent element, , position alertbox... } } every component has it's own loadmask property. can use calling yourcomponent.setloading . here fiddle illustrate i'm talking about. another way using new ext.loadmask(yourcomponent.el, {msg:"please wait..."}); . can @ usage in fiddle . update here code example shows how apply extjs4 loadmask , messagebox specified widget ext.create('ext.panel.panel', { width: 600, height: 400, title: 'bo

java - Configuring Jetty 6 to use commons.dbcp datasource -

hi i'm trying configure jetty 6.1.26 use connection pooling , it's giving me hard time. i put commons-dbcp-1.4.jar , commons-pool-1.5.6.jar , mysql-connector-java-5.1.16 in jetty/lib/ext folder. i added references jars in jetty/pom.xml <dependencies> ... <dependency> <groupid>commons-dbcp</groupid> <artifactid>commons-dbcp</artifactid> <version>1.4</version> </dependency> <dependency> <groupid>commons-pool</groupid> <artifactid>commons-pool</artifactid> <version>1.5.6</version> </dependency> <dependency> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> <version>5.1.16</version> </dependency> </dependencies> in web project in eclipse, jetty-env.xml (in web-inf) file this: <configure class="org.mortbay.jetty.webapp.webappcontext&

sql server - T-SQL for a normalized average -

i'm looking way calculate useful average given set of values may contain huge spikes. (e.g 21, 54, 34, 14, 20, 300, 23 or 1, 1, 1, 1, 200, 1, 100) spikes can throw things off when using standard average calculation. i looked using median doesn't give desired result. i implement in t-sql any ideas? this way can take away highest , lowest 25 % before calculating result. declare @t table (col1 int) insert @t select 21 union select 54 union select 34 union select 14 union select 20 union select 300 union select 23 union select 1 union select 1 union select 1 union select 1 union select 200 union select 1 union select 100 select avg(col1) ( select top 67 percent col1 ( select top 75 percent col1 @t order col1 ) order col1 desc) b

maven adds dependency but eclipse does not see it -

i've created new project in maven this: mvn archetype:generate -dgroupid=com.mycompany.app -dartifactid=my-app -darchetypeartifactid=maven-archetype-quickstart -dinteractivemode=false after use: mvn eclipse:eclipse the problem when add project ide, eclipse indicates errors. when run classnotfound junit. in project properties see junit added build path in project properties see: m2_repo/junit/junit/3.8.1/junit-3.8.1.jar but cant use example: import junit.framework.test; why that? honest, have major problems dependency in maven , eclipse. maven adds them correctly eclipse doesn't see correctly. it's not junit. should check/set? should install plugin eclipse maven support ? edit i thought again everything. of course problem small. m2_repo not recognize eclipse. i've added variable , set in od maven directory. worked charm. you can use m2eclipse plugin eclipse http://m2eclipse.sonatype.org/installing-m2eclipse.html i don't know if ha

jpa - Hide / remap field values in Hibernate entity based on user permissions -

in spring 2.6 / jpa 1 / hibernate 3.3 application need "hide" entity field data based on current user's permissions. e.g. on entity "document" there's field "title" maps title column in doc table. depending on user's permission title should either read "confidential" if he/she not allowed read title or should contain correct value fetched database. same applies lot of other properties. the problem cannot apply presentation model or filtering in ui. because entity objects passed layer takes care of post-processing , displaying data in ui , real data (i.e. real value of "title") should not passed layer in terms of being publicly accessible. entity object should "sealed" without real value being accessible through api - entity may store it's state internally of course. a naive approach fetch list of document objects, iterate on , set title "confidential" if user not allowed. of course, change e