Posts

Showing posts from June, 2013

Merging two git repositories together with Django web server, one developer -

i started django project locally , have been using git fine. i got ahead of myself , copied code server instantly became out of sync local version. hadn't done branch or anything. the 2 part question what's best structure me work locally, push/pull test server , update live server when test solid, , how setup i'm at? i've been developing no branches in these stages, i'd instead follow standard practices branching , merging. i'm using netbeans 6.8 locally coding , i've got gitx. integration tips helpful i'm comfortable doing whatever command lines necessary. thanks! james first should able have form of communication between git repositories you've got on local machine, test server , live server. git flexible in regard few of options are: have test , live server pull local repository. from development push test , live servers on appropriate times. from development push production , have test server pull production. ha...

c# - ASP.Net intelligent scaling page based on page content -

like iphone safari browser or firefox (ctrl + scrolling), need intelligent scaling not divs font-size , images scaled based on viewable area of screen. i need implement in asp.net. suggestion? regards thant zin it's not server side thing, presentation layer thing. need @ using relative measurement sizes in css applying appropriate scaling. i.e, using percentages or ems, instead of pixels. one thing can on server side browser-sniffing. find out user agent user using, , push down page can apply appropriate stylesheet appropriate.

javascript - I need to match strings that don't contain a keyword at an arbitrary position -

i need match strings don't contain keyword ( beta2 ) @ arbitrary position. consider: var astr = [ '/beta1/foo', 'beta1/foo', '/beta1_xyz/foo', 'blahblah/beta1/foo', 'beta1', '/beta2/foo', 'beta2/foo', '/beta2_xyz/foo', 'blahblah/beta2/foo', 'beta2', '/beat2/foo', 'beat2/foo', '/beat2_xyz/foo', 'blahblah/beat2/foo', 'beat2' ]; function btestformatch (str) { return /.*\b(?!beta2).*/i.test (str); } (var j=0, ilen=astr.length; j < ilen; j++) { console.log (j, btestformatch (astr[j]), astr[j]); } we need regex matches strings exclude beta2 . beta2 start @ word boundary, not end @ one. can...

sql 2008 procedure -

create procedure csgorevduzenle @duzenle int, @grup_ad varchar(30), @islem_grubu varchar(30), @tamamlayan varchar(30), @kayit_zamani datetime, @sonuc_zamani varchar(30), @arayan varchar(30), @telefon varchar(20), @tanim varchar(1000), @durum varchar(15), @aciklama varchar(1000) if @duzenle = 1 begin update gorevler set grup_ad = @islem_grubu, tamamlayan = @tamamlayan, sonuc_zamani = @sonuc_zamani, arayan = @arayan, telefon = @telefon, tanim = @tanim, durum = @durum, aciklama = @aciklama grup_ad = @grup_ad , kayit_zamani = @kayit_zamani end end if go msg 156, level 15, state 1, procedure csgorevduzenle, line 20 incorrect syntax near keyword 'then'. msg 156, level 15, state 1, procedure csgorevduzenle, line 26 incorrect syntax near keyword 'if'. this not correct sql syntax if statement: if @duzenle = 1 change to: if ( @duzenle = 1 )

How do I hash a string with Delphi? -

how make md5 hash of string delphi? if want md5 digest , have indy components installed, can this: uses sysutils, idglobal, idhash, idhashmessagedigest; tidhashmessagedigest5.create try result := tidhash128.ashex(hashvalue('hello, world')); free; end; most popular algorithms supported in delphi cryptography package : haval md4, md5 ripemd-128, ripemd-160 sha-1, sha-256, sha-384, sha-512, tiger update dcpcrypt maintained warren postma , source can found here .

Alternatives to XCopy for copying lots of files? -

the situation: have pieceofcrapuous laptop. 1 of things make pieceofcrapuous battery dead, , power cable pulls out of little effort. i received non-pieceofcrapuous laptop, , in process of copying old new. i'm trying xcopy c:*.* old machine external hard drive, because cord pulls out frequently, xcopy interrupted often. what need switch in xcopy copy eveything except files exist in destination folder -- exact opposite of behavior of /u switch. does know of way this? /d may looking for. find works quite fast backing-up existing files not copied. xcopy "o:\*.*" n:\whatever /c /d /s /h /c continues copying if errors occur. /d:m-d-y copies files changed on or after specified date. if no date given, copies files source time newer destination time. /s copies directories , subdirectories except empty ones. /h copies hidden , system files also. more information: http://www.computerhope.com/xcopyhlp.htm

Best Way to Unit Test a Website With Multiple User Types with PHPUnit -

i'm starting learn how use phpunit test website i'm working on. problem i'm running have 5 different user types defined , need able test every class different types. have user class , pass each function can't figure out how pass or test different errors come being correct or not. edit: should have said. have user class , want pass different instance of class each unit test. if various user classes inherit parent user class, recommend use same inheritance structure test case classes. consider following sample classes: class user { public function commonfunctionality() { return 'something'; } public function modifiedfunctionality() { return 'one thing'; } } class specialuser extends user { public function specialfunctionality() { return 'nothing'; } public function modifiedfunctionality() { return 'another thing'; } } you following te...

