Posts

Showing posts from July, 2015

iphone - How to pause and resume NStimer -

possible duplicate: how can programmatically pause nstimer? i have question. how can pause countdown using timer? developing game. in game, need go next view when timer pauses, , after coming want resume it. i try code in view: [mytimer pause]; // resume [mytimer resume]; i try code, warning saying: "nstimer may not respond 'pause'" i build warning , when press pause button, app crashes. nstimer indeed doesn't have resume , pause methods can end crash in runtime after such warning. can create 2 kinds of timers (see nstimer class reference) 1 implements once , second, repeats. example: this way create timer, enter callback mymethod each second. nstimer *mytimer = [nstimer scheduledtimerwithtimeinterval:1 target:self selector:@selector(mymethod:) userinfo:nil repeats:yes]; you choose 1 purpose in class should maintain bool pause variable , in callback mymethod following: - (void) mymethod:(nstimer *) ...

sql - DB2 UDF to return added date? -

i trying make db2 udf takes input date , returns new date months added it. query syntax step use select date + 12 months sysibm.sysdummy1; inside udf can't work monthstoadd integer; set monthstoadd=4; set result= inputdate + monthstoadd + months; return result; it says sql state: 42816 vendor code: -182 message: [sql0182] date, time, or timestamp expression not valid. cause . . . . . : 1 of following has occurred: -- operand of addition date , other not date duration. -- operand of addition time , other not time duration. -- operand of addition timestamp , other not duration. -- operand of subtraction date , other not date, character, or date duration. -- operand of subtraction time , other not time, character, or time duration. -- operand of subtraction timestamp , other not timestamp, character, or duration. recovery . . . : correct arithmetic expression contains valid date, time, or timestamp expression. try request again. it's simple fix...

Java JNA WindowProc JVM Crash -

in a previous question wanted implement wndproc handle wm_devicechange message in order know when usb device attached or detached. i managed solve issue, .... in cases jvm crashes followin ugly error message: fatal error has been detected java runtime environment: exception_access_violation (0xc0000005) @ pc=0x1000cb77, pid=3448, tid=4432 jre version: 6.0_17-b04 java vm: java hotspot(tm) client vm (14.3-b01 mixed mode, sharing windows-x86 ) problematic frame: c 0x1000cb77 if submit bug report, please visit: http://java.sun.com/webapps/bugreport/crash.jsp crash happened outside java virtual machine in native code. see problematic frame report bug. i found crashes jvm if close frame after inserting usb device, message isn't handled properly. in error message says there "problematic frame", hidden static window, handles wm_devicechange message causes crash, i'm not sure. so question can done in situa...

c# - Is there a way top quickly find all the class whose base class is A -

possible duplicates: visual studio: how show classes inherited base class? get derived types of type in visual studio, wondering if can find classes base class a? for example, i know b derived a, can find other classes derived a? hope resharper helps

asp.net mvc 3 - selected menu item in mvc3 -

i creating first mvc3 application (no previous mvc either) wanting create top level menu , able add "selected" or "active" css class select li tag. found link active menu item - asp.net mvc3 master page ihave tried add class error "error 1 'system.web.mvc.htmlhelper' not contain definition 'actionlink' , no extension method 'actionlink' accepting first argument of type 'system.web.mvc.htmlhelper' found (are missing using directive or assembly reference?) g:\mvcmusicstore-v2.0\mvcmusicstore-completed\mvcmusicstore\helpers\htmlhelpers.cs 26 31 mvcmusicstore " so thinking missing reference don't know what. can kindly tell me need reference work. add following using @ top of htmlhelpers.cs file: using system.web.mvc.html; now htmlhelper.actionlink line should compile fine.

javascript - What problems may using the MIME type application/json cause? -

i working on web service needs return json data. i read should use application/json not sure problems may cause? for example, older browsers support it? (ie6+, ff, opera, etc.) or possible users behind corporate firewalls/proxy servers block mime type application/json? what, if any, problems have had following advice? let's consider ie. have hidden iframe use request file download. example <iframe src="getfile?id=123"> now, server may send json-encoded error message like { error: 'file 123 not exist', retrylater: false } if error message sent application/json , download dialog appear, because json text mistaken actual file. on other hand, mime type of text/plain cause message rendered in iframe, , can extract it, , transform fancy pop-up or using jscript. (edit) real-world example: extjs fileupload - problem ie8 security bar

c# - Same membership table for different asp.net application -

i have asp.net website has form authentication, have develop website access same database login. i believe have create application id before going further. or when execute below statement create application id in aspnet_membership table? membershipuser newuser = membership.createuser("username", "password", "email@xyz.com"); what best way deal it? you should set in web.config file: see scottgu's blog entry so in 1 website, set applicationname "app1" in web.config, , in other 1 you'll name "app2".

jquery - Hide CCK field group based on taxonomy term in Drupal6? -

