Posts

Showing posts from February, 2012

git diff - How can I get content of a file from git index? -

i have file has been added local repository. i've modified in working tree, git-status shows me file modified. know file content kept in index before stage file. i can think of 2 ways of doing that: revert patch generated git-diff, , apply on file in working tree use git-checkout-index, point temporary file , read content there is there easier way? use : prefix access objects in current index (staged not yet commited). git show :file see gitrevisions more information.

Create Themes for Windows Phone 7 -

how can create theme controls on interface don't have set style each control? in case need override default system styles. can find more info reading: theme forcing windows phone 7 (silverlight) how override theme resources in windows phone 7.5 also, recommend checking out thememanager jeff wilcox

ios4 - How to correct interfaceOrientation of viewControllers that weren't in response chain when rotating? -

i've build paginated interface using uiscrollview (something spring board). each page has own view controller logic on each page rather complicated. the code worked smoothly in portial orientation. need make react orientation changes. self.interfaceorientation not react orientation changes. if controller invisible during interface rotation interfaceorientation remains unchanged. suppose because controller wasn't in response chain when rotation happend. is there way correct interface orientation programmatically? i know can use [uiapplication sharedapplication].statusbarorientation correct orientation doesn't clean me. i've propagated interface orientation change manually down page view controllers.

c++ - Retrieve environment variables of a QProcess -

i want run environment script within qprocess , read environment (as qstringlist) start other scripts environment. if start env script , read environment, empty qstringlist. there way read out environment of qprocess? i tried first start environment script , start actual script on same qprocess object did not either. if able rewrite script sets environment in c++ can create environment , set using void qprocess::setprocessenvironment ( const qprocessenvironment & environment ) method in example given in method's documenation: qprocess process; qprocessenvironment env = qprocessenvironment::systemenvironment(); env.insert("tmpdir", "c:\\myapp\\temp"); // add environment variable env.insert("path", env.value("path") + ";c:\\bin"); process.setprocessenvironment(env); process.start("myapp"); update if can't use above method try using cmd.exe this; #include <qtcore/qcoreapplication...

javascript - JQueryUI: drop within container, append and revert -

i got stuck jqueryui. specifically, have following html snipped: <div class="from"> <div class"item">item 1</div> <div class"item">item 2</div> <div class"item">item 3</div> </div> <div class="to"></div> now want make items draggable , droppable on "to" box via jqueryui library. therefore, use javascript snippet: $('.item').draggable({ revert: true }); $('.to').droppable({ drop: function(event, ui) { ui.draggable.appendto(this); } }); while works far result concerned, animation handling 'revert' doesn't behave want to. problem dragging implemented setting "position: relative" , changing 'top' , 'left' css properties. item attached new container (which happens before revert animation), jumps new position because it's positioned relatively new container. revert animation starts @ new po...

sql server - Sum Function with division -

i trying figure out correct format when using sum function division: which 1 correct? sum(filesize/1024) or sum(filesize)/1024 the filesize column measurement in kilobytes converting megabytes. they mean different things. sum(filesize/1024) reduces file size megabytes, , sums megabytes. each file, "forgets" size in excess of megabytes boundary, underreport total file size. sum(filesize)/1024 report correct size in megabytes-- rounded down.

perl - Problem with Hash of Array -

