Posts

Showing posts from March, 2010

actionscript - Can the Flash CS4 [embed] tag be made to export assets to frame 2 rather than frame 1? -

we're working on flash cs4 project main .fla file has ballooned in size , 'publish' taking forever. suspect large amount of size (and @ least of compile time) due quantity of audio symbols in library. i love remove unnecessary bloat .fla file. i've experimented removing audio symbol library , using [embed] metadata tag instead, so: [embed(source="audio/music/endoflevelditty.mp3")] public var endoflevelditty:class the resulting published file works perfectly, there problem. our game uses preloader on first frame of timeline, other classes need exported in frame 2 (as set in publish settings > actionscript 3.0 settings ). size report begins this: frame # frame bytes total bytes scene ------- ----------- ----------- ---------------- 1 284515 284515 scene 1 2 5485305 5769820 (as 3.0 classes export frame) however, if use [embed] tag on small sound, size report now: frame # ...

java - function of getHibernateTemplate().flush() -

i new hibernate. please tell me use of gethibernatetemplate().flush() , how works. when using hibernate, entities loaded persistence context called session , changes creating, updating, deleting persistent objects made in memory. when want or need synchronize in memory state database make changes persistent, need flush session , causing hibernate generate appropriate sql insert, update, delete statements.

php - How can i add view in the content template module in drupal? -

