Posts

Showing posts from March, 2014

linux - How do I use sed to change my configuration files, with flexible keys and values? -

i want search configuration file expression: "central.database". want change setting associated "central.database" "sqltest". the layout of config file initially: central.database = sqlfirsttest this want after sed replacement: central.database = sqltest i doing in bash script, suggestions, recommendations or alternative solutions welcome! (actually both central.database , sqltest come bash variables here.) my current code (third attempt): sshretvalue=$(ssh -p "35903" -i $home/sshids/idrsa-1.old ${1} <<eof sed -i "s/^\($central_db_name\s*=\s*\).*\$/\1$central_db_value/" /home/testing.txt; echo $? eof ) error message: pseudo-terminal not allocated because stdin not terminal. sed: -e expression #1, char 58: unknown option `s' -bash: line 3: eof: command not found here's example expression: sed -i 's/^\(central\.database\s*=\s*\).*$/\1sqltest/' file.cfg if want

python - Using git to manage virtualenv state: will this cause problems? -

i have git , virtualenv set in way suits needs and, far, hasn't caused problems. i'm aware setup non-standard , i'm wondering if more familiar virtualenv's internals can point out if, , where, it's go wrong. my setup my virtualenv inside git repository, git set ignore bin , include directories , in lib except site-packages directory. more precisely, .gitignore file looks this: *.pyc # ignore virtualenv stuff except actual packages # /bin /include /lib/python*/* !/lib/python*/site-packages # ignore easyinstall , setuptools /lib/python*/site-packages/easy-install.pth /lib/python*/site-packages/setuptools.pth /lib/python*/site-packages/setuptools-* /lib/python*/site-packages/pip-* with arrangement -- , else working on checkout of project -- can use virtualenv , pip normal following advantages: if updates or installs package , pushes changes, else pulls changes automatically gets update: don't need notice requirements.txt file has changed o

iOS UIScrollView with UIImageView rotation aspect problem -

i apologize in advance lack of ios sdk knowledge, android developer has been tasked maintaining , updating iphone application. i using uiscrollview handle zooming , dragging of image being displayed on uiimageview. the image in uiimageview requested web server multiple times second. when orientation of device changes image dimensions change of current frame, example when using ipad in portrait mode image dimensions 768x1024 when switching landscape mode dimensions of image 1024x768. webserver work of adding black bars top/bottom or left/right of image depending on orientation , aspect ratio of image requesting. my problem after rotating device uiimageview never behaves way expect to. expected behavior uiscrollview continue perform scrolling actions reset base view of new frame dimensions after rotation. if don't specify contentmode uiscrollview image appears squished though scrollview trying display image in previous orientations dimensions. if specify contentmode

android - Black background while ScrollView loads -

i have scrollview in activity contains webview , looks scrollview takes little bit load showing black background until has loaded. if try , put layout behind scrollview white background fade indicates can scroll turns white too. i've tired putting background colour on layouts both within , outside scroll view; 1 affects scrolling fade , other doesn't load leaving black space, same setting colour on scroll view itself. if takes time scrollview load, means have processing can done in background. may want move processing background thread (using asynctask) , update gui in onpostexecute .

Eclipse rcp - how to load jdbc driver? -

i wondering if give me instructions on how following: how add mysql connection jar file eclipse plugin build path how add connector jar file library , adding plugin's runtime classpath i getting com.mysql.jdbc.driver exception when trying load driver class using class.forname("com.mysql.jdbc.driver") . have added jdbc driver project right clicking on project name , selecting add library button. found out there eclipse rcp project there different way of adding jdbc jar file. i've never used mysql eclipse, i've done postgres sql. maybe you: right-click project in package explorer build path add external archives... select mysql jar archive press ok the library should referenced in "referenced librairies" under package explorer. try run program again.

css - Image sprite in inline style? -

i able use image sprites (@sprite) explicitly defining clientbundle sibling cssresource , imageresource accessors. i'm wondering whether using sprite means must have separate .css file. if define styles inline <ui:style> , how known name image accessor use gwt-image: ? answered own question: <ui:style> @sprite .panel { gwt-image: "titlebackground"; } </ui:style> <ui:image field='titlebackground' src="constants/title-bg.jpg" /> the field names of image resources in same template serve names of image accessor functions in generated client bundle.

ios - Apple Push Notification listening port on iPhone -

i trying determine when ios receives push notification , want listen on port. app being worked on "always on" in background (lbs app), therefore nice use apn service send requests app when in background without requiring user click view. does know incoming port push service on iphone? push notification tcp 5223. see: important apple ports apple push notification support

Is it possible to run openoffice macro from external file? -

i want run openoffice macro external file. like: vlad@leo ~ $ soffice macro:///home/vlad/q.vbs not answer - comment instead, bump question, , answer :) this possibly has having explicitly set permissions macros, instance: can't execute macro command line (view topic) • openoffice.org community forum edit: in fact seems impossible call document macros, perfect security reasons. see also: custom openoffice.org basic macros , libraries - openoffice.org wiki openoffice.org forum :: enable openoffice macro through command line . openoffice.org forum :: simple command line question openoffice.org forum :: howto run macros document shell as side note, standard module1 file can found in (on linux): ~/.openoffice.org/3/user/basic/standard/module1.xba ~/.libreoffice/3/user/basic/standard/module1.xba and note .xba xml file, contains basic macro source, in: <?xml version="1.0" encoding="utf-8"?> <!doctype script:module pu

