Posts

Showing posts from March, 2013

internet explorer - Selecting an html radio button dynamically through javascript does not work in IE -

i want select radio button javascript. using simple html file test issue. code below works correctly on firefox , chrome, not work in ie (no version works). know why supplied code not work on ie, , how select radio button in ie? <html> <head> <script type="text/javascript"> function chooseone() { var randomchoice = math.round(math.random() * 2); if(randomchoice == 0) { document.getelementbyid("test0").checked = true; } else if (randomchoice == 1) { document.getelementbyid("test1").checked = true; } else { document.getelementbyid("test2").checked = true; } } </script> </head> <body> <input type="radio" id="test0" name="test" value="a" /> a<br /> <...

big o - C++ - Big-O Notation -

for reason im unable solve this. big-o notation for (int = 0; < n; i++) (int j = 0; j < n; j++) { c[i][j] = 0; (int k = 0; k < n; k++) c[i][j] += a[i][k] * b[k][j]; } for (int = 0; < n; i++) (int j = 0; j < n; j++) { c[i][j] = 0; (int k = 0; k < n; k++) c[i][j] += a[i][k] * b[k][j]; } it looks it's o(n^3) because has 3-level loops.

Good book for Unix Internals -

am interested in unix. want learn in , out. can guys me listing books can make me wizard? want become unix programmer. i not novice user in unix. you want system administration knowledge, or programming knowledge? for programming: advanced programming in unix environment unix network programming the art of unix programming for system administration: automating linux , system administration unix , linux administration handbook

c++ fraction class. overloading operators? -

i making fraction class school project, , brain frying. told overload << , >> operators through friend keyword. i'm getting errors this. i've posted relevant code here: http://pastebin.com/ngcabgj2 the errors include: error c2270: '<<' : modifiers not allowed on nonmember functions (this error ones declared friends) this @ operator< definition. error c2333: 'fraction::operator <' : error in function declaration; skipping function body there's 46 in all... nightmare. edit: thanks, solved errors, there's still 3 error c2664: 'fraction::fraction(const fraction &)' : cannot convert parameter 1 'int' 'const fraction &' occurs @ statement: fraction<int> test1, test2, test3(10); error c2248: 'fraction::operator ==' : cannot access private member declared in class 'fraction' error c2248: 'fraction::operator <' : cannot access private member declared in ...

Why are main runnable Python scripts not compiled to pyc files like modules? -

i understand when import module, file compiled .pyc file make faster? why main file not compiled .pyc ? slow things down? better keep main file small possible then, or not matter? when module loaded, py file "byte compiled" pyc files. time stamp recorded in pyc files. this done not make run faster load faster. hence, makes sense "byte compile" modules when load them. http://docs.python.org/tutorial/modules.html#compiled-python-files [edit : include notes, references] from pep 3147 on "byte code compilation": cpython compiles source code "byte code", , performance reasons, caches byte code on file system whenever source file has changes. makes loading of python modules faster because compilation phase can bypassed. when source file foo.py, cpython caches byte code in foo.pyc file right next source. how byte code compiled files tracked respect python version , "py" file changes: it inserts m...

string - How to replace repeated instances of a character with a single instance of that character in python -

i want replace repeated instances of "*" character within string single instance of "*" . example if string "***abc**de*fg******h" , want converted "*abc*de*fg*h" . i'm pretty new python (and programming in general) , tried use regular expressions , string.replace() like: import re pattern = "***abc**de*fg******h" pattern.replace("*"\*, "*") where \* supposed replace instances of "*" character. got: syntaxerror: unexpected character after line continuation character. i tried manipulate loop like: def convertstring(pattern): in range(len(pattern)-1): if(pattern[i] == pattern[i+1]): pattern2 = pattern[i] return pattern2 but has error prints "*" because pattern2 = pattern[i] redefines pattern2 is... any appreciated. the naive way kind of thing re is re.sub('\*+', '*', text) that replaces runs of 1 or more asterisks 1 asterisk. runs...

php - What is wrong with this MySQL Query? -

it's 12:30am , have been coding 9 hours straight. need project done, mysql messing deadline. examine snippet me , see if can find out wrong? php/mysql query $q = $this->db->query("select * bans ip='".$ip."'"); keeps returning following error... mysql error [oct 6th, 2010 11:31pm cdt] have error in sql syntax; check manual corresponds mysql server version right syntax use near '* bans ip='206.53.90.231'' @ line 1 (1064) i not see wrong query. i've tried different methods of including variable $ip no avail. edit: add in here, ip column in database varchar(255). edit 2: here whole affected code. keep in mind in class. if i'm missing something, let me know. line function if($this->isbanned($_server['remote_addr'])===true) { return json_encode(array('error'=>'you banned shoutbox.')); } affected function function isbanned($ip) { $q = $this->db->query(...

uinavigationcontroller - Change tabbar size and color iphone -

they apple doesn't let apps custom tabbar color or height in. true? want change height of both navigationbar tabbar in application. ok? thanx in advance. in apple documentation here : you can specify color , translucency of navigation bar coordinate overall of application , other bars in (that is, toolbars, tab bars, , status bar). can use custom color or choose 1 of standard colors: blue (the default color) blackblue (the default color) black now don't think possible change height.

c# - Can we create a 1-D array of UserControl. ..? -