hi got problem cannot return value , key in hash of array sub nextwords{ $language(0 .. $#language ) { $eng = $db->selectall_arrayref("select word words left outer join language on words.languageid = language.languageid words.languageid = $language order word asc ;"); # @language[$id] limit 10 offset $currentoffset #%returnarray2d = (@language[$language] =>[@$eng] ); $returnarray2d{@language[$language]} = [@$eng]; } return %returnarray2d; } i cannot return list of words my %newwordslist =nextwords(); foreach $key(keys %newwordslist) { print "here 2 : " . $key . "\n"; $ind(0 .. @{$newwordslist{$key}}){ print "dzo" . $newwordslist{$key}[$ind] . "\n"; } } output: $key ==> 132 not 123 and word cannot printed.. prints some array(0x320d514) array(0x320d544) array(0x320d574) array(0x320d5a...

Using DDHotKey wrapper for cocoa/carbon instantiate NSWindow -

with of dave delong , others on stackoverflow i've given tutorial app cool hotkey effect can't figure out how make instantiate window. i have following setup: a calculator not active when first run has nsstatusitem icon , menu, menu option opens main window. also, have added ddhotkeycenter.h , ddhotkeycenter directory + linked carbon.framework. the nsstatusmenu connected window through: -(ibaction)activatemain:(id)sender{ [nsapp activateignoringotherapps:yes];} what wondering if it's possible connect actions fired hotkey, using blocks method, ibaction directly, or if there's intermediate step connect them? would better have ddhotkey fire nsevent, or can that? i seem bit confused it's implementation. ddhotkey not "fire nsevent". invokes method on object. set hotkey fire activatemain: method of whatever object owns it: ... ddhotkeycenter * c = [[ddhotkeycenter alloc] init]; [c registerhotkeywithkeycode... target:self actio...

Dynamically changing text in twitter button (rails+jquery) -

ok, have index.html.erb . in have menu, render _menu.html.erb , , div, in render link show.html.erb using show action in controller. link shown <%=link_to h(@link), h(@link) %> (code show.html.erb). div, in link rendered, refreshed $('#div_with_link').load('controller/show'); , @link changes lot. the problem is, don't know, should put in twitter button text area. want people able share current link. i've tried data-text="<%=@video %>" , showing link on webpage, not generated one. what should do, put generated link in twitter button? suggestions help, thank in advance. alright, if you're using twitter's default button pretty hard achieve. i'd recommend build your own button , update href attribute link via javascript including mentioned parameters. here's code started: use instead of twitter button , style accordingly: <a href="http://twitter.com/share" id="tweet">tweet...

unit testing - Mocking grails method that uses a findAll, Generating a MissingMethodException -

def retrieveeatenfood(string token, string addeddate) { def consumer = consumer.findbymobiletoken(token) if(consumer != null) { def eflist = [] def list = consumer.findall("from eatenfood ef date(ef.dateadded) = date(:da)",[da:sdf_long.parse(addeddate)]) list.each{ def eatenlist = [:] eatenlist.put("foodtype",it.food.name) eatenlist.put("sequencenumber",it.sequencenumber) eatenlist.put("eatendate", it.eatendate) eatenlist.put("dateadded",it.dateadded) eflist.add(eatenlist); } return eflist; } } trying mock above method, findall keep generating exception. this issue works! need write test , keep getting exception. can me please! groovy.lang.missingmethodexception: no signature of method: carrotdev.consumer.findall() applicable argument types: (java.lang.string, java.util.linkedhashmap) values...

Is there a ruby equivalent to the PHP spl_autload_register? -

in php, use spl_autoload_register function lot. allows load classes on demand referenced. there way accomplish same thing in ruby? you can mimic php __autoload() behavior (like defining classname filename algotithm , requiring it) redefining object#const_missing method, called when constant (like classname) not found. here there's example. (update: i've updated link above.)

RegEx for a string of length 0-2 -

i'm trying match string can either empty or have 1 or 2 numbers in such following: "" (empty) "1" "23" string more numbers or non-numeric characters should not match. closest guess regex: [0-9]{0,2} which read "the numbers 0 through 9 occurring 0 2 times." however, in practice find regex matches longer strings "333". how possible restrict string length in regular expressions? use following regex: ^[0-9]{0,2}$ you had -- ^ , $ characters anchors match beginning , end of string, respectively. for more in-depth discussion on anchors, see here : [anchors] not match character @ all. instead, match position before, after or between characters. can used "anchor" regex match @ position.

android - PreferenceActivity lifecycle -

i read http://developer.android.com/reference/android/app/activity.html have question preferenceactivity lifecycle: does preferenceactivity onstop() or ondestory() call? i understand gets onstop() called when user clicks 'back', ondestory()? when ondesgtory() preferenceactivity called? thank you. as preferenceactivity subclass of activity , should follow same lifecycle. click on link provided , navigate indirect subclasses or here direct http://developer.android.com/reference/android/preference/preferenceactivity.html

c++ - OpenCV videoInput.h Capture speed different than write speed -

i trying write recording software write video stream coming in computer avi file. using opencv , accompanied videoinput.h handle directshow code. in case matters using visual studio 2010 compiler. the problem having recorded file plays faster previewed file. not alot, enough noticable. example: 10 second preview 7 second file moves little bit fast. if( bwritevideo ) { writer=cvcreatevideowriter(szfilename,cv_fourcc('d','i','v','x'), fps,cvsize(width, height),iscolor); if( !writer ) return 1; } if( bdisplayvideo ) cvnamedwindow("video", 0); while( key != 'q') { if(vi.isframenew(nsource)) { vi.getpixels(nsource, yourbuffer1, false, true); frame = cvcreateimage(cvsize(width, height), ipl_depth_8u, 3); frame->imagedata = (char*)yourbuffer1; frame->imagedataorigin = frame->imagedata; if( !frame ) break; // display image s...

java ee - weblogic cluster context -

i have web service app running on weblogic 10.3. recently, created cluster app run on multiple servers , share resources. have servletcontextlistener bind/unbind properties/objects @ server startup/shutdown. with single server, works great. however, in cluster, when 1 server goes down, context listener ( contextdestroyed method) invoked , unbound context (the other servers can no longer use resources then). there listener use or there way run contextdestroyed method when last server in cluster being shutdown? any appreciated. i'm kinda new weblogic , java ee in general. i use singletonservice controlling resources on cluster

c# - How can I convert an EF4 Code-First ICollection to an EntityCollection? -

say have following entity: public class post { public int id { get; set; } public virtual icollection<comment> comments { get; set; } } when retrieve post object database, need convert comments collection entitycollection<t> can check ef4 related data collection, such if data eager loaded or not. unfortunately, if try direct cast icollection<t> entitycollection<t> , exception due fact comments property system.collections.generic.list<t> , cannot converted entitycollection<t> . so how go getting ef information on collection when using code-first? this might more appropriate comment, i'm hoping ef4 guru can respond , explain what's going on. asked question below while ago, on ctp4. 1 response author of ef 4 recipes, saying @ runtime collection created entitycollection if declared virtual , icollection (which questioner doing) that's not happening. also, rowan miller (who's on ef4 team) wrote more ...

Controlling Python application with C# -

hey, issue addressed before not in angle. i'm trying control python application c#. application runs unknown time , need hold main c# application form until "knows" when python application done processing. should mark python application has own gui i'm trying keep. far, i've used: processstartinfo processstart= new system.diagnostics.processstartinfo(@app); processstart.windowstyle = system.diagnostics.processwindowstyle.hidden; processstart.useshellexecute = false; processstart.redirectstandardoutput = true; processstart.createnowindow = true; process myprocess = process.start(processstart); then send couple of "sendkey" methods including tab , enter. furthermore, can infer code i'm trying make entire python process hidden – did succeed in open\close python application didn't succeed in controlling @ all. suggestions? redirect stdin , push characters in way (rather sendkeys)?

html - How does Reddit display anchor tags as images? -

example here: http://www.reddit.com/r/fffffffuuuuuuuuuuuu/comments/fn9e7/the_best_thing_about_walking_to_school/c1h7af4 i tried peek dom via firebug couldn't find reference images. found href attribute of anchor tags decides image displayed. new me. how work? it's css background-image in :after pseudo-selector.

How would I keep music playing on a website as a user navigates it? -

not wanna anytime wanna know how it's done. when website has music, stops playing after navigate page on site, , starts playing again when page loads. how keep music playing if user clicks on link? don't wanna put website on frame. and also, if open new tab of website how stop song replaying on tab if they're playing it? method 1: a flash website. method 2: frames (1 frame player, other navigable site) method 3: the future method 4: everything on single page, content loaded ajax...possible, not cool seo @ mo as far active browser tab using jquery can check using window.focus & window.blur events: $(window).focus(function() { //dothisandthat; }); $(window).blur(function() { //dothatandthis; });

javascript - php's "setcookie" doesn't work cross-browser? -

at moment i'm using setcookie set cookies, works in firefox , safari, , cookies not set in ie , chrome (and maybe other browsers). setcookie($name, $value, time()+3600 * 25); i read in article setcookie , ie, if expiry date in past (or small), ie ignores it. i know javascript can set cookies (i'm using mootools) i'd prefer using php , mootools & cookies isn't working me. any appreciated. check server's clock. if it's running more 25 hours behind, time() + 3600 * 25 still in past far browser concerned.

python click event scope issue in pygame -

i've created gameobject class, using python pygame library, draws rectangle on screen. integrate event handler allow me draw rectangle around, click events gameobject not registering. here couple snippets of code class: def on_event(self, event): if event.type == pygame.mousebuttondown: print "i'm mousedown event!" self.down = true self.prev_x=pygame.mouse.get_pos(0) self.prev_y=pygame.mouse.get_pos(1) elif event.type == pygame.mousebuttonup , event.button == 1: self.down = false def on_draw(self, surface): #paints rectangle particular color of square pygame.draw.rect(surface, pygame.color(self.red, self.green, self.blue), self.geom)` do need make rect image mouse events register, or there other way can drag box around? do need make rect image mouse events register, or there other way can drag box around? no image required. solution: note: you use event mousemotion...

asp.net - Reuse Razor Partial View with Form -

i have partial view has form post controller. can include view using @html.renderpartial. the problem parent view linked controller. , partial view post orginal controller. is possible , how write partial views form supports reuse? thanks, you can pass form's action url (or action name) parameter partial view.

biztalk - Error in two-way WCF-Port without using Orchestration -

i want pass response wcf biztalk . my itinerary is onramp(one way receive port ) ->message transform(mapping) ->uddi resolver ->off ramp(two waysend port) am calling wcf , getting response ,after getting below error a response message sent adapter "wcf-basichttp" on receive location: "dynamicresolutiontwoway" uri:" http://pc133056.cts.com/twowayallocation/crmdetailservice.svc " suspended. error details: there failure executing response(receive) pipeline: "microsoft.practices.esb.itinerary.pipelines.itineraryselectsendreceive, microsoft.practices.esb.itinerary.pipelines, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" source: "esb itinerary selector" send port: "dynamicresolutiontwoway" uri: " http://pc133056.cts.com/twowayallocation/crmdetailservice.svc " reason: value cannot null. parameter name: config here getting response wcf, after passing data again , getting a...

c# - How to store an image into database -

how can use openfiledialog , picturebox , upload image , store sql server you need keep field datatype varbinary(max) in database table. convert image byte array. pass byte array parameter respect varbinary field. saved in database. while retrieving, value database byte array convert image object. hope sequence helps you. or more code example can find here

orientation - Android: Dynamically change location of Options Menu -

i have drawing activity creates custom 'canvas' view occupies entire screen, allowing user draw on it. have requirement lock activity portrait orientation, drawing app sketchpad replacement, , user have need rotate 'pad' draw without pad flipping around on them. of course means options menu locked orientation , depending on user, menu popping out of top, bottom or sides. i'd have options menu located @ bottom relative user... options considering , appreciate suggestions or info: allow orientation changes, menu moves needed, use sensormanager listen orientation, , manually rotate canvas view 'correct' orientation (portrait). ugly, there delay in rotation of canvas, , introduces potentially complex calculations, etc due x/y being swapped. restrict orientation changes, use sensormanager listen orientation, , manually rotate options menu bottom. no idea if possible. lock orientation, , create custom view intercepts menu button , displays 'fake...

uitextfield - iphone propgramatically read from textfield -

i have created tables text fields inside, in contacts iphone, (inspired uicatalog example) all working, how can programatically read values of text fields, see have tag, how can read them (because cannot use ib created programatically go inside tables)(noob here!) thanks, im using example hello world style type on text field of table, click on button , text typed goes label, sample populate coredata db table textfields said im preatty noob please walk me trough so when user hit submit, text label (and coredata) - (ibaction) submityourname;{ lblusertypedname.text = txtusername.text; nslog(@"received"); } this code textfield - (uitextfield *)textfieldnormal { if (textfieldnormal == nil) { cgrect frame = cgrectmake(kleftmargin, 8.0, ktextfieldwidth, ktextfieldheight); textfieldnormal = [[uitextfield alloc] initwithframe:frame]; textfieldnormal.borderstyle = uitextborderstyleroundedrect; textfieldnormal.textcolor = [uicolor blackcolor]; t...

jquery on blur but focus on the other one -

i have situation have hidden div 2 input elements hides default , shows if hover , disappears if hover out. want div not disappear if 1 of input element focused , disappears if blurred. have solved part until, if focus transferred 1 input another, div disappear don't want disappear because 1 of input still focused. here's code: // code problem think. $('#inputtext1, #inputtext2').live("blur", function() { if ($('#mydiv').is(":visible")) { if (!$(this).hasclass("jqtransforminputwrapper_focus")) { $('#mydiv').fadeout("slow"); } } }); // hover show , hide div $(".visiblediv").hover( function() { $('#mydiv').fadein("slow"); }, function() { if(!$(this).find(".jqtransforminputwrapper").hasclass("jqtransforminputwrapper_focus")) { $('#mydiv').fadeout("slow"); } ...

asp.net mvc 3 - How to unit test modelbinder with ModelMetadata -

how unit test custom modelbinder? here's code. public class magicbinder : defaultmodelbinder { public override object bindmodel(controllercontext controllercontext, modelbindingcontext bindingcontext) { var boundmodelobject = base.bindmodel(controllercontext, bindingcontext); var properties = bindingcontext.modeltype.getproperties().where(a => a.canwrite); foreach (var propertyinfo in properties) { object outvalue = null; bindingcontext.trygetvalue(propertyinfo.name, propertyinfo.declaringtype, out outvalue); propertyinfo.setvalue(boundmodelobject, outvalue, null); } return boundmodelobject; } } and here test script. [testmethod] public void testfoobinding() { var dict = new valueproviderdictionary(null) { {"number", new valueproviderresult("2", ...

iPhone fill values for UIPickerView -

i've created uipickerview, displays on button click. question how fill in rowitems uiactionsheet *actionsheet = [[uiactionsheet alloc] initwithtitle:@"select location" delegate:self cancelbuttontitle:@"cancel" destructivebuttontitle:nil otherbuttontitles:nil]; [actionsheet setactionsheetstyle:uiactionsheetstyleblacktranslucent]; uipickerview *pickerview = [[uipickerview alloc] initwithframe:cgrectmake(0,100,0,0)]; pickerview.showsselectionindicator = yes; pickerview.datasource = self; pickerview.delegate = self; [actionsheet addsubview:pickerview]; [pickerview release]; uisegmentedcontrol *closebutton = [[uisegmentedcontrol alloc] initwithitems:[nsarray arraywithobject:nslocalizedstring(@"done", @"...

java - Rendering lightweight markup languages with maven -

i render project documentation in html lighweight markup language markdown or textile. what's easiest way this? the maven site plugin able render apt format ("almost plain text") build html project (documentation) site. @see: http://maven.apache.org/plugins/maven-site-plugin/examples/creating-content.html http://maven.apache.org/doxia/references/apt-format.html

tsql - Nesting of FOR XML Expressions -

i tried xml query similar what's shown here under subtitle 'nesting of xml expressions'. problem have have 3 xml element levels. results should this. <steptree name="alfki"> <step name="foo"> <result id="123" /> <result id="456" /> </step> <step name="bar"> <result id="789" /> <result id="987" /> </step> </steptree > i tried type of query. select 1 tag, null parent, steptrees.name [steptree!1!name], null [step!2!name], null [result!3!id] steptrees steptrees.name = 'alfki' union select 2, 1, steptrees.name, steps.name, null steps join steptrees on steps.steptreeid = steptrees.id steptrees.name = 'alfki' union select distinct 3, 2, steptrees.name, steps.name, results.id steptrees join steps on steps.steptreei...

By using Sqlite database How can i retrieve an html document using webview in android -

how can fetch html document sqlite table using webview in android if html document written string in database, can use regular projection(select query) , obtain html using cursor.

Ant script: Prevent duplication of JAR in javac-classpath war-lib -

i have ant script , have lot of duplicated path same set jar files. there many double wording in classpath , in war element. <path id="my.classpath"> <pathelement location="foldera/subfoldera/1.0/a.jar"/> <pathelement location="folderc/subfolderb/1.0/b.jar"/> <pathelement location="folderf/subfolderz/2.0/z.jar"/> <pathelement location="compile/subfolderx/1.0/onlyforjavac.jar"/> </path> .... <javac ...> <classpath refid="my.classpath" /> </javac> .... <war ...> <lib file="foldera/subfoldera/1.0/a.jar"/> <lib file="folderc/subfolderb/1.0/b.jar"/> <lib file="folderf/subfolderz/2.0/z.jar"/> <lib file="morefolderf/subfolderz/2.0/additionfile.jar"/> <lib file="morefolderf/subfolderz/2.0/additionruntimefile.jar"/> </war> i want summary them 1 list easier keep update. ...

iphone - Custom UITableViewCell redraw issues -

i have custom uitableview cell i've added textbox editing, shows , hides based on edit mode. i've tried adding vertical line shows when editing, , that, i'm running drawing issues. added green checkmark rightview start working on input validation feedback, , i'm seeing similar issues. here code cell, , part of cellforrowatindexpath. #import <uikit/uikit.h> @interface editablecellstyle2 : uitableviewcell { cgrect editrect; uitextfield *editfield; uiview *lineview; } @property (nonatomic, readonly, retain) uitextfield *editfield; @property (nonatomic, readonly, retain) uiview *lineview; @end #import "editablecellstyle2.h" @implementation editablecellstyle2 @synthesize editfield; @synthesize lineview; - (id)initwithstyle:(uitableviewcellstyle)style reuseidentifier:(nsstring *)reuseidentifier { self = [super initwithstyle:style reuseidentifier:reuseidentifier]; if (self) { // in...

cocoa touch - Using Protocols in Objective C to Transfer Data Between Different Objects? -

hey guys, have root table view has toolbar @ bottom , has labels , refresh button within it, mail app's toolbar. root table view controller obtains data server allocating , initializing dataupdater class. within class nsurlconnection delegate methods called while communicating server. as can guess, need know when (delegate) functions called within dataupdater class , values of parameters passed these delegate functions can update labels on toolbar accordingly (i.e. connecting..., updated, etc). the problem having determining how notify root table view controller of going on in these delegate methods. use protocols, if how? have been skimming documentation , don't quite see how effect. or suggest implement program way? thanks in advance! a protocol kind of contract says: i promise provide non-optional methods defined in protocol, , maybe optional ones. it's purpose java interfaces: work around missing multiple-inheritence. the delegate pattern in object...

Querying csv with raw_input in Python -

i'm new programming decided take on python. i have csv file logged hours users looks (but containing around 200 rows): user,project,hours user1,projecta,5 user1,projectb,10 user2,projecta,7 user2,projectb,12` i'd extract data it, through several raw_inputs dependant on previous. eg. start asking if you'd want see full list, if yes print , close there. if answer no, move on next raw_input, eg. enter user you'd see. i've code, know it's still basic, i'm newbie this, haven't been able figure out solution. appreciated.. import csv reader = csv.reader(open("loggedhours.csv", "rb")) team = raw_input("do want see detailed team numbers? y/n: ") if team =="y": user, project, hours in reader: print user, project, hours else: print "ok" print "" user = raw_input("enter user id wish check: ") if user == user in reader: user, project, hours ...

Drupal Views Ajax Pager Styling Guide -

Image
i using ajax pager views multiple rows, pager looks nasty , whenever navigation button clicked loading animation jumps right hand side of block. is there guide anywhere outlines how style elements of pager , how change animation? since using firebug, select of pager links in , either add views-throbbing if <a> element has class -or- right click on element , add new attribute: class = "views-throbbing" this have on , see why element jumps, without view doing anything. i suspect rogue float somewhere in stylesheet.

c# - Changing a Setter Value Dynamically in WPF -

i trying change setter value dynamically. though successful partially, stuck progressing further. attempt change column colours of wpf toolkit generated column chart depending on series. used static member of separate class set color of background property of column data point. in way assigned color gets set columns regardless of being different series. following useful code spinets: column datapoint style defined following xaml: <local:mybackcolor x:key="mybackresource"></local:mybackcolor> <style x:key="infocruiseraquacolumn" targettype="dvc:columndatapoint"> <setter property="background" value="{binding source={staticresource mybackresource}, path= mybackcolor}"/> <setter property="borderbrush" value="transparent" /> <setter property="borderthickness" value="1" />... class sets color: public class mybackcolor { private static strin...

Is it possible to boost up views/indexes creation in couchdb by multiple cores? -

we have converted database of app run-time logs mysql couchdb. there around 3m docs converted, occupy around 7gb. then scripted out our first view (with reduce function) , did query invoke first run of view, make out view creation/generation. should take time , did 'top' on machine see process/cpu load stuff. noticed there 2 heavy process: beam.smp couchjs it's interesting seems occupy 1 core, there 4 cores on machine. possible make couchdb make use of multiple cores while creating/updating views? currently not supported. guess multicore support add complexity couchdb. so far, couchdb chooses simplicity instead of features. (did know couchdb 18,000 lines of code? compare 1 million in mysql or 100,000 in sqlite .) when design document view index building, uses 1 couchjs process. if have multiple design documents, will run in parallel. couchdb spawn 1 couchjs process per design document, , os spread them across multiple cores. however , if need p...

c++ - Converting from signed char to unsigned char and back again? -

i'm working jni , have array of type jbyte, jbyte represented signed char i.e. ranging -128 127. jbytes represent image pixels. image processing, want pixel components range 0 255. therefore want convert jbyte value range 0 255 (i.e. same range unsigned char), calculations on value , store result jbyte again. how can these conversion safely? i managed code work, pixel value incremented 30 clamped value 255, don't understand if it's safe or portable: #define clamp255(v) (v > 255 ? 255 : (v < 0 ? 0 : v)) jbyte pixel = ... pixel = clamp_255((unsigned char)pixel + 30); i'm interested know how in both c , c++. this 1 of reasons why c++ introduced new cast style, includes static_cast , reinterpret_cast there's 2 things can mean saying conversion signed unsigned, might mean wish unsigned variable contain value of signed variable modulo (the maximum value of unsigned type + 1). if signed char has value of -128 max_char+1 added value of 128...

MAMP - does not show index.php -

i have downloaded public_html folder website have work on , added mamp > htdocs. then, type http://localhost:8888/projectname , shows blank page in state of index.php. mamp not find index.php , can not find way around it. believe, website using smarty (tpl.php) @ places index index.php note: have disable // @require_once("config.inc.php"); // include "stored.function/db.inc"; , seems works. how can find real path them? in default, mamp comes error reporting closed. need edit /applications/mamp/conf/php5.3/php.ini file.

XmlReader.ReadtoFollowing has state EndofFile why? -

i've produced code read xml file string, has problems. notably readtofollowing() method returns nothing. seems seek whole xmlstring, set xmlreader state endoffile. i'm puzzled this, readstartelement() works , next element read "heading" you'd expect. here's code, idea read through xml pulling out fields require; list<string> contentfields = new list<string>() { "heading", "shortblurb", "description" }; string xml = @"<filemeta filetype='audio'><heading>fatigue &amp; tiredness</heading><shortblurb>shortblurb</shortblurb><description /><comments /><albumtitle /><tracknumber /><artistname /><year /><genre /><tracktitle /></filemeta>"; using (xmlreader reader = xmlreader.create(new stringreader(xml))) { reader.readstartelement("filemeta"); foreach (string field_str in contentfields) ...

LaTeX: How to set the pdf dpi when using images -

i'm writing thesis in latex , have troubles image imports. i want thesis pdf, imports jpeg images of charts , other things. i'd have higher resolution; default miktex settings have image resized crappy resolution. i'm using miktex, adobe reader 9.4, win7 32. how can raise resolution of pdf produced latex sources? is there other way insert pick without losing resolution? i know vectorial formats, have bmp or jpg insert in thesis. a part of code this: (the first 2 rows doesn't work =/) \pdfpxdimen=2in \divide\pdfpxdimen 300 \documentclass[12pt, a4paper]{report} \usepackage[italian]{babel} \usepackage[t1]{fontenc} \usepackage{graphicx} \begin{document} \include{frontespizio} \newpage \include{ringraziamenti} \tableofcontents \newpage \include{introduzione} \pagenumbering{roman} \pagenumbering{arabic} \pagestyle{fancy} \lhead{} \chead{} \rhead{\scriptsize \leftmark} \lfoot{} \cfoot{\thepage} \rfoot{} \renewcommand{\headrulewid...

How to hide an item in a listview in Android -

i know, question asked before, haven't seen working answer it. is there way hide items in listview without changing source data? i tried set visibility of item view gone, won't displayed anymore, place reserved item still there. i set: android:dividerheight="0dp" android:divider="#ffffff" without success. you can either write own listadapter or subclass 1 of existing ones. in listadapter , filter out items not want displayed returning modified values getcount() , getitem() , getitemid() appropriate.

wpf - UserControl in DataTemplate doesn't applied style for font -

i have user control in datatemplate , style of textblock doesn't change fontsize changes background . attached samples: create wpf window. create user control, usercontrol1 inside window paste below code: <window.resources> <style targettype="{x:type textblock}" x:key="textblockstylefontandbackgound"> <setter property="fontsize" value="20" /> <setter property="background" value="blue" /> </style> <datatemplate x:key="contenttemplate"> <stackpanel> <m:usercontrol1 /> </stackpanel> </datatemplate> </window.resources> <grid> <contentcontrol fontsize="10"> <stackpanel x:name="stackpanel"> <button click="button_click" /> <contentcontrol contenttemplate="{static...

Inserting images into java code editor -

i'm using eclipse write math related programs. i want make code more understandable, math code, using images representing math code in example latex formulas. i know how translate math code mathml , picture, main problem inserting images. hope answers. you can't insert images (except ascii-art! ;) in java source code. you can write javadoc includes images providing <img /> tag. btw, should know java allows unicode in it's source code, it's legal write ∫, ∑, Π, α, Δ, δ, Ï€, ε, Θ, θ etc directly in source code (even though i'm not sure recommend it.)

iphone - UILabel's sizeToFit/sizeThatFits ignore the numberoflines property -

problem: determine size (number of lines) uilabel needs, assuming width 300 px. string longer, set linebreakmode uilinebreakmodewordwrap , invoked sizethatfits try determine size. gives width of 457 px in single line, rather expected 300px in 2 lines. please see: cgsize available = cgsizemake(300, infinity); uilabel *label = [[[uilabel alloc] initwithframe:cgrectmake(0, 0, 300, 400)] autorelease]; label.text = title; label.linebreakmode = uilinebreakmodewordwrap; label.font = [uifont fontwithname:kboldfont size:ktitlefontsize]; label.numberoflines = 3; cgsize sizedtofit = [label sizethatfits:available]; but find sizedtofit variable has width of 457 pixels , height of 22 px, , ui displays single line clipped text. expect width of 300 pixels, , height of 44 px 2 lines. the uilabel doc numberoflines says: when receiver resized using sizetofit method, resizing takes account value stored in property. example, if property set 3, sizetofit method resizes receiver big enough disp...

Cognos 8+ - Use Query Results in an Html Object -

i'm pretty new cognos reports studio, wondering if there's way take results of query, , work them inside of html object. say have query returns 1 record following: -genre -artist -album -song and want fill html object following: '<%=song%> example of <%=genre%> <%=artist%>, album <%=album%>' thanks in advance i think you're trying use asp.net shorthand echo basis idea, , unfortunately, don't think can use in cognos. idea use data container/block, such list report, , create data item inside of it. there, concatenate static elements data items you're retrieving database, example: [song] || ' example of ' || [genre] || ' ' || [artist] || ', album ' || [album] hope helps.

objective c - iPhone UIView center property returning bad value -

i'm working view-based application compiling iphoneos 4.0 simulator (debug), xcode 3.2.3. i've got uiimageview, imgview, center want coordinates of. obtain them this: cgpoint imgviewcoords=[imgview center]; this doesn't produce compile-time errors, when nslog coordinates this: nslog(@"x: %i, y:%i", imgviewcoords.x, imgviewcoords.y); i output: x: 0, y:108762 it's showing 0 imgview's x coordinate (which know isn't right, because imgview near top-middle of screen on interface builder) , giant impossible number way past boundaries of iphone's screen y coordinate (the y coordinate in output above may not correct, it's giant number that). same exact output each time. imgview linked file's owner outlet, , can change image using [imgview setimage:[uiimage imagenamed:@"./blahblah.png"]]; i can't seem center coordinates. i've tried cgpoint viewcoords=[[imgview frame] origin]; and gives me same erroneous co...

c - Why is my OpenMP implementation slower than a single threaded implementation? -

i learning openmp concurrency, , tried hand @ existing code have. in code, tried make loops parallel. however, seems make program slower, @ least 10x slower, or more single threaded version. here code: http://pastebin.com/zylzuwu2 i used pthreads, turns out faster single threaded version. now question is, doing wrong in openmp implementation causing slowdown? thanks! edit: single threaded version 1 without #pragmas one problem see code using openmp across loops small (8 or 64 iterations, example). not efficient due overheads. if want use openmp n-queens problem, @ openmp 3.0 tasks , thread parallelism branch-and-bound problems.

html - monotouch: Image not displaying in email -

i have html has image in table. table displays fine in uiwebview. take same html , send in email (using mfmailcomposeviewcontroller). code snippet build html is: html += "<tr><td><img src=\"reading.png\" align=left></td><td>" the table created properly, image has question mark in blue box. (obviously, can't find image, why?) how fix this? the path "reading.png" not found, reason why not see image. there in fact several potential solutions. 1) put image web url http://yourweb address.com/reading.png, works , show, clients supports , user need click "show images" if he/she has disabled default in email client. 2) second solution put specific image representation img tag, can opening file, reading content , adding base64 data src of img, there plenty of samples this. 3) third add attachment email. again plenty of samples here , on web how that. conversion of sample code objectivec s...

c# - How to implement a blinking label on a form -

i have form displays queue of messages , number messages can changed. want blink label (queue length) when number of messages increased improve form usability. should implement custom control , use additional thread or timer change color of label? has implemented functionality? best solution (less resources , less performance degradation) implement behaviour? solution: form's component timer can restrict number of animations per second , implement fade out effect external control background color. you can create custom component , events start blinking. think solution. blinking can implement timer.

visual studio 2008 - XML Parsing Error: no element found Location: http://localhost/Test/TestService.asmx Line Number 1, Column 1: -

i created web service in vs 2008 , hosted in iis when trying oprn in brwoser throws error. any appreciated. thanx don't open in browser. write unit test call service. how service behaves in browser may not how behaves in real life. use fiddler watch network traffic. you'll see interesting things. i bet reason you've got xml parsing error xml isn't what's being returned server. bet you've got text or html telling there's been error in web service.

.net - Castle Windsor Releasing Typed Factory Components -

i see breaking change made windsor following: change - ireleasepolicy interface has new method: ireleasepolicy createsubpolicy(); usage of sub-policies changes how typed factories handle out-of-band-release of components (see description) impact - medium fixability - easy description - added attempt enable more fine grained lifetime scoping (mostly per-typed-factory right now, in future - per-window in client app). side-effect of (and change release policy behavior described above) no longer possible release objects resolved via typed factories, using container.release. objects tracked in scope of factory released if call factory releasing method made, or when factory released. fix - method should return new object exposes same behavior 'parent' best return object of same type (as built-in release policies do). i using auto-releasing idisposable implementation described here: http://devlicio.us...

c# - Parser Error Debugging VS2008 -

when create new vs2008 asp.net application builds fine. when start debugging below error in browser. i've rebuilt app. inherits clause of markup page matches class in code-behind c#. clues? server error in '/' application. -------------------------------------------------------------------------------- parser error description: error occurred during parsing of resource required service request. please review following specific parse error details , modify source file appropriately. parser error message: not load type 'webapplication3._default'. source error: line 1: <%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="webapplication3._default" %> line 2: line 3: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> source file: /default.aspx line: 1 ------------------...

HTML upload file using AJAX and PHP script - help? -

i trying perform task may not possible. haven't found same scenario yet around internet. i have 4 fields that, on click, call javascript function ajax call data php file. the fields filling row in database , php query new set of data, , user see it. part of data image user can click on , expand. the ajax call works, expanding image works, adding image via upload not, breaking whole thing. here snippet of html form: entry: <input type='text' id='entry' /> stop: <input type='text' id='stop' /> final: <input type='text' id='final' /> chart: <input type='file' id='chart' value='get chart'/> <input type='button' onclick='addresult()' value='add' /> the addresult() processes things this: var entry = document.getelementbyid('entry').value; var stop = document.getelementbyid('stop').value; var final = document.getelementbyid('...

greasemonkey - Javascript page load delay of specific set of pages -

i want delay specific set of webpages using small greasemonkey script. basically, if website being loaded part of set of pages, want delay time page takes load. e.g. if page being loaded "http://www.a.com/","http://www.a.com/b", etc. want delay load 30 secs. assuming dushara's comment correct: "see xkcd.com/862 poster wants. (hover mouse on image see reasoning). in fact, found question while googling same thing." then not possible in greasemonkey. reason gm fires after page has loaded (except slow pictures or ajax calls). user see page , would, say, flash blank 30 seconds... but, after quick eyeballs have seen much. ;) update: possible in greasemonkey (with @run-at document-start directive -- added august 2011). see this answer example . note xkcd's creator uses good, old-fashioned willpower implement "simple 30-second delay". his blog entry : "lots of people have asked me system used implement ...

memory - flash player crashes while looping over movies -

i'm trying realize kind of slideshow in flash, loops on 100 h.264 encoded movies. i'm using netconnection , netstream classes connecting files locally on harddisk (see code below). private function playmovie():void { var currentmovie:string = movies[index]; index = (index + 1) % movies.length; netconnection = new netconnection(); netconnection.connect(null); if(netstream != null) { netstream.removeeventlistener(netstatusevent.net_status, netstatushandler); netstream = null; } netstream = new netstream(netconnection); netstream.client = this; netstream.addeventlistener(netstatusevent.net_status, netstatushandler); stagevideo.attachnetstream(null); stagevideo.attachnetstream(netstream); netstream.play(currentmovie); } private function netstatushandler(evt:netstatusevent):void { if(evt.info.code == "netstream....