Posts

Showing posts from March, 2013

Handling standby on iPad using Javascript -

regarding ipad events, how determine if/when ipad changing awake state standby state? what put mobile-safari web app in locked state whenever ipad becomes inactive/standby , ask pin when becomes awake again. i agree there ought signal can hook on to know when application goes sleep , when wakes up, should able figure out when safari wakes indirectly. when webview goes background, safari puts in sleep. pauses video, defers network request, stops updating ui , pauses setinterval/settimeout operations. js never aware (as far can tell) how these things happened, can tell has happened. simplest way use build regularly invoked method , check see if it's been unexpectedly long time since last update. if expect update every 10 seconds , it's been 5 minutes, can sure device has woken up. here's quick example thought up: var inttime = new date().gettime(); var gettime = function() { var intnow = new date().gettime(); if (intnow - inttime >

performance - My Drupal site uses approx 30mb per page (node & user profiles) load. Acceptable or not? -

i using drupal , website uses approx 30mb per page load nodes , user profiles. website has round 150 contributed modules in addition few core optional modules. of them small , installed improve user experience. my php memory limit 128mb. is 30mb per page acceptable?? , how many page loads can handled in 128mb?? any idea? honestly, @ 30mb app sipping on memory. php memory limits set pretty low. as far how many "page loads can handled 128mb" of memory, well, that's not valid. when request comes in, apache (or whatever server you're using) hands request mod_php or fcgi , php code interpreted, compiled, run, , quit. "application" doesn't act daemon waiting requests come in, memory consumes used duration of request , gets released use other requests/processes. that 128mb limit per request . means long have enough memory (and apache child processes, etc) can handle additional requests. if want see how application performs under load, che

c# - How to enable Virtual Space in AvalonEdit? -

i want achieve "virtual space" functionality, similar 1 in visual studio, in avalonedit. i.e. caret positioned beyond end of text line, , if press key, there spaces automatically added match. i used feature, neither googling nor studying avalonedit's code gave me clues on how enable it, if supported @ all. if not, suggestions how extend caret handling mechanisms nice. thanks! edit: virtual space support has been added avalonedit in version 4.2.0.8283. set texteditor.options.enablevirtualspace = true; . below original answer. it's not supported. if want try adding it, make sure read "coordinate systems" documentation (in file on codeproject). you'll want extend "visual column" positions after line end valid. , you'll have adjust position<->column calculations (visualline.getvisualcolumn , friends). use textview.widespacewidth figure out columns past end of line. the above should allow use mouse place ca

php - Generate custom Windows-based EXE installer from *nix webserver on the fly (OpenVPN client custom installer) -

this related this other question . need dynamically generate custom windows exe installer *nix machine (running php, or whatever) contains custom files installed on client's machine. this used generate client-specific openvpn installers based on preferences , authentication information. runtime not important, can done async. some ideas, tried , not working: use scheme similar ninite.com, downloaded executable same, filename different, installer uses information in filename make decisions. using resource editor edit prebuilt installer's resources. not unix resource editors windows executable rare, creates new problems, , don't solve problem of different files being installed. what work best nsis/innosetup compiler (targeting windows) running on unix, other inventive solutions okay. answering own question, seems both nsis (used default on openvpn source code) , inno setup can run on linux. inno setup can used under wine, it's command line utility

Maven annotation processing with maven-compiler-plugin -

i try compile code contains annotations generate source code. use maven-compiler-plugin , build-helper-maven-plugin . pom looking that: <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <version>2.2</version> <configuration> <source>1.6</source> <target>1.6</target> <generatedsourcesdirectory>${project.build.directory}/generated-sources/apt</generatedsourcesdirectory> </configuration> </plugin> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>build-helper-maven-plugin</artifactid> <version>1.5</version> <executions> <execution> <phase>generate-sources</

xcode - UIPopovercontroller detached from UIButton -

i'm running problem detached uipopovercontroller , hoping has seen behavior before. my app runs in landscape mode , offers number of popover elements using presentpopoverfromrect call. launched within top view while others presented view buried deep in display. popovers seem work fine if popover presented upper 2/3rds of ipad's display when attempting launch popover bottom 1/3 of display popover displayed detached uibutton. x coordinate appears correct, y coordinate of popover tends in middle or top of ipad screen. i've played around presenting popover using fixed position creating cgrect object in lower 1/3 of display when ipad renders popover either renders popover in upper 2/3rd of view or bottom of screen (if force cgrect value large y value). at point i'm out of ideas , hoping on forum has seen or can make suggestions try. thanks , help, wes i able fix issue , thought i'd share solution incase else has same problem. the solution add c

java - How to Insert Image into JTable Cell -