Google Maps & Flex: How to Use Standard Map Marker Instead of Custom Marker? -

i'm using google maps flex 3. i'm using custom markers (custom icons) mark places on map. works fine. problem in cases, don't need custom icon, need standard marker. for example, how set condition c's icon standard marker: public function iconsetter():void { if (condition blah blah){myicon=star; mypointsbuilder(); return;} if (condition b blah blah){myicon=circle; mypointsbuilder(); return;} if (condition c blah blah){myicon=standard marker; mypointsbuilder(); return;} } in mypointsbuilder function create markers so: for (i=0; < arraylength; i++) { mymarker = new marker(new latlng(mydata[i].latitude, mydata[i].longitude), new markeroptions({ icon: new myicon, iconoffset: new point(2,2), iconalignment:1, hasshadow:true })); markerboss.addmarker(mymarker, 15, 15); } markerboss.refresh(); i don't know how revert default marker wrote "standard marker". suggestions? thank you.

Imploding in PHP vs imploding in MySQL - which uses less cpu? -

which of these options more optimal? imploding in mysql $rsfriends = $cnn->execute('select cast(group_concat(id_friend) char) friends table_friend id_user = '.q($_session['id_user'])); $friends = $rsfriends->fields['friends']; echo $friends; vs. imploding in php $rsfriends = $cnn->execute('select id_friend table_friend id_user = '.q($_session['id_user'])); while(!$rsfriends->eof) { $friends[] = $rsfriends->fields['id_friend']; $rsfriends->movenext(); } echo implode(',',$friends); you should know correct ("most optimal") choice going factor of many variables: your database , application hardware. the size of data what load on database , application servers. indexes , other things may affect query execution plan on dataset how actually want use da

php - ImageMagick and mogrify crop -

i have having problems getting crop work on image (i have got resize working fine) the orginal image x , after resize: mogrify -resize x75 /my/path/image.jpg i can see resize has worked after performing getimagesize(): array ( [0] => 148 [1] => 75 [2] => 2 [3] => width="148" height="75" [bits] => 8 [channels] => 3 [mime] => image/jpeg ) the crop command is: mogrify -crop 100x75! +0+0 /my/path/image.jpg once complete try , confirm image correct size using getimagesize() following error , can't access image. warning (2): getimagesize(/my/path/image.jpg) [function.getimagesize]: failed open stream: no such file or directory any ideas? using wrong syntax crop? thanks in advance! looks error in syntax there no space between image size , crop position. it should this : mogrify -crop 100x75!+0+0 /my/path/image.jpg the below incorrect : mogrify -crop 100x75! +0+0 /my/path/image.jpg

redirect - default URL redirection -

i having anoying problem here. i trying test web site locally using unused url "lwww.domain.com". set including host file, , when try access in ie. network provider (cox) redirects request own page "finder.cox.com/dsfjlsjdlfjlf". wondering how happen , how turn off. want 404 page if nothing found. actually, redirection happen after disable network adapter, although cannot back. thanks lot

c# 4.0 - How to compile unsafe code in MonoDevelop 2.4 -

i trying compile unsafe code blocs in monodevelop 2.4. apparently (google search result) there supposed a tickbox under options->build->general allows compiler handle unsafe blocks not there in 2.4. know how set monodevelop compile unsafe code? in solution view, on left default, click on project's name. then, in menu bar, click on project, click on '"thenameofyourproject" options' under compilation or build (i have french version) have line named build guess. see on right written "complmentary options" or that. type in /unsafe , there go

java - Applet can't find classes in weblogic 11 -

i have applet , few libraries in jar files. obviously, required classes deployed applet added them library path in ide (jdeveloper). can't access these classes. applet freeze ups without errors. maybe caused security permissions ? here structure in deployment archive (war) web-inf classes other_packages lib jar libs here applet.html package of classes, don't know why duplicated here html file: <applet code="my.base.applet1" height="200" width="200" mayscript align="bottom">this browser not support applets. </applet> i tried add jar libraries , works if open html file applet local disk. have specify path libraries archive="web-inf/lib/commons-logging.jar". if use "commons-logging.jar" in official tutorials causes "class not found" error. can't find these jar files archive="web-inf/lib/commons-logging.jar" when deployed on server , accessed t

graphics panel in c# -

instead of setting image using 'background' property, draw image using graphics class on panel. how can in c#.net? you can try following piece of code. public class imagepanel:panel { private image image; public image image { { return image; } set { image = value; refresh(); } } protected override void onpaint(painteventargs e) { if(image!=null) { e.graphics.drawimage(this.image,point.empty); } base.onpaint(e); } }

android - Japanese Kanji handwriting input -

i'd ask if there plans provide built-in handwriting ime japanese kanji. , perhaps traditional , simplified chinese well. the reason ask because thing thing seem miss iphone. it's convenient able naturally input said characters on phone , i've still yet find enough input method. thanks in advance. the add-on ime multiling keyboard provides chinese/japanese handwriting input plugin.