hi m working on content template module in drupal,but there problem in showing view of ranking field below coding <td width="10%" align="left"><font color="#669900"><b>address:</b></font></td> <td colspan="3"><?php print $node->field_perm_add_line1[0]['view'] ?>,<?php print $node->field_perm_add_line2[0]['view'] ?></td> <td align="left"><font color="#669900"><b>website:</b></font></td> <td align="left"><?php print $node->field_website[0]['view'] ?></td> <td width="8%" align="left"><font color="#669900"><b>phone:</b></font></td> <td width="42%" align="left"><?php print $node->field_phone1[0]['view'] ?><?php echo ","; print $node->field_phone2[0...

internationalization - Multilanguage document in Latex -

how prepare latex document translation... need 1 multilanguage document. should like: \section{pl:costam; en:something} then i'd render in polish or english... if else fails, can go more basic, insultingly dumb approach: \newcommand{\dumblang}[2]{{#1}} this defines command 2 arguments ( [2] ) , spits out first ( {#1} ). so example can have... \usepackage[\dumblang{english}{italian}]{babel} %snip \section{\dumblang{introduction}{introduzione}} \dumblang{your introduction goes here!}{scrivi qua la tua introduzione!} ...and when want document in italian, can change \dumblang to: \newcommand{\dumblang}[2]{{#2}}

html - Facebook social plugins not always showing up -

im added few weeks ago button , comments website , reason - not showing up. http://www.raal.co.il/content/view/58/%d7%a1%d7%99%d7%a4%d7%95%d7%a8%d7%95-%d7%a9%d7%9c-%d7%9c%d7%95%d7%97%d7%9d-%d7%91%d7%99%d7%97%d7%99%d7%93%d7%aa-%d7%93%d7%95%d7%91%d7%93%d7%91%d7%9f heres example, on bottom part of page there should comment box, appears.. on top part on right side (near share button) theres recommend button.. also.. appears. thanks! (im using chrome) make sure add xmlns:fb="http://www.facebook.com/2008/fbml" <html> declaration, consider explicitly invoking fb.xfbml.parse() in init callback.

python - How can I make this Python2.6 function work with Unicode? -

i've got function, modified material in chapter 1 of online nltk book. it's been useful me but, despite reading chapter on unicode, feel lost before. def openbookreturnvocab(book): fileopen = open(book) rawness = fileopen.read() tokens = nltk.wordpunct_tokenize(rawness) nltktext = nltk.text(tokens) nltkwords = [w.lower() w in nltktext] nltkvocab = sorted(set(nltkwords)) return nltkvocab when tried other day on sprach zarathustra, clobbered words umlat on o's , u's. i'm sure of know why happened. i'm sure it's quite easy fix. know has calling function re-encodes tokens unicode strings. if so, seems me might not happen inside function definition @ all, here, prepare write file: def jotindex(jotted, filename, readmethod): filemydata = open(filename, readmethod) jottedf = '\n'.join(jotted) filemydata.write(jottedf) filemydata.close() return 0 i heard had encode string unicode after reading file....

java - saving running instance in netbeans -

i've created application in netbeans ide 6.9. want save running application. select various things in applications. want if run application again things should selected. want save running instance of application. can me this? -thanks in advance the java language , runtime system not directly support kind of thing. if want application save state can resume doing later, have code state-saving mechanism yourself; e.g. writing key data structures file or keeping persistent state in database of kind. incidentally, few programming languages directly support application checkpointing , resumption. dialects of lisp do, did "persistent programming languages" ps-algol , napier-88. exception rather rule.

operators - What does (myVar && foo()) mean in JavaScript? -

(myvar && foo()) what above code mean? equivalent to? i think runs on single line. the expression evaluates myvar if myvar falsey, , foo() if myvar truthy. following snippets identical. var x = (myvar && foo()); if(myvar){ var x = foo(); } else { var x = myvar; }

actionscript 3 - Flash optimisation confusion -

i'm new actionscript (v3), 20 years c++ though, , i'm trying head around of performance caveats i'm reading. i checked out site: http://www.nbilyk.com/optimizing-actionscript-3 and scared death of 'code' section saying actionscript has dynamic lookup when trying find static methods in package. point being inefficient put util-type functions (typically math functions) in own package static functions, because has lookup namespace , method dynamically each time call it. is true? it's not expected, coming c++, , changes how structure code , libraries. wonder if it's better have singleton util library new()'d once, containing methods normal public methods, have them static in package. are there other obvious gotchas this? cheers, shane yes true. calling static functions outside class slow. tested myself, on 10,000 iterations 220ms static vs 160ms calling function on instance. other tips avoid adobe compiler. have started using h...

Actionscript 3: Check an array for a match -

if have array 6 numbers, say: public var check:array = new array[10,12,5,11,9,4]; or public var check:array = new array[10,10,5,11,9,4]; how check match (of pair?) array class has indexof method : function indexof(searchelement:*, fromindex:int = 0):int searches item in array using strict equality (===) , returns index position of item. parameters searchelement:* — item find in array. fromindex:int (default = 0) — location in array start searching item. returns int — zero-based index position of item in array. if searchelement argument not found, return value -1.

MySQL datetime into PHP -

i have found proper solution "problem" after reading mysql pages, don't understand logic behind it. i store registration information in system in "datetime" formatted field in 1 of tables (yyyy-mm-dd hh:mm:ss) . when want display data on 1 of php pages, posting exact field data shows format mentioned above. i think using date("y-m-d",$row["date"]) $row["date"] corresponds particular row value return desired format. instead have use: date("y-m-d", strtotime($row["date"])) . why this? $row["date"] field not string in first place. should able simple rearrange data stored in datetime field? wasn't purpose of rebuilding entire tableset accomodate datetime? mysql has built in function called date_format can use display date how want to. select date_format(date_field, '%y-%m-%d') date_field table_name the manual has list of formats , variables needed display way. usi...

security - Restricting access to files within a folder to webservice IIS6/7 -

i looking way restrict direct access folder or folders on our website hosted in iis7 in our second dev environment, iis6 in our first dev environment , iis6 on production. basically should able link these files our website i.e.: http://www.domain.com/stuff/survey.pdf but if tries link blog post, etc. should not serve content. there way in web config or beyond abilities of iis? what ended doing writing php script served content outside of web root, if user logged in , had valid site cookie. then created folders replace content serving (.pdf, .png, etc.) since there not wanted secured. name folder same original document, i.e.: /webroot/survey.pdf/ , placed index.php inside of survey.pdf folder. this worked, , can use script link content want secured.

matplotlib - How do I plot a graph in Python? -

i have installed matplotlib, , have created 2 lists, x , y. i want x-axis have values 0 100 in steps of 10 , y-axis have values 0 1 in steps of 0.1. how plot graph? have through matplotlib gallery , graphs there have source code available. find 1 like, cut & paste, dissect!

python - Sql Alchemy What is wrong? -

i got tutorial http://www.rmunn.com/sqlalchemy-tutorial/tutorial.html when compile got error message the debugged program raised exception unhandled nameerror "name 'boundmetadata' not defined" i use latest sqlalchemy . how fixed this? after read modified own latest version sqlalchemy: from sqlalchemy import * engine = create_engine('mysql://root:mypassword@localhost/mysql') metadata = metadata() users = table('users', metadata, column('user_id', integer, primary_key=true), column('name', string(40)), column('age', integer), column('password', string), ) metadata.create_all(engine) = users.insert() i.execute(name='mary', age=30, password='secret') i.execute({'name': 'john', 'age': 42}, {'name': 'susan', 'age': 57}, {'name': 'carl', 'age': 33}) s = users.select() rs = s.execut...

sql - How the schema migration tools work? -

i have db based application , delete schema & db content every time whenever there changes in schema. in development mode. release application in production. suspect there many changes after release application in production use. software shall installed on many locations across globe. (not web based app) how schema migration tool work in case? or how can use them in typical database based applications suspect changes in schema? download redgate tools , find out. believe have trial periods , i'm sure sql compare does. typically, point them 2 databases , list out of differences between two. can configure them ignore things, comments, constraint names, etc. there can select items want synchronize , in direction , tool either generate script or make changes you. in situation generate script , use basis send customers or include in install scripts. keep database each version of application , can generate scripts go 1 version pointing @ 2 databases. can keep the...

c# - SQL - SQLDataAdapter Update causing primary key violation -

i need able change primary keys in table. problem is, of keys changing existing key values. e.g. record1.id 3=>4 , record2.id 4=>5. need keep these primary keys set foreign keys (which cascade update) there reasonable way accomplish this, or attempting sql heresey? as why, have data 1 set of tables linked primary key getting inserted/updated set of structured tables. insertion in parts, part of deduping process, , if update of tables inserted new primary key, life easier. one solution start indexing on destination table higher incoming tables row count ever reach (the incoming table gets re=indexed every time), i'd still know if possible above, otherwise. tia you attempting sql heresy. i'm pretty open-minded , know lot of times 1 must things seem crazy. annoys me when people arrogantly answer "you should differently", when have know idea situation is. must tell you should differently . heh heh. no, there no way elegantly sql\dataadap...

ffmpeg - java Runtime.exec() programm and pass character to getch() -

i want run ffmpeg java external process. after several minutes want stop it. asks me click 'q', , works in console, when try write 'q' stdin (process.getoutputstream() using java -- not work. i take "c", convert byte using ascii charset, write stream, flush , close it. ffmpeg not stop. i briefly looked in sources, , found uses getch() function (according manual) "reads character associated terminal". ffmpeg stop signal, not work in windows too. does know how solve issue? and yes: want run ffmpeg external program. know xuggle, not work me, need bare ffmpeg, , not want write jni myself now. thank you! see, readch() reads 1 character terminal keyboard, not input stream! in *nix uses ioctl, in windows (i believe) kind of console api. looks can't stop ffmpeg java out of jni:(

string - Formatting floats in Objective C -

i need format float (catchy title, he?) 2 decimal places, if decimal places have values aren't zero. example: i have nstextfield named 'answer', after math couple of floats, want assign 'answerfloat' variable 'answer' nstextfield. far i've got: [answer setstringvalue:[nsstring stringwithformat:@"%.2f", answerfloat]]; but sets 45 45.00. want whole numbers displayed without zeroes, , decimal numbers displayed respective decimal values. do need run kind of check before giving stringwithformat? or nsstring offer way handle this? have tried %g format specifier? nslog([nsstring stringwithformat:@"%g, %g", 45.0, 45.5]); 2010-01-12 19:54:38.651 foo[89884:10b] 45, 45.5

Hiding / Showing a Table with JavaScript -

hi have atable data , have expand , collapse button there if click on + expand , show table , if click on-it collapse , using following code getting error document.getelementbyid('elename'); imagexchk='expand'; loadedcheck='false'; function toggledisplaycheck(e, tablesize){ element = document.getelementbyid(e).style; if (element.display=='none') { element.display='block'; } else { element.display='none'; } if (loadedcheck=='false') { myupdater('returnsdetailstable', '/oasis/faces/merchant/dashboard/returnsdetailscheck.jsp', { method: 'get' }); loadedcheck='true' } size = tablesize-1; elename = 'mercperfdashboardform:returnsdetailstable:' + size +':switchimageretchk' if (imagexchk=='collapse') { document.getelementbyid('elename').src='${pagecontext.request.contextpath}/images/expand.gif';imagexchk='ex...

visual studio 2010 - C# App Developed with VS2010 fails on startup with .NET 3.0 -

read ton of material on 1 , still cannot find workable solution... we have "hello, world1" app--one text block on mainwindow--built , tested vs2010 (c#). target version set .net 3.0. when "deployed" on .net 3.0 (sp2) system app fails on startup. fails in call initializecomponent() in mainwindow. error dump. when same app put on system .net 3.5 works flawlessly. note modules loaded during debugger (in vs2010) indicate dll being loaded .net 2.0. v2.50727. can't figure out how identify what's causing load problem. thoughts, strategies, tools, suggestions? (this holding deployment.) ps. upgrading v3.5 in near future not , option--should be, it's not. don't guess @ cause of error, let .net tell you. write event handler appdomain.currentdomain.unhandledexception , display or log value of e.exceptionobject.tostring(). you may need know innerexception in case since constructor failed. cast e.exceptionobject exception. if can...

mysql: substring that returns the first occurrence from the right? (subrstring?!) -

is there way return first occurrence of space right side of string in sql? hmm, brief browse through function list didn't pop "search backwards" functions @ me, reverse string , search forwards: select length(`haystack`) - position('needle' in reverse(`haystack`))

How to pass optional arguments to a method in C++? -

how pass optional arguments method in c++ ? code snippet... here example of passing mode optional parameter void myfunc(int blah, int mode = 0) { if(mode == 0) do_something(); else do_something_else(); } you can call myfunc in both ways , both valid myfunc(10); //mode set default 0 myfunc(10, 1);//mode set 1

Does Android's CursorAdapter run in a background thread? -

does cursoradapter run on background thread , posts updates via ui looper thread? if not best pattern load data asynchronously contentprovider? the easier way using asynctask class. cursoradapter not run on background thread, afaik.

c# - Programmatically convert docx file to doc -

what options have convert .docx documents .doc document programmatically using c#? i'm looking cheaply possible. ideally want directly in code via libraries within .net framework or via establish downloadable dll. the 1 constraint have can't install office onto our servers. consider aspose.words . high quality product fast, reasonably priced , accurate. converting documents docx doc, word automation may result in data loss , may impact fidelity. may important users. i'm not affiliated product.

c# - Memory problems in .NET -

i have c# service listens queue xml messages, receives them, processing them using xslts , writing them in database. process 60k messages day of 1mb each. memory when idle going down 100mb good. have started processing messages of 12 mb in size. blow memory , when idle has memory of 500mb. suggestions why might problem? don't think there memory leak have surfaced after processing many (60k messages of 1mb). that looks fine. why think problem? the garbage collector release unused memory, doesn't mean going happen service idle. raymond chen has written article explaining basic idea of garbage collection: everybody thinks garbage collection wrong way however - pure speculation information given in questions - there might memory leaks related extension methods in xslt. extension methods may lead problems in case recompile stylesheet every time new xml document transformed. fix simple: once compiled, cache stylesheet.

elisp - Set some word with highlight color in emacs -

if want highlight words in doc in emacs, how can it. for example have log file recorded daily information. , want make "todo" in log highlighted. how can it? thank in advance. you should take @ thread : how highlight occurrences of word in emacs buffer this blog entry describes simple way : http://emacs-fu.blogspot.com/2008/12/highlighting-todo-fixme-and-friends.html the best way implement depends on want : can toggle highlighting manually, or create hook mode.

layout - Vertically expandable Composite -

i'm building swt ui, , has window (shell) 3 composites stacked 1 below other. want that: all expand maximum possible width (width of window) the first , third composites have height of 100px each the third composite expand height of height_of_parent - 200px - any_margins_or_paddings . objective 2 trivial, , did objective 1 using columnlayout defined here . how impolement objective 3? many :) ps: i'm new swt. i use gridlayout , this: gridlayout layout = new gridlayout(); parent.setlayout(layout); griddata data1 = new griddata(swt.left, swt.fill, false, true); data1.heighthint = 100; widget1.setlayoutdata(data1); griddata data2 = new griddata(swt.left, swt.fill, false, true); data2.heighthint = 100; widget2.setlayoutdata(data2); griddata data3 = new griddata(swt.left, swt.top, false, false); data3.heighthint = math.max(1, parent.getsize().y - 200 - layout.marginheight * 2); widget3.setlayoutdata(data3); parent.addcontrollistener(new controladapter...

java - Elegant way to handle upsert with Hibernate and MySQL -

i'm working on batch import feature sits on top of hibernate , mysql. goal have upsert functionality several tables. i'm finding myself writing lot of code deal seeing if row exists key , branching right method. wondering if there might better way, i.e. analogous tools come sql-server ssis hibernate , mysql. tools or elegant solutions have used handle bulk upserts hibernate and/or mysql? you might mysql's on duplicate key update feature: http://dev.mysql.com/doc/refman/5.1/en/insert-on-duplicate.html

web config - DbProviderFactories for .NET Error -

i having trouble getting odp.net library work .net dbproviderfactories. getting following error code: _dbfactory = dbproviderfactories.getfactory(providername); an error occurred creating configuration section handler system.data: column 'invariantname' constrained unique. value 'oracle.dataaccess.client' present. with providername: oracle.dataaccess.client and following entry in web.config: <system.data> <dbproviderfactories> <add name="oracle data provider .net" invariant="oracle.dataaccess.client" description=".net framework data provider oracle" type="oracle.dataaccess.client.oracleclientfactory, oracle.dataaccess, version=10.2.0.100, culture=neutral, publickeytoken=89b483f429c47342" /> </dbproviderfactories> </system.data> does know wrong? don't think have set twice anywhere. if installed odp.net (eg using oracle universal installer, opposed xcopy),...

java - Setting transparency makes textures translucent -

ok, problem have plane in java3d has texture painted on it. texture png alpha transparency. when scene rendered texture on plane partially translucent, if has transparency on entire image. have played around variety of texture , transparency settings trying work appearance ap = new appearance(); textureloader tl = new textureloader(textimage); texture tex = tl.gettexture(); textureattributes ta = new textureattributes(); ta.settexturemode(textureattributes.modulate); transparencyattributes transat = new transparencyattributes(); transat.settransparencymode(transparencyattributes.blended); transat.settransparency(0f); ap.settextureattributes(ta); ap.settexture(tex); ap.settransparencyattributes(transat); shape.setappearance(ap); any appreciated if don't want transparency @ of texture, try this: transparencyattributes tattr = new transparencyattributes(); tattr.settransparencymode(none); ap.settransparencyattributes(tattr);

delphi - Array of procedures inside a class pointing to class method -

i have class (texample) , want have array of pointers point texample methods. example, i'd have texample.thinkone , apointers[1] := @texample.thinkone or similar. how can this? thanks. you can this: type tproctype = procedure(const aparm: integer) of object; // method type tprocarray = array of tproctype; // dynamic array texample = class public procedure a(const aparm: integer); // method signature matches tproctype procedure b(const aparm: integer); end; var pa : tprocarray; procedure init(const aexample: texample); begin setlength(pa, 2); pa[0] := aexample.a; pa[1] := aexample.b; end;

version control - Tfs 2010: Why is my build account explicitly denied all permissions? -

i'm setting new deployment of tfs 2010. i've got couple stub projects built sitting inside solution, , i'm attempting configure continuous integration build on it. so, configured build defaults, , kicked off. got error: tf215097: error occurred while initializing build build definition \ticm\ticm.ci: item $/ticm/buildprocesstemplates/defaulttemplate.xaml not found in source control @ version t. i sort of confused, because sitting right there in source control. thinking reason might going off of workspace (and because think it's practice bind build templates branch they're building anyway) moved buildprocesstemplates inside main branch, , created custom ci build template in adjacent folder. tf215097: error occurred while initializing build build definition \ticm\ticm.ci: item $/ticm/main/build/templates/custombuilds/ticm.ci.xaml not found in source control @ version t. which same thing. in build definition, left build agent folder in "working folde...

web services - Call external json webservice from asp.net C# -

i need make call json webservice c# asp.net. service returns json object , json data webservice wants this: "data" : "my data" this i've come can't understand how add data request , send , parse json data back. string data = "test"; uri address = new uri("http://localhost/service.svc/json"); httpwebrequest request = (httpwebrequest)webrequest.create(address); request.method = "post"; request.contenttype = "application/json; charset=utf-8"; string postdata = "{\"data\":\"" + data + "\"}"; how can add json data request , parse response? use javascriptserializer , deserialize/parse data. can data using: // corrected webrequest httpwebrequest webrequest request = webrequest.create("http://localhost/service.svc/json"); request.method="post"; request.contenttype = "application/json; charset=utf-8"; string postdata = "{\"da...

mouse - Actionscript 3 mouse_over play movie, mouse_out reverse movie -

i'm trying make flash buttons mouse_over animation plays in reverse on mouse_out. have working 1 of 3 movie clip instances. i using e.currenttarget.play() instead of having function each movie clip, how do same playreverse function? tried putting e.currenttarget.prevframe() instead of mc1.prevframe() did not work. code follows: mc1.addeventlistener(mouseevent.mouse_over,mover); mc2.addeventlistener(mouseevent.mouse_over,mover); mc3.addeventlistener(mouseevent.mouse_over,mover); mc1.addeventlistener(mouseevent.mouse_out,mout); mc2.addeventlistener(mouseevent.mouse_out,mout); mc3.addeventlistener(mouseevent.mouse_out,mout); function mover(e:mouseevent):void { stopplayreverse(); e.currenttarget.play(); } function mout(e:mouseevent):void { this.addeventlistener(event.enter_frame, playreverse, false, 0, true); } function playreverse(e:event):void { if (mc1.currentframe == 1) { stopplayreverse(); } else { mc1.prevframe(); } } function s...

iphone - UINavigationController - how to not animate when popping using backbutton? -

this ought simple can't figure 1 out: the default behaviour when clicking backbutton in uinavigationcontroller current view gets popped animation. how can override default behaviour transition not animated? [self.navigationcontroller poptoviewcontroller:viewcontroller animated:no]; http://developer.apple.com/library/ios/documentation/uikit/reference/uinavigationcontroller_class/reference/reference.html#//apple_ref/occ/instm/uinavigationcontroller/poptoviewcontroller:animated :

Create variables from strings in Python -

is following possible in python: >>> vars = {'a': 5} >>> makevars(vars) >>> print 5 so, makevars converts dictionary variables. (what called in general?) it's possible, sometimes, it's bad idea. in spite of name, variables themselves should not variable. they're part of code, part of logic. trying 'replace' local variables way makes code inefficient (since python has drop of optimizations), buggy (since can accidentally replace didn't expect), hard debug (since can't see what's going on) , plain unreadable. having 'dynamic values' dicts , lists , other containers for.

javascript - HTML5 Video Element on iPad doesn't fire onclick or touchstart events? -

i'm trying attach events html5 video element inside ipad web app don't seem firing? i've tested both on device , in simulator , same results. events (for onclick @ least) work fine in desktop safari. i've tried swapping video element div , events fire fine? has else come across , have idea work around? <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>test video swipe</title> </head> <body> <video src='somevid.mp4' id='currentlyplaying' width='984' height='628' style='background-color:#000;' controls='controls'></video> <script> var thevid = document.getelementbyid("currentlyplaying"); thevid.addeventlistener('touchstart', function(e...

c - Strange behavior of memcpy/memmove -

i have problem memcpy/memmove change pointer of struct foo foo , neither src nor destination of function. here gdb outputs: before memmove(y,y_temp,size_y); : (gdb) p y $38 = 0xbff7a2e0 (gdb) p y_temp $39 = (float *) 0x815ea20 (gdb) p foo $40 = (foo *) 0x81d4e90 and after: (gdb) p y_temp $41 = (float *) 0x343434 (gdb) p y $42 = 0x343434 (gdb) p foo $43 = (foo *) 0x343434 here definitions of variables: foo *foo; float y[nsamples]; float size_y = nsamples*sizeof(y); float* y_temp = (float*) malloc(size_y); i know, not bug memcpy/move, looking tipp, programming error on side have caused it. thanks size_t size_y = sizeof(y); sizeof(y) gives size of whole array, , type should size_t . if this, y , memory y_temp points same size. should make sure you're moving in right direction. right now, y destination. also, if source , destination don't overlap (which won't here), use memcpy .

caching - NHibernate 2nd Level Cache Provider Differences -

i've been using nhibernate while now, i'm still wondering differences between the second level cache providers ? do perform better\worse ? what popular , why ? for clarity i'm talking about: nhibernate.caches.memcache nhibernate.caches.prevalence nhibernate.caches.sharedcache nhibernate.caches.syscache nhibernate.caches.syscache2 nhibernate.caches.velocity and i'm sure there others. thanks comparing these cache providers boils down comparing memcached vs prevalence vs velocity, etc, , not related nhibernate. here reasons (by no means complete list) pick 1 on others: if want keep simple , don't run app in farm, might want use syscache/prevalence, runs in-proc. if use ms sql server, use syscache2. if need huge cache across many cache-dedicated servers, might want use memcached, can run on linux you'd avoid licensing costs. if application runs on azure or uses appfabric, might want use velocity. personally prefer caching m...

JavaScript Newb - Screen Width and CSS, ARGH! -

i'm trying write bit in javascript mobile website. i've searched on google , found help, i'm having kind of problem implementing it. in html header (note, no css file specified here): <script type="text/javascript" src="scrnsz.js"></script> javascript: if (screen.width > 200) { link = document.getelementsbytagname("link")[0]; link.href = "style.css"; } if (screen.width <= 200) { link = document.getelementsbytagname("link")[0]; link.href = "smstyle.css"; } can pros help? :) thank you. to make work, you'd need lone <link rel='stylesheet'> instruction in head. script search first 1 finds, , replace href accordingly. however, there more ways , options prepare site mobile browsers. check out these questions: web site designing mobile what quickest , easiest ways ensure existing web pages display on mobile platforms? designing web interfaces mobile devic...

text - Easiest way or lightlest library to get bigrams and trigrams in Java? -

i'd rather not have fire lingpipe if possible leaves me wondering if there quick, easy ways in java extract bigrams , trigrams string of text? thanks always easiest way use existing library. can take on simmetrics library. can use lucene ngramtokenizer . can implement algorithm yourself. first, have find words (using stringtokenizer ) in text , generate n-grams need.

php - Accessing a defined constant returns messed up characters -

this strange have constant defined such: define("rj_files_path", rj_site_directory."\assets\files\\"); however when try access constant in code weird result on localhost.. c:\wamp\www\my.app\assetsiles\2688 the \f replaced square indicating unrecognised character. whats happening because of unable save files folder constant supposed point to. you need escape backslashes before a , f : define("rj_files_path", rj_site_directory."\\assets\\files\\"); otherwise they're interpreted escape codes, since they're within string. (just \n newline, et cetera.)

Is it possible to create datasources dynamically in Tomcat 6 without redeploying web application? -

i need create databases on fly in web application. need create datasources new databases. possible create datasource in tomcat 6 without need redeploy web application every time new datasource created? you can apparently accessing admin app own code - see this thread. the other option not use container-managed datasources.

Can I call CUDA runtime function from C++ code not compiled by nvcc? -

is there way can call cuda runtime function calls such as cudamemcpy(...); in .cpp file, compiled regular c++ compiler? edit: there example here it's not longer found, of example copied below. the caller c (but c++) #include <stdio.h> #include <stdlib.h> #include <string.h> #include <cuda.h> extern void kernel_wrapper(int *a, int *b); int main(int argc, char *argv[]) { int = 2; int b = 3; kernel_wrapper(&a, &b); return 0; } the callee (cuda) __global__ void kernel(int *a, int *b) { int tx = threadidx.x; switch( tx ) { case 0: *a = *a + 10; break; case 1: *b = *b + 3; break; default: break; } } void kernel_wrapper(int *a, int *b) { int *d_1, *d_2; dim3 threads( 2, 1 ); dim3 blocks( 1, 1 ); cudamalloc( (void **)&d_1, sizeof(int) ); cudamalloc( (void **)&d_2, sizeof(int) ); cudamemcpy( d_1, a, sizeof(int), cudamemcpyhosttodevice ); cudamemcpy( d_2,...

C# Question regarding rewriting from VB -

i'm vb guy learning c#. seem getting hang of i've got couple questions regarding code i'm writing. in first 1 here i'm getting error when write code so: irowindex = sf1411bindingsource.find(sf1411dataset.sf1411.columns(groupbox4.tag.tostring).tostring, textbox1.text); if (irowindex == -1) error 1 'system.data.datatable.columns' 'property' used 'method' c:\11180_application\11180_application\edit.cs 186 71 11180_application my other issue in vb use tags in c# doesnt seem them: //set find label display new find column groupbox4.text = "find - " + sender.tag.tostring + ":"; //store sort column name in lblfind's tag property groupbox4.tag = sender.tag.tostring; error 4 'object' not contain definition 'tag' c:\11180_application\11180_application\edit.cs 211 36 11180_application any ideas here? try columns[groupbox4.tag.tostring()] first error. regarding tags, in c# s...

c++ - Template parameters dilemma -

i have dilemma. suppose have template class: template <typename valuet> class array { public: typedef valuet valuetype; valuetype& getvalue() { ... } }; now want define function receives reference class , calls function getvalue(). consider following 2 ways: method 1: template <typename valuetype> void dogetvalue(array<valuetype>& arr) { valuetype value = arr.getvalue(); ... } method 2: template <typename arraytype> void dogetvalue(arraytype& arr) { typename arraytype::valuetype value = arr.getvalue(); ... } there no difference between 2 methods. calling both functions same: int main() { array<int> arr; dogetvalue(arr); } now, of 2 best? can think of cons , pros: method 1 pros: the parameter real class not template, easier user understand interface - explicit parameter has array. in method 2 can guess name. use valuetype in function more clear way when hidden inside array...

iphone - scrollRowToVisible -

the error goes out when scrollrowtovisible executed. 'uitableview' ..in xcode.. may not respond '- scrollrowtovisible' it writes follows. iboutlet uitableview *tableviews; [tableviews scrollrowtovisible:2]; want move second line. reloaddata operates. why reloaddata valid method on uitableview . scrollrowtovisible: not, , have no idea got it—there's nothing else called in api. method you're looking -scrolltorowatindexpath:atscrollposition:animated: , you'd use this: [tableviews scrolltorowatindexpath:[nsindexpath indexpathforrow:2 insection:0] atscrollposition:uitableviewscrollpositionnone animated:yes];

data structures - Should I use structs in C++? -

the difference between struct , class small in c++, struct members per default public , class members per default private. however, still use structs whenever need pure data structures, instance: struct rectangle { int width; int height; }; i find convenient work with: rectangle r; r.width = 20; r.height = 10; however, data structures procedural programming, , i'm doing object oriented programming. bad idea introduce concept oo? no. if makes sense use struct somewhere, why complicate things using else isn't meant fit purpose ? in projects, tend use struct simple "structures" need hold trivial data. if data structure needs have "smartness" , hidden fields/methods, becomes class.

sql - Advantages to Vertical Partitioning of Table -

( note situation isn't how is, made example) i have entity in table data updated every 5 seconds ( kinematic data : speed, heading, lat, long, , positiontime), , other data updated hardly @ all, if ever (color, make, origintime). alt text http://www.freeimagehosting.net/uploads/a67205e99e.jpg now boss wants me partition data separate tables in our database (with 1 one relationship), so: alt text http://www.freeimagehosting.net/uploads/1c699bc3c5.jpg he makes sound "obvious" should way, there advantages having data separated inserting , updating (for instance if put index on color or make)? it might make sense vertical partitioning this. or might not. when use mvcc based engine, each time update row, generally* copies entire row , creates new 1 modifications. other transactions not yet see update can continue read original row if need to. this means updating few small columns in wide row causes database lot more writes needs to. but not many, ...

user interface - How to set a background color of a JButton in Java? -

i developing java desktop application. in have 4 jbuttons on jpanel . want whenever button clicked background color changes other color (say orange) represent has been clicked , background color of other 3 buttons reset default color (in case of them had orange background color). so, @ 1 time 1 button can have orange color. the current approach have applied have implemented following code in xxxactionperformed() method of jbutton button1 button1.setbackground(color.orange); button2.setbackground(color.gray); button3.setbackground(color.gray); button4.setbackground(color.gray); and rest 3 buttons. now in actual, don't want backgroud color gray (for unclicked button). instead, want default background color backgroud color adjust look-and-feel of gui according end-user's platform's look-and-feel. q1. how can default background color? q2. correct approach or there other mechanism through can group 4 buttons in button group 1 can have specified property @ 1 t...

encoding - How do I display a Registered Trademark symbol (®) using VB.NET? -

i have taken on support of application @ company work for. of sudden, customer wants able enter registered trademark in name field. symbol, using alt+0174, being saved correctly, app not encoding properly. i'm doing: private sub btnsave_click(byval sender system.object, byval e system.eventargs) handles btnsave.click dim ms new memorystream dim xml_text_writer new xmltextwriter(ms, _ system.text.encoding.utf8) xml_text_writer.formatting = formatting.indented xml_text_writer.indentation = 4 xml_text_writer.writestartdocument(true) xml_text_writer.writestartelement("employees") makeemployee(xml_text_writer, txtfname.text, txtlname.text, 11111) xml_text_writer.writeendelement() xml_text_writer.writeenddocument() xml_text_writer.flush() ms.flush() ms.position = 0 dim b(cint(ms.length) - 1) byte ms.read(b, 0, cint(ms.length)) ms.close() dim strreturn string = system.text.asciiencoding.as...

Objective-C Unit Tests cannot find my resources -

when run unit tests fails on loading external resources (images) same error if don't exist. in xcode have added resources unit test target. don't know try next. i using cocos2d framework, try load following code within unit test atlasspritemanager *at = [atlasspritemanager spritemanagerwithfile:@"player2.png" capacity:50]; it seems calls uiimage imagewithcontentsoffile returns nil. the actual code throws error looks like image = [uiimage cgimage]; if(image == null) { [self release]; nslog(@"image null"); return nil; } it seems images required not copied on application support directory before unit tests run, after successful pass. not sure if problem, if is there way change build order images copied first , unit tests can find them? the resources aren't getting included target. before have run script phase of test bundle, make sure have "copy resources" phase copies resources test bundle tests need.

iphone - How to implement NTLM Authentication for UIWebView? -

i have use case uiwebview may need connect web server secured ntlm. have use case have credentials passed. instead of forcing user enter them, how perform handshake uiwebview ? update: using method here works enough when doing simple requests, utterly fails when doing posts, mere fact doing after posted. the asihttprequest , asiwebpagerequest have same problem. requests work wonders, posts don't work. if world worked on requests. i have been able use this method of including username , password in http request string, grossly insecure defy reason using it. using sniffer able see three-way handshake occur without problems on both , post requests. you can set default credential: nsurlprotectionspace *protectionspace = [[nsurlprotectionspace alloc] initwithhost: _host port: 80 protocol: @"http" ...

search - Change SharePoint scope at runtime -

i have requirement based on users sharepoint group, there search should specific scope. question is, possible change sharepoint search box use search particular scope @ runtime? sharepoint search search box based upon query string ever text passed in query string parameter "s" treated scope if replace "s" "cs" becomes contextual scope. suggest create custom web part may using c# or can use editor web part.

sql - MySQL: how to select many results from linked table at one row to another? -

at first - im sql newbie, sorry (mbe typicall) question. i have 2 table: table of organisations... id_org org_name 1 organiz1 2 organiz2 and table of organization staff. id_staff staff_name id_org 1 john 1 2 jack 1 3 sally 1 4 peter 1 5 andy 2 6 joe 2 i want sql answer(two rows) this 1 organiz1 1 john 2 jack 3 sally 4 peter 2 organiz2 5 andy 6 joe and want each name or id of staff named staff_1_name(staff_2_name,staff_3_name) , staff_1_id. how can it? select o.id_org, o.org_name, group_concat(concat(s.id_staff, ' ', s.staff_name) order s.id_staff separator ' ') organizations o, staff s s.id_org = o.id_org group id_org, org_name;

c# - Event handler reference from utility class -

i have method i'm putting in each page make, know there should way move single place ease of maintenance , simplicity. i'm not sure how should handle event handler. event handler needs on each page, how pass in reference page can reference event handler? private void insertlinkbutton(string text, string id, updatepanel updatesummary) { linkbutton link = new linkbutton(); link.text = text; link.click += new eventhandler(link_click); <------ link.causesvalidation = false; asyncpostbacktrigger trigger = new asyncpostbacktrigger(); trigger.controlid = link.id = "link" + id; trigger.eventname = "click"; utils.tag(link, placeholdersummary); updatesummary.triggers.add(trigger); } why not pass event handler method argument? private void insertlinkbutton(string text, string id, updatepanel updatesummary, eventhandler clickhandler) { ...

asp.net - changing selected text of dropdownlist in Gridview using javascript -

i have dropdownlist, , gridview 1 of columns dropdownlist. both dropdown lists use same data source. when value selected in dropdownlist (outside gridview) want chaneg selectedvalue , selecttext of every dropdownlist in gridview. this have tried: dropdownlist: <asp:dropdownlist onclick="javascript:onjdselection()" id="dropdownlist3" runat="server" datasourceid="sqldatasource4" datatextfield="circt_cstdn_nm" datavaluefield="circt_cstdn_user_id"> javascript: <script type="text/javascript"> function onjdselection() { var jd = document.getelementbyid('dropdownlist3.clientid').selectedtext; var grid = document.getelementbyid('gridview2.clientid'); //loop starts 1 because zeroth row header. (var = 1; < grid.rows.length; i++) { var othertext = grid.rows[i].cells[2].innertext; // works fine grid.rows[i].cells[3].getele...

sockets - How do online port checkers work? -

for example http://www.utorrent.com/testport?port=12345 how work? can server side script attempt open socket? there many ways of accomplishing through server-side scripting. @oded mentioned, server-side handlers capable of initiating socket connections on arbitrary ports, , of have dedicated port-scanning packages/libraries (php has one in pear repository, python's 'socket' module makes type of tasks breeze, etc...) keep in mind on shared host platforms, socket connections typically disabled security purposes. another way easy accomplish use command-line port-scanner such nmap server-side script. i.e in php, echo ``nmap -p $port $ip \

c# - Using an ObjectDataSource with a GridView in a dynamic scenario -

i have search page tasked searching 3.5 million records individuals based on name, customer id, address, etc. queries range complex simple. currently, code relies on sqldatasource , gridview. when user types serach term in , presses enter, textboxchanged runs search(term, type) function changes query sqldatasource uses, adds parameters, , rebinds gridview. it works well, i've become obsessed rewriting code more efficiently. want paging done sql server instead of inefficiencies of sqldatasource in dataset mode. enter objectdatasource. caveat: have never used 1 before today. i have spent better part of day putting class: using system; using system.data; using system.data.sqlclient; using system.configuration; using system.text; using system.web; using system.web.security; using system.web.ui; using system.web.ui.webcontrols; using system.web.ui.webcontrols.webparts; using system.web.ui.htmlcontrols; /// <summary> /// summary description multisearchdata /// ...

c# - Only parameterless constructors and initializers are supported in LINQ to Entities -

while trying sem-complex query display listview content on page got stuck on famous "only parameterless contstructor , initializers supported in linq entities" error. here code used ... can't find place initialized inside query parameters .... protected void artistslist() { guid cat1 = new guid("916ec8ae-8336-43b1-87c0-8536b2676560"); guid cat2 = new guid("92f2a07f-0570-4521-870a-bf898d1e92d6"); var memberorders = (from o in datacontext.orderset o.status == 1 || o.status == 0 select o.id); var memberorderdetails = (from o in datacontext.orderdetailset memberorders.any(f => f == o.order.id) select o.product.id ); var inventoryitems = (from in datacontext.inventoryitemset select i.inventory.product.id); var products = (from p in datacontext.productset join m in dat...

How to split space delimited field into rows in SQL Server? -

i found this function returns 3 rows following query: select * dbo.split('1 2 3',' ') however, need use values field instead of '1 2 3'. i tried: select * dbo.split(select top 1 myfield mytable,' ') but fails saying incorrect syntax. it doesn't have use function above, feel free recommend function or different way go it. clarify, need parse values single row of single field. you need apply split(myfield) function each row in mytable. when split function table valued function correct answer apply operator: the apply operator allows invoke table-valued function each row returned outer table expression of query. so answer must be: select * mytable cross apply dbo.split(myfield, ' '); example: create table mytable (myfield varchar(10)); insert mytable (myfield) values ('1 2 3'); go create function split (@list varchar(max), @delimiter char(1)) returns @shards table (value varchar(8000)) sc...

ASP.NET webreferences/servicereferences for WCF -

a couple of questions: is app_webreferences wcf schema files? should not app_servicereferences? also, dynamic compilation in asp.net? thanks from msdn : app_webreferences folder contains files used create reference web service (in same project or external project), including .disco , .wsdl files there's no special folder in asp.net called app_servicereferences . as far dynamic compilation concerned may take @ this article explains good.

python - How can I better structure this code? -

i have lxml.objectify data structure restful web service. need change setting if exists , create if doesn't. right have along lines of following, feel it's ugly. structure i'm looking in has list of subelements have same structure, can't specific tag unfortunately. thing_structure = lxml.objectify(get_from_rest_service()) found_thing = false if thing_structure.find('settings') not none: i, foo in enumerate(thing_structure.settings): if foo.is_what_i_want: modify(thing_structure.settings[i]) found_thing = true if not found_thing: new = lxml.etree.subelement(thing_structure, 'setting') modify(new) send_to_rest_service(thing_structure) overall, structure isn't bad (assuming need call modify on 1+ items in settings -- if "just one", i.e., if is_what_i_want flag going set 1 setting @ most, that's of course different, , should use break for loop -- that's not impression of ...

.net - ODBC Support for Informix Serial and BigInt Data Types -

i have informix dynamic server 11.50 , informix client sdk 3.5 installed on server. developing .net application read data informix database using odbc functions. in database, have table columns of serial , bigint data types defined. data retrieve function looks this. dim cmd new odbc.odbccommand dim da new odbc.odbcdataadapter dim ds new dataset dim sb new stringbuilder("") try using cn new odbc.odbcconnection(configurationsettings.appsettings("connstring")) cn.open() sb.append("select * interfacesp ") sb.append("join interface on interfacesp.interfaceid = interface.interfaceid ") sb.append("left join interfacespaction on interfacesp.interfacespid = interfacespaction.interfacespid , action_status = 'actv' ") sb.append(" interfacesp.interfaceid = ? ") sb.append(" order interfacesp.spname") ...

regex - Regular Expression to validate the field: field must contain atleast 2 AlphaNumeric characters -

i need validate varchar field. conditions are: field must contain atleast 2 alphanumeric characters so please 1 give regular expression above conditions i wrote below expression check atleast 2 letters alphanumeric. , if input have other alphanumeric nt validating. '^[a-za-z0-9]{2,}$' please help......... [a-za-z0-9].*[a-za-z0-9] the easy way: @ least 2 alnum's anywhere in string. answer comments never did (nor intended do) benchmarking. therefore - , given know nothing of op's environment - not 1 judge whether non-greedy version ( [a-za-z0-9].*?[a-za-z0-9] ) more efficient. do believe, however, performance impact totally negligible :)