can point me in right direction on how add image java table cell. jtable provides default renderer icons. need tell table data stored in given column can choose appropriate renderer. done overriding getcolumnclass(...) method: import java.awt.*; import javax.swing.*; import javax.swing.table.*; public class tableicon extends jframe { public tableicon() { imageicon abouticon = new imageicon("about16.gif"); imageicon addicon = new imageicon("add16.gif"); imageicon copyicon = new imageicon("copy16.gif"); string[] columnnames = {"picture", "description"}; object[][] data = { {abouticon, "about"}, {addicon, "add"}, {copyicon, "copy"}, }; defaulttablemodel model = new defaulttablemodel(data, columnnames); jtable table = new jtable( model ) { // returning class

How to read list elements using Mootools -

how read each list elements using mootools in follows, <ul id="tickervertical"> <li>first</li> <li>second</li> <li>third</li> <li>fourth</li> <li>fifth</li> <li>sixth</li> <li>first</li> <li>second</li> <li>third</li> <li>fourth</li> <li>fifth</li> <li>sixth</li> </ul> thanks not sure mean "read" var items = $('tickervertical').getelements('li'); items.each(function(item, index){ // item , index @ service });

java - How to install third-party APIs? -

sorry if has been asked before, searched couldn't find anything. i'm novice (like, moving on true object-oriented programming) java programmer taking ap computer science online. outside of class, i've been working on programs personal use. 1 program i'd write needs third-party apis, notably apache commons. i'd have google's guava api available, among others. problem is, have no idea how make apis available ide. i'm still trying decide on ide, i'd make apis available system-wide if possible, @ minimum need compatibility intellij idea 9 ce. i'm on mac osx, have work on windows pc. you need download necessary jars , in netbeans, believe there "libraries" or "classpath" menu option somewhere toward end. thats you'll need add libraries plan on using referencing jars you've downloaded. you can see here website

c# - HwndSource win32 integration with Ribbons and KeyTips -

my situation rather complex, i've seen other people this. unfortunately, there no mention of specific problem. in process of trying integrate wpf usercontrol including ribbon win32 host application. far, has been working pretty neat (to surprise, even). using hwndsource create raw win32 child-window , embed win32 host top-level window. have tried tabcontrols, buttons, radiobuttons, webbrowsers , inside usercontrol , usable within win32 host application. and, of course, there ribbon control @ top row of usercontrol's grid. here's doing: mhwnd = new hwndsource ( 0, 0x40000000 | 0x10000000, 0, left, top, width, height, "cintegrationtest", parenthandle); muserctrl = new usercontrol1 (); mhwnd.rootvisual = muserctrl; this works rather good. have other controls (like edit , few buttons) in usercontrol1 below ribbon. when keyboard focus inside 1 of these controls, can use alt+ access keytips of ribbontabs , it's elemen

multithreading - How to catch a Lua exception in C# -

i using assembly named luainterface run lua-code inside c# application. during lua execution create winforms & map event handlers (lua-methods) them. the problem dostring (aka runluacode ) method runs init routine , constructors. fine , intended, dostring function acts non blocking function returns while lua-created-forms still there. means exception (null-ref , alike) not raised during constructor not handled lua error handling crashes way wndproc of editor - kills editor , make error handling virtually impossible. is there way create new thread / process / appdomain handles it's own wndproc sub-task needs handle exceptions? should block editor @ dostring while loop in lua until forms closed? what other options have? any advice on matter appreciated! another lua enthusiast!! finally! :) toying idea use lua macro scripting in .net apps. i not sure it. wrote sample code , seems working ok. simple try catch around dostring gets luaexceptions. dostring

javascript - How to keep child elements from interfering with HTML5 dragover and drop events? -

i have <div> drop target have attached 'drop' , 'dragover' events to. <div> contains image inside anchor tag (simplistically: <div><a><img /></a></div> ). child elements of target seem block 'drop' or 'dragover' events being triggered. when dragged element on target, not on child elements, both events triggered expected. the behavior achieve 'dragover' , 'drop' events triggered anywhere on target <div> , regardless of existence of child elements. somewhat oblique original question, googled way here wondering following: how make <img /> , child of <div draggable="true">...</div> container, behave correctly handle move container? simple: <img src="jake.jpg" draggable="false" />

ZookeeperConnectionException in HBase Standalone mode -

i'm using hbase-0.90.0. i'm running in standalone mode. while trying execute commands "hbase shell" giving me following error. hbase(main):003:0> status 'detailed' error: org.apache.hadoop.hbase.zookeeperconnectionexception: org.apache.hadoop.hbase.zookeeperconnectionexception: org.apache.zookeeper.keeperexception$connectionlossexception: keepererrorcode = connectionloss /hbase i'm new hbase. can please me out problem? thanks in advance for 1 reason or hbase client not talking zookeeper. had same problem , issue me hbase config (hbase-site.xml) had wrong port zookeeper (the default 2181 , had set 2182 incorrectly). config using zookeeper @ http://hbase.apache.org/book.html#zookeeper . also checking hbase , zookeeper think names , are. usual suspect /etc/hosts file has entries localhost / 127.0.0.1. make sure localhost has 1 line localhost , put aliases 127.0.0.1 on single line in /etc/hosts sometimes having ipv4 , ipv6 entries i

windows - How to get Bak file or MDF without close connection sql server? -

i have database (ms 2005 server). how bak or mdf file but; running windows 2008 server on 600 stuffs using db. if .bak file or mdf. must close connection. dislike it. there useful methods or method bak or mdf? method may exe or ms sql property or tool? you not need drop users make backup. right click database in sql server management studio -> tasks -> up even better, setup regular backup schedule. here's further instructions on backing sql server 2005 .

asp.net mvc razor: How to directly access .cshtml page? -

how can directly access .cshtml file in asp.net mvc using razor view engine? for example have url: localhost/home/about. load site inside "master" page. i want load page without loading master page. thinking use url: localhost/home/about.cshtml. it's not working. how can load view page without loading master page? you can use method html.partial this: @html.partial("about") edit i might have missunderstood question. if want avoid including master page need remove layout. add top of view: @{ layout = null; }

Howto disable mirror repository in maven settings -

in maven ~./.m2/settings.xml have defined mirror , repositories: <mirrors> <mirror> <id>someid</id> ..... </mirro> </mirrors> ... <profiles> <profile> <id>default</id> <activation> <activebydefault>true</activebydefault> </activation> <repositories> <repository> <id>repo....</id> .... </profile> </profiles> this works fine. there projects want disable mirror , default profile. know can define seperate profile repositories, don't know how can tell maven eclipse plugin not use default profile or specific profile. also: how can change mirror project? copy settings.xml file, remove mirror entry , tell maven use --settings file command line option. use xsl

Show progress of running java process, even after reopening webpage -

i working company developing web based software j2ee. on our webapp possible upload csv file. ive got kind of reader class reads each line , processes it. (it checks if values in each csv line valid , inserts them database). along reader counts lines read show number @ end of process. users can upload file , click on 'process' button, after process starts. these processes can have long duration since csv files can big. when users closes webbrowser process still continues on server. i want users let them follow progress. when close browser , log in again. guess there should kind of id attached each process, know user's process , status of progress is? is there kind of mechanism in java can accomplish this? the simplest way track progress process write update database table - 'jobs'. when user uploads new csv file , hits 'process', can first make entry table. process periodically writes table progress. when user logs in account can see jo

c# - XDocument: saving XML to file without BOM -

i'm generating utf-8 xml file using xdocument . xdocument xml_document = new xdocument( new xdeclaration("1.0", "utf-8", null), new xelement(root_name, new xattribute("note", note) ) ); ... xml_document.save(@file_path); the file generated correctly , validated xsd file success. when try upload xml file online service, service says file wrong @ line 1 ; have discovered problem caused bom on first bytes of file. do know why bom appended file , how can save file without it? as stated in byte order mark wikipedia article: while unicode standard allows bom in utf-8 it not require or recommend it . byte order has no meaning in utf-8 bom serves identify text stream or file utf-8 or converted format has bom is xdocument problem or should contact guys of online service provider ask parser upgrade? use xmlt

c# - How to access user control properties if i load it programatically? -

i loaded user control (.ascx) programmatically like: loadcontrol("~/controls/mycontrol.ascx") . every thing ok until today when added 2 members control: public stufftype stufftype { get; set; } protected void page_load(object sender, eventargs e) { switch (stufftype) { case cardtype.a: fillgvstuff(); break; case cardtype.b: fillgvexstuff(); break; default: break; } } how can access stufftype? i found kind of solution . i think you'd this: mycontrol ctrl = (mycontrol)loadcontrol("~/controls.mycontrol.ascx"); ctrl.stufftype = ...; // put control somehwere basically, when load it, assign variable , cast type , should have access methods , properties you might want move page_load event page_prerender definetly setting property before page_load event occurs in control

android - How to delete a whole folder and content? -

i want users of application able delete dcim folder (which located on sd card , contains subfolders). is possible, if how? let me tell first thing cannot delete dcim folder because system folder. delete manually on phone delete contents of folder, not dcim folder. can delete contents using method below: updated per comments file dir = new file(environment.getexternalstoragedirectory()+"dir_name_here"); if (dir.isdirectory()) { string[] children = dir.list(); (int = 0; < children.length; i++) { new file(dir, children[i]).delete(); } }

creating and parsing a 3D array in javascript? -

this question has answer here: is possible create empty multidimensional array in javascript/jquery? 6 answers can 1 me create , parse 3d array in javascript. im having questionid each question id have selected option , optional option text. so need create 3d array questionid,optionid,optiontext(string).. thnks in advance a 1 dimension array be: var myarr = new array(); myarr[0] = "hi"; myarr[1] = "there"; myarr[2] = "dude"; alert(myarr[1]); // alerts 'there' a 2 dimensional array be: var myarr = new array(); myarr[0] = new array("val", "va"); myarr[1] = new array("val", "yo"); myarr[2] = new array("val", "val"); alert(myarr[1][1]); // alerts 'yo' a 3d array more complicated, , should evaluate proposed use of has limited scope within w

java - Is there benefit in a generified interface? -

recently in answer suggested me this: public interface operation<r extends operationresult, p extends operationparam> { public r execute(p param); } is better this: public interface operation { public operationresult execute(operationparam param); } i can't see benefit in using first code block on second 1 ... given both operationresult , operationparam interfaces implementer needs return derived class anyway , seems quite obvious me. so see reason use first code block on second 1 ? this way can declare operation implementations return more specific result, e.g. class sumoperation implements operation<sumresult, sumparam> though whether of value application depends entirely on situation. update: of course return more specific result without having generic interface, way can restrict input parameters well.

c++ - Case insensitive string::find -

is there exist case insensitive find() method std::string? you upper-case both strings , use regular find. (note: approach may not correct if have unicode string.) in boost there's ifind_first case-insensitive search. (note returns range instead of size_t ). #include <string> #include <boost/algorithm/string/find.hpp> #include <cstdio> #include <cctype> std::string uppercase(std::string input) { (std::string::iterator = input.begin(); != input.end(); ++ it) *it = toupper(*it); return input; } int main () { std::string foo = "1 foo 2 foo"; std::string target = "foo"; printf("string.find: %zu\n", foo.find(target)); printf("string.find w/ uppercase: %zu\n", uppercase(foo).find(uppercase(target))); printf("ifind_first: %zu\n", boost::algorithm::ifind_first(foo, target).begin() - foo.begin()); return 0; }

c# - Is multi-level ConcurrentDictionary still thread-safe? -

i have 4 level data structure defined this: dictionary<type1, dictionary<type2, dictionary<type3, list<type4>>>> the whole thing encapsulated in class maintains thread-safety. locks whole collection while reads/manipulates data (reading orders of magnitude more common writing). i thinking of replacing dictionary concurrentdictionary , list concurrentbag (its items don't have ordered). if so, can eliminate locks , sure concurrent collections job correctly? the concurrent collections prevent data corruption , crashes, code won't semantically equivalent current one. example, if iterate 1 of concurrent dictionaries, some of items may belong different updates : the enumerator returned dictionary safe use concurrently reads , writes dictionary, not represent moment-in-time snapshot of dictionary. contents exposed through enumerator may contain modifications made dictionary after getenumerator called. if want mai

javascript - Adding an icon to content & handling its events -

i trying use code dont know exact class google search results replace "the_search_result_class". please me find out dom class google search results on google search page. function somefunction() { alert("the user clicked on icon.") } var icon = document.createelement("img"); icon.src = chrome.extension.geturl("icon.png"); var searchresults = document.getelementsbyclassname("the_search_result_class") (var = 0; < searchresults.length; i++) { var searchresulticon = icon.clonenode(); searchresulticon.addeventlistener("click", somefunction, false); searchresults[i].append(searchresulticon); } to find out dynamic class name on page: open developer console (ctrl+shift+j) click on "elements" tab , on magnifying glass icon select element interested in on page , see html source below.

tracking - Fetching UPS Shipment Progress -

i'm aware can tracking detail package through url: http://wwwapps.ups.com/webtracking/onlinetool?inquirynumber=number there, can click on "shipment progress", posts request to http://wwwapps.ups.com/webtracking/detail is there url can progress directly? don't have fetch first page, make second post request details. thanks.

sftp - Saving remote files using Eclipse RSE -

when connect remote server using eclipse's rse can upload , edit file via sftp , can save locally can't figure out how save remote server. can't tell if functionality available or not. help! i not know sftp ssh, i'm positive files loaded remote server saved remotely. imagine same holds true sftp. understanding of rse lies on top of ecf (eclipse communcation facility) , thereby provides different transport mechanism (ssh, sftp) achieve same end result. among editing remote files.

How can I jump to function when doing C development in Emacs? -

i doing c development in emacs. if have source file open multiple functions , "the marker" @ function call e.g. int n = get_number(arg); there way can "jump to" implementation of function? e.g. int get_number(int *arg) { ... } i have done java development in eclipse , missing functionallity, because i'm not used emacs learn. you have create tag file. under unix, have etags program understands syntax of c , c++ , java ... , create tag file can used emacs. this rather old page (2004) provides more information. to jump function use m-. (that’s meta-period) , type name of function. if press enter emacs jump function declaration matches word under cursor.

c# - Can't draw on Picturebox -

suppose have form picturebox on it: where problem? rectangle disapears on picture box. why? private void picturebox1_paint(object sender, painteventargs e) { graphics gr = picturebox1.creategraphics(); gr.fillrectangle(brushes.red, new rectangle(10, 10, 50, 50)); } i checked , yeah case mentioned in comments. the problem not taking reference of graphics when painting instead pushing rectangle in picturebox's graphics wont rendered. to right need use e.graphics refrence on graphic going painted. so correct code is: private void picturebox1_paint(object sender, painteventargs e) { graphics gr = e.graphics; gr.fillrectangle(brushes.red, new rectangle(10, 10, 50, 50)); }

plsql - Oracle weird behavior string comparison with day of the week -

while below code prints 'wrong thursday',(10-feb thursday) begin if to_char(to_date('10-feb-2011','dd-mon-yyyy'),'day')='thursday' dbms_output.put_line('correct'); else dbms_output.put_line('wrong '||to_char(to_date('10-feb-2011','dd-mon-yyyy'),'day')); end if; end; the following prints 'correct',(09-feb wednesday) begin if to_char(to_date('09-feb-2011','dd-mon-yyyy'),'day')='wednesday' dbms_output.put_line('correct'); else dbms_output.put_line('wrong '||to_char(to_date('09-feb-2011','dd-mon-yyyy'),'day')); end if; end; i've been trying figure out couldn't. appreciated. in advance. to_char default space-padded: sql> begin 2 dbms_output.put_line('x' || 3 to_char(to_date('10-feb-2011','dd-mon-yyyy'),'day'

How to dynamically fill a progress bar in Flex/Actionscript? -

i want create progress bar of % of filled in different color based on variable. example 33 % fill 33 % of progress bar different color , 40 % likewise, fill 40 % of it. best way in actionscript , flex 3? the way i've done in past create custom progress bar skin, set fill gradient goes entire length of bar (even though smaller portion of bar gets drawn.) sounds strange use gradient has hard stops colors, it's pretty easy. set stop next color right next end stop previous color. here's example color changes green red @ mid point: package some.package.skins { import flash.display.gradienttype; import flash.geom.matrix; import mx.core.uicomponent; import mx.skins.halo.progressbarskin; public class coloredprogressbarskin extends progressbarskin { override protected function updatedisplaylist(w:number, h:number):void { super.updatedisplaylist(w, h); graphics.clear(); var fullwidth:int = w;

java - A convenient way to preload data in development environment datastore -

i'm developing application on google app engine using maven. when run local server have data preloaded in datastore, such local user table. server puts datastore file under web-inf/appengine-generated of target directory , cleaned before every build. there convenient way so? you have couple of options: a. backup , reload local_db.bin in build steps b. use datastore.backing_store system property with: dev_appserver.sh --jvm_flag= -ddatastore.backing_store=\path\to\local_db.bin

javascript - dynamically deploying content scripts in chrome extensions -

i want deploy content scripts sites user wants deploy them to. have list of sites, , want deploy script.js these sites. something (in background page): chrome.tabs.onupdated.addlistener(function(tabid, changeinfo, tab) { if(changeinfo.status == "complete" && isinuserlist(tab.url)) { chrome.tabs.executescript(tabid, {file:"script.js"}, function() { //script injected }); } });

php - Auto post stream (feed) to app users -

how can post stream ( $facebook->api('/me/feed', 'post', $attachment); ) app users on anytime. think can access token via $facebook->getaccesstoken(); after, how can post wall? grant publish_stream permission , use user id after instead of me : $facebook->api("/$user_id/feed", 'post', $attachment); for more information, check last edit ( edit 4 ) on answer (also follow discussion on other answer linked there).

How to start Internet Explorer browser instance with POST request -

i have 2 part question: is there way start internet explorer , have send post request url? know can start ie url , have send get, need post is there way start ie browser instance set of cookies? no, if you're in control of web application can load page post through javascript.

How to transfer a 2007 excel spreadsheet to excel 2003 without losing functionality -

i have built excel spreadsheet filters , formulas. when change format 2007 97-2003 , send client, filters no longer there , don't work. how can save 2007 excel spreadsheet 2003 file type without losing functionality? a problem can functions(like countifs() ) strictly function found in 2007 .they not valid function in 2003. if not case save in 03 format , go.

pthreads - Determine whether a thread is blocked -

does know of way determine whether thread blocking? basically, want check whether thread blocking (in case on af_unix datagram socket receive call) , send signal interrupt if is. i'm working on linux using boost.thread meaning underneath i'm using pthreads. system has nptl. i think answer "no", want see if i'm missing something. this not possible (it possible using functionality intended debuggers, neither simple, portable or safe). you not want anyway, because such use have inherent race condition. may check if thread blocking before block (in case miss waking it), or may stop blocking after find blocking. the usual method solve problem "self-pipe trick": create pipe pipe() ; the target thread, instead of blocking in recvfrom() , blocks in poll() or select() . file descriptors monitor include datagram socket , read end of pipe. to wake target thread, other thread writes single byte write end of pipe. (the recvfrom() sh

regular expression: trying to include unlimited whitespaces for any words in ASP.NET C# -

[regularexpression(@"\s*[a-z\s]\s*\s*", errormessage = "please add category name letters only")] this works fine if input words this...test test. if try this... test test test, errormessage implemented. thing don't know how many words going put in end user. there way unlimted whitespaces put in place? tell me how this? in advance. using vs2010 ([a-za-z\s]{1,}) use regex above resolve problem. baically a-za-z match word case insensitive, , \s match whitespace character , {1,} tell combination needs have 1 or number of matches. i hope helps

c# - How do I update a Strongly-Named DLL within an ASP.NET website to use a newer version of delay signed DLL? -

in debugging linkedintoolkit , downloaded dotnetopenauth source git. i've added reference i'm getting following error when compiling prebuilt websites come linkedintoolkit could not load file or assembly dotnetopenauth version 3.4.7.11039. strong name signature not modified.... considering dotnetopenauth dll delay signed, how make website compile , run? i've searched web.config , references mention of named dll. else strong name check done? if you're compiling dotnetopenauth yourself, should either turn off delay signing completely, or change key signed 1 have private key to. don't disable strong name checking -- that's security risk. curious why have compile own dotnetopenauth library though.

asp.net - Embedding Images into Email - What is the difference between ContentID and ContentLocation? -

i using aspnetemail send emails embedded images , trying choose between 2 options: contentlocation: embed images using content-location header. contentid: embed images using content-id header. i checked aspnetemail website documentation there wasn't information. suspect these options applicable embedding images in email applications? what difference between 2 settings, , how affect emails? contentid represents identifier contents of attachment. contentid can set string value. applications can use contentid implement own identification mechanisms. contentlocation contains uniform resource identifier (uri) corresponds location of content of attachment.

Format a string for cents only in C# -

i have dollar amount, 23.15. want format can return .15 or 15 want place cents in html <sup> tag. to return dollars only, used {0:c0} or without $ sign {0:n0} edit: apparently {0:c0} , {0:n0} not work me round whole number :( if need string html tags can use this: var decimalvalue = 23.15m; string value2 = decimalvalue.tostring("$ #.<sup>##</sup>"); //$ 23.<sup>15</sup> also if want amount cents instead of var value = string.format("{0:c0}", decimalvalue); // $23 use var value = string.format("{0:c2}", decimalvalue); // $23.15 zero after 'c' in '{0:c0}' format means number of signs after point.

Out of memory in Android 2.3.2 -

i have application upon start request around 10-12kb of data server (in onresume, have thread starts data server) , paints in tabular form on view. each row of view consist of 5 textview s , 2 drawable s. now, application works fine on 2.2 , previous version of os, crashes on 2.3.2 out of memory error in oncreate method (while setting layout r.main). way recreate error keep on rotating device (around 20-25 times), app keeps on switching portrait landscape mode. looked @ ddms output , see pattern. if switch between portrait , landscape mode pretty fast ... system tries run gc... showing messages such 02-09 12:20:08.617: debug/dalvikvm(109): gc_explicit freed 426k, 47% free 6201k/11655k, external 4752k/5934k, paused 122ms but before crashing prints out lot of gc messages 02-09 12:20:12.875: debug/dalvikvm(184): gc_external_alloc freed 112k, 52% free 3022k/6215k, external 5127k/5136k, paused 110ms 02-09 12:20:12.933: debug/dalvikvm(28163): gc_external_alloc freed 108k, 34% fr

What's a good programming language for a Windows GUI application that's not Java? -

i've been developing application in java few months now. more work on it, more realize bad programming languege java is, , longer wait, harder it'll switch. i'm switching now. i'd need language can handle gui , mysql queries. , importantly, i'll love. because it's come point literally hate java now. and if matters i'd prefer program in linux, it's not necessary. , it'll application windows. i recommend c# , .net. make 1 of mature , 1 of productive environment developing under windows. plus c# similar java (in it's best parts, not hate it)

jqgrid viewGridRow bug? -

i'm using tabletogrid feature, along viewgridrow feature. when viewgridrow method called, dialog displays correctly. when paging through records using pager buttons, or when close dialog , execute viewgridrow method on record, values columns names have space (" ") in them not updated. keep value placed there first viewgridrow execution. values columns names not have space updated should. i've tried recreateform:true (although property of editgridrow method, , not viewgridrow method), , did not resolve issue. tried various, semi-random combinations of other settings. below code. ideas? tabletogrid("#mytable", height:'400', ondblclickrow: function(rowid,irow,icol,e) { jquery("#mytable").viewgridrow(rowid, {closeonescape:true}); } }); <table id="mytable"> <thead> <tr class="header"> <th id="customerid">customerid</th> <th id="account id">account i

jquery - Using Xpath selectors to extract / combine data from Javascript Objects? -

i'm quite fond of cakephp set class , comes few awesome tools love. use extract or combine arrays. i wondering if there way javascripts objects/arrays of data. // desired usage: var users = {user: {0:{id:1,name:'a'},1:{id:2,name:'b'}}} var results = $.extract('/user/id', users); // results returns: // {0:1,1:2}; // /user[id>2][<5] selects users id > 2 < 5 it support on jquery or maybe sizzle. do have develop thoses functions 0 or there native/plugin xpath selector/extractor support out there ? can sizzle ? thanks lot! look library http://code.google.com/p/jsonpath/ not sure, whether process request in syntax: user[id>2] [<5] , it's rather powerful library , should have similar feature. even if there's no function request parts "[<5]", may call .slice(0, 5);

c# - Does IE setting "do not save encrypted pages to disk" prevent caching within same browser session as well? -

i've asp.net application served on https. noticed in logs none of resources files (css/images/js/xsl) being served 304 header, should since i'm sending necessary headers correctly. client's browser settings are: check newer versions of stored pages: 'automatically' disk space use: 65 days keep page in history: 7 do not save encrypted pages disk:checked on i assume last setting preventing user's browser use cached files. correct? i've seen fresh copies of same file being requested in same session well. question "do not save encrypted pages disk" feature prevents https caching within same browser session well? if yes, there way deal other serving static pages through sub domain w/o ssl? thanks help! ps: noticed interesting thing. have emptu.html file (that more static placeholder) served on same ssl , file status code 304. if caching not allowed on ssl due client settings how come file being used browser cache same user?

apache - Inaccessible rawurlencoded UTF-8 URL -

i have shared hosting account , using filezilla connect server. under public_html/items/ folder, there many subfolders , folder names encoded using php rawurlencode function, these: apple banana orange %e6%bc%a2%e5%a0%a1%e9%a3%bd %e8%96%af%e6%a2%9d the problem 404 error when access files under folders names contain non-ascii characters (e.g. chinese characters). this means can access url one: http://my-domain.com/items/apple/index.html but not: http://my-domain.com/items/%e6%bc%a2%e5%a0%a1%e9%a3%bd/index.html what kind of problem possibly be? many all. if folders contain physically urlencoded names, you'll need ensure these names urlencoded in urls. in fact, anytime create url 'uncontrolled', potentially url-unsafe elements, must urlencode elements. thus if have directory named %e8%96%af%e6%a2%9d you refer in url %25e8%2596%25af%25e6%25a2%259d pretty, isn't it? another way of looking @ when use existing urlencoded url, server tries r

delphi - Dunit console mode - Executing tests twice -

i have dunit test project , trying run in console mode. when execute project runs twice (it opens 1 console window , see executing twice tests) , taking more time execute when run in gui mode. know how run dunit console test once? dpr source code: var r: ttestresult; begin application.initialize; if isconsole begin texttestrunner.runregisteredtests(rxbhaltonfailures) begin r := texttestrunner.runregisteredtests; exitcode := r.errorcount + r.failurecount; free; end end else begin guitestrunner.runregisteredtests; end; end. you calling texttestrunner.runregisteredtests twice causing tests execute twice. call once , fine.

security - Why do I get these 404-Errors? -

i have website , check 404 errors quite often. of them, have quite explanation why them. appear quite often, although sure have never posted link this. here list of strange 404 errors: js/swiff.callbacks //phpscheduleit/ or //sched/ or //scheduler/ /%b0z2%b5%b5a js/+this.options.encoding: js/).match(/\d+/g);return{version:parseint(a[0]||0+ js/application/json js/text/xml js/;this.headers.set( i jused mootools javascript part, use google closure. hacking attempt? how attempt successfull? should change because of this? //phpscheduleit/ checking software has vulnerability . /%b0z2%b5%b5a name 1 might use install malicious script keep obscure, since google search doesn't turn it's not standard name. (it might testing unicode decoding vulnerability , make more sense check particular vulnerable url involving %c0%af directly.) js/;this.headers.set( , bits of javascript code web crawler might pick out possible urls. these string appear on website

.net - Numbers in namespace -

Image
i have bunch of classes under these 4 different namespaces: a.b.c.x a.b.c.y a.b.c.z neither of classes contain definition "myenum" directly under namespace "a.b". have "myenum" defined in "a.b.c.x" , "a.b.c.z" following error: the namespace 'a.b' contains definition myenum. why this? , how can fix it? edit: well fixed it. apparently cannot have numbers "a.b.202.x" in namespace. that's complaining about. know why? apparently cannot have numbers "a.b.202.x" in namespace. that's complaining about. know why? the same reason can't declare int 202; - identifiers cannot begin digits in c#. edit : here's attempt explain specific (strange) compiler error, reproducing it. the following code: namespace a.b { enum myenum {} } namespace a.b.202.x { enum myenum {} } fails curious (to me anyway) errors: { expected namespace 'a.b' c

regex - Url Rewrite to redirect any js to a common folder -

i'm using isapi_rewrite3 the following examples /extfile/banner.js /home/home/foo.js /this/that/file.js have been physically moved /include/js/*.js how write redirect redirect request js file new single directory? want same css well. here have far. feel getting pretty close, making overly complicated. rewriterule ([^/]*)\.(js|css)$ /include/$2/$1.$2 [nc] this correct rewriterule ([^/]*)\.(js|css)$ /include/$2/$1.$2 [nc] .

dictionary - objects as keys in python dictionaries -

i'm trying use object key in python dictionary, it's behaving in way can't quite understand. first create dictionary object key: package_disseminators = { contenttype("application", "zip", "http://other/property") : "one", contenttype("application", "zip") : "two" } now create object "the same" 1 key. content_type = contenttype("application", "zip", "http://other/property") i have given contenttype object custom __eq__ , custom __str__ methods, such __eq__ method compares __str__ values. now, interactive python: >>> key in package_disseminators: ... if key == content_type: ... print "match" ... else: ... print "no match" ... no match match >>> content_type in package_disseminators.keys() true ok, looks object being identified key, so: >>> package_dissemina

How to guard against nulls in python -

in python, how check if string either null or empty? in c# have string.isnullorempty(some_string) also, i'm doing regex like: p = re.compile(...) = p.search(..).group(1) this break if group doesn't have @ index 1, how guard against ? i.e. how re-write 2 lines safely? just check it. explicit better implicit, , 1 more line won't kill you. a = p.search(...) if not none: # ...

java - Accessing external URL resources in iText -

i'm working on jsf 2.0 project using mojarra, primefaces , tomcat 6.x, in front have apache http server. i created web form can select pdf files want merge. these files external of war in directory under apache httpd's control. use itext 2.1.7 merge pdf files. at moment i'm accessing files follows: pdfreader reader1 = new pdfreader(new url("file:///appli/vignette/vcm/inst-vgninst/docroot_cdc" + file)); however, want access them http: pdfreader reader1 = new pdfreader(new url("http://centos" + file)); centos name of server, webapp deployed. file string variable "/folder/folder1/file.pdf" this fails. url http://centos/folder/folder1/file.pdf accessible normal webbrowser. what's wrong , how can fix it? the pdfreader apparently can't work directly urls point external resource. if intend work url rather file or fileinputstream , best bet use url#openstream() return inputstream pdfreader . has namely cons

javascript - What makes Firebug/Chrome console treat a custom object as an array? -

Image
when developing in jquery, find myself typing selectors chrome/firebug console , seeing give me. nicely formatted if arrays: i trying work out makes console treat object array. instance, following custom object not treated array: function elementwrapper(id) { this[0] = document.getelementbyid(id); } if add length property , splice method, magically works array, properties integer keys treated members of arrays: function elementwrapper(id) { this[0] = document.getelementbyid(id); this.length = 1; this.splice = array.prototype.splice; } so question is: what determines whether console displays object array ? there rationale it, or arbitrary "if object has these properties, must array?" if so, decisive properties? this firebug's isarray method does: (from firebug source ) if (!obj) return false; else if (isie && !isfunction(obj) && typeof obj == "object" && isfinite(obj.length) &&am

algorithm - sorting hashes with opencl -

i have lines of 3 hashes (ie md5, 128bit). plenty of them. think billions, wont fit in main memory. in file , need sorted. using gnu sort takes long time obviously, works. i think possibly worth split them ie vector of 6 64bit ints , sort them in batches opencl, mergejoin them. have radeon hd 6950 2gb @ hand. but have no experience opencl. so questions: which opencl datastructure want use task? which sorting algo use could mergejoin accelerated? since on disk use stlxxl. http://stxxl.sourceforge.net/ there opencl code.... try first :)

java - How to mark that at which i something = true -

(int i=1;i<10;i++) { if == true else } here want do: outside loop for, need summarize @ something = true , @ something = false . list<integer> positiveresults = new arraylist<integer>(); list<integer> negativeresults = new arraylist<integer>(); (int = 1; < 10; i++) { if (somecondition) positiveresults.add(i); else negativeresults.add(i); } where somecondition supposed boolean variable or expression. if explicitly want results in array instead of list , add integer[] resultsinarray = positiveresults.toarray( new integer[positiveresults.size()]);

flash - physical screen pixels with CSS -

i have flash object need embed in page, , i've got in wrapper div styled exact width of object: 323px. problem have when zoom whole page in browser (for example, using ctrl+mouse wheel, or ctrl++ or ctrl+-, wrapper div zooms, while flash object not. there way can specify width in physical screen pixels, when zoom in or out, wrapper div stays size of flash object? you use onresize in javascript, , set wrapper div's size fixed value of 323px if use jquery see this . $(window).resize(function() { $('#wrapper').width(323px); }); hope helps.

c# - Common Access Card (CAC) (PKCS#11) Demographic Information -

is there .net api available (paid or free) gives me demographic information available on card? (it have cpu architecture agnostic, or set of apis x86 , x64 architectures.) i can use opensc don't think gives me demographic information. (i wrong here.) i having hard time trying understand mean demographic information. pkcs#11 interface provides access public , private asymmetric keys, symmetric keys, x.509 certificates , application data. looking application data. our secureblackbox product supports access application data on pkcs11 devices can looking for. pkcs#11 supported on desktop .net 1.1 4.0 (but not on mono or .net cf).

Django: Getting "ManyToManyField cannot define a relation with abstract class" error -

i need inheritance: item(models.model) ... class meta: abstract = true food(item) ... meal(item) items= models.manytomanyfield(item,related_name='meal_items') but getting error: assertionerror: manytomanyfield cannot define relation abstract class item what should do? other option? multi-table inheritance ? manytomany fields have link actual database tables.

JavaScript alert box with confirm on button press -

i have link: <p id="accept-favor"><a title="accept favor" href="?wp_accept_favor=<?php comment_id(); ?>">accept favor</a></p> i want show javascript alert box when user clicks saying: "are sure accept reply favor?" 2 buttons 1 saying "yes" allow function run , other saying "no" cancel postback , keep user on page. how this? :) you can confirm onclick: <p id="accept-favor"><a title="accept favor" href="?wp_accept_favor=<?php comment_id(); ?>" onclick="return confirm('are sure accept reply favor?');" >accept favor</a></p> though ok/cancel instead of yes/no. if want yes/no, you'll have use custom dialog.

msysgit - Git clueless -- please clarify -

i contemplating jump git bandwagon. environment made 1-4 windows client machines , single freenas server. what need make git work in type of configuration? is there git software need install on server? (in cvs, example, don't need install software, if repository accessed windows (smb) share). what install on client machine (windows) if have cygwin installed? there pre-compiled git.exe (just cvs.exe) takes less space proposed 130mb msysgit ? do have go through compiling git binaries in order have git on windows client? i totally clueless move cvs paradigm git paradigm entails. please bare me. thanks. git not same svn or cvs, since "fully distributed", there not clients , server, nodes. in case you'll want "client machines" pointing remote repo on nas, can push changes. can point repo using many methods including file, outlined here: http://www.kernel.org/pub/software/scm/git/docs/git-push.html#urls in git clients nodes too, example

graphics - how to draw circular arc with give two points and radius and clockwise direction -

the problem draw arc 2 pints on bitmap radius , clockwise direction. from one-sentence question, i'm gonna assume you're ok drawing bezier curves. if not, there plenty of information them out there. anyway, cannot create perfect circular arc bezier curves (or splines). can approximating circle level eye won't able see difference. done 8 quadratic bezier curve segments, each covering 1/8th of circle. i.e. how adobe flash creates circles. if you're after plain parametrization using sin , cos, it's way easier: for (float t = 0; t < 2 * math.pi; t+=0.05) { float x = radius * sin(t); float y = radius * cos(t); }

java - OneToMany Update not working in child class -

i have onetomany relationship between person , role class. person can have multiple roles. when create new person, roles (existing records) should updated person ids. using @onetomany mapping cascadetype all, role class not getting updated person id. if new role created , set relationship while creating person, works fine. when create new person , try set existing role doesn't updated. this must done manually bidirectional links. hibernate tutorial provides example: http://docs.jboss.org/hibernate/core/3.6/reference/en-us/html_single/#tutorial-associations-usingbidir in case: on onetomany side, make setpersons(...) method protected, , define public addperson(person p) method this: public void addperson(person p) { this.getpersons().add(p); p.setrole(this); } by way, if person can have multiple roles, , role can assigned multiple persons, want manytomany relationship. you'd have: public void addperson(person p) { this.getpersons().add(p); p

c# - How to change orderby on postback for LINQ to SQL query -

i have drop down list set auto post needs return list of products in specified order. thought put query in own method , use parameter specify orderby, cannot work. here example: protected void show_products(int item) { using (storedatacontext db = new storedatacontext()) { string query = ""; switch (item) { case 1: query ="x.name"; break; case 2: query = "x.msrp"; break; default: break; } var q = db.items.orderby(x=> query).select(x => x); foreach(var n in q) { work } } } and drop down list method gets called on postback: protected void ddlsortby_selectedindexchanged(object sender, eventargs e) { int value =int.parse(ddlsortby.selecte

Stream closed exception in java -

please @ have done private inputsource getcontent(string fname) throws saxexception, ioexception, serviceexception { // code here if(currentnoderef != null) { contentreader reader = contentservice.getreader(currentnoderef,contentmodel.prop_content); inputstream inputstream = null; try { inputstream = new bufferedinputstream(reader.getcontentinputstream(),16384); return new inputsource(inputstream); } { if(inputstream!=null) try { inputstream.close(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } } return new inputsource(); } in parsedocument method called above method. parsedocroot(getc

php - How do you set the color changes for all pages? -

i have menu lets select color schemes, can figure out how on 1 page without making different links of pages, there easier way this? use cookie, or store in session. session_start(); $_session['scheme'] = 'blue;

data structures - in C++, how to handle hash collision in hash map? -

in c++, how handle hash collision in hash map? , how time spend search element if collision occurred? and, hash function? there dozens of different ways handle collisions in hash maps depending on system you're using. here few: if use closed addressing , have each item hash linked list of values, of have same hash code, , traverse list looking element in question. if use linear probing , following hash collision start looking @ adjacent buckets until found element looking or empty spot. if use quadratic probing , following hash collision @ elements 1, 3, 6, 10, 15, ..., n(n+1)/2, ... away collision point in search of empty spot or element in question. if use cuckoo hashing , maintain 2 hash tables, displace element collided other table, repeating process until collisions resolved or had rehash. if use dynamic perfect hashing , build perfect hash table elements sharing hash code. the particular implementation pick you. go whatever simplest. find chained h

unix - How to store result from SQLPlus to a shell variable -

my requirement store result of sqlplus operation variable in shell script. need result of following operation in .sh file sqlplus 'user/pwd' @test.sql i have tried testvar = 'sqlplus 'user/pwd' @test.sql' but doesn't work. edit:: i changed to testvar=sqlplus foo/bar@schm @test.sql and says sql*plus:: not found [no such file or directory] i tried testvar=$(sqlplus foo/bar@schm @test.sql) and gives same error. when try without variable assignment below sqlplus foo/bar@schm @test.sql it works fine employ backticks: testvar=`sqlplus foo/bar @test.sql` or should of syntactical eyesore: testvar=$(sqlplus foo/bar @test.sql) you know take right sql*plus commands limit superfluous output, yes? :) , of course beware backticking collapse whitespace of output.

sql - how to update row -

i hv table this:- id model value dax fab01 daz fab01 daa fab01 dax fab02 daz fab02 daa fab02 i need update table final output this:- id model value dax fab01 123 daz fab01 789 daa fab01 963 dax fab02 456 daz fab02 951 daa fab02 753 i tried below:- update [table] set value = case when model='fab01' , id='dax' '123' when model='fab01' , id='daz' '789' when model='fab01' , id='daa' '963' when model='fab02' , id='dax' '456' when model='fab02' , id='dax' '951' when model='fab02' , id='dax' '753' else value end re-run above & works now. thanks. update [tablename] set value = 123 id = "dax" , model = "fab01"

Is there a tool for Django project structure/information flow visualization? -

i able view structure of django project, i.e. urls point views, views point templates, css files included in templates etc. i know great model visualization tool in django command extensions , need different tool able visualize links between: urls , views; views , templates; templates , other templates (via {% extends %} , {% include %} , custom template tags); templates , static files (css, js, images). are there any? it impossible create tools looking work in practice. django not force structure. tool can made work strict structure. django allows take full advantage of dynamic nature of python. difficult create tools understand dynamics of project. few examples: views can methods generated factory-methods. a view can render different templates in different situations. urls can generated dynamically custom url reslover can used variable can used in {% extend %} tag. lets 1 base template authenticated user , other anonymous. tools gives lot of vis

iphone - Core data problems on real device -

i had problem in simulator - when want edit table in core data or create new table program using database fails every time start it. google problem , found solution - every time want change in tables have manually delete database. works fine nowadays license testing on real device, not know how works on real device. work company , maybe database expanding new tables, , not know how prevent in real device. admit strange problem, can me? if change core data model during testing, can delete app simulator/device. in case xcode install new database on simulator/device when re-install app , app won't crash. if app has been released in itunes , want change database, have implement data migration in app. hope understood question right. please ask if have more questions.

libvirt - How to deal with interactive API in python -

i'm in situation need pass texts prompt generate api (seems api it's pretty weird behavior, first time ran this), below: kvm_cli = libvirt.open("qemu+ssh://han@10.0.10.8/system") then prompt shows asking ssh password ( password 10.0.10.8 is: ), have manually type there in order move on , yield kvm_cli object needed. i tried use pexpect module deal it's os command line instead of api. it's possible work around using ssh certification files it's not favorable authentication approach in our scenario. since our wrapper 'open' method not interactive, cannot ask user input password, guys have thought how address it? i not libvirt user, believe problem not in library, in connection method. seem connecting via ssh, need authenticate yourself. i've been reading libvirt page on archwiki , , think try: setting simple (tcp/ip socket) connection method, or setting key-based, password-less ssh login virtual host.

format number in C# -

possible duplicate: .net string.format() add commas in thousands place number how format number 1234567 1,234,567 in c#? for format options int32.tostring() , see here or here . for example: string s = myintvalue.tostring("#,##0"); the same format options can use in string.format, in string s = string.format("the number {0:#,##0}!", myintvalue);

Entity Framework 4 + Silverlight persisting entity graphs -

we building our first large application silverlight 4 (using prism) , entity framework 4. i'm having general question persisting view model data. suppose have domain objects translate ef4 entities multiple associations (entity having collections, having collections again etc..). best way persist graphs during / after user actions? better write more granular repository methods "addentitytoparent" , "removeentityfromparent" or take data view , push "savelargeparententity" method? can "cache" view model items child objects in silverlight , push down ef4 later or have make granular update every single item changed in user interface? advise? hope question clear enough. thank you. you making choice between basic crud operations , working object graphs. choose second approach because crud operations on web service can chatty. when working object graphs send on web service have deal detached behavior. detached entities + object graph