i have generic content type ("property") has bunch of content sorted via taxonomy. how can hide or display cck fields (or better yet, groups of cck fields) based on taxonomy term selected? should via jquery? views? alternately -- if have taxonomy term-specific cck fields structured in collapsed fieldset groups, how can uncollapse fieldset when relevant taxonomy term selected? (i'm guessing candidate quick jquery code) thanks! i figured out. need 2 modules: conditional fields -- http://drupal.org/project/conditional_fields content taxonomy -- http://drupal.org/project/content_taxonomy in short, add content taxonomy field content type, can use conditional fields conditionally display things. works well, actually.

deployment - Deploying Django on EC2 -

i'm having django project should deployed on amazon's ec2. there various tutorials on installing django on ec2, think it'll time consuming step generate new ami image whole application... thinking should possible deploy on persistent storage, ebs? i'm wondering if have disadvantages because there no tutorials describing out there... if having ideas on or having other tutorials on how deploy new versions in easy fast way ec2 please let me know! i used bitnami djangostack 1.2.3 (i'm not associated bitnami in way). http://bitnami.org/stack/djangostack the ec2 image "ami-18fb0f71", described "bitnami-djangostack-1.2.3-0-linux-ubuntu-10.04-ebs". this ebs backed instance, can't comment on advantages/disadvantages of this. i found of pertinent configuration files in these locations: /opt/bitnami/apache2/conf/httpd.conf /opt/bitnami/apps/django/conf/django.conf the file served default (as configured in httpd.conf) '/opt/bitn...

curl - When is a HTTP request lost? -

i need send quite large http requests mobile device. in situation request lost (so data sent have resent)? what happen example if there no radio-connection few seconds? depend on decision in network can't control? there not timeouts on server. control client , can assume stable. calls goes curl libraries (posix c++, embedded linux), , limited how can change it. as "some" said, should split upload parts, number them , re-assemble them on other end. once wrote webservice that, client have confirmation particular part has been received right checksum (for example sha-1 hash). if confirmation doesn't come because of time out or hash doesn't match, client should re-send part. advice make each chunk small enough 1-10 kb, depending on expected network speed (slow network smaller chunks).

.net - Working with MySQL in C# -

here's code print data terminal: public static void writedata() { string connstring = "server=localhost;" + "database=db;" + "uid=user;" + "password=pass;"; mysqlconnection connection = new mysqlconnection(connstring); mysqlcommand command = connection.createcommand(); mysqldatareader reader; command.commandtext = "select * table1"; connection.open(); reader = command.executereader(); while (reader.read()) { (int = 0; < reader.fieldcount; i++) console.write(reader.getvalue(i).tostring() + " "); console.writeline(); } connection.close(); } now i'd view results in datagridview . tutorials i've found involve adding external data sources grid, have no idea how in mysql. (also please note have no experience in developing windows forms, guess gui development drag-and-drop anyway). as daniel said, datatab...

Rename MYSQL column names for php select element -

hi i'm constructing html select element so: $result = mysql_query("show columns table") or die(mysql_error()); echo '<select name="column" class="column">'; while ($row = mysql_fetch_array($result)) { if($row[0] == 'id' || $row[0] == 'tstamp' || $row[0] == 'boiler2oil') continue; echo "<option value='".$row[0]."'>".ucwords($row[0])."</option>"; } echo '</select>'; the way i've named columns in table rather ugly, underscores, etc...how can rename them can change select element display (value can stay same) changes bit more readable , visually pleasing. possible? sort of preg_match/preg_replace? depends want rename them to. want simple remove underscores? there rule can use clean them up? if not, why not add hash entries map name in table name want print out drop-down list? # ma...

jquery - Queue, delay, stop queue -

i'm working on two-levels menu animation tabs: main menu tab items open tabbed sub-menus. at load, default submenu opened, according current page location. user may choose open other subemenus browse through navigation. but, when user not care more of menu, default submenu should reappear after while match current location. code works correctly use: $("#menu").mouseleave(function(){ settimeout(function(){ $("#menu").tabs( "option", "selected", index );}, 2000); }); }); here problem. if user comes on menu after timeout launched (in 2 seconds delay), default submenu appears anyway, may disturb user experience. great stop timeout when user comes menu. i think better use queue, delay... don't know how since of documentation refers animation queuing... thanks help... you can stop started timeout cleartimeout, so: var menutimeout; $("#menu").mouseleave(function(){ menutimeout =...

asp.net mvc 3 - Difference between use of a controller factory and NinjectHttpApplication? -

using ninject 2 mvc 3. correct me if wrong ive seen 2 way of using ninject in mvc 3 application. can use new controller factory controllerbuilder.current.setcontrollerfactory(new ninjectcontrollerfactory()); or using ninjecthttpapplication , configure kernel. i wondering difference between use of controller factory , ninjecthttpapplication configure binding di? and best place setup di ? ninjecthttpapplication calls controllerbuilder.current.setcontrollerfactory(new ninjectcontrollerfactory()) internally. but additionally sets various bindings , provides many new features. in other words it's less work , adds new features. best read blog post mvc3 extension. http://www.planetgeek.ch/2010/11/13/official-ninject-mvc-extension-gets-support-for-mvc3/

soap - CWMP CPE (Client) implementation -

i trying tr-069/cwmp protocol , running. have found open source acs server called openacs. problem cpe, there not seem open source cpe implementations around. have found few projects none alive. wondering if knows full cpe implementation? also, know how work involved in implementing protocol myself? thank you. i had implemented generic stand alone cwmp client in pure c before 5-6 years. project university (there publication http://ieeexplore.ieee.org/xplore/login.jsp?url=http%3a%2f%2fieeexplore.ieee.org%2fiel5%2f30%2f34592%2f01649657.pdf%3farnumber%3d1649657&authdecision=-203 ) well, actually, if read paper you'll see propose there methodology creating (instantiating) cwmp clients through java. use java program define model of cwmp client , create configuration file used generic cwmp client. after used hooks define should done on set or of each parameter of model. if remember correctly, cwmp client implemented of requirements of tr-69 document , add model (se...

oracle - What is pro *c? -

how useful? how can access data database? pro*c pre-compiler oracle database access within c code. you write code statements like: int sal; exec sql select salary :sal employees name = 'diablo, pax'; if (sal < 100000) printf ("i'm not being paid enough!\n"); intermixing regular c pro*c statements (as can see) , run through pro*c compiler. what comes out of c program has pro*c statements replaced equivalent function calls same thing. you run through real c compiler , gives executables run perform whatever tasks want.

sql server - How to calculate Rank SQL query -

hi, have following table save agent ranking on daily basis on basis of tickets status. no. **agent name** **incidents** **workorder** **rank** **timestamp** 1 cedric 200 29 1 21 jan 2011 2 poul 100 10 2 21 jan 2011 3 dan 200 20 1 21 jan 2011 4 cedric 100 19 2 22 jan 2011 5 poul 200 26 1 22 jan 2011 6 dan 150 20 2 22 jan 2011 now need query fetch ranking between 2 dates means if select date between 21 jan 2011 22 jan 2011 query return me agents average ranking between these 2 dates of agent not return agent ranking details on date wise. need single name of agent ranking. regards, iftikhar hashmi try select [agent name], avg(rank) my_table [timestamp] between date1 , date2 group [agent name] (upda...

Convert Unix epoch timestamp to MySQL timestamp in PHP -

i have issue whereby client has legacy environment (iis 6 / php 5.0.1) , keeps getting following error: warning: date() [function.date]: windows not support dates prior midnight (00:00:00), january 1, 1970 in" when using date() function. i need find way convert unix timestamp, i.e "1293559200" (28th of dec, 2010) can pass on correct date. select from_unixtime(unix_timestamp(), '%y-%m-%d %h:%i:%s'); where can replace unix_timestamp() timestamp value.

java - How is a thread in blocked state caused by waiting on a objects lock handled by the JVM -

i have seen there different ways thread blocked state. im interested know happens after thread in blocked state. how running state. if blocked sleep(time) moves runnable queue after time milli secs. if blocked on i/o operation gets runnable queue once done. how runnable queue when waiting on objects lock. how know lock on ocject waiting available. can 1 explain internals of how blocked thread on i/o works. please correct me if understanding on of above topics isn't right.. thank how runnable queue when waiting on objects lock? if thread blocked due trying enter synchronized block, thread automatically marked runnable when other thread (holding lock) releases lock exiting synchronized block of same object. if current thread blocked due call someobject.wait() , thread "released" when thread calls someobject.notify() . on bytecode level looks follows: [load object, obj, onto operand stack] monitorenter // grab lock // stuff [load obj onto oper...

Why does my Silverlight BusyIndicator stay invisible after setting IsBusy = true? -

my busyindicator works expected when domaindatasource fetches data. control stays invisible when set isbusy true in code. i'm using silverlight 4 , toolkit busyindicator. in xaml have bound busyindicator.isbusy property isbusy property of domaindatasource control. busyindicator control wraps main grid (layoutroot) , child controls. <toolkit:busyindicator isbusy="{binding elementname=labsampledomaindatasource, path=isbusy}" name="busyindicator1"> <grid x:name="layoutroot"> </grid> </toolkit:busyindicator> the problem busyindicator not show when set busyindicator1 = true; in button click event. idea doing wrong? the ui updates quite naturally on ui thread. events things button clicks run on ui thread. in cases property changes , method calls controls result in method being dispatched ui thread. means method invoked not occur until ui thread becomes available execute (and else queued has been executed). is...

php - how do i use string replace to remove a carrage return from a string -

hi how use string replace remove carrage return string here string: { $content = '<p>some random text <a href= "http://url.co.uk/link/">link text</a> more random text.</p>'} and here sring replace command {$content=str_replace('carrage return', '', $content);} the think cant seem find replace 'carrage return' with. reason doing reg expression on string fails if there carrage return in serached string doesnt match reg expression. also on asside note if 1 posts response question how query them on posting. second asside how hell html show on here ive tried '' "" () {} :( be gentil im newby , got punched in face on here :( second post , dropped load of score :( there 2 chars used line endings, \n (ascii: 10, unix/linux) , \r (ascii: 13, mac os). on windows combination of 2 used \r\n . rid of of them use this: $str = str_replace(array("\n", "\r", "\...

ASP.NET MVC 3 JSONP: Does this work with JsonValueProviderFactory? -

phil haack has excellent blog post on how use json, data binding, , data validation. enter browser's "same origin policy security restriction." , jsonp use $.getjson() retrieve content. is there built in mvc 3 way this, or need follow advice of posts this ? can post content? ask because colleague implemented jsonpfilterattribute among other things make work. it's preferred avoid if exists in mvc 3. edit: summary: works exception of accessing post variable, i.e., how access post variable in context? (comment marking in last section of code) i elected use format call server: $.ajax({ type: "get", url: "getmydatajsonp", data: {}, contenttype: "application/json; charset=utf-8", datatype: "jsonp", jsonpcallback: "randomfunctionname" }); which produces response: randomfunctionname([{"firstfield":"111","secondfield":"222"}]); and works...

C#: How to suppress UserControl to give focus the first child-control? -

i have usercontrol can have childcontrol. the usercontrol have styles: this.setstyle( controlstyles.allpaintinginwmpaint | controlstyles.optimizeddoublebuffer | controlstyles.selectable | controlstyles.supportstransparentbackcolor | controlstyles.userpaint, true); now if click on usercontrol (not child-control) want usercontrol keep focus, focus automatically goes first child-control. same thing happens if use tab key. i tried override ongotfocus without success. any idea? this hard-coded behavior inside usercontrol class, traps wm_setfocus message , passes focus child control. not know of way override this, trapping in wndproc() doesn't work since there no way uc base class handle it. the best approach avoid battle , use docked panel control stand-in focusing events want uc handle. requires hacking well, panel container control, can bypassed. check out my answer here focusable pan...

Public CDN for CKEditor -

simple one: there public cdn load ckeditor when load jquery google's cdn? i haven't been able find big cdn. guess hotlink ckeditor.com's .js file that's not optimization means. http://cdn.ckeditor.com it official cdn ckeditor , hosted amazon cloudfront , ssl support. more information using cdn and/or available types of releases can found on ckeditor cdn website .

Retrieve HTTP POST request parameters (sent from flex app) in python -

i sending parameters flex application through http post request python/psp script. able call psp script flex app using http post request, not able use/retrieve these parameters in python/psp. you want cgi module standard library. see the documentation .

internationalization - Java International Address Parsing -

i wondering if knew of java api parsing addresses various locales? international app needs work in various places saudi arabia , germany. desolate see following: parse usable street address, city, state, zip string regular expression parsing mailing addresses it seems library looking not implemented yet. implement it? :) believe links posted here can you. luck. sorry. here yet link: java postal address parser it useful! go on first.

java - Specific Query runs fine directly or when any change to it is made but in current state takes longer to run -

major update after couple days of debugging: i run few queries similar : select rtrim(part) part tablep pm left join tables s on pm.id = s.id inner join tablec cm on cm.id = pm.id name = 'ngw' , status not in ('nl', 'z') group rtrim(part), isnull(s.value,0) order isnull(s.value,0) it run in java so: preparedstatement select = con.preparestatement( "select rtrim(part) part" + "from tablep pm " + "left join tables s on pm.id= s.id " + "inner join tablec cm on cm.id= pm.id " + "where name =? , status not in ('nl', 'z') " + "group rtrim(part), isnull(s.value,0) " + "order isnull(s.value,0) " ); select.setstring(1, name); resultset rs = select.executequery(); while(rs.next()){ ... data loaded... the queries have been running fine inside of java application. 3 or 4 queries of f...

sql server - Ordered insertion at next unused index, generic SQL -

there have been various similar questions, either referred specific db or assumed unsorted data. in case, sql should portable if possible. index column in question clustered pk containing timestamp. the timestamp 99% of time larger inserted value. on rare occasions however, can smaller, or collide existing value. i'm using code insert new values: if not exists (select * foo timestamp = @ts) begin insert foo ([timestamp]) values (@ts); end else begin insert foo ([timestamp]) values ( (select max (t1.timestamp) - 1 foo t1 timestamp < @ts , not exists (select * foo t2 t2.timestamp = t1.timestamp - 1)) ); end; if row unused yet, insert. else, find closest free row smaller value using exists check. i novice when comes databases, i'm not sure if there better way. i'm open ideas make code simpler and/or faster (around 100-1000 insertions per second), or use different approach altogether. edit thank comments ans answers far. to e...

Parameter value not passed in ASP.NET MVC route -

i'm learning creating custom routes in asp.net mvc , have hit brick wall. in global.asax.cs file, i've added following: public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( "default", // route name "{controller}/{action}/{id}", // url parameters new { controller = "home", action = "index", id = urlparameter.optional } // parameter defaults ); // custom route. routes.maproute( "user_filter", "home/filter/{name}", new { controller = "home", action = "filter", name = string.empty } ); } the idea me able navigate http://localhost:123/home/filter/mynameparam . here controller: public class homecontroller : controller { public actionresult index() { return view(); } public actionresult filter(string name) { ...

php - How to do pagination from multiple array and calculate the total? -

i have array present data use display paganation. $display_array = array ( [0] => array ( [0] => 1 [1] => 2 [2] => 5 [3] => 5 ) [1] => array ( [0] => 1 [1] => 2 [2] => 5 [3] => 5 ) [2] => array ( [0] => 1 [1] => 2 ) [3] => array ( [0] => 1 [1] => 2 ) ) i want paganation expected result this: if defined $show_per_page = 2 ; call paganation($display_array,1);//page 1 firstpage output : 1 2 call paganation($display_array,2);//next page 2 output : 5 5 total:13 // total appear here ....//...

web services - how to store and search mp3 by its content in android -

in app have store no of audio files in database in webserver , after recording audio in android mobile have send server match previous audio files. how this?? this involves high understanding of audio data parsing , fingerprinting. if trying make clone of shazam, should read post : http://laplacian.wordpress.com/2009/01/10/how-shazam-works/ bonus : article contains link article developper of shazam. good luck on endeavour.

asp.net mvc 3 - Online game using .net technologies -

i new in game development, i'm thinking creating online browser game on asp.net mvc3 using entity framework orm data mapping , sql server 2008 db data data storage. hear thoughts this. advantages , disadvantages of approach. why worse using classic lamp. first of costs. assume paying licences, second speed(linux faster windows), third portability , safety (apache more secure iis , faster) , apache/mysql/php can run on windows while iis , not work on else. overall more lamp hosters windows hosters far know. php faster asp (execution speed , development speed), cheaper develop, more flexible , lighter(even if use framework symphony or zend). examples: facebook works php, yahoo works php, ibm befriending php . mysql fast , easy maintain. microsoft technology corporations (as personal opinion on technology, rather keep self, raise hands ie6 friends). if going php or mysql though flexibility can tricky, can lot of things, if not master school theory might end monster. ...

c# - send email via asp.net 3.5 -

im looking send email vi .net 3.5 form (c#) ive seen few posts elsewhere , got thing running ok addresses not others, eg gmail accounts. finished app have pick addresses database im having cater lot of possibilites. im not looking have work done me, shove in right direction cool! thanks dd is possible gmail accounts blocking spammer? if you're sending out lot of emails, or if there configuraiton issue on server, may have blacklisted you. if emails going out server ok, not reaching of recipients reaching some, there issue outside of direct control. email goes through several servers in between server , enduser's inbox (and that's case if inbox on google's server gmail.) that said, there things can reduce likelihood of being blocked/blacklisted. this place start: http://www.andreas-kraus.net/blog/tips-for-avoiding-spam-filters-with-systemnetmail/ and here go there. (sorry - it's google search, gave relevant terms, @ least.) http://www.g...

internationalization - Rails i18n: Translation missing problem, locale not defined -

i have problem rails 2.3.8 application. i'm using rails i18n make site in different languages. works perfect, everywhere, except 1 place. after successful signup, do: flash[:notice] = t 'path.to.locale.key' just everywhere else. but renders following: translation missing: 'locale.path.to.locale.key' not found it seems it's not loading current locale (or else 'en', or 'es', or whatever instead of 'locale'). any idea causing this? thanks maybe overwrite somewhere down yml file. maybe did many nesting. maybe key has subkeys. delete locale.yml , place message , see if works. the problem having happens me every , then, , it's messed in yml file.

How to set default to -j2 in Makefile? -

i have make option "-j2" default. can modify makefile that? looking @ gnu make manual (3.82), there nothing can see allows that. you might able set environment variable makeflags (to either ' -j 2 ' or perhaps ' j 2 '), otherwise, appears cannot.

.net - c# enumerable class - compatible with VBA -

can instruct me on how code c# enumerable class such "for each" construct in excel vba works properly? tried out test class called people implements ienumerable , contains array of person objects. "foreach" construct works fine in c#, in vba able loop old fashioned way. this vba code works fine: dim p person dim pp new people = 0 pp.count - 1 set p = pp(i) debug.print p.firstname + " " + p.lastname next but fails @ run time ("object doesn't support property or method"): for each p in pp debug.print p.firstname + " " + p.lastname next p here c# code (compiled com visible in vs 2008 use excel vba - office 2010): using system; using system.collections; using system.runtime.interopservices; public class person { public person(string fname, string lname) { this.firstname = fname; this.lastname = lname; } public string firstname; public string lastname; } public class ...

how to implement titanium-urban airship push notifications for android -

i new titanium , want implement push notification in titanium android. got know possibly attain using google c2dm or urban airship. not know how? google c2dm not recommended work v2. of android. want dug using urban airship. could 1 me implement push notification android using titanium via urban airship? stuck on in app urban airship website not providing assistance implement in titanium. please any support highly welcomed. thank you we have guide doing push notifications urban airship on our doc site .

java - Filling a rectangle - paint method (MIDP) -

im trying paint rectangle using 2 calls of .fillrect method thread.sleep call between each method. happening sleep method getting called before rectangle initialised, appears rectange has been painted. want paint part of rectange, pause 5 seconds , paint antother part. here code - public void paint(graphics g, int w, int h) { g.drawrect(0, 0, w - 1, h - 1); g.fillrect(0, 0, 10, h-1); try { thread.sleep(5000); } catch (interruptedexception e) { // todo auto-generated catch block e.printstacktrace(); } g.fillrect(0, 0, 50, h-1); } thanks it bad idea cause event thread block, no matter platform. what should doing defining variables somewhere store current extent of area want painted. update variables on separate thread (you can block thread want) , call repaint() method schedule repaint whenever update variables.

sql - Opening Hours Database Design -

we developing application in multiple entities have associated opening hours. opening hours may span multiple days, or may contained within single day. ex. opens monday @ 6:00 , closes @ friday @ 18:00. or opens monday @ 06:00 , closes monday @ 15:00. also, entity may have multiple sets of opening hours per day. far, best design have found, define opening hour consist of following: startday, starttime, endday , endtime. this design allows needed flexibility. however, data integrity becomes issue. cannot seem find solution disallow overlapping spans (in database). please share thoughts. edit: database microsoft sql server 2008 r2 presuming robust trigger framework on insert/update check if new start or end date falls inside of existing range. if roll change. create trigger [dbo].[mytable_iutrig] on [mytable] insert, update if (select count(*) inserted, mytable (inserted.startdate < mytable.enddate , inserted.startdate > mytable.startda...

c++ - Is this an appropriate use of class friendship? -

when creating windows parent , child dialog classes, idea make child class friend of parent class access private data or should use accessor functions? the need friend rare - it's when need reimplement deep behaviour in 1 class without either rewriting both inherit single base or without providing lots of asccessors. only time have needed rewrite opengl based renderer in activex - when needed @ lot of low level model data, couldn't (for non-technical reasons) reimplement common abc.

Svn problem with Kiln -

i'm new kiln (never used before) trying upload code via netbeans i following error. http://my.jetscreenshot.com/5627/20110125-xea9-127kb repository moved temporarily '/auth/logon returnurl=%2frepo%2frepositories%2fgroup%2fbestprice4me'; please relocate any appreciated. kind regards, j kiln works mercurial, attempting use netbeans' subversion report interact it. thankfully, netbeans has great mercurial support. tell you're trying connect mercurial repository, rather subversion repository, , should good.

c# - WPF Reference User Control in MainWindowViewModel Code -

user control located in controls\tabcontrol. contains tabcontrol 2 tabitems (ruletab , diagramtab). in mainwindowviewmodel class have: private void showsavedialog() { system.windows.forms.savefiledialog sfd = new system.windows.forms.savefiledialog(); sfd.filter = "text file (*.txt)|*.txt"; bool? saveresult = sfd.showdialog() == system.windows.forms.dialogresult.ok; if (saveresult == true) { string s = sfd.filename; filepath = s; savefile(s); settitle(sfd.filename); ruletab.header = new system.io.fileinfo(sfd.filename).name; ruletab.focus(); } ruletab (tabitem) isn't being found because it's in user control. how reference in class? tabcontrol.xaml x:name="tabeditor" x:fieldmodifier="public" mc:ignorable="d" d:designheight="300" d:designwidth="423"> <tabcontrol x:nam...

c# - Assembly, Namespace, DAL; What classes belongs where? -

Image
i understand few basics assemblies , namespaces. i've reproduced nhibernate tutorial, , works fine. i'm not sure if agree on classes go where. @ solution explorer image attached.. domain , repositories (with classes in folders) namespaces . , here both in ...dal assembly. is there logical reason put there? product poco class. shouldn't more naturally belong outside dal assembly? is correct put iproductrepository in domain namespace? , if suggest move poco classes, move iproductrepository? what need if wanted make dal usable both c# , vb.net projects? is there logical reason put there? product poco class. shouldn't more naturally belong outside dal assembly? the argument putting poco class in persistence implementation simplify deployment , reduce total number of needed assemblies. that not agree practice. it better practice, , perhaps more conventional, place definitions of domain objects in 1 assembly, , implementations d...

interop - Cneonction and nnCoection HTTP headers -

we have issues in terms of interoperability on web. 1 of these issues browsers vendors wrongly spelled connection http header. common errors given these 2 forms. nncoection: cneonction: there has been few articles this, including fun http headers . happening period, disappear. seems of them created load balancers such this example : netscaler appliance. do know other instances of hardware or software create these issues? update here example among others of site doesn't send connection http header. curl -si ehg-nokiafin.hitbox.com http/1.1 200 ok date: tue, 25 jan 2011 20:35:45 gmt server: hitbox gateway 9.3.6-rc1 p3p: policyref="/w3c/p3p.xml", cp="noi dsp law nid psa adm our ind nav com" cneonction: close pragma: no-cache cache-control: max-age=0, private, proxy-revalidate expires: tue, 25 jan 2011 20:35:46 gmt content-type: text/plain content-length: 23 update 2011-01-26 on amazon forum aws, there thread nncoection . comment says: fyi...

javascript - Won't Iterate Over Array In jQuery -

so can of images want array , pass them $image. when try loop on array keeps alerting same item 3 times. the code i'm having trouble with. getitem : function($image){ console.log($image) console.log(jquery.type($image)) var setup ='<img src="' + $($image).attr('href') + '" title="' + $($image).attr('title') + '"/>'; $.each($image, function(i){ alert( setup); }); } the html <a href="images/slideshow/1-gw.phillipbarnhart.reverendmemory.jpg" title="phillip barnhart as: reverend memory - clergyman stands decorum , truth." rel="slideshow"><img src="images/view-slideshow.jpg" width="490" height="352" alt="view slideshow"></a> <a rel="slideshow" href="images/slideshow/2-gw.bethbrooks.pollytodd.jpg">fff</a> <a rel="slide...

javascript - How make Autocomplete in JsHelper? -

how make ajax autocomplete in 'pure' jshelper? possible? thanks, celso you might find http://cakephp.1045679.n5.nabble.com/cakephp-1-3-jshelper-and-autocomplete-missing-method-td3270384.html useful.

algorithm - Modular multiplicative inverse function in Python -

does standard python module contain function compute modular multiplicative inverse of number, i.e. number y = invmod(x, p) such x*y == 1 (mod p) ? google doesn't seem give hints on this. of course, 1 can come home-brewed 10-liner of extended euclidean algorithm , why reinvent wheel. for example, java's biginteger has modinverse method. doesn't python have similar? maybe find useful (from wikibooks ): def egcd(a, b): if == 0: return (b, 0, 1) else: g, y, x = egcd(b % a, a) return (g, x - (b // a) * y, y) def modinv(a, m): g, x, y = egcd(a, m) if g != 1: raise exception('modular inverse not exist') else: return x % m

c# - Call a Javascript Method from code-behind Web Method -

i have web method in code behind: [system.web.services.webmethod] public static string getstatedata(string state) { //this want call javascript method "getitems" } i have javascript method retrieves values me , want use 1 of values in web method function getitems() { var variable1= $("#<%=item1.clientid %> input:checked"); var variable2= $("#<%=item2.clientid %>").val(); return [variable1.text(), variable2.val(), variable2];} i've searched ways call javascript method web method every time search results in how call web method javascript. i did find done code-behind of silverlight project , when tried adding correct reference code-behind wasn't there var result = htmlpage.window.invoke("getitems"); is there reference i'm missing? thanks response you can't that. calling webmethod through ajax. sending small pieces of information static method on server knows nothing ...

Flex 3 : Easy Deep Linking Question -

i'm having problem deeplinking on flex 3 site. want people able link different parts of site. want able type url browser bar , taken particular part of site. also, need default open #view=2. i'm having problems setting default #view=2. so, it's supposed check browser fragment see whether valid section of site. if should call parseurl() , open section of site. far, good. problem how set default view=#2, if loop doesn't find valid view number? here's code: private function initbrowsermanager(): void { browsermanager = browsermanager.getinstance(); browsermanager.addeventlistener(browserchangeevent.browser_url_change, parseurl); browsermanager.init("","my website"); if(browsermanager.fragment != null){ (var j:uint = 0; j < comboboxdp.length; j++){ if(browsermanager.fragment == "view="+comboboxdp[j].series){ parseurl(); break; ...

python - Google Chart API - Line Chart: Averaging data -

i have data maps across ~4 years on line chart: 0 72 346 172 193 240 34 24 18 26 25 34 52 104 23 34 29 32 55 46 44 25 36 45 48 60 65 69 66 24 28 39 2 72 74 65 69 44 66 57 49 35 77 49 32 63 47 79 47 the line chart seems limit 100 max value, of values 'off chart'. figure want calculate data in such way max value (in case, 346) equal 100 , average out in-between. makes sense google chart api allows floating numbers. im not sure how it. let's had numbers in list l - following scale numbers percentage of max value: [ float(i) * 100 / max(l) in l ] then if want original value value n: n / 100 * max(l)

MongoDB - Maintain data integrity automatically -

i'm interested in migrating relational db mongodb performance improvements. storing redundant, denormalized data in multiple locations , wondering if possible automatically maintain integrity of data without application code. for example, if have user document... user: { _id: "...", username: "johndoe", displayname: "john doe", totaltasks: 3 } and task document... task: { _id "...", title: "finish reports", userid: "...", username: "johndoe", userdiplayname: "john doe" } how can automatically ensure username , displayname stay same in appropriate documents? how can ensure totaltasks updated when new tasks added or deleted user? you can't enforce these constraints on server side. triggers that's planned . constraint that's supported unique indexes.

haskell - Multiple declarations of 'MyModule.myTypeclassFunction' -

in main.hs class aable getname :: aable → string class b bable getname :: bable → string returns compilation error leksah/ghc src\main.hs:23:4: multiple declarations of `main.getname' declared at: src\main.hs:20:4 src\main.hs:23:4 i need both able return name, different signification in both cases. should declare class , b in 2 different modules ? kneejerk reaction: use show . reading better, see want propably different semantically (despite identical type signatures). why not use different name? descriptiona , descriptionb perhaps? declaring them in different modules solve compilation error, (1) still have 2 different things same name , (2) whenever import both modules (unqualified), you'll same error.

Security issues with PHP's Readfile method -

hey. there security issues should worry when using readfile method in php? i'd use readfile method takes in url of file stored on various third party servers. serve file user. intuitively, seem there risk url point file. on other hand, i'm using readfile method (after processing file-independent data) , not sure if allow malicious execute on server. also, according manual, seems if want use url readfile , need enable fopen wrappers . thanks. readfile not execute code on server there no issue there. however, strange folks use server perform web requests in order server trouble making unauthorized requests or cause overloading you'll want keep in mind when coding type of functionality. according manual, seems if want use url readfile, need enable fopen wrappers yes, you'll need make sure allow_url_fopen on. if isn't, you'll have using curl .

Selective file renaming in Powershell -

i've got large directory of files, many (but not all) of have been backed in place means of copying them , inserting .backup inbetween filename , extension. using powershell create backup of files have been backed once, time tagged .backup.(date). i'm still new powershell i'm bit shaky basics. in case snag can't think through how select files there exists identical filename .backup. getting .backup files can do, getting .backup-less counterparts , passing them pipe can't yet. guess i'm curious there being exists operator use in where-object or something. any ideas? this should give list of filenames of ones have existing backup: $files = gci <directory path> -name $backups = $files | {$_ -match "\.backup\.[^\.]+$"} $backedup = $backups | foreach {$_ -replace "backup\."} $newbackups = $backedup | {$files -contains $_} get names of .backup. files. remove .backup name. see if original list of files has name ...

mysql - How to restrict Search page numbers on bottom of search result page-php? -

Image
i having problem in restricting search result page number in php page. i using 3 fields select user input , displaying search results @ bottom . whenever select fields, page number goes on increasing @ bottom equals total number of pages in db , hence stretches page wide , hence changes page layout. what if want 10 or 15 pages display , rest of them shown next-> m using changing page 1 page 2. image below 34 result total number of entries , want 15. i using following code: $nav=""; if($page > 1) { $nav .= "<a href=\"search.php?page=". ($page-1)."&countrycode=". urlencode($country)."&linkagetype=". urlencode($linkage)."&college=". urlencode($college) . "\"><< prev</a>"; } for($i = 1 ; $i <= $numberofpages ; $i++) { if($i == $page) { $nav .= "&nbsp;<b>$i</b>"; }else{ $nav .=...

.net - Should I use the client proxies when needed or open them all at the beginning? -

i have wcf client application consists of 5 proxies make own connections throughout lifecycle of application. duration client running not long @ (less 1 minute). i calling method on proxies when needed to, seems alleviated me having call "proxy.open()". guess proxy opens automatically after first method call made. now wondering if should explicitly calling "proxy.open()" on proxies before call method on them? additionally, should open of them @ start of client application, since runtime less 1 minute? there best practice? appreciate help. when proxy used in more thread, invoking open explicitly preferable described in article .

How can I generate html test report using python in my code -

from selenium import selenium import unittest, time, re import htmltestrunner class untitled(unittest.testcase): def setup(self): self.verificationerrors = [] self.selenium = selenium("localhost",4444,"*iexplore","http://google.com.ua/") self.selenium.start() def test_untitled(self): sel = self.selenium sel.open("/") sel.type("q", "home") sel.click("btng") sel.click("link=welcome home.com") sel.wait_for_page_to_load("30000") self.failunless(sel.is_text_present("results * selenium rc")) def teardown(self): time.sleep(25) self.selenium.stop() self.assertequal([], self.verificationerrors) if __name__ == "__main__": unittest.main() when faced similar problem had override testresult , testcase.defaulttestresult() collect data number of lists convenient...

Apachebench request count and Node.js script counter don't match -

no doubt i'm doing stupid, i've been having problems running simple node.js app using nerve micro-framework. testing apachebench, seems code within single controller being invoked more app being called. i've created test script so: 'use strict'; (function () { var path = require('path'); var sys = require('sys'); var nerve = require('/var/www/libraries/nerve/nerve'); var nervecounter = 0; r_server.on("error", function (err) { console.log("error " + err); }); var app = [ ["/", function(req, res) { console.log("nc = " + ++nervecounter); }] ]; nerve.create(app).listen(80); }()); start server. box, run load test: /usr/sbin/ab -n 5000 -c 50 http://<snip>.com/ ... complete requests: 5000 ... percentage of requests served within time (ms) ... 100% 268 (longest request) but node script printing way to: nc =...

osgi - Adding a servlet filter that wraps the request into a HttpServletRequestWrapper seem to break page forwading -

i'm having issues getting servlet forwarding work when request have been wrapped httpservletrequestwrapper. this server-side equinox application, running within eclipse using embedded jetty web server provide httpservice implementation. to isolate issue, thing field wrap request , pass forward: public class testfilter implements filter { public void dofilter(servletrequest request, servletresponse response, filterchain chain) throws ioexception, servletexception { chain.dofilter(new httpservletrequestwrapper((httpservletrequest)request), response); } ... } ...and servlet nothing trying forward jsp: @override protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { requestdispatcher dispatcher = request.getrequestdispatcher("/account.jsp"); try { dispatcher.forward(request, response); } catch (exception e) { e.printstacktrace(); } } according ...

xamarin.ios - Monotouch.Dialog: Enable Selection in UITableView -

using monotouch.dialog create table of values. when user clicks row, row should flash blue per normal. how enable in monotouch.dialog? monotouch.dialog supports flashing behavior elements can respond events (like stringelement when has tap-handler attached) or other elements need respond user's interaction. this done setting selectionstyle property on cell uitableviewcellselectionstyle.blue most of cells not respond user's input have value in monotouch.dialog set none. can either change source code make use blue everywhere, or make sure using right element right use case. i blogged design patterns building elements recently, if want roll own: http://tirania.org/monomac/archive/2011/jan-18.html

azure - How to make a role only accessible via AzureConnect -

is possible configure role endpoint only allows communication on azure connect? ie, have web application not want expose outside world, local endpoints (azure connect machines) have access without additional security. in full-vpn scenario happen, i'm struggling define/setup in constraints of azure connect , csdef. have role(s) communicating on-campus resources via connect, can't seem limit access these resources without declaring standard http endpoint. tried creating internal endpoint, appears allowing access w/i actual datacenter (b/t hosted roles) i think internal endpoint trick. iis (assuming you're using web role) listen on right (be sure specify 1 know is), , won't open traffic internet. what happens when use internal endpoint , try connect it? , other sorts of connections work? (are sure connect working?)

android - PNG overlay over active Canvas animations -

i developing 2d sprite-based game bunch of animations. developed separate threads , in general great. i added level has alpha png graphic drawn on canvas after rest of animated bitmaps have been drawn. there noticeable speed degradation on level , seems sputter etc... top off added multiply xfermode paint graphic , went stand-still. is there better way overlay graphics in fashion avoid hit in performance (i'm assuming has calculate alpha channels , apply canvas bitmap)? there alternative drawing overlay drawbitmap/png? to better performance put overlay in window, either using windowmanager.addview or using poupwindow. composition done on gpu.

Why I can't read replicate data in MongoDB? -

i have created replica set 4 mongod running. port: 2017, 2018, 2019, 2020 very standard. followed instruction in documentation. then set 2020 primary one. , insert data. then go , login one. e.g. ./mongo localhost:2017 and try find(). returns: error: { "$err" : "not master", "code": 10107} why ?? tried on other replicates , gave me same error. i notice error in mongod output when insert data. failed allocate new file: /home/ec2-user/db/r04/test.1, size: 134217728, aborting. i'm no clue what's going on yet. you need set slaveok when querying slaves.

ruby on rails - Bundler: What does :require => false in a Gemfile mean? -

the line one: gem 'whenever', :require => false does means gem needs installed or not required? this means install gem, not call require when start bundler. need manually call require "whenever" if want use library. if do gem "whenever", :require=>"whereever" then bundler download gem named whenever, call require "whereever" this used if name of library require different name of gem.

c++ - Convert Qt 4.7 to 4.2 -

hey, i'm in group compsci project @ school. need write interface in qt. group member wrote gui in qt 4.7 , needs compile qt 4.2. when try qmake project, says "uic: file generated old of version of qt designer". i'm new qt don't know how has changed between versions. group member isn't being help. there painless way me convert files right version of qt? the first thing i'd try open *.ui files in old qt designer , try save them. if doesn't want save newly opened file, i'd make insignificant changes changing property of component different value , back. however, may happen qt designer complain being old particular file, uic did. in case you'll have edit *.ui files hand. plain xml files can done relatively easy. first open them , change version attribute "4.2" or whatever used qt 4.2 there in case it's different qt version. try compile. uic complain properties aren't supported 4.2 or specified in different way. yo...

algorithm - What is the fastest way to check for duplicate digits of a number? -

let's want check if number n = 123 has duplicate digits. tried: #include <iostream> using namespace std; int main() { int n = 123; int d1 = n % 10; int d2 = ( n / 10 ) % 10; int d3 = ( n / 100 ) % 10; if( d1 != d2 && d1 != d3 && d2 != d3 ) { cout << n << " not have duplicate digits.\n"; } } is there faster solution problem? update sorry being unclear. code above written in c++ description purpose. have solve problem in ti-89, number of 9 digits. , since limitation of memory , speed, i'm looking fastest way possible. ti-89 has several condition keyword: if if ... then when( for ... endfor while ... endwhile loop ... endloop custom ... endcustom thanks, chan faster, possibly not (but should measure anyway, in case - optimisation mantra "measure, don't guess" ). clearer in intent, think, yes, , able handle arbitrary sized integers. int hasdupes (unsign...