i created "usercontrol" in winforms- contains 1-button style. and need use same array(10) , load form. ex: dim mybutton() button = new ucspecialbutton(dataset4category(i).tables(0).rows.count - 1) {} here usercontrol name ucspecialbutton can create one-dimensional array of winform usercontrol.? with makkam's words: yes, can. guess you're uncertain whether can add dynamic number of controls form, because in designer cannot define arrays, drag , drop number of controls on form. however, in fact visual studio generates code in background adds these controls collection. can write own code add arbitrary number of usercontrols collection dynamically. @ forms' .designer.cs file see how works. taking makkam's array controls this, e.g.: public myform() { initializecomponent(); // call auto-generated code // here add own code: foreach (control control in controls) { this.controls.add(control); // how add control fo...

css - How to easily change a font-sizing from px to em for a big, existing site? -

how change font-sizing px em big, existing site? any tips quickly? it depends on existing stylesheet, it’s not going quick i’m afraid (assuming want site same after you’re done). potential problems when text sized in pixels, visual size of text same put in css. example, css p {font-size: 12px;} result in <p> tags having font size of 12 pixels. however, when text sized in ems, visual size calculated relative font size of nearest ancestor. so, if had following css: body {font-size: .625em;} p {font-size: 1.2em;} .header {font-size: 1.5em;} and following html: <body> <p>paragraph</p> <div class="header> <p>paragraph inside header</p> </div> </body> then visual font size of first paragraph 1.2 (paragraph’s size) × .625 (body’s font size) × 16 pixels (the default root font size of modern browsers) = 12 pixels . but visual size of second paragraph 1.2 (paragraph’s size) × 1.5 ( .header ...

java - Maven 2 multi module pom -

i have started migrating project ant maven. have 2 module in application able build using maven. now have automated tests project use web driver testing ui functionality. trying using maven build both module wars , deploy them on tomcat. run automation tests against them , pass build if automation test passes. have configured pom this(just mentioning important part): <packaging>pom</packaging> <modules> <module>../module1</module> <module>../module2</module> </modules> now both projects build , deploy doesn't run automation tests. reason thought packaging type pom. if change war starts throwing error. i can think of creating third pom automation , parent pom include module also. thinking whether right way. should common scenario , maven should supporting directly. (...) automation module webdriver based automation tests testing ui. depends on web war there no package dependency. deploying tomcat...

jquery - .serialize() not returning values from dynamically generated form -

i'm missing here. i have form dynamically loading form using jquery .click() pulls in $.post query outputs form specific data .html(). i'm trying serialize data form , it's not giving me anything. doing wrong? code inserting form: $(".edit").click(function(){ var mid = $(this).attr("uid"); $.post("inc/menu_mod.php", { page: "edit",menu_id: mid, sender: 'sent'}, function(data){ $('#menu_mod').html(data); }); }); my attempt serialize: $(".update_menu").live('click', function(){ alert("this fires, know it's working"); var form = $('#menu_form form').serialize(); alert(form); }); thanks in advance! i suspect selector should var form = $('#menu_form').serialize(); because menu_form id of form.

user interface - How should I allow my members to cancel their accounts for my site? -

what best way allow member cancel account? should have them click cancel button on site? have button or allows canceling account confirmation user doesn't cancel mistake. don't delete account, have deleted flag in users table can reactivate account if needed. regards, alin

c++ - An intrusive list of unique_ptrs? -

i have program highly multi-threaded , contains intrusive linked list of objects. need pass off objects in list several threads, 1 thread ever own object @ time, meaning don't need object or pointer shared. i wanted create intrusive list unique_ptr using boost, i've read unique_ptr not compatible boost intrusive library not have right ownership semantics. per this intrusive library requires it's elements (pointers) have same ownership semantics raw pointer. unique_ptr or shared_ptr not qualify. i wondered if give me advice on how best implement intrusive list can safely pass elements through several threads , know being moved thread , not shared amongst threads? as far follow, work need kind of auto-unlink hooks . since intrusive container not own objects contains, should not have problem adding raw pointers unique_ptrs refer to, intrusive container. if need able access actual unique_ptr raw pointer in intrusive list, along lines of enable_shared_...

php - Magento: programmatic search depending on store -

i'm using catalogsearch module of magento. have 2 stores. when searching "test" on first one, 5 results. when searching "test" on second one, 3 results. i'd add results of second store (just number of results) when search in first one. i added block , template, need code retrieve number of results in second store, , that's i'm stucked. i tried controller code, returns me number of results in first store : private function _getstorequery($storeid) { $query = mage::helper('catalogsearch')->getquery(); $query->setstoreid(7); if ($query->getquerytext()) { if (mage::helper('catalogsearch')->isminquerylength()) { $query->setid(0) ->setisactive(1) ->setisprocessed(1); } else { if ($query->getid()) { $query->setpopularity($q...

how to use array_push when pushing both key and value in PHP -

i have empty array. able push values using array_push($list, item[0]); but how push both key , value. array_push($list[$key], $item[0]) this not work. $list['key']=$item[0]; should work. note: if use array_push() add 1 element array it's better use $array[] = because in way there no overhead of calling function.

design patterns - Single instance in the cluster with WF 4 and AppFabric -

i trying single instance workflow wf4 , appfabric. want 1 instance of workflow running in cluster. i have tried biztalk style: method (callservice()) creates instance, , same method in other receive activity (callservice()) not have cancreateinstance checked. (i think correlate through xpath action in soap message, lets forget correlating @ step). my problem wf creates instance , not correlate in second call. do know how solve it? priorize correlation against creation of instances. other way it? thanks in advance. i have found solution. here have written about: http://pablocastilla.wordpress.com/2010/10/09/single-instance-of-a-workflow-in-the-cluster-with-wf-4-0-and-appfabric/ how can receive messages same instance? easy making little trick in receive shape: we create correlation handler. let’s call singleintancehandler in receive shape set correlateswith property singleinstancehandler. in correlateson definition should insert string, not xpath expression....

java - Socket print to Toshiba B-SA4TM -

i should print barcode labels toshiba b-sa4tm printer. have found code snippet print directly socket can't figure out how should pass commands. have example please. thank much. kindly elvisd the problem understand how commands composed. have found it. here example: string s = "{d0920,0870,0800,0900|}"+ // "{ax;+000,+000,+00|}"+ // "{ay;+01,1|}"+ // "{c|}"+// "{pv01;0350,0010,0025,0060,j,11,b=article desc 1|}"+// "{pv02;0295,0010,0025,0060,j,11,b=desc2|}"+// "{pv03;0240,0010,0020,0032,j,11,b=qty|}"+// "{pv04;0200,0010,0020,0032,j,11,b=exp|}"+// "{pv05;0160,0010,0020,0032,j,11,b=lot|}"+// "{pv06;0240,0100,0030,0040,j,11,b=12x|}"+// "{pv07;0200,0100,0030,0040,j,11,b=2012.12|}"+// "{pv08;0160,0100,0030,0040,j,11,b=lo...

Drupal Views exposed filter of Author name -

i have view add exposed filter of author name. can filter posts created "john smith" etc. can't seem see listed under filter. possible do? under build > views ( /admin/build/views ) add filter (from filter category user ) click expose in filter configuration section (near right border).

python - closing files properly opened with urllib2.urlopen() -

i have following code in python script try: # send query request sf = urllib2.urlopen(search_query) search_soup = beautifulsoup.beautifulstonesoup(sf.read()) sf.close() except exception, err: print("couldn't programme information.") print(str(err)) return i'm concerned because if encounter error on sf.read() , sf.clsoe() not called. tried putting sf.close() in finally block, if there's exception on urlopen() there's no file close , encounter exception in finally block! so tried try: urllib2.urlopen(search_query) sf: search_soup = beautifulsoup.beautifulstonesoup(sf.read()) except exception, err: print("couldn't programme information.") print(str(err)) return but raised invalid syntax error on with... line. how can best handle this, feel stupid! as commenters have pointed out, using pys60 python 2.5.4 why not try closing sf , , passing if doesn't exist? ...

android - png downloaded size different to server size? -

my app downloads .png files sd card later use. kept getting outofmemoryerrors (if explain too, that'd great!) , took @ sizes of images saved sd card, , seem double on server. why this, , how can make them smaller? public void oncreate(bundle saved) { setcontentview(r.layout.namedrxnscreen); textview t1 = (textview)findviewbyid(r.id.rxn_text1); textview t2 = (textview)findviewbyid(r.id.rxn_text2); textview t3 = (textview)findviewbyid(r.id.rxn_text3); textview t4 = (textview)findviewbyid(r.id.rxn_text4); iv = (imageview) findviewbyid(r.id.rxn_image); pb = (progressbar) findviewbyid(r.id.rxn_loading); vs = (viewswitcher) findviewbyid(r.id.rxn_switch); try { super.oncreate(saved); [ boring stuff here ] bitmapdrawable image = getimage(c.getstring(5)); if (image != null) { iv.setimagedrawable(getimage(c.getstring(5))); iv.setbackgroundcolor(color.white); vs.setdisplayedchild(...

web applications - PHP: Session Security -

i read session security eg. session fixation, hijacking & injection confused workings of session security. way it: // when user logins, $_session["user"] = "someuser"; // check user login if (isset($_session["user"]) && !empty($_session["user"])) maybe doing wrong, don't have session ids anywhere, or @ least didn't use it. can explain how should session ids used & how affects session security? also, understanding of following threats correct? session fixation user visits link (http://site.com?session_id=123) , logs in server "marks" session id logged in hacker can visit http://site.com?session_id=123 my understanding of session fixation seems wrong me. if correct won't mean hackers can randomly use session ids , used existing user? session hijacking hacker somehow gets session id whether fixation or guessing etc session injection what this? you're not using sessio...

c# - ASP.NET JavaScriptSerializer requires HttpResponse? -

it appears system.web.script.serialization.javascriptserializer class tries obtain httpresponse current request, presumably apply appropriate character encoding. however means when to use class no httpcontext in scope, blows following exception + stack trace: [httpexception (0x80004005): response not available in context.] system.web.httpcontext.get_response() +8753496 system.web.util.httpencoder.get_current() +39 system.web.httputility.javascriptstringencode(string value, boolean adddoublequotes) +13 system.web.script.serialization.javascriptserializer.serializestring(string input, stringbuilder sb) +31 system.web.script.serialization.javascriptserializer.serializecustomobject(object o, stringbuilder sb, int32 depth, hashtable objectsinuse, serializationformat serializationformat) +240 system.web.script.serialization.javascriptserializer.serializevalueinternal(object o, stringbuilder sb, int32 depth, hashtable objectsinuse, serializationformat serializationfo...

No ButtonGroup.clearSelection() method in Apache Harmony Java -

when tried port code sun jdk apache harmony, clearselection() method of the buttongroup objects flaged compilation error. can instead? something like enumeration<buttonmodel> buttons = buttongroup.getelements(); while(buttons.hasmoreelements()) { buttongroup.setselected(buttons.nextelement().getmodel(), false); } iterate through group , set each buttons selection state false.

ipad - Add SplitViewController in Tabbar -

i looking add splitviewcontroller in tabbar & per tabbar item clicked data of tableview changed. is possible resize view of splitviewcontroller window visible ? so 1 can suggest me on issue ..... have checked out solution? uisplitviewcontroller in tabbar ( uitabbarcontroller )?

sql server - Get SQL Insert to work when PK is supplied or NOT -

i have following stored procedure: alter procedure dbo.appl_serverenvironmentinsert ( @serverenvironmentname varchar(50), @serverenvironmentdescription varchar(1000), @usercreatedid uniqueidentifier, @serverenvironmentid uniqueidentifier output ) recompile -- stores serverenvironmentid. declare @appl_serverenvironment table (serverenvironmentid uniqueidentifier) -- insert data table. insert appl_serverenvironment with(tablockx) ( serverenvironmentname, serverenvironmentdescription, datecreated, usercreatedid ) output inserted.serverenvironmentid @appl_serverenvironment values ( @serverenvironmentname, @serverenvironmentdescription, getdate(), @usercreatedid ) -- if @serverenvironmentid not supplied. if (@serverenvironmentid null) begin -- serverenvironmentid. select @serverenvironmentid = serverenvironmentid @appl_serverenvi...

c - void * assignment problem -

i want take fields packet struct using pointer arithmetic.but wrong code below ? in first condition think if go 4 byte(2 short field) beginning of packet tlow .but not give expected value.additionally second case want data field going 12 byte beginning of packet .what wrong idea ? struct packet{ short len; short field; int tlow; int thigh; void *data; } int main() { struct packet pack; struct packet *pck; pack.len=3; pack.field=34; pack.tlow=712; pack.thigh = 12903; pack.data = "message"; pck = &pack; int *timelow = (int * )pck + 4; // want tlow printf("time low :%d\n",*time); char *msg = (char *)pck + 12 ;// want data printf("message :%s\n",msg); return 0; } you better using standard method int *timelow = &(pck->tlow); compilers allowed insert padding bytes between member of struct. rules these padding bytes are, @ best, implementation...

java - Apache qpid queue url -

i'm trying learn more information on how apache qpid works , following examples official svn : http://svn.apache.org/repos/asf i looking @ : http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/hello.java which uses configuration/property file : http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/hello.properties can break down me line configuration represents : connectionfactory.qpidconnectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672 i. assume guest:guest credentials use when connecting qpid ii. assume localhost , 5672 should hostname:port my question test? represent ? name of queue or it? possible specify queue name directly in amqp url ? short answer : "test" stands qpid virtual host. longer answer : whole helloword sample explained here , line-by-line. page, there link apache qpid jndi prop...

javascript - Launch / Check application -

i have following script using in intranet environment: function launchapp(the_app) { var ws = new activexobject("wscript.shell"); ws.exec(the_app); } this allows me pass exe path launch directly web page long internet explorer's intranet security settings adjusted. the problem is, not in out network has same applications, has more, others have less. wondering, possible extend script above how check if path given exists on users computer before attempting launch it? you can create filesystemobject , interact client's filesystem.

c# - WPF: Validation.ErrorTemplate not hidden when adorned control (TextBox) hidden -

i have textbox gets hidden depending on whether item selected in combobox. this part works fine. however, has validatesondataerrors set , if textbox has error present, when textbox gets hidden, errortemplate (in adorner layer) remains. i think understand because errortemplate gets set global adorner layer, doesn't realize textblock, has no logical connection to, has been hidden. any thoughts on how work or around this? i've tried adding explicit adornerdecorator inside grid, bound combobox value. you apparently can bind visibility of adornerelementplaceholder of adorner itself. here code: <controltemplate x:key="emptyerrortemplate"> <border background="transparent" borderbrush="transparent" borderthickness="0" ishittestvisible="false" visibility="{binding elementname=placeholder, path=adornedelement.visibility}"> <stackpanel orientation="horizontal...

iphone - using UIScrollView generating issues -

this may simple problem. have uiscrollview 3 views. need display 3 dots indicator ( indicate there more pages user). how do this? use uipagecontrol: pagecontrol = [[uipagecontrol alloc] initwithframe:cgrectmake(...)]; // set in header [pagecontrol setnumberofpages:3]; [pagecontrol setcurrentpage:0]; [pagecontrol setbackgroundcolor:[uicolor clearcolor]]; [self.view addsubview:pagecontrol]; that ui component shows dots... number of pages number of dots. current page 1 highlighted. then need use scroll view delegate method determine page you've scrolled to: - (void)scrollviewdidenddecelerating:(uiscrollview *)scrollview{ int newoffset = scrollview.contentoffset.x; int newpage = (int)(newoffset/(scrollview.frame.size.width)); [pagecontrol setcurrentpage:newpage]; }

wordpress - Looking For a "Camera Flash" like Page Transition -

i hope makes sense. i'm add page transition effect 1 of wordpress sites. i'm looking simple white flash, ie. in single frames, webpage filled white, black, white, webpage revealed. if possible i'd set opacity. any ideas? someone kind enough send me link, incase wants attempt similar here link -http://www.motyar.info/2010/07/camera-flash-effect-with-jquery.html

c# - Install .Net assembly reference in Mono -

i earlier thread got track down deprecated .net assembly reference , able port project build within visual studio 2010. is there option reportviewer work within mono? building project monodevelp 2.2.2 gives me similar errors: assembly "microsoft.reportviewer.common version=8.0.0 [...] not found assembly "microsoft.reportviewer.winforms [...] not found thanks :) try running of dependent assemblies through mono migration analyser . targets mono 2.6, 2.8 has been released. if assemblies pass tests in they'll work fine in mono. if don't pass tests there's slim chance they'll work, depends functionality used.

.net - How will you process date values stored in varchar fields? -

your user wants report sorted date. report being created using c# , odp.net sort on date column , output not user expected. upon closer inspection, find date column varchar2 field. values in column stored in dd-mon-yy "01-jan-10" format. how sorted date? my answer: select to_date(fakedatecolumn,'dd-mon-yy') table order to_date(fakedatecolumn,'dd-mon-yy') is there available in front-end? suppose datetime.parseexact trick well. you answer correct. sorting should done @ database level. using datetime.parseexact mean rows need fetched @ client , sorted might not efficient. once results fetched sorted database parse string datetime show formatted in user interface.

.net - Help with static constructor in c# -

i need initializing static readonly variables in c#. have class signature public class agentdescriptions { public static readonly int p1; public static readonly int p2; static agentdescriptions() { int agencyid = 1; //i need pass in constructor somehow p1 = getidfromdb(agencyid); p2 = getidfromdb(agencyid); } } p1 , p2 used on , on in application , trying avoid 2 things. 1)magic numbers , 2)trip db every time need use p1 , p2. in application using them in many places in manner if (something == agentdescriptions.p1) //blah(); please help. how can pass agencyid in static constructor? if add contructor , pass agencyid there, have initialize class every time use it? mean trip db every time? why class static. if you're passing variable in constructor you're implying instance of object state, not class. i'd make variables private member variables methods available them. have constructor takes agency id , sets 2 vari...

jQuery show href links problem -

new this, sorry if it's silly. problem follows. have been given list of anchors, html , pdf. these grouped div #anchors hidden on document ready. 2 buttons choice show either html links or pdf links , href$ selector must used. can't show. code follows: $(document).ready(function(){ alert("anchors hidden"); $('#anchors').hide(); }); $(document).ready(function(){ $('#htmllinks').click(function(event){ alert("html pressed"); $("a[href$=html]").show(); }); }); the alert shows, none of links listed. i've tried loads of things. doing wrong? i've tried $('#anchor a[href$=".html"]').show(); , various other things different combinations of quotation marks, i've tried creating new div , outputting that, i'm getting nowhere. can whole div display, not selection of it. appreciated. many thanks. you're hiding whole div here: $('#anchors').hide();...

objective c - How to call an action on double click at a custom NSCell in Cocoa? -

i have nstableview custom view cells nscell i'm trying double click action code [thetableview setdoubleaction:@selector(mydoubleclick:)]; and have method set this: - (void)mydoubleclick:(id)sender{ nslog(@"double click"); } when double click cells nothing happens , nslog not showing thing. maybe customs cell. any suggestions on this? you should on ib selecting row , setting column bindings there's option co choose selector 1 of controllers.

c - Mixing variables and integer constants in the Boost Preprocessor -

i using boost_pp precompile computations in preprocessor. focusing on application code size extremely important me. (so please don't compiler should or usually that, need control performed @ compile time , code generated). however, want able use same name of macro/function both integer constants , variables. trivial example, can have #define twice(n) boost_pp_mul(n,2) //..... // somewhere else in code int = twice(5); this want to, evaluating int = 10; during compile time. however, want used at int b = 5; int = twice(b); this should preprocessed int b = 5; int = 5 * 2; of course, can using traditional macros like #define twice(n) n * 2 but doesnt want integer constants (evaluating them during compile time). so, question is, there trick check whether argument literal or variable, , use different definitions. i.e., this: #define twice(n) boost_pp_if( _is_constant(n), \ boost_pp_mul(n,2), \ n *...

Make SVN Commit also print the diff -

when svn commit , let svn editor pick i'd love svn editor show diff of files have changed instead of list of files. helps jog memory when writing detailed commit messages. ideas on how accomplish? looks script here works after all. from - http://push.cx/2007/seeing-subversion-diffs-for-commit-messages needed make few changes. i'll paste entire script here create file, name svn in case it's put in ~/bin #!/bin/sh realsvn=/usr/bin/svn args="$@" if [ "$1" = "commit" -o "$1" = "ci" ]; shift # pop off $1 diff template=`mktemp -t tmp` $realsvn diff "$@" > "$template" $realsvn $args --editor-cmd="~/bin/svn-diff-editor '$template'" else $realsvn $args fi and create file named ~/bin/svn-diff-editor echo >> "$2" cat "$1" >> "$2" rm "$1" $svn_editor "$2" for osx had add '-t tmp...

iphone - how to create a UIView with a UINavController and a UITableView -

i have app and, when press 'i' button, show app view, need have view, background image, uinavigationcontroller , uitableview. how can achieve that, interfacebuilder, or progamatically? it's not done in appdelegate. need done on view. have following code, creates uinavcontroller , uitableview. code i'me unable put uiimage in background: uitableviewcontroller *tableviewcontroller = [[uitableviewcontroller alloc] initwithstyle: uitableviewstylegrouped]; tableviewcontroller.title = @"about"; uinavigationcontroller *navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller: tableviewcontroller]; navcontroller.modaltransitionstyle = uimodaltransitionstylefliphorizontal; [self presentmodalviewcontroller:navcontroller animated:yes]; [navcontroller release]; [tableviewcontroller release]; how can it? thanks, rl not sure if work worth @ try: tableviewcontroller.backgroundcolor = [uicolor colorwithpatternimage:[uiimage imagenamed:...

iphone - Is it okay these days to use PNG with alpha-transparency in websites? -

i remember 3 years ago absolutely huge pain use nice png alpha in websites, because of ie6 , other bad browsers. but how now? how if target audience iphone, ipad , ipod touch users? believe these people aren't stupid use old-aged bad browsers. use newest, best stuff can, , they're tech-savvy , intelligent. valid assumption? mean can safely use png alpha create great websites apps without having worry uglyness? yes it's absolutely fine use png's alpha transparency. has been, had fix ie6 filters. so go ahead , use them :)

WPF DatePicker default to today's date -

wpf datepicker show 'show calendar' default. want show current/todays date. how do that. tried doing below in constructor won't work, datepicker.selecteddate = datetime.now.date; or datepicker.displaydate = datetime.now.date; please try .... <my:datepicker selecteddate="{x:static sys:datetime.now}"/> add reference xmlns:sys="clr-namespace:system;assembly=mscorlib"

c# - LINQ to SQL use of => operand on String not allowed -

possible duplicate: string1 >= string2 not implemented in linq sql, workarround? to give brief summary of want achieve have table called application , stores application version numbers. contents of table example is applicationid versionid 1 r1.01.01.01 2 c8.00.00.01 2 c8.00.00.02 2 r8.10.00.00 2 r8.20.00.02 2 r9.00.00.01 2 r9.00.00.02 2 r9.00.00.03 3 r7.00.30.00 when doing query in tsql, there no problems , correct results (take note versionid nvarchar type) select * applications versionid >= 'r9.00.00.01' , applicationid = 2 but when start using linq sql such var applications = v in db.applications v.versionid.startswith("r") && v.versionid >= "r9.00.00.01" ...

wpf - Get result of a Binding in code -

i'm searching wrong way, but: is there way resulting value of binding through code? probably glaring obvious, can't find it. you need call providevalue method of binding. hard part need pass valid iserviceprovider method... edit: actually, that's not true... providevalue returns bindingexpression , not value of bound property. you can use following trick: class dummydo : dependencyobject { public object value { { return (object)getvalue(valueproperty); } set { setvalue(valueproperty, value); } } public static readonly dependencyproperty valueproperty = dependencyproperty.register("value", typeof(object), typeof(dummydo), new uipropertymetadata(null)); } public object evalbinding(binding b) { dummydo d = new dummydo(); bindingoperations.setbinding(d, dummydo.valueproperty, b); return d.value; } ... binding b = new binding("foo.bar.baz") { source = datacontext }; object value...

How to get value stored in a register, using gdb? "p/x $ebx" fails with "No registers." -

suppose following asm code 8048deb: e8 41 05 00 00 call 8049331 <explode_bomb> 8048df0: 03 73 f4 add -0xc(%ebx),%esi 8048df3: 83 c3 04 add $0x4,%ebx 8048df6: 8d 45 f8 lea -0x8(%ebp),%eax 8048df9: 39 c3 cmp %eax,%ebx 8048dfb: 75 e7 jne 8048de4 <phase_2+0x22> i set breakpoint @ last line, time, expecting both %eax , %ebx have stored in them. in gdb, do p/x $ebx and get: no registers. what error mean? how can current content stored in register? p/x $ebx works fine me. (or rather, p/x $rbx, because i'm testing in 64-bit os, imagine p/x $ebx work in 32-bit.) application must running. if try p/x $rbx when application has not started or has exited, "no registers". sure breakpoint hit?

jQuery UI Button - Text beneath the Custom Icon -

i trying create jquery ui button custom icon on top of text. default behavior creates icon on left/right of text want icon on top! can done? if so, help/guidance appreciated. also, how can 1 have 32x32 size custom icon (even increasing height of button didn't , stripping icon). in advance. html: <button id="btnsave">save</button> js: $('#btnsave').button({ icons: {primary: "saveicon"} }); css: .saveicon { background-image: url(../images/save.png) !important; } try bit of css ( demo ): .ui-button-icon-primary.ui-icon.saveicon { height: 32px; width: 32px; margin: 10px 0 2em -16px; text-align: center; left: 50%; top: 5px; background-image: url(../images/save.png) !important; } .ui-button-text-icon-primary .ui-button-text { display: block; position: static; padding: 50px 10px 5px 10px; }

inserting html with php on submit, but how to use jquery to fade out that html? -

i'm inserting h3 tag when form submitted. how fade h3 tag out in 5 seconds using jquery? i tried didn't work. have use .live? $(document).ready(function() { $('h3').delay(5000).fadeout(300); }); edit: i'm submitting form in case matters. i think in situation, want in form submit: //insert h3 var header = $('<h3>my header!</h3>'); //append wherever $('body').append(header); //set timeout, fade away! settimeout(function() { header.fadeout(300); }, 5000); here's demo of that: http://jsfiddle.net/wsxfw/

c# - ms ajax $find('clientID') keeps coming up with error -

i have modal extender called modal2 , when call $find('modal2').show(); it comes classic error saying 'null' null or not object; i searched google bit , made related controls visible testing purpose has not made difference. any suggestions please? thanks. check client id; unless using clientidmode of static, like: ct100_contentplaceholder_modal2 , have do: $find("<%= modal2.clientid %>") instead id. hth.

performance - Determing if two lists contain the same numeric items without sorting -

i have 2 lists , need determine if contain same values without sorting (ie. order of values irrelevant). i know sorting work, part of performance critical section. item values fall within range [-2, 63] , we're comparing equal size lists, list sizes range [1, 8]. example lists: a = (0, 0, 4, 23, 10) b = (23, 10, 0, 4, 0) c = (0, 0, 4, 27, 10) == b true == c false i think possible solution compare product of 2 lists (multiply values together), there problems solution. 0 , negative numbers. workaround adding 4 every value before multiplying. here's code have far. bool equal(int a[], int b[], int size) { int suma = 1; int sumb = 1; (int = 0; < size; i++) { suma *= a[i] + 4; sumb *= b[i] + 4; } return (suma == sumb) } but, work no matter order/contents of list were? in other words following mathematically true? i'm asking following (unless there's way solve problem): given 2 equal sized lists. if products (m...

database - Weighted average calculation in MySQL? -

i using following query numbers: select gid, count(gid), (select cou size gid = infor.gid) infor id==4325 group gid; the output getting @ current stage following: +----------+-----------------+---------------------------------------------------------------+ | gid | count(gid) | (select gid size gid=infor.gid) | +----------+-----------------+---------------------------------------------------------------+ | 19 | 1 | 19 | | 27 | 4 | 27 | | 556 | 1 | 556 | +----------+-----------------+---------------------------------------------------------------+ i trying calculate weighted average i.e. (1*19+4*27+1*556)/(19+27+556) is there way using single query? use: select sum(x.num * x.gid) / sum...

apache2 - Problem With Routes After Deploying Sinatra Application -

i wrote simple sinatra application 2 "routes": "/show" , "/listshows". when run application on top of webrick, works beautifully both static , non-static routes. here url's use: http://localhost:4567/listshows http://localhost:4567/show?guid=someguid today, deployed simple application on top of apache , passenger 2. web server on private network , named millhouse. want access application using following urls: http://millhouse/slwa/listshows http://millhouse/slwa/show?guid=someguid the probem "slwa" string isn't part of of url's. example, when try visit "http://millhouse/slwa", should automatically redirected "http://millhouse/slwa/listshows". while app redirect, ends sending me "http://millhouse/listshows". "slwa" part missing. i didn't want create new virtual host, reused "root" virtual host on ubuntu server. here's virtual host: <virtualhost ...

xna - When to load textures? -

i'm working on couple of windows phone projects (although question may fit iphone/android) , got me thinking, when best time load textures content manager. at first, loading them up, game base class, , passing them along required. getting sick of this, have created small resource manager class, pass out requires it. so i'm thinking, perhaps best load texture in, when class requires it, , assign variable, when need again - ready go... best way (efficient?, fastest?) handle loading resources? if not, how recommend go it? don't create kind of "resource manager" class. pass xna contentmanager class around (the instance game.content ). the default content manager automatically handle reusing loaded objects you. can content.load<texture2d>("something") multiple places , same texture instance. so if have bunch of classes game objects, standard design of giving each update , draw method call respective methods in game - add meth...

mysql - php mysql_connect security -

if web server , database server on different hosts, possible hacker packet sniffing or use other method database username/password when use mysql_connect in php code? yes mysql_connect() can sniffed. password "scrambled" , not stop attacker. quires thrown on wire in plain text , authenticated session can hijacked if sniffing tcp sequence id's. you must use full transport layer encryption possible using mysql_client_ssl flag if worried attack. if putting mysql connection on internet or otherwise untrusted network necessity. not necessary if connecting via localhost.

java - how to send a message from jsp/servlet/swing? -

thank t give me answer of past quetion. this question swing/jsp/servlet. want code send message smtp or other using swing / jsp / sevlet.. , how make jar file f our swing program in netbeans.. thanks mihir if need send mail message through java application, might want take @ javamail api can obtained here . however, org.life.java said, need restructure question make clearer.

sql - How to get rightmost 10 places of a string in oracle -

i trying fetch id oracle table. it's tn0001234567890345 . want sort values according right 10 positions (e.g. 4567890345 ). using oracle 11g. there function cut rightmost 10 places in oracle sql ? thanks in advance tismon you can use substr function as: select substr('tn0001234567890345',-10) dual; output: 4567890345

mysql performance for php calls -

i have multiple php functions code , each function tries setup mysql connection, send queries , closes mysql connection. design or should set 1 connection master function , pass variables each of these functions execute queries? also, possible code give errors when trying execute 2nd instance of mysql_query in func1() ? won't instance of mysql connection called in func2 independent instance called in func1? in code, seem inconsistent behaviors. @ times, getting error when refresh page, there seems no problem. suggestions welcome. thanks. def func1() { mysql_connect(params) mysql_query() func2() mysql_query() mysql_close() } def func2() { mysql_connect(params) mysql_query() mysql_close() } i can't it's awful performance hit, has no sense. database connection intended opened once. if need 5 apples box - open , close box 5 times? or open , @ once? ;-) same here. just open connection once , never close it. done automatically.

STL related seg fault in C++ std::string? -

does point when can below seg fault occur, below: - heap corruption - memory leak - flaw in stl implementation of strings 0xf0f1d672 in std::__default_alloc_template<true, 0>::allocate(unsigned int) () /usr/lib/libstdc++.so.5 to give context, stack trace below: #0 0xf0f1d672 in std::__default_alloc_template<true, 0>::allocate(unsigned int) () /usr/lib/libstdc++.so.5 #1 0xf10bdae1 in std::__simple_alloc<std::_rb_tree_node<std::pair<std::string const, calculator*> >, std::__default_alloc_template<true, 0> >::allocate(unsigned int) () /export/work/install/lib/plugin.so from stack trace appears you're creating dynamically loaded .so plugin. if plugin interface uses heap allocation, must make sure same instance of runtime library used on both sides of plugin api boundary.

Javascript image preload strategy -

like many people i've been doing image preload long time, not rationally. i've come short list of thoughts right way preload images javascript. an image preload script should executed possible. should placed @ top of html (in head section), unlike others scripts go bottom of body section. it must not rely on library (such jquery) because delay execution. css sprites , background-images need not preloaded because css - called @ top of html - job (this of course reduces overall need javascript image preload). the preload script can placed , run on every page of site sure effective no matter page user enters site. (but overhead of running script every time, if check images cached?) i'd interested hear opinions on subject. an image preload script should executed possible. should placed @ top of html (in head section), unlike others scripts go bottom of body section. this puts greater precedence on images might shown if user on images part of initial ...

multithreading - Question about Thread + iPhone -

i having confusion threads. suppose start thread in viewcontroller doing heavy processing. if pop viewcontroller while thread still in execution thread stop executing or whether continue execution. it continue run until finishes or make stop. should either kill thread @ appropriate point, or make sure thread doesn't access stale objects.

air - Allow end user to define state transitions in a Flex mxml application -

Image
adobe has great tool designers called adobe catalyst develop air based desktop apps designers can customize define state transition in screen-flow based application. there way in end-user gets application can change conditions state transition , the content of state. example, application made of 3 screen based states. each have text label , buttons. screen state label , 2 buttons. label says "do want go screen b". buttons "yes" , "no". end-user want change text "do want go screen c" , application logic assocated change screen c. doesn't use adobe catalyst , not programmer. way allow ? i'm exploring technology allow end user doctor define state-based interactive diagnosis systems simple diseases. example below:

c - Issue with NULL pointers on Harvard Architecture platform -

interesting issue came across here week. we working in c on harvard architecture embedded platform, has 16-bit data addresses , 32-bit code addresses. the issue occurs when working function pointers. if have code if (fp) fp(); or if (fp != 0) fp(); everything fine. however if have code like if (fp != null) fp(); then, because null defined (void *) 0 , compiler (gcc in case) a) not warn , b) 16-bit comparison against function pointer instead of 32-bit comparison. fine long function pointer doesn't happen lie on 64k boundary bottom 16 bits 0. at moment have large swathes of code contain explicit checks against null. of them data pointers, of them function pointers. quick grep != null or == null revealed on 3000 results, many go through manually check. so, either a way find cases function pointers (but not data pointers) compared (so can instead have them compare against fp_null define 32-bit 0), or to redefine null in such way right thing. (or, sup...

How do I just LINQ Join() to link two IQueryables? -

i have 2 iqueryables: ingredient: ingid description availableingredient: ingid i have iqueryable ingredient: var ingquery = in context.ingredients select i; how can add join filters availableingredient (i.e. inner join)? know how if had join time, i.e. from... join context.available... etc), join conditional, need use other syntax: if (filterbyavailable) { iqueryable<available> availablequery = getavailableingredientquery(context); ingquery = ingquery.join(...); // can use join query? } this may not right method, want do: getavailableingredientquery returns available ingredients query, i.e. 3000 of 6000 (but doesn't enumerate results yet it's returned iqueryable ef) join availablequery ingquery, there's inner join between 2 queries edit: this code i'm using (very fast), means duplicated code: iqueryable<ingredient> query; if (filterbyavailable) { iqueryable<available> availablequery = getavaila...

.net - WCF discovery: Interface not found exception -

i'm trying use .net 4's discovery in wcf. no matter do, i'm getting not useful exception: system.argumentexception crossed native/managed boundary message=interface not found. source=mscorlib stacktrace: @ system.runtimetypehandle.verifyinterfaceisimplemented(runtimetypehandle handle, runtimetypehandle interfacehandle) @ system.runtimetype.getinterfacemap(type ifacetype) @ microsoft.visualstudio.diagnostics.servicemodelsink.servicemethodresolver.resolvemethodinfo(type implementationtype, methodinfo contractmethod) @ microsoft.visualstudio.diagnostics.servicemodelsink.servicemethodresolver..ctor(contractdescription contract, dispatchruntime runtime, message request, instancecontext instancecontext) innerexception: (stack trace empty.) hitting "continue", program chokes few seconds, continues , displays correct results. happens in microsoft's supplied wcf examples. made sure unhandled exceptions displayed in excep...

android - Samsung Galaxy Tab AVD with Google API? -

i installed add-on provided samsung create avd emulate galaxy tab, unfortunately important project uses google api (for using maps external library) not supported single additional target add-on provides. know of way have avd tab with support google api? the above posting got mangled. here again. copy (android sdk)/add-ons/(galaxy target/skins/ . (android sdk)/add-ons/(google target) edit manifest file in directory (google target) add "skin=galaxy tab" (without quotes) manifest file. google target launch without system default , instead use skin info samsung.

msdeploy - What is up with this PowerShell command line quoting/escaping? -

i don't know i'm doing. i have got powershell command work. can't figure out why works. my concern final "" chars: &"c:\program files\iis\microsoft web deploy\msdeploy.exe" ` -verb:sync ` -source:contentpath="$build_directory\deploy" ` -dest:contentpath="$server_temp_directory,computername=$server,username=$server_username,password=$server_password" ` -verbose ` -postsync=runcommand="powershell -nologo -noprofile -command $server_temp_directory\remotetasks.ps1 deploy"" why need double double-quotes? my ide (powergui) says line not ended correctly, way can make command run wanted. what it, - , ide - don't know qouting in powershell? a little output echoargs: if run: echoargs -postsync=runcommand="powershell -nologo -noprofile -command $server_temp_directory\remotetasks.ps1 deploy"" i get: arg 0 <-postsync=runcommand=powershell -nologo -noprofil...