problem in calling cgi from javascript -

i executing cgi file directly javascript onclick of button. cgi return doc, xls, exe etc file in turn opens savaas dialog let client save file on machine. problem comes when multiple cgi files executing in for/while loop, executes first cgi , opens saveas dialog, once saveas opens not enter "for" loop again execute cgi opens saveas dialog . here code fragment - for(i = 0; < datapopup.elements['checkbox'].length; i++) { j=0; obj = datapopup.elements['checkbox']; if(obj[i].checked) { var temp=obj[i].value; temp = temp.split("."); if(temp[1] == "txt") { savewins[temp[1]] = settimeout("document.location='../cgi/savetextfile.cgi?fname=070319185708701_1'", 100); } else if(temp[1] == "pdf") { savewins[temp[1]] = settimeout("document.location='../cgi/savepdffile.cgi?fname=065726729272220_1'"...

namespaces - Question about a simple PHP Autoloader -

i learning aboutt php namespaces , starting create simple autoload function. o did was: function __autoload($name) { echo $name . "<br />"; require_once $name . ".php"; } so, works if not use aliasing or importing statements eg. use mainnamespace\subnamespace because if did that, assuming have: \greatapp\models\user.php \greatapp\models\project.php \greatapp\util\util.php \greatapp\util\test\test.php if try do: new greatapp\models\user(); it works because $name in autoload become greatapp\models\user greatapp\models\user.php found. when do: use greatapp\models; new user(); it fails because $name user , user.php not found. how should setup autoloading then? full namespace path passed autoloader no matter how import namespace , reference class. should work. just __autoload function should belong main (root) namespace

validation - Silverlight MVVM Business Application : Where to place the resource files? -

the default silverlight business application (vs2010) creates resources files ( validationerrorresources.resx , registrationdataresources.resx ) in web project , creates links these in silverlight project. but in client silverlight project there resource files ( applicationstrings.resx , errorresources.resx ) i implement following design: client presentation.silverlight (only xaml) presentation.viewmodel (viewmodels presentation.domain (entities , links validation resource files) server server.infra (entity framwork) server.domain (poco entities + repositories + validation resource files) server.web (web applicatin project) my question : put resource files translations labels presentation layer ? is defined in : presentation.silverlight , presentation.viewmodel or presentation.domain ??? itb depends on label onviously! instance display name of field ....need same on application thus, needs defined on server side...i.e. in data annotations of busin...

Which problem do we face after switching from PHP 4.0 into PHP 5.3.3? -

as know yesterday php released new version of 5.3.3. question following: what kind of possible problems have if update php 4.0 date 5.3.3.? mean functions or operators on php 4.0 don't work on php 5.3.3. , kind of such problems? that's it. thank you. see official php migration doc ...

mysql - How can I prevent SQL injection in PHP? -

if user input inserted without modification sql query, application becomes vulnerable sql injection , in following example: $unsafe_variable = $_post['user_input']; mysql_query("insert `table` (`column`) values ('$unsafe_variable')"); that's because user can input value'); drop table table;-- , , query becomes: insert `table` (`column`) values('value'); drop table table;--') what can done prevent happening? use prepared statements , parameterized queries. these sql statements sent , parsed database server separately parameters. way impossible attacker inject malicious sql. you have 2 options achieve this: using pdo (for supported database driver): $stmt = $pdo->prepare('select * employees name = :name'); $stmt->execute(array('name' => $name)); foreach ($stmt $row) { // $row } using mysqli (for mysql): $stmt = $dbconnection->prepare('select * employees name = ?'); ...

mysql - What is the best way to implement a substring search in SQL? -

we have simple sql problem here. in varchar column, wanted search string anywhere in field. best way implement performance? index not going here, other tricks? we using mysql , have 3 million records. need execute many of these queries per second trying implement these best performance. the simple way far is: select * table column '%search%' i should further specify column long string "sadfasdfwerwe" , have search "asdf" in column. so not sentences , trying match word in them . full text search still here? check out presentation practical fulltext search in mysql . i compared: like predicates regular expression predicates (no better like ) myisam fulltext indexing sphinx search apache lucene inverted indexing google custom search engine today use apache solr , puts lucene service bunch of features , tools. re comment: aha, okay, no. none of fulltext search capabilities mentioned going help, since assume kind of ...

bash - How can I send the stdout of one process to multiple processes using (preferably unnamed) pipes in Unix (or Windows)? -

i'd redirect stdout of process proc1 2 processes proc2 , proc3: proc2 -> stdout / proc1 \ proc3 -> stdout i tried proc1 | (proc2 & proc3) but doesn't seem work, i.e. echo 123 | (tr 1 & tr 1 b) writes b23 to stdout instead of a23 b23 editor's note : - >(…) process substitution nonstandard shell feature of some posix-compatible shells: bash , ksh , zsh . - written, answer accidentally sends output process substitution's output through pipeline too . - echo 123 | tee >(tr 1 a) >(tr 1 b) >/dev/null prevent that, has pitfalls: output process subsitutions unpredictably interleaved, and, except in zsh , pipeline may terminate before commands inside >(…) do. in unix (or on mac), use tee command : $ echo 123 | tee >(tr 1 a) | tr 1 b b23 a23 usually use tee redirect output multiple files, using >(...) can redirect process. so, in general, $ proc1 | tee ...

ANTLR3 C Target with C++ Exceptions -

i have experience antlr 2's c++ target, have been hesitant spend time on antlr 3 because of fears exception safety. sadly, antlr 3 has c target produces c "c++ compatible." not seem include c++ exception safety, based on following: you can use [exceptions] carefully, point out, have careful memory. runtime tracks normal memory allocations long close 'classes' correctly should ok. however, should make sure throwing exceptions not bypass normal rule clean up, such resetting error , backtracking flags , on. ( antlr-interest, circa 2009 ) does have experience using antlr c target (advanced) c++? possible safely throw exceptions? code (if any) have write make safe? i don't have antlr experience (sadly...), there no way make c code work exceptions around. refer more effective c++, item 9 : "use destructors prevent resource leaks" the idea if exception thrown during cleanup, have no information on del...

uitableview - How to subClass UITableViewCell and use it to not clear UILabel background color on UITabeViewCell selected? -

in app, use label display specified color set background color in customized uitableviewcell (because color maybe changed according incoming data internet), after viewdidload, ok, when cell selected (highlighted) color cleared. after searching, found out have subclass uitableviewcell , overwrite sethighlight method not clear label background color. have tried unlucky. so know how this? right way subclass uitableviewcell , use in uitableviewcontroller not clear label background color? please me. thanks advice. from latest uitableviewcell documentation: note: if want change background color of cell (by setting background color of cell via backgroundcolor property declared uiview) must in tableview:willdisplaycell:forrowatindexpath: method of delegate , not in tableview:cellforrowatindexpath: of data source. changes background colors of cells in group-style table view has effect in ios 3.0 different previous versions of operating system. affects area inside ro...

svn - How do I move tags in Subversion -

i wish subversion had better way of moving tags. way know move tag remove file tag , copy again. revision tree browsers don't seem handle well. requires keeping directory structure under trunk , tag in sync. use case: have thousands of "maps" , want tag version of each map "production" version. need able production version of maps. can suggest better way address our use case? have considered properties can't prod version of files easily. merging tag doesn't appear easy either. (originally posted http://jamesjava.blogspot.com/2007/12/subversion-moving-tags.html ) i don't think can ever way subversion operates. believe best solution @ tool git seems fits use case. you're production system 'pull' in "maps" accepted. while realize isn't subversion, using git might closer match use pattern svn. a write on why git's pull based development model better match scenario here . there tutorials on how start ...

asp.net - Debugging Sitecore 6 with Visual Studio 2008 -

i'm trying debug sitecore 6 asp.net code using visual studio 2008 (windows server 2003 os). trying breakpoints work. tried setting breakpoint , on vs, debug -> attach process.. -> iis web server process , nothing happens when browse .aspx page breakpoint located @ beginning of sitecore.web.ui.webcontrol.dorender method. i tried checking both client-side , server-side debugging settings on website's properties -> configuration -> debugging nothing changes. tried stopping website, recycling apppool , restarting, re-attaching debugger , nothing happens. does have better idea? make sure trying attach correct process. called w3wp.exe in iis 6+.

.net - How to compare list of X to list of Y in C# by using generics? -

i have 2 classes, x , y. both classes have same similar property below. class x { public string t1 { get; set; } public string t2 { get; set; } public string t3 { get; set; } } class y { public string t1 { get; set; } public string t2 { get; set; } public string t3 { get; set; } public string o1 { get; set; } } i've couple hundreds classes similar x , y; similar structure, , decide create generic class problem. i have list of x , y , want compare them t1; 1 property, find out element exist on both list, element exist on x , on y. how can this? the best thing first create interface contains t1 only. inherit each class x , y interface. can create generic classes or helper classes based on interface. alternatively, may use reflection, or if use c# 4.0, can use dynamic . classic reflection way slow (large) lists, unless cache method calls, shouldn't take approach. c# 4.0 however, provided method caching through dlr, sufficient...

C# SQL Restore database to default data location -

i'm writing c# application downloads compressed database backup via ftp. application needs extract backup , restore default database location. i not know version of sql server installed on machine application runs. therefore, need find default location based on instance name (which in config file). the examples found had registry key read, not work, since assumes 1 instance of sql installed. another example found created database, read database's file properties, deleting database once done. that's cumbersome. i did find in .net framework should work, ie: microsoft.sqlserver.management.smo.server(servername).settings.defaultfile the problem returning empty strings, not help. i need find out nt account under sql service running, can grant read access user on backup file once have extracted. what discovered microsoft.sqlserver.management.smo.server(servername).settings.defaultfile only returns non-null when there no path explicitly defined. s...

cocoa touch - New Images Can't Be Found in iPhone SDK -

i've been trying update image packaged app, app refuses load new file. i had png called "board.png". created new file higher resolution copy of original. deleted "board.png" resources group in xcode , added new image under same name. when run app, old, smaller image still used. then, cleaned build , tried again. still doesn't work. next, renamed new image "bigboard.png" , tried loading filename thusly: uiimageview* board = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"bigboard.png"]]; but image not load @ though in resources folder. else have experience this? appreciated. thanks! i had same problem twice now. first time had forgotten check 'copy items destination group's folder' option when added new image image want in folder when went build. second time needed clean targets (build -> clean targets) before built again. gets rid of precompiled stuff , forces xcode recompile project. when...

google app engine - GAE + Python vs Webfaction + Python + django - for a relative new dev -

basically have webfaction space (assume purposes of question free). i trying learn python created simple web applications on google app engine using eclipse + pydev development. so far have basic functionality working in app engine, though have had frustration library imports not working , whatnot (this may not app engine specific). so, worth switch webfaction, , leave gae? i trying learn python created simple web applications on google app engine using eclipse + pydev development. this seems reasonable. nothing wrong using gae, eclipse, , pydev learn python web dev. so far have basic functionality working in app engine, though have had frustration library imports not working , whatnot (this may not app engine specific). so, worth switch webfaction, , leave gae? you haven't provided of reason leave gae you've started there. think "some frustration" normal learning on platform. beyond think descend general gae ...

How to replace a character by a newline in Vim? -

i'm trying replace each , in current file new line: :%s/,/\n/g but inserts looks ^@ instead of actual newline. file not in dos mode or anything. what should do? edit: if curious, me, check question why \r newline vim? well. use \r instead of \n . substituting \n inserts null character text. newline, use \r . when searching newline, you’d still use \n , however. asymmetry due fact \n , \r do different things : \n matches end of line (newline), whereas \r matches carriage return. on other hand, in substitutions \n inserts null character whereas \r inserts newline (more precisely, it’s treated input <cr> ). here’s small, non-interactive example illustrate this, using vim command line feature (in other words, can copy , paste following terminal run it). xxd shows hexdump of resulting file. echo bar > test (echo 'before:'; xxd test) > output.txt vim test '+s/b/\n/' '+s/a/\r/' +wq (echo 'after:'; xxd te...

javascript - Why won't my script update my div dynamically like it's supposed to? -

<html> <head> <style type="text/css"> body { background-color: #000000; font-family: arial, helvetica, sans-serif; font-size: 20px; text-align: center; color: #ffffff; } </style> <script type="text/javascript" src="jquery-1.4.js"></script> <script type="text/javascript"> function sleep(ms) { var dt = new date(); dt.settime(dt.gettime() + ms); while (new date().gettime() < dt.gettime()); } function update() { while (0 < 1) {<?php $contents = file_get_contents("my url here"); ?> var count = <?php echo $contents ?>; document.getelementbyid('div').innerhtml = count; sleep(1500); } } </script> </head> <body onload=update()> <iframe id="iframe" src="my url" style="visibility: hidden;"/> <table width=100% height=100%> ...

Why JavaScript rather than a standard browser virtual machine? -

would not make sense support set of languages (java, python, ruby, etc.) way of standardized virtual machine hosted in browser rather requiring use of specialized language -- really, specialized paradigm -- client scripting only? to clarify suggestion, web page contain byte code instead of higher-level language javascript. i understand pragmatic reality javascript have work due evolutionary reasons, i'm thinking more long term. regard backward compatibility, there's no reason inline javascript not simultaneously supported period of time , of course javascript 1 of languages supported browser virtual machine. well, yes. if had time machine, going , ensuring lot of javascript features designed differently major pastime (that, , ensuring people designed ie's css engine never went it). it's not going happen, , we're stuck now. i suspect, in time, become "machine language" web, other better designed languages , apis compile down (and cater d...

foreach - What are the Advantages of Enhanced for loop and Iterator in Java? -

can please specify me advantages of enhanced loop , iterators in java +5 ? the strengths , weaknesses pretty summarized in stephen colebourne (joda-time, jsr-310, etc) enhanced each loop iteration control proposal extend in java 7: feature summary: extends java 5 for-each loop allow access loop index, whether first or last iteration, , remove current item. major advantage the for-each loop new popular feature java 5. it works because increases abstraction level - instead of having express low-level details of how loop around list or array (with index or iterator), developer states want loop , language takes care of rest. however, benefit lost developer needs access index or remove item . the original java 5 each work took relatively conservative stance on number of issues aiming tackle 80% case. however, loops such common form in coding remaining 20% not tackled represents significant body of ...

iphone - How to add a label to a plot -

i have core-plot graph this: graph http://img413.imageshack.us/img413/8347/img0157h.jpg how can add label each of these plots. have seen references adding cptextlayer graph, not figure out how it. there example can point me to? i able add 3 labels top of graph this: cptextstyle *textstyle1 = [cptextstyle textstyle]; textstyle1.color = [cpcolor bluecolor]; textstyle1.fontsize = 14; cptextstyle *textstyle2 = [cptextstyle textstyle]; textstyle2.color = [cpcolor greencolor]; textstyle2.fontsize = 14; cptextstyle *textstyle3 = [cptextstyle textstyle]; textstyle3.color = [cpcolor redcolor]; textstyle3.fontsize = 14; cptextlayer *layer1 = [[[cptextlayer alloc] initwithtext:[nsstring stringwithformat:@"text1"]] autorelease]; cptextlayer *layer2 = [[[cptextlayer alloc] initwithtext:[nsstring stringwithformat:@"text2"]] autorelease]; cptextlayer *layer3 = [[[cptextlayer alloc] initwithtext:[nsstring stringwithformat:@"text3"]] auto...

php - I NetBeans, can I somehow store the RSA key fingerprint of the remote server or not have NetBeans confirm the key before taking action? -

i'm using netbeans 6.9 php plugin , php application remote server project. however, every time upload or download it, i'm prompted warning reads: the authenticity of host x can't established. rsa key fingerprint y. sure want continue connecting? i'm connecting own server, yes, trust it. getting popup annoying , able have way of either checking key against stored key , telling me if key changes or connecting server tell to, regardless of rsa key fingerprint. you can create empty file , set known hosts file in manage remote connections window. next time tell netbeans connect anyway, save fingerprint in file , stop bothering you. think it's safe assume if key changes, prompted again.

User validation pattern in PHP with Smarty -

i using php , smarty. have simple application that: shows page header checks if user logged in -> check session checks if user wants log out -> clear session if logged in shows menu. if not logged in, challenges user id/password -> set session shows page footer now want add following header: username if logged in "login" string if not logged in to seems require placement of printheader function become complicated. cannot print header, until know if user logged in/just logged in/has logged out, plus header has go before user/password challenge. what approach can use here? possible buffer "not logged in" header, replace "logged if header" if required. smartyapp::printheader(); application->isloggedin() application->doesuserwantstologout() application->ifnotloggedinthenshowchallengetouser() application->ifloggedinthenshowfullmenu() smartyapp::printfooter(); i think more convenient pattern incorporate c...

c# - How do I enumerate an enum? -

how can enumerate enum in c#? e.g. following code not compile: public enum suit { spades, hearts, clubs, diamonds } public void enumerateallsuitsdemomethod() { foreach (suit suit in suit) { dosomething(suit); } } and gives following compile-time error: 'suit' 'type' used 'variable' it fails on suit keyword, second one. foreach (suit suit in enum.getvalues(typeof(suit))) { // ... }

c# - How to create an efficient loop for performing actions every X minutes in windows services? -

i'm writing windows service should perform action every, lets say, 60 seconds. how best way implement main loop? implementations i've seen far: 1) using timer object executes delegate every xx seconds 2) using manualresetevents (the implementation i've seen executes once, far understood, possible create loop such resetevents) the windows service run time, best create service has no memory leak. what best way implement main loop? edit after comments: action performed every x seconds start several (lets max 10) threads. each thread not run longer 30 seconds if use system.timers.timer make sure set autoreset false , start , end of process. here's full example needed: windows service executes jobs job queue in db; wanted: example code

Flash - time from press -

i working on little project, what's goal working widget system in flash - creating separate class, , loading flash movies this, dragging them around screen. i ran little problem when writing dragging code: can not found code can time function call. more precise, want container draggable after 2 seconds of continuous press, , that's trying detect. is there easy solution? timer presstimer = new timer(2000); presstimer.addeventlistener(timerevent.timer, ontimer); container.addeventlistener(mouseevent.mouse_down, onmousedown); container.addeventlistener(mouseevent.mouse_up,onmouseup); function onmousedown(e:mouseevent):void { presstimer.start(); } function onmouseup(e:mouseevent):void { presstimer.reset(); } function ontimer(e:timerevent):void { presstimer.reset(); //do dragging , stuff. }

JavaScript Chart Library -

would recommend particular javascript charting library - 1 doesn't use flash @ all? there growing number of open source , commercial solutions pure javascript charting not require flash. in response present open source options. there 2 main classes of javascript solutions graphics not require flash: canvas-based, rendered in ie using explorercanvas in turns relies on vml svg on standard-based browsers, rendered vml in ie there pros , cons of both approaches charting library recommend later because integrated dom, allowing manipulate charts elements dom, , importantly setting dom events. contrast canvas charting libraries must reinvent dom wheel manage events. unless intend build static graphs no event handling, svg/vml solutions should better. for svg/vml solutions there many options, including: dojox charting , if use dojo toolkit already raphael -based solutions raphael active, maintained, , mature, open-source graphic library cross-browser suppor...

ColdFusion REGEX - to determine the file's extension -

i'm looking regex obtain files extension. given examples like: modocument.doc modocument.docx dasddsa.pdf kdsksdklsadklasdklads.png ads123.jpg i need regex provides 3-4 char extension, isn't fooled things like: asdadsasdads.jpg.png and gets png seen above. i think listlast better job you: <cfset fileext=listlast(yourfilename,".")>

c++ - Should one prefer STL algorithms over hand-rolled loops? -

i seem seeing more 'for' loops on iterators in questions & answers here for_each(), transform(), , like. scott meyers suggests stl algorithms preferred , or @ least did in 2001. of course, using them means moving loop body function or function object. may feel unacceptable complication, while others may feel better breaks down problem. so... should stl algorithms preferred on hand-rolled loops? it depends on: whether high-performance required the readability of loop whether algorithm complex if loop isn't bottleneck, , algorithm simple (like for_each), current c++ standard, i'd prefer hand-rolled loop readability. (locality of logic key.) however, c++0x/c++11 supported major compilers, i'd use stl algorithms because allow lambda expressions — , locality of logic.

sql - How To Move an Updated Record into a History Table? -

i have following table: create table fe_user ( userid int identity (321,4) constraint userid_pk primary key, username varchar(40) ); its corresponding history table is create table fe_user_hist ( userid int, username varchar(40), v_action varchar(50) ); every time insert or update occurred on fe_user table, need input newly inserted record or updated record history table. how can write trigger in t-sql? here pseducode, alot of errors: create or replace trigger user_to_hist after update or delete on fe_user each row declare v_action varchar(50); begin v_action := case when updating 'update' else 'delete' end; insert fe_user_his(userid, username, v_action) select :old.userid, :old.username, v_action .......; end; sql server not support create or replace unfortunately. need use either create or alter dependant upon action doing. also not have row level triggers. ...

Python: Unpacking an inner nested tuple/list while still getting its index number -

i familiar using enumerate() : >>> seq_flat = ('a', 'b', 'c') >>> num, entry in enumerate(seq_flat): print num, entry 0 1 b 2 c i want able same nested list: >>> seq_nested = (('a', 'apple'), ('b', 'boat'), ('c', 'cat')) i can unpack with: >>> letter, word in seq_nested: print letter, word apple b boat c cat how should unpack following? 0 apple 1 b boat 2 c cat the way know use counter/incrementor, un-pythonic far know. there more elegant way it? for i, (letter, word) in enumerate(seq_nested): print i, letter, word

java - How to merge jsp pre-compiled web.xml fragment with main web.xml using Ant -

we have usual web.xml our web application includes jsp , jsp tag files. want switch using pre-compiled jsp's. have pre-compilation happening in build ok, , generates web.xml fragment , want merge fragment main web.xml. is there include type directive web.xml let me include fragment. ideally leave things dev- useful change jsp's on fly , see changes uat/prod, jsp's pre-compiled , work faster. i use tomcat jasper ant tasks in project, precompile jsps servlets , add new servlet mappings original web.xml. in dev builds, skip step , deploy jsps without pre-compile , modification of web.xml. <?xml version="1.0"?> <project name="jspc" basedir="." default="all"> <import file="${build.appserver.home}/bin/catalina-tasks.xml"/> <target name="all" depends="jspc,compile"></target> <target name="jspc"> <jasper validatexml="fa...

jquery - Custom "Add Data" - how to post data to PHP server? -

i have following php script: $opermode = $_post['oper']; switch($opermode) { /* [...] */ case 'manadd': // data $firma = $_post['name']; $adresse = $_post['address']; $plz = $_post['plz']; $ort = $_post['ort']; $telnr = $_post['telnr']; /* [...] */ // save data sql database adapted strings $insert ="insert adresse (nachname, vorname, strasse, hausnummer, postleitzahl, ort, telefonnummer) values('$nachname', '$vorname', '$strasse', '$hausnummer', '$plz', '$ort', '$telnr')"; if(mysql_query($insert)) { echo "eintrag erfolgreich."; // successful } else { die("eintrag nicht erfolgreich!<br>telefonnummer existiert bereits!"); // not successful } ...

web applications - What is the recommended strategy of complete refactoring of a live product? -

consider have "system_a" web application. , system_a has 3 layers: ui, businesslayer , data-layer. and want make widespread refactoring of system_a (the ui , businesslayer only) while working live product. what should safest strategy of refactoring system_a , release refactored product after testing -let's call "rf_systema"- in way can reversed system_a in case of unexpected bug (without forcing users change urls)? i haven't web-development, idea: you write/generate redirect-layer first so: let's had 3 functions in system_a this: system_a.call1(...) system_a.call2(...) system_a.call3(...) then rename calls this... system_a.call1(...) -> old_system_a.call1(...) system_a.call1(...) -> old_system_a.call2(...) system_a.call1(...) -> old_system_a.call3(...) ...and create temporary redirect system this: system_a:call1(...) { old_system_a.call1(...); } system_a:call2(...) { old_system_a.call2(...); } system_a:call3(...) {...

.net - Rich Text in Windows Forms application -

i update windows forms application provide following features: spell checking limited formatting of text: bold, italics, bulleted lists ideally formatted text accessed in plain text way reporting through tools don't support formatting, rendered html tools support html tags when rendering text. it seems me wpf richtextbox provide functionality. best way incorporate it? suggest other alternatives? you can add / create drop-in spell checker window forms richtextbox. a ready go richtextbox custom control spell checking. app checking spelling integrated also here article on adding wpf richtextbox application, getting spell checking working. (requires .net 3.0+)

Google Checkout - XML API associate callback serial number with original order -

via xml api, how associate google checkout callback serial number original order? on same line - serial number in "option b - submit server-to-server checkout api request" section of xml api doc correspond (format: serial-number="981283ea-c324-44bb-a10c-fc3b2eba5707" )? relate serial sent callback url ( numeric-only )? the way i've done in past using <merchanrt-private-data> tag in original cart, like: <checkout-shopping-cart xmlns='http://checkout.google.com/schema/2'> <shopping-cart> <merchant-private-data> <merchant-note>[some secret cart on system]</merchant-note> </merchant-private-data> <items> ... </items> </shopping-cart> </checkout-shopping-cart> then, after google has called serial number, use notification history api retrieve order details, includes private data, like: <new-order-notification xmlns="http://checkout.google.com/schem...

android - How to display a "Loading..." text while retrieving items for a ListView -

there others applications doing this, twitter, facebook, or native applications such android market. when want display list of items retrieved internet, looks standard way displaying user notification action in progress. white background screen animated spinning wheel , "loading..." text. does know how this? i've been able similar code, don't yet. still work in progress: <listview android:id="@+id/post_list" android:layout_width="fill_parent" android:layout_height="wrap_content"/> <textview android:id="@android:id/loading" android:background="@color/white" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:text="loading..." /> when user scrolls bottom adapter's getview should return view "loading.." text , spinning progress. @ same time...

python - Styling multi-line conditions in 'if' statements? -

sometimes break long conditions in if s onto several lines. obvious way is: if (cond1 == 'val1' , cond2 == 'val2' , cond3 == 'val3' , cond4 == 'val4'): do_something isn't very appealing visually, because action blends conditions. however, natural way using correct python indentation of 4 spaces. for moment i'm using: if ( cond1 == 'val1' , cond2 == 'val2' , cond3 == 'val3' , cond4 == 'val4'): do_something but isn't pretty. :-) can recommend alternative way? you don't need use 4 spaces on second conditional line. maybe use: if (cond1 == 'val1' , cond2 == 'val2' , cond3 == 'val3' , cond4 == 'val4'): do_something also, don't forget whitespace more flexible might think: if ( cond1 == 'val1' , cond2 == 'val2' , cond3 == 'val3' , cond4 == 'val4' ):...

How to get google search results in my application? -

i have textbox , button in page. on giving in textbox , pressing button should go google server , collect search result. how that? i can use google ajax search api can't these things without using api? you can establish tcp connection on port 80, , manually create request google search. need parse resulting html extract search results. have @ rfc 2616 more information. -- dev, don't know programming language using, it's hard me give example, concept demonstrated using telnet client. can use telnet connect google on port 80. telnet www.google.com 80 from here, can type requests. if quick google search in browser , check url, see along lines of http://www.google.com/search?q=stack+overflow this gives general form of search request, , template, can construct search query replacing "stack+overflow" our desired query. in telnet client, can type request, after connecting, typing get http://www.google.com/search?q=stack+overflow http/1.0 ...

java - Windows Mobile Native Code - jstring to LPCTSTR -

i have java app needs interact camera on windows mobile device. have written java code , native code , works fine. problem having want start passing variables java native code, e.g. directory , file name use photo. the native code uses shcameracapture object interact camera , expects directory , filename specified using lpctstr s. string passed in jstring, can const char * calling: const char *strdir=(jenv)->getstringutfchars(dirname, 0); but not sure how can pass the shcameracapture object because cannot convert const char * lpctstr . tried cast (lpctstr)strdir , compiled, error when runs (that can't create file). i java developer , pretty new c++ etc. not sure need string native call. ideas? i think should try getstringchars() instead of getstringutfchars() according this page returns unicode string. windowsce , windows mobile use unicode exclusively lpctstr lpcwstr (long pointer const widechar string) shcameracapture shcc; zeromemory(&s...

vhdl - Configurable processor implemented on FPGA board -

for university mid-term project have design configurable processor, write code in vhdl , synthesize on spartan 3e fpga board digilent. i'm beginner point me information configurable processors, ideas related concept? you can check out answer related question . did same, building cpu in vhdl fpga board.

javascript - Checking length of dictionary object -

i'm trying check length here. tried count. there i'm missing? var dnames = {}; dnames = getallnames(); (var = 0, l = dname.length; < l; i++) { alert("name: " + dname[i].name); } dnames holds name/value pairs. know dnames has values in object it's still skipping on , when alert out dname.length that's not how this...so not sure. looked on web. not find on this. what use object.keys() return list of keys , length of that object.keys(dictionary).length

wpf - How do I bind to different property on ComboBox SelectedItem? -

i have combobox in wpf this: <combobox text="select language..." iseditable="true" isreadonly="true" itemssource="{binding xpath=item/@name, source={staticresource items}}" selecteditem="{binding path=test, mode=onewaytosource}"/> where items is: <xmldataprovider x:key="items" source="/itemlist.xml" xpath="/itemlist"/> test property of type object on viewmodel set datacontext of window. everything works fine, , test property receives xmlnode object, makes sense. however, receive different attribute xml example xpath=item/@value how do that? use displaymemberpath , selectedvaluepath : <combobox text="select language..." iseditable="true" isreadonly="true" itemssource="{binding xpath=item, source={staticresource items}}" displaymemberpath="@name" selectedvaluepath="@id" selected...

Vim Macro on Every Line of Visual Selection -

i'd run macro on every line in selection, rather totalling number of lines in head. instance, might write macro transform: last, first into first last and i'd run on these lines: stewart, john pumpkin, freddy mai, stefan ... any ideas vim gurus? edit: example, trivialy regexable, there other instances come aren't quite easy i'd prefer use macros. suppose had macro q ran (and remained) on single line. run on every line in selection with: :'<,'>normal @q (if have group of lines selected, hitting : produces :'<,'> on command line) for example, following macro capitalizes every word first on line: :let @q="^dwgu$p" so running on following (where + lines selected) 0000: long long time ago 0001: in galaxy far away +0002: naboo under attack +0003: , thought me , qui-gon jinn +0004: talk federation in 0005: maybe cutting them little slack. with above normal @q command, produces: 0000: lo...

c++ - Retrieving data type information for columns in an Oracle OCCI ResultSet -

after sending simple query via occi (example: select * all_users) i'm in need know datatype column, moment i've been playing resultset::getcolumnlistmetadata() method without success. questions: 1. how can datatype using aforementioned method , metadata class? 2. there better documentation out there 1 provided oracle? i've got old code laying around, guess want. using oci, not occi, maybe helps. /* number of columns in query */ ub4 colcount = 0; oracheckerr( m_err, ociattrget((dvoid *)_stmt, oci_htype_stmt, (dvoid *)&colcount, 0, oci_attr_param_count, m_err)); ub2 oratype = 0; ociparam *col = 0; ub4 namelen, colwidth, charsemantics; text *name; (ub4 = 1; <= colcount; i++) { /* parameter column */ oracheckerr( m_err, ociparamget((dvoid *)_stmt, oci_htype_stmt, m_err, (dvoid**)&col, i)); /* data-type of column */ oratype = 0; oracheckerr( m_err, ociattrget((dvoid *)col, oci_dtype_param, ...

.net - Launching an application (.EXE) from C#? -

how can launch application using c#? requirements: must work on windows xp , windows vista . i have seen sample dinnernow.net sampler works in windows vista. use system.diagnostics.process.start() method. check out this article on how use it.

c++ - Why is vector<Data*>::iterator valid and vector<Data*>*::iterator not? -

i have these 3 related class members: vector<frame*>* poolframes; vector<frame*>*::iterator frameiterator; vector<vector<frame*>::iterator>* poolframeiterators; when compile, gcc tells me error: invalid use of ‘::’ error: expected ‘;’ before ‘frameiterator’ in reference middle line, define frameiterators. goes away when loose pointer vector , make vector::iterator. however, want them pointers. there special way define data type want, or need use vector::iterator , dereference? i see trying do. you've defined poolframes pointer vector. want define frameiterator iterator poolframes . since poolframes pointer, think need special pointer-to-vector iterator, you're mistaken. a vector iterator vector iterator vector iterator, no matter how managed refer vector in first place. need frameiterator simple iterator: vector<data*>::iterator frameiterator; to assign value variable, you'll need dereference vector pointer,...

java - Message Driven Bean with a Datasource -

my question how configure ejb 3.0 style message driven bean use configured jms datasource in jboss. for example, mdb looks like: @messagedriven(mappedname = "examplemdb", activationconfig = { @activationconfigproperty(propertyname = "destinationtype", propertyvalue = "javax.jms.topic"), @activationconfigproperty(propertyname = "destination", propertyvalue = "mytopic"), @activationconfigproperty(propertyname = "channel", propertyvalue = "mychannel"), }) @resourceadapter(value = "wmq.jmsra.rar") @transactionattribute(transactionattributetype.not_supported) @transactionmanagement(transactionmanagementtype.bean) public class mymdb implements messagelistener { ..... } but bean attached given jms datasource ( in case of jboss 4.2.2 in deploy/jms/jms-ds.xml). perhaps not possible worth asking. if understood problem correctly, mymdb listens topic on weblogic, , want us...

iphone - My subclass as a property won't accept new values for its properties -

i have uiviewcontroller presents uiviewcontroller picker , returns 4 values. have custom class called chemical can hold these values. in delegate method receives values (the didselectsource 1 in adjustviewcontroller ) put breakpoint , can see proper values come back, when try assign them local chemical called selectedchemical , values don't stick , exc_bad_access . when hover on selectedchemical.chemname says, "out of scope". i don't it. #import <foundation/foundation.h> @interface chemical : nsobject { nsstring *chemname; nsstring *chemconcentration; float chemconstant; bool chemisliquid; } @property (nonatomic, retain) nsstring *chemname; @property (nonatomic, retain) nsstring *chemconcentration; @property float chemconstant; @property bool chemisliquid; - (id)initwithchemical:(nsstring *)chemical andconcentration:(nsstring *)concentration andconstant:(float)constant andisliquid:(bool)i...