Mongodb shutting down -

i have problem mongodb shutting down. throwing segmentation fault , shutting down. error log given below. suggest causing error. wed may 11 12:50:53 db version v1.6.5, pdfile version 4.5 wed may 11 12:50:53 git version: 0eb017e9b2828155a67c5612183337b89e12e291 wed may 11 12:50:53 sys info: linux domu-12-31-39-01-70-b4 2.6.21.7-2.fc8xen #1 smp fri feb 15 12:39:36 est 2008 i686 boost_lib_version=1_37 wed may 11 12:50:53 [initandlisten] waiting connections on port 27017 wed may 11 12:50:53 [websvr] web admin interface listening on port 28017 wed may 11 12:51:03 [initandlisten] connection accepted 127.0.0.1:36745 #1 wed may 11 12:51:03 [conn1] end connection 127.0.0.1:36745 wed may 11 12:51:05 [initandlisten] connection accepted 127.0.0.1:36747 #2 wed may 11 12:51:05 [conn2] end connection 127.0.0.1:36747 wed may 11 12:51:05 [initandlisten] connection accepted 127.0.0.1:36748 #3 wed may 11 12:51:05 [conn3] error: have index [twitter.home_timeline.$aves_user_id_1] no namespacedetails

view - Iterative display of objects in Rails -

i find when iteratively render collection of objects, say, comments, rails lists addresses of objects. example, view may contain following: <h3>comments</h3> <% if @blogpost.comments.any? %> <%= @blogpost.comments.each |comment| %> <%= render :partial => "comment", :locals => {:comment => comment} %> <% end %> <% end %> the view shows this: <h3>comments</h3> <p>comment #2</p> <p class="post-info"> >> example user, 1 hour ago. </p> <p>this user 1's comment on user 5's article</p> <p class="post-info"> >> example user, 2 days ago. </p> #&lt;comment:0xb6f91968&gt;#&lt;comment:0xb6f9016c&gt; as can see, there couple of address listings objects, prefer not have in view. there way suppress output? in advance time! remove = <%= @blogpost.comments.each |comment| %>

According to a temporary table (Table Schema and data) -

according temporary table (table schema , data), how can create physical table , insert returned records it? hi, in below sample code , retriving columns temp table using case condition.. in step 2 checking column has been selected case statement.. in step 3 selecting columns have been retrieved above case stmnt.. in step 4 creating physical table columns names have selected above , inserting it.. atlast drop both tables i hope you step1: declare @dynsql nvarchar(max) select @dynsql = case when columnname1 >0 ',columnname' else '' end + case when columnname2 >0 ',columnname2' else '' end + . . case when columnnamen >0 ',columnnamen ' else '' end ##temptble condition = cond; step 2: if(len(@dynsql) > 0) begin step 3: set @dynsql = stuff(@dynsql,1,1,'

java - Creating Menus in the project and files panes in Netbeans -

i'm trying create simple module in netbeans can check in , check out files in netbeans. don't understand how can create menu item in project , files popup menus subversion does. can please help. regards, sunil have @ actions: how add things files, folders, menus, toolbars , more section of netbeans developer faq should point in right direction.

C, C++ Interface with Python -

i have c++ code has grown exponential. have number of variables (mostly boolean) need changed each time run code (different running conditions). have done using argument command line inputs main( int argc, char* argv[]) function in past. since method has become cumbersome (i have 18 different running conditions, hence 18 different argument :-( ), move interfacing python (if need bash ). ideally code python script, set values of data members , run code. does have pointer/information me out? better still simple coded example or url up. edit original question: sorry don't think clear question. don't want use main( int argc, char* argv[]) feature in c++. instead of setting variables on command line. can use python declare , initialize data members in c++ code? thanks again mike interfacing between c/c++ , python heavily documented , there several different approaches. however, if you're setting values may overkill use python, more geared toward customis

taking a screenshot of user's current page in ruby on rails -

this fo debugging purpose, please take account following: the user logs in his/her account manually fetching url not work - screenshot must happen when user access admin pages. would love receive guidelines specific ruby on rails , heroku (i guess heroku not issue dump screenshot s3). so ideally mentioned in #1, when user access page, app takes screenshot of entire page , dumps in tmp folder. can point me how handle that? in order screenshot of user seeing, have have code on user's machine uses underlying operating system api take screenshot. api calls involved different windows, mac os x , linux. ruby on rails executes on remote server , generates html , javascript etc. sent user's web browser. html rendered browser , javascript executes within browser's sandbox, has no direct access operating system api. important point there no direct interaction between server-side code , os running on user's computer. if possible massive security hole. the

Django haystack search returning items that are excluded -

i have been having issues django-haystack , need help. i run site indexes projects , projects in status should not seen, ie status='de' , status='pr' my current setup is. from haystack.indexes import * haystack import site models import project class projectindex(realtimesearchindex): project_name = charfield(document=true, use_template=true) description = charfield(use_template=true, model_attr='description') location = charfield(use_template=true, model_attr='location') owner = charfield(model_attr='owner') def search(self): return project.objects.filter(status='ap').exclude(status='pr').exclude(status='de') def index_queryset(self): """used when entire index model updated.""" return project.objects.filter(status='ap').exclude(status='pr').exclude(status='de') def get_queryset(self): ""

ios - Detecting individual touches on Multiple UIImageviews? -

i have added around 15 16 uiimageviews on view using following code - (void) setupcellsusingimage: (uiimage *) masterimage { rows = 4; cols = 4; containercellheight=hight/4; containercellwidth=width/4; nsinteger row, col; cgimageref tempsubimage; cgrect temprect; cgfloat ypos, xpos; uiimage * auiimage; uiimageview *label; cellarray = [[nsmutablearray new] autorelease]; int =0; (row=0; row < rows; row++) { ypos = row * containercellheight; (col=0; col < cols; col++) { xpos = col * containercellwidth; label = [[uiimageview alloc]init]; temprect = cgrectmake(xpos, ypos, containercellwidth, containercellheight); tempsubimage = cgimagecreatewithimageinrect(masterimage.cgimage, temprect); auiimage = [uiimage imagewithcgimage: tempsubimage]; imgview = [[uiimageview alloc] initwithimage:auiimage]; imgview.tag =i; i++; nslog(@"original tags = %d",label.tag); [cell

android - Onstop method is called when Orientation changes -

when change orientation of android application, calls onstop method , oncreate. how avoid caling onstop , oncreate when orientation changes? it have been long time since question have been active, sill need answer this. had same issue , found answer. in manifest should add android:configchanges=orientation|screenlayout|layoutdirection in activity should not call default actions on orientation change. ... <activity android:name=".activity" android:screenorientation="portrait" android:configchanges="orientation|screenlayout|layoutdirection|screensize" ... , in activity: @override public void onconfigurationchanged(configuration newconfig) { super.onconfigurationchanged(newconfig); // overrides default action } original example: http://android-er.blogspot.fi/2011/05/prevent-activity-restart-when-screen.html

vim - Couldn't find package libncurses5-dev -

while installing vim 7.3 on ubuntu 10.04 lts, encounter error below checking --with-tlib argument... empty: automatic terminal library selection checking tgetent in -lncurses... no checking tgetent in -ltermlib... no checking tgetent in -ltermcap... no checking tgetent in -lcurses... no no terminal library found checking tgetent()... configure: error: not found! need install terminal library; example ncurses. or specify name of library --with-tlib. and googled , found need install libncurses-dev , typed $ sudo apt-get install libncurses-dev package libncurses-dev not available, referred by another package. may mean package missing, has been obsoleted, or available source e: package libncurses-dev has no installation candidate when change libncurses-dev libncurses5-dev , got error $ sudo apt-get install libncurses5-dev e: couldn't find package libncurses5-dev so happened?

iphone-webservice-image -

i want display image in uitableviewcell, in uitableview data fetch webservice , use xmlparsing i.e. -(void)parser:(nsxmlparser *)parser didstartelement:(nsstring *)elementname namespaceuri:(nsstring *)namespaceuri qualifiedname:(nsstring *)qname attributes:(nsdictionary *)attributedict{ } -(void)parser:(nsxmlparser *)parser foundcharacters:(nsstring *)string { } -(void)parser:(nsxmlparser *)parser didendelement:(nsstring *)elementname namespaceuri:(nsstring *)namespaceuri qualifiedname:(nsstring *)qname { } now , if xml ouput return image path name,, like hhtp://www.abc.com/a.png then uitableviewcell can display image ? if not how can display image... nsdata *data = [[nsdata alloc] initwithcontentsofurl:[nsurl urlwithstring:@"http://www.abc.com/a.png"]]; uiimage *img = [[uiimage alloc] initwithdata:data]; cell.imageview.image = img; [img release]; [data release];

iphone - When to do finalize statement in sqlite in iOS? -

when using sqlite in ios, when finalize statement ? do need finalize statement after every query ? what difference between reset , finalize ? if reset, need finalize ? thanks. you use sqlite3_finalize() function when finished statement, either because did one-off query following: const char *sql = "select count(*) bonds molecule=? , structure=?"; sqlite3_stmt *bondcountingstatement; unsigned int totalbondcount = 0; if (sqlite3_prepare_v2(database, sql, -1, &bondcountingstatement, null) == sqlite_ok) { sqlite3_bind_int(bondcountingstatement, 1, databasekey); sqlite3_bind_int(bondcountingstatement, 2, numberofstructurebeingdisplayed); if (sqlite3_step(bondcountingstatement) == sqlite_row) { totalbondcount = sqlite3_column_int(bondcountingstatement, 0); } else { } } sqlite3_finalize(bondcountingstatement); or if done prepared statement you'll never need again (possibly because you're cleaning on e

css - Table is forcing width of div in IE -

we have page similar following: <?xml version="1.0" encoding="iso-8859-1"?> <!doctype html public "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" /> <title>welcome application</title> <style type="text/css"> html, body, div, table, tr, th, td { border: 0; font-family: inherit; font-size: 100%; font-style: inherit; font-weight: inherit; margin: 0; padding: 0; vertical-align: baseline; } html { font-size: 100%; } body { background: #fff; color: #036; font-family: verdana, sans-serif; font-size: 11px; line-height: 18px; } * html body { text-align: center; } .container { display: b

git svn - git-svn creates a lot of branches appended with @rev -

possible duplicate: git-svn clone | spurious branches i converted svn repo git git-svn. everything seems fine, there lot of branches named branch-name@rev (i.e. remotes/release-1.0@10920 ), not in svn. does know come from? this may not time kinds of refs show up, 1 place show when entire project moved (renamed) in svn.

jquery - Dialog box not showing on the second click of the confirmation box ok button? -

i have button named submit, when click button got confirmation box. if click ok button on confirmation box got dialog box. if cancel dialog box , try once again not able see dialog box. html looks this <input type="submit" id="btnsubmit" class="button" value="<%= osfladminresources.text_users_permanently_delete_selected_users %>" onclick="return validate();" /> jquery :- function validate() { if(confirm("<%= osfladminresources.text_delete_warning_popup_message %>")) { dialog(); return false; } else { return false; } } function dialog() { $("#dialogtoshow").dialog({ title: "confirm password", closetext: "cancel",

syntax - Simple C program - help needed -

i have c++ snippet: #include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { char s[2048]; while (fgets(s, sizeof(s), stdin)) { char *pos = strpbrk(s, ">\r\n"); if (pos != 0) { char *end = strrchr( pos, '<' ); if ( end ) *end = '\0'; fputs(pos+1, stdout); } return 0; } } although when trimming text file using it, works 1 line e.g. trims 1 line only. if try trim multiple lines e.g. file 30 lines in it, trims 1 line still. pretty confused, appreciated. example text file: report2011510222820.html: <td width="60%" bgcolor="#ffffff" class="tablebody" valign="top">c:\users\admin\mon.bat</td> report2011510222820.html: <td width="60%" bgcolor="#ffffff" class="tablebody" valign="top">c:\test123.bat</td> o

.net - Is there a way to call a stored procedure with Dapper? -

i impressed results of dapper micro orm stackoverflow.com. considering new project , have 1 concern times project requires have stored procedure , have search lot on web not found stored procedure. there way have dapper work stored procedure? please let me know if possible otherwise have extend in way. i checked in rich support procs: in simple case can do: var user = cnn.query<user>("spgetuser", new {id = 1}, commandtype: commandtype.storedprocedure).first(); if want more fancy, can do: var p = new dynamicparameters(); p.add("@a", 11); p.add("@b", dbtype: dbtype.int32, direction: parameterdirection.output); p.add("@c", dbtype: dbtype.int32, direction: parameterdirection.returnvalue); cnn.execute("spmagicproc", p, commandtype: commandtype.storedprocedure); int b = p.get<int>("@b"); int c = p.get<int>("@c"); additionally can use exec in batch, more clunky

integer - R: remove data in a logical variable using a factor variable -

i made following example code give idea of real dataset. have 2 datasets, factor variable list , logical variable ok . df1 <- c("a","b","c","d","e","f","g") df2 <- c("a","d","e") list <- factor(as.integer(df1 %in% df2)) ok <- c(true,false, false,false,true,false,true) the list , ok variables has both length of 7. want remove samples in list condition true in ok . example: first, fifth , seventh variables need removed in list variable. can me this? thanks easier think. list[!ok]

php - "Warning: PDO::prepare() expects parameter 2 to be array, string given" - when only one argument was specified -

i'm not experienced pdo , mysql query.. look @ function: function add($mynick, $friend) { $dbh = new pdo(dsn,username,password); $sth = $dbh->prepare('update pinfo set friends=concat_ws(',' , friends, $friend) nick = :mynick'); $sth->bindparam(':mynick', $mynick); //$sth->bindparam(':friend', $friend); $sth->execute(); } this function not working: warning: pdo::prepare() expects parameter 2 array, string given in /test5.php fatal error: call member function bindparam() on non-object in /test5.php i tried blind $fliend var , in concat_ws , or removing $var , bindparam ; db connection , db table ok. why wrong ? if try use pdo simple update query, without concat_ws works. $sth = $dbh->prepare(' update pinfo set friends=concat_ws(',' , friends, $friend) nick = :mynick '); i've reformatted query make error more obvious. don't see it? check ou

winapi - It is posible to create a hotkey in a Delphi console application? -

i tried: registerhotkey(getconsolewindow(),$29a,mod_alt,'a') but didn't work. do have idea? you need message loop receive wmhotkey messages. have message loop in console application? edit: try capital 'a' instead of 'a'. because last parameter of registerhotkey wants virtual-key code. , virtual-key code of letter 0x41 = 'a'.

c# 4.0 - How can I save the picture on image control in wpf? -

i have simple wpf application wia .my app has image control... wondering how can save scanned picture on hard disk? depends on type of image.source , assuming have bitmapsource in article should along lines: var encoder = new pngbitmapencoder(); encoder.frames.add(bitmapframe.create((bitmapsource)image.source)); using (filestream stream = new filestream(filepath, filemode.create)) encoder.save(stream);

php - Is unsetting $_SESSION variable a bad idea before setting session var? -

in page i'm designing, i'm storing data via $_session since i'm calling pages dynamically jquery wanted add security , unset($_session['var']) before set them in case happen. question if unsetting session bad idea before set, or valid? it's unnecessary , have no effect. if calling sensitive data through ajax calls, need secure against attacks, secure normal page - example having session-based login, , checking whether current user logged in!

java - If I build a Spring app on App Engine, will it use multithreading by default or can it be configured to? -

according latest app engine news , java apps can minimize number of instance hours use enabling multi-threading - allow them use more resources per instance-hour. if build spring app on app engine, use multithreading default optimize resource use? or there need configure take advantage of app engine feature? servlet multithreading on appengine off default. can enable adding <threadsafe>true</threadsafe> element appengine-web.xml . in case servlets must thread safe: means should not have internal state (fields) or access state data must synchronized. about spring: i'm not familiar spring internals, not if it's thread safe.

c++ - Dynamic 2d shadows - Blending issue -

Image
good day dear community. i'm working on dynamic shadows game shall work on, happens bring problem, in hope (i'm actually) help. this right now: notice red square, want gradually fade away light source moves out of sight. check if point of polygon inside circle's radius, of course doesn't solve it; said want fade gradually until blacks out if light far away. there's 1 idea on mind hope better one. not talk since it's last option , find 'brute force' technique. this how render light: glbegin(gl_triangle_fan); { graphics::instance()->setcolor(r_,g_,b_,intensity_); glvertex2f(posx_,posy_); glcolor4f(0.f, 0.f, 0.f, 0.0f); (angle_=0.0; angle_<=3.14159265*2; angle_+=((3.14159265*2)/64.0f) ) { glvertex2f(range_*(float)cos(angle_) + posx_, range_*(float)sin(angle_) + posy_); } glvertex2f(posx_+range_, posy_); } and how blend it: glbl

html5 - custom fonts, eot, not working -

i cant custom fonts work in ie7 , ie8: http://i-creative.dk/ijob/ it works fine in ie9, firefox , chrome... for firefox , chrome fonts in ttf , ie, it's in eot however, works in ie9 :( try css formatting instead: @font-face { font-family: 'fontname'; src: url('/path/to/font.eot?') format('eot'), url('/path/to/font.otf') format('otf'), url('/path/to/font.ttf') format('truetype'); } this use (sans otf, woff & svg instead). , have never had of ie's not render font.

authorisation REST service in Python -

i quite new python world. since in design @ deciding phase whether choose python primary language implement software. task to: - implement set of restful web services - authorizing http methods group of users, required use xacml policies definition (or can standard) , saml info. exchange thanks in advance recommendations, eric if question libraries can use implement these restful services, have basehttpserver module of standard python library. the following code shows how easy implement simple server accepting requests: class myhandler(basehttprequesthandler): def do_get(self): try: f = open(curdir + sep + self.path) #self.path has /test.html self.send_response(200) self.send_header('content-type', 'text/html') self.end_headers() self.wfile.write(f.read()) f.close() except ioerror: self.send_error(404,'file not found: %s' % self.path)

How can I turn off the Visual Studio tooltip? -

i have visual studio 2010 , have installed productivity powertools . visual studio quickinfo hiding power tools interactive tooltips: when hover on variable 2 tooltips, , 1 visual studio covering powertools interactive tooltip. how can turn off visual studio tooltip? i had same problem , solved using little visual studio extension noah richards posted answer in this question download disablequickinfo.vsix file , install it. tooltips (or quickinfo called) should gone.

javascript - Difference between eval and window.json.parse for a dealing with a responseText? -

i have following code @ hand var finalcompletedata = eval("("+jsonresponse.responsetext+")"); when used this, received security flaw error in fortify saying might lead javascript hacking. so, changed var finalcompletedata = window.json.parse(jsonresponse.responsetext); for this, fortify did not show error. window.json.parse method ? can please explain. in advance :-) eval execute javascript code supposed evaluate, , evaluates highest level of security. means if response text returns non-json code, valid javascript, eval execute it. sky limit this, can add new functions, change variables, redirect page. with window.json.parse json evaluated, risk of rogue code getting entered much less.

How do you install perl DBD::Oracle on OSX Snow Leopard 10.6 -

i'm trying connect oracle 10.2.0.4 on remote system intel mac running osx 10.6 snow leopard. i've tried using perl cpan install dbd::oracle (dbi worked ok) compilation errors. provide easy follow guide? getting mac install of perl play nicely oracle bit of pain - once it's running fantastic, getting running little frustrating.. the below has worked me on few different intel macs, there superfluous steps in there , not going same other platforms. this require use of shell, root user , bit of cpaning - nothing onerous first off create directory oracle pap - libraries, instant client etc sudo mkdir /usr/oracle_instantclient64 download , extract 64 bit instant client packages oracle above directory create symlink within directory 1 of files in there sudo cd /usr/oracle_instantclient64 sudo ln -s /usr/oracle_instantclient64/libclntsh.dylib.10.1 libclntsh.dylib the following dir hardcoded oracle instant client - god knows why - need create , symlink

SQL Server Training Books and Videos -

i starting out in world of sql server database/server administration, due unexpected workload.. can suggest good, free training books or free training videos. which cover profiler, perfmon , other essential aspects of administering server i have read book how become exceptional dba brad m mcgehee more dba person. (i fit profile not wage @ moment) 10 years. there! probably best documentation sql books online http://msdn.microsoft.com/en-us/library/ms130214.aspx videos covering backup basics , few other tips/tricks here http://www.sqlservervideos.com

Oracle delete row using sequence number -

my db knowledge quite limited , trying delete row following query: delete table column in (select sequence .currval dual); this used in .sql clean database after integration tests run in maven. have googled still haven't found answer delete statement work. appreciated! you can't use currval in delete statement, can read here: http://www.orafaq.com/wiki/ora-02287 but since using sql scripts, can in sql*plus: sql> create table t( id number); table created. sql> create sequence seq; sequence created. sql> insert t (id) values (seq.nextval); 1 row created. sql> column new_value curseqval sql> select seq.currval dual; ---------- 1 1 row selected. sql> delete t id = &curseqval; old 1: delete t id = &curseqval new 1: delete t id = 1 1 row deleted. regards, rob.

Can't install jenkins (AKA hudson) slave on windows -

i have followed instructions: first, need start jenkins before installing it.(i did on server command line running "java -jar jenkins.war".) now connect jenkins going following url http://:8080/ once jenkins started way, "install windows service" link in "manage jenkins" page (requires .net framework version >= 2.0): don't have install windows service link in manage jenkins page. anyone? please? why not use tomcat host jenkins instance? tomcat runs fine windows service.

BB Simulator does not start -

when run bb simulator; keep getting following error: port in use - blackberry smartphone simulator could not open port 19780 because in use program (possibly instance of simulator). must close other program network operations function correctly. i have modified rimpublic.properties under mds/config, no luck. [udp] udp.receive.port=29781 udp.send.default=29780 any suggestions mds , simulator running??? running win 7. i had microsoft client isa server installed on machine , seems causing problems bb mds simulator. mds , bb simulator work fine after disabling isa client. in general if mds simulator having problems running, there web server running on machine causing port conflicts.

Losing OpenGL Textures in Android after a resume -

my game working correctly except in case press home button resume. needs done use textures again? have tried calling onpause , onresume on glsurfaceview (when activity's onpause , onresume called). any ideas doing wrong? if else fails, reload textures: pseudocode for tex in textures: if glistexture(tex.opengl_name) == false: glgentextures(1, &tex.opengl_name) glbindtexture(tex.texture_target); glteximage(..., texture.image);

Linux utility for Disk health Monitoring -

we looking implementing in-memory utility can recover system in case of disk/filesystem lockup. utility has detect lockup , take corrective action rebooting or shutting down interface. the server platform gentoo linux 2.4 any suggestions on - existing utility or scripting method work best (expect, native c++)? you'll want s.m.a.r.t. monitoring tools (smartmontools) http://en.wikipedia.org/wiki/s.m.a.r.t . note not statistics correlate impending drive failure, , (for brands , models) may need pass in special flags or garbage. see wikipedia article attributes indicate danger. the command smartctl . may need sudo . smartctl --all give summary of drives, spinning them briefly check health.

How does iphone application life cycle works in terms of development? -

here's understand in terms of high level view. user launches application load mainwindow.xib uiapplication initialized waiting events execute events exit application my questions info.plist , main.m ,* appdelegate * , viewcontroller.xib files fit in above sequence or called in terms of sequence? have nice day! user launches application means int main(int argc, char *argv[]) in main.m invoked. everything else happens result of main method, particularly call uiapplicationmain. from uiapplicationmain docs this function instantiates application object principal class , and instantiates delegate (if any) given class , sets delegate application. sets main event loop, including application’s run loop, , begins processing events. if application’s info.plist file specifies main nib file loaded, including nsmainnibfile key , valid nib file name value, function loads nib file. it's explained there.

ruby on rails 3 - RSpec tests with devise: could not find valid mapping -

i'm trying run controller specs devise 1.3.4. (and factory girl) followed instructions in git wiki project. able log in user using login_user method created in macro, login_admin fails following error: ... sign_in factory.create(:admin) not find valid mapping #<user id: 2023, email: "admin1@gmail.com", .... > factory: factory.define :user |f| f.sequence(:username) {|n| "user#{n}"} f.sequence(:email) {|n| "user#{n}@gmail.com"} f.email_confirmation {|fac| fac.email } f.password "a12345den123" f.password_confirmation "a12345den123" # f.admin 0 end factory.define :admin, :class => user |f| f.sequence(:username) {|n| "admin#{n}"} f.sequence(:email) {|n| "admin#{n}@gmail.com"} f.email_confirmation {|fac| fac.email } f.password "a12345den123" f.password_confirmation "a12345den123" f.admin 1 end controller macros module: module controllermacros def lo

class - PHP - best way to initialize an object with a large number of parameters and default values -

i'm designing class defines highly complex object ton (50+) of optional parameters, many of have defaults (eg: $type = 'foo'; $width = '300'; $interactive = false; ). i'm trying determine best way set constructor , instance/class variables in order able to: make easy use class make easy auto-document class (ie: using phpdocumentor) code elegantly in light of above, don't want passing constructor ton of arguments. passing single hash contains initialization values, eg: $foo = new foo(array('type'=>'bar', 'width'=>300, 'interactive'=>false)); in terms of coding class, still feel rather have... class foo { private $_type = 'default_type'; private $_width = 100; private $_interactive = true; ... } ...because believe facilitate documentation generation (you list of class' properties, lets api user know 'options' have work with), , "feels" right way it. but

ruby 1.9.2 lambda with paperclip -

i upgrading working app 1.9.2 can't find answer following : i create asset in controller : @asset = asset.new(params) and in model use lambda dynamically generate styles : has_attached_file :asset, :styles => lambda { |attachment| attachment.instance.choose_styles} then check value in params so: def choose_styles if self.item_name == 'car' { :small => ["200x200>"], :medium => ["400x400>"], :large => ["700x700>"], :full_screen => ["1000x700>"] } else ........ end the problem item_name nil in 1.9.2 till after has been run seems set params. works switching 1.8.7 is can see me please ?? thank rick i know not answer fits question. way, can switch carrierwave ( https://github.com/jnicklas/carrierwave ). can choose formats in more granular way creating various versions , nesting them. as example, ipothetic assetuploader be: ... version :thumb_200x200 process :

javascript - problem with clone - jquery/php -

i have div has inside piece of php code i need replicate div , php, how can that? clone method doesn't work php , clone div without php code. <div id="wrap" style="margin: 80px;"> <p> <label>Área profissional :</label> <select name="area" class="area"> <option selected="selected">seleccione Área</option> <?php $sql=mysql_query("select id_formation_area, area formation_area"); while($row=mysql_fetch_array($sql)){ $area=$row['area']; $id_area=$row['id_formation_area']; echo '<option value='.$id_area.'>'.$area.'</option>'; } ?> </select> <label>profissão:</label> <select name="profissao"

sql - using declare variables in ORACLE -

hope doing well. having syntax issue declaration in oracle. using these variables on ms sql server , work fine; however, how declare these in oracle? use in ms sql server: declare @from_dt datetime declare @end_dt datetime declare @location varchar(100) set @from_dt = '04/01/2011' set @end_dt = '05/09/2011' set @location ='va' thanks much! you cannot declare variables outside of pl/sql block. the format of variable declarations inside pl/sql block described detailed in manual (including examples): http://download.oracle.com/docs/cd/b28359_01/appdev.111/b28370/fundamentals.htm#cihggiah

ruby hash memory leak after key deletion -

helo, can't succeed how release memory after key deletion in hash. when delete key hash, memory not released nor after calling gc.start manually. expected behavior or gc not release memory when keys deleted hash , these objects leaking somewhere? how can delete key in hash in ruby , unallocate in memory? example: irb(main):001:0> `ps -o rss= -p #{process.pid}`.to_i => 4748 irb(main):002:0> = {} => {} irb(main):003:0> 1000000.times{|i| a[i] = "test #{i}"} => 1000000 irb(main):004:0> `ps -o rss= -p #{process.pid}`.to_i => 140340 irb(main):005:0> 1000000.times{|i| a.delete(i)} => 1000000 irb(main):006:0> `ps -o rss= -p #{process.pid}`.to_i => 140364 irb(main):007:0> gc.start => nil irb(main):008:0> `ps -o rss= -p #{process.pid}`.to_i => 127076 ps: use ruby 1.8.7. i've tried ruby 1.9.2, not better. see stackoverflow: how malloc , free work for variety of reasons (spelled out in citation above) virtual

jsf 2 - JSF calling viewparams for every AJAX request -

i have jsf page accepts viewparam , sets variable looks respective entity database , load bean found details follows: <f:metadata> <f:viewparam name="attractionid" value="#{attractionsbean.attractionid}" /> </f:metadata> i have google map using primefaces api , when marker dragged, ajax call issued update marker location. <h:outputtext value="location" /> <f:view contenttype="text/html"> <p:gmap id="gmap" center="41.381542, 2.122893" zoom="10" type="hybrid" style="width:380px;height:350px" model="#{attractionsbean.attractionmodel.mapmodel}" markerdraglistener="#{attractionsbean.onmarkerdrag}" onmarkerdragupdate="growl" /> </f:view> the problem after every marker drag event , ajax call, method setattractionid metadata cal

css - main content div won't center -

i have twitter layout, sorta.. main table kinda looks it, way it's sectioned off... html { -webkit-user-select: none; text-shadow: 2px 2px 2px #000; color: #fff; font-smooth: always; padding: 0; width: 100%; height: 100%; background: url("./img/main_back.jpg"); background-size: cover; background-attachment: fixed; background-repeat: no-repeat; } body { height: 100%; width: 100%; } .content_wrap { position: relative; top: 5px; display: inline-table; margin-right: auto; margin-left: auto; width: 90%; height: 100%; background-color: transparent !important; } .left_table { overflow: hidden; display: table-cell; text-align: center; width: 50%; height: 100%; padding-left: 5px; padding-bottom: 20px; } .right_table { display: table-cell; text-align: center; width: 20%; height: 100%; } html5 doc type header <-- floated left section <-- floated right section <-- content wrap section <-- left_t