Posts

Showing posts from July, 2013

c++ - How can I make a proccess in an OnLButtonDown() event happen again and again untill I live the button? -

what happen until this: any line happens once, , if use a while(1) or while (nflags == mk_lbutton) working should crash. the other problem, or maybe same 1 delay if able it, maybe using while() timer() ? i thinking timer() recall function delay can't call onlbuttondown() because asi understand message can call arguments. in onlbuttondown() call settimer() start timer running, eg. every 100ms. add onlbuttonup() , call killtimer() stop timer running. then, code in ontimer() function (add wm_timer message map) , run while mouse held down. note if user clicks , drags mouse outside window, onlbuttondown() called not onlbuttonup() can leave program thinking mouse button stuck down. functions deal are: call setcapture() @ same time settimer() , releasecapture() @ same time killtimer() keep receiving mouse messages no matter mouse is. i'd advise looking functions i've mentioned in answer on msdn , reading on them more information.

c# - When should I create a destructor? -

for example: public class person { public person() { } ~person() { } } when should manually create destructor? when have needed create destructor? the c# language calls these "destructors", people call them "finalizers" since .net name , reduces confusion c++ destructors (which quite different). how implement idisposable , finalizers: 3 easy rules

textmate - moving project drawer to right side -

is solution problem? http://www.devdaily.com/blog/post/mac-os-x/how-to-move-textmate-project-drawer-left-right-side here better solution. defaults write com.macromates.textmate oakprojectdrawerprefersrightedge -bool no

mib - Definition of SNMP Gauge32 vs Counter32 -

can point me definition of gauge32 vs counter32? understand counter32 can wrap, gauge32 can't. i'm trying understand semantics. example, i've heard should take difference between 2 counter32 readings value/second. there gauge32 value? thanks insight. yes, gauge32 can use that. deep down inside, gauge32 , counter32 same, except data stored in counter32 keeps increasing (and wrap when upper limit hits). http://www.ireasoning.com/javadocs/com/ireasoning/protocol/snmp/snmpcounter32.html for gauge32 can expect data increases , decreases based on real world information tries provide. http://www.ireasoning.com/javadocs/com/ireasoning/protocol/snmp/snmpgauge32.html

xhtml - Is it possible to make cross browser website without having any IE conditional CSS? -

if i'm not using transparent png, not using :hover on other thank a:link, is possible make cross browser layout without having ie conditional css .and keep main css valid? i want keep 1 css file whole needs. screen, print, handheld. what things should consider? sure. main thing work on test css files incrementally in multiple browsers build site. it's harder make site correct in multiple browsers once built out single browser. element widths biggest problem since different browsers calculate widths differently.

c# - Can I Re-Use Common Html in an ASP.NET Child Control? -

i have 5 or different pieces of html in page contain same scaffolding html surrounding it, this: //panelbase.ascx <div class="panel" id="[panel-specific-id]"> <h3>[panel-specific-header]</h3> ... [panel-specific-html] ... </h3> </div> where panel-specific things different each panel type. there way can create common base control handle scaffolding , inherit supply panel-specific-html? panel-specific-id , panel-specific-header can pass panel directly, since panel specific html large don't want pass directly string. or there way in each child control's ascx file: <my:panelbase panelid="mychildpanel" header="my child's header"> // html child panel. </my:panelbase> basically, i'm looking way reuse common portions of control don't have duplicate each child. i guess "most proper" way of doing have main content of container...

SQL Server database synchronization issues -

i have 2 sql server 2008 enterprise databases (on 2 machines), , 1 of databases master database , database slave database (master database read/write, slave database readonly). want have daily update master database slave database (i.e. new data inserted/updated/deleted in master database synchronized slave database daily or manually controlled). need sync several tables of databases, not of database. any solutions or documents? thanks in advance, george another option in ssis (sql server integration services) . here's tutorial giving overview of can do. tutorial sql server 2005 concepts remain same. you can run packages manually or can scheduled. hth

c# - WCF - Binary Encoding over HTTP throwing client and service binding mismatch exception -

the exception: content type application/soap+msbin1 not supported service http://localhost:1500/myservice.svc . client , service bindings may mismatched. the client configuration: <system.servicemodel> <bindings> <custombinding> <binding name="nethttpbinding" closetimeout="00:01:00" opentimeout="00:01:00" receivetimeout="00:10:00" sendtimeout="00:01:00"> <binarymessageencoding /> <httptransport allowcookies="false" bypassproxyonlocal="false" hostnamecomparisonmode="strongwildcard" maxbuffersize="65536" maxbufferpoolsize="524288" maxreceivedmessagesize="65536" transfermode="buffered" usedefaultwebproxy="true" /> </binding> </custombinding> </bind...

modalpopups - How can I create a non-modal dialog in Perl/Tk? -

i learning perl/tk. want give alert user whenever he/she receives mail. i have planned use message box in tk, expecting user click ok or cancel button. until user clicked 1 button wont further operations. but want, needs give alert user , user can continue further process. refer link non blocking dialog box in perl tk

Simple "Hello World!" console application crashes when run by windows TaskScheduler (1.0) -

i have batch file starts multiple instances of simple console application (hello world!). work on windows server 2008 64-bit. configure run in taskscheduler, @ startup, , whether user logged-in or not. later configuration means instances run without gui (i.e. - no window). when run task, of instances fail, after consuming 100& cpu. application event-log shows following error: "faulting module kernel32.dll, version 6.0.6002.18005, time stamp 0x49e0421d, exception code 0xc0000142, fault offset 0x00000000000b8fb8, process id 0x29bc, application start time 0x01cae17d94a61895." running batch file directly works fine. seems me os has problem loading many instances of application when no window displayed. - can’t figure out why... any idea?? this issue has fix, microsoft expert: http://social.msdn.microsoft.com/forums/en/windowsgeneraldevelopmentissues/thread/9102531c-cf60-4682-b014-c11a190b00f1?prof=required

windows phone 7 - How to share files created by an app? -

how share files (music, video, image) create app? interested in sharing audio file specifically. imagine have program generates wav file. how take isolated storage? is possible sent attachment e-mail? save on skydrive? share on facebook? put media library? at least in convenient user way take out wp7 device? any regarding topic welcome you cannot directly send attachment through emailcomposertask, can use own implementation of email sending mechanism. you can save skydrive, again have use custom api layer (developed or third-party) achieve this. a better choice in opinion having wcf service transmit byte array of generated content specific location - give more control on transmission layer.

How to detect when a tab is focused or not in Chrome with Javascript? -

i need know if user viewing tab or not in google chrome. tried use events blur , focus binded window, blur seems working correctly. window.addeventlistener('focus', function() { document.title = 'focused'; }); window.addeventlistener('blur', function() { document.title = 'not focused'; }); the focus event works weird, sometimes. if switch tab , back, focus event won't activate. if click on address bar , on page, will. or if switch program , chrome activate if tab focused. 2015 update: new html5 way visibility api (taken blowsie's comment): document.addeventlistener('visibilitychange', function(){ document.title = document.hidden; // change tab text demo }) the code original poster gives (in question) works, of 2011: window.addeventlistener('focus', function() { document.title = 'focused'; }); window.addeventlistener('blur', function() { document.title = 'not focused...

Is there any way of handling events in php -

is there way handle events in php, i'm looking way handle event's posting form. thanks, sreejith posting form not event: page called (that's event you'll far know), can check values present in $_get , $_post or combined $_request , , act on them.

Java Package defnition -

is there website can come know information about technical implementation possibilities where package used extensively why used? for example timertask, used scheduling task execute in batch mode. other have other scenarios can use it? please share information helpful. i sorry if question appears vague, want learn possibilities in java the offical java api: http://java.sun.com/javase/6/docs/api/index.html?overview-summary.html and java book or tutorial tell lot of examples , possibilities java.

python - Google App Engine - Use Task Queues or Deferred Jobs -

google app engine has 2 methods running jobs @ later point, task queues , deferred jops they support same features far can tell (e.g. deferred job can placed on particular task queue can throttle execution) - deferred jobs easier implement , more flexible. anyone know of pro's con's of each method? circumstances want use task queues on deferred jobs? i'm not sure if noticed it, documentation deferreds has section in end: you may wondering when use ext.deferred, , when stick built-in task queue api. here our suggestions. you may want use deferred library if: you use task queue lightly. you want refactor existing code run on task queue minimum of changes. you're writing 1 off maintenance task, such schema migration. your app has many different types of background task, , writing separate handler each burdensome. your task requires complex arguments aren't serialized without using pickle. you writing library other ap...

javascript - Hide certain values in output from JSON.stringify() -

is possible exclude fields being included in json string? here pseudo code var x = { x:0, y:0, divid:"xyz", privateproperty1: 'foo', privateproperty2: 'bar' } i want exclude privateproperty1 , privateproperty2 appearing in json string so thought, can use stringify replacer function function replacer(key,value) { if (key=="privateproperty1") retun "none"; else if (key=="privateproperty2") retun "none"; else return value; } and in stringify var jsonstring = json.stringify(x,replacer); but in jsonstring still see as {...privateproperty1:value..., privateproperty2:value } i string without privateproperties in them. the mozilla docs return undefined instead of "none" : http://jsfiddle.net/userdude/rz5px/ function replacer(key,value) { if (key=="privateproperty1") return undefined; else if (key=="privateproperty2") retu...

windows - How to kill a process opened with open () -

i trying kill process opened in background in perl on win32 (xp) tried several things.... not seems working.... $pid = open( cmd, "| cmd.exe > c:\\cmdout.txt" ); to kill background process tried several things....:( system('taskkill /f /im cmd.exe'); system("taskkill /f /pid $pid"); close cmd || warn "cmd exited $?"; option 2 never works tried print values of pid print , actual in system different. option 1 works feel process still running in ground because after end process wait time , re start process... please -thanks i played bit case. apparently 2 cmd.exe started, parent pid returned open , child doing commands. second scenario partially works, kills parent, child remain running. using /t option taskkill can force kill children: system("taskkill /f /t /pid $pid"); you see message termination of both processes: success: process pid 3956 child of pid 1864 has been terminated. success: proces...

css - html and divs content -

i have such structure (divs): #content-wrapper-> #left #center #right #footer #footer { position: relative; } #content-wrapper { position: relative; clear: both; overflow: hidden; width: 100%; height: 100%; min-height: 300px; } but when text in #center div bigger, min-height , becomes on #footer . what's wrong? upd: example address: link thanks providing content. looks problem happening because #content-center has fixed height of 200px. rid of (and fixed height #content-left , #content-right unless have reason keep it), or change min-height instead, , footer should show below content expected. you'll still run problems if #content-left or #content-right longest column. deal that, remove footer #content-wrapper div -- set structure this: <div id="content-wrapper"> <div id="content-left"></div> <div id="content-right"></div> ...

intellij idea - Simple test with Scala Test 1.2 -

i'm trying run test using scala 2.8 in intellij 10 scala test 1.2 i don't know scala syntax, can this code ? :) package test.ui { import org.scalatest._ import matchers.shouldmatchers import ui._ import observer._ object buttonobserverspecification extends spec { "a button observer should observe button clicks" in { val observablebutton = new observablebutton("okay") val buttonobserver = new buttoncountobserver observablebutton.addobserver(buttonobserver) (i <- 1 3) observablebutton.click() buttonobserver.count should equal (3) } } } the error : error: value in not member of java.lang.string "a button observer should observe button clicks" in { here rest of code : package ui { abstract class widget class button(val label: string) extends widget { def click() = { println (label + " clicked") } } } package observer { trait subject { type observer = {def receiveupdat...

SVNKit: How to get the revision number from a working directory -

i implement method can svn revision number path svn repository has been checked out. method declaration this: long getrevisionnumber(string localpath) { ... } i'm trying use svnkit this, seems require svn url start with. there way start local path? public static long getrevisionnumber(string localpath) throws svnexception { final svnstatus status = svnclientmanager.newinstance().getstatusclient().dostatus(new file(localpath), false); return status != null ? status.getrevision().getnumber() : -1; }

Creating and writing file from a FileOutputStream in Java -

okay, i'm working on project use java program initiate socket connection between 2 classes (a filesender , filereceiver ). basic idea filesender this: try { writer = new dataoutputstream(connect.getoutputstream()); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } //while have bytes send while(filein.available() >0){ //we write them out our buffer writer.write(filein.read(outbuffer)); writer.flush(); } //then close our filein filein.close(); //and our socket; connect.close(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); the constructor contains code checks see if file exists, , socket connected, , on. inside filereader though: input = recvsocket.accept(); bufferedreader br = new bufferedreader(new inputstreamreader(input.getinputstream())); fileoutputstream fout= new fileoutputstream(filename); string line = br.readline(); while(line != null){ fout.write(line.getbytes()); ...

unicode - Python: 'ascii' codec can't encode character u'\\u2026' -

i trying use bing api in python following code: #!/usr/bin/python bingapi import bingapi import re import json import urllib import cgi import cgitb htmlparser import htmlparser class mlstripper(htmlparser): def __init__(self): self.reset() self.fed = [] def handle_data(self, d): self.fed.append(d) def get_data(self): return ''.join(self.fed) def strip_tags(html): s = mlstripper() s.feed(html) return s.get_data() def strip_tags2(data): p = re.compile(r'<[^<]*?>') q = re.compile(r'[&;!@#$%^*()]*') data = p.sub('', data) return q.sub('', data) def geturl(item): return item['url'] def getcontent(item): return item['description'] def gettitle(item): return item['title'] def getinfo(qry, sitestr): qrystr = qry + "+" + sitestr #qrystr = u"%s" % qrystr.encode('utf-8') ...

cocoa - Make NSView in NSPanel first responder without key window status -

is possible give nsview inside nspanel first responder status without giving nspanel key window status (making main application window resign key)? thanks. well, ended figuring 1 out, took lot of research i'll post details here in case else runs same problem. first of all, few basics: it's impossible have 2 windows key @ same time it's possible fake window thinking it's key overriding -iskeywindow won't give views contained in window first responder status. my scenario: i added child window containing nstableview main application window (the reason irrelavant). child window nspanel nsborderlesswindowmask . wanted give nstableview first responder status without making panel key window because took away focus main window (and whole point of child window illusion make child window part of main window). the first thing tried fooling table view thinking inside key window overriding iskeywindow return yes . made table view draw if first res...

java - Default constructor vs. inline field initialization -

what's difference between default constructor , initializing object's fields directly? what reasons there prefer 1 of following examples on other? example 1 public class foo { private int x = 5; private string[] y = new string[10]; } example 2 public class foo { private int x; private string[] y; public foo() { x = 5; y = new string[10]; } } initialisers executed before constructor bodies. (which has implications if have both initialisers , constructors, constructor code executes second , overrides initialised value) initialisers when need same initial value (like in example, array of given size, or integer of specific value), can work in favour or against you: if have many constructors initialise variables differently (i.e. different values), initialisers useless because changes overridden, , wasteful. on other hand, if have many constructors initialise same value can save lines of code (and make code mo...

debugging - Installing ZFDebug toolbar on ZF 1.10+ -

i think it'll have zfdebug tutorial in so. i wondering if use zfdebug toolbar zf 1.10+ (i'm using 1.11.2 ). have following code in bootstrap nothing seems happen: protected function _initzfdebug() { $autoloader = zend_loader_autoloader::getinstance(); $autoloader->registernamespace('zfdebug'); if ('development' == application_env) { $options = array( 'jquery_path' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', 'plugins' => array('variables', 'html', 'database' => array(), 'file' => array('basepath' => application_path . '/application'), 'memory', 'time', 'registry', //'cache' => array('backend' => $cache->getbackend()), 'exception') ); $debug = new zfdebug_controller_plugin_debug($options...

c++ - QNetworkRequest (HTTP GET) doesn't fire, after refactoring into a standalone class -

i've began tedious process of modularising large, monolithic audio player application wrote 2 months ago. this process going reasonably well, although appears 1 of methods (scrobblemedia - predictably enough makes http requests submit information playing track last.fm) no longer seems make network requests. however, qurl object passed through qnetworkaccessmanager instance/qnetworkrequest being built correctly. for comparison, functional mercurial revision of code available on bitbucket . the scrobblemedia method looks this, after refactoring: #include "scrobblemedia.h" #include <qdebug> #include <cstdio> scrobblemedia::scrobblemedia(qstring asusername, qstring aspassword, qstring asartist, qstring astrack, qstring asalbum) { qstring kendpointurl = "http://lastfmstats.livefrombmore.com/universalscrobbler/scrobble.php"; qurl iscrobbleendpoint(kendpointurl); qnetworkaccessmanager *iscrobbledispat...

xml - Does it matter if I use relative or absolute path's when running a php script via cron? -

i working on script attempting automate via cron. running script via terminal fine, when attempt run script crontab, getting issues. part of script loads , validates , xml file via domdocument::loadxml() , domdocument::validate() , php throws error when attempting validate stating: failed load external entity: /linuxuser/homefolder/my_dtd.dtd within xml file, dtd set to: ../../../../../../../my_dtd.dtd is there misconfiguration of server or more wrong php code @ point? seems grab linux home directory rather path relative xml file. wondering if else has seen issue or point me in right direction. thanks. quoting php documentation differences in cli usage (command-line interface): the cli sapi not change current directory directory of executed script! when php scripts run via cron, executed on user's home directory. can either replace relative path references used script absolute, or place on start of script: chdir(dirname(__file__)); # php 5.2...

java - Kryo serialization library: is it used in production? -

kryo new , interesting java serialization library, , 1 of fastest in thrift-protobuf benchmark. if you've used kryo, has reached enough maturity try out in production code? update (10/27/2010): we're using kryo, though not yet in production. see answer below details. update (3/9/2011): updating latest jackson , kryo libraries shows jackson's binary smile serialization pretty competitive. there bug report , discussion thread . dateserializer comes kryo more efficient size-wise simpleserializer implementation posted on because uses longserializer optimized positive values. edit: forgot answer original question. believe kryo used in @ least few production systems. there mention of in article, jive sbs cache redesign: part 3 . in destroy humans project, kryo used communicate android phone serves robot brain ( video here ). not direct answer, might browse kryo source and/or javadocs . check out read* , write* methods on kryo class, @ serializer clas...

javascript - JQuery: How does Gowalla perform it's "slide" effect? -

how gowalla.com perform it's slide effect on frontpage? what jquery effect can mimic functionality of sliding down effect? in jquery, can use slidedown similar, gowalla seems use different method: the individual panels inside parent panel periodically changes position. is, panels aren't animating, , nothing changing size: it's moving panels through viewport. when reaches bottom, gowalla page stops - loads enough panels 4 minutes of sliding - though in case, might want take panels off bottom , push them in top make continuous.

Substring in excel -

i have set of data shown below on excel. r/v(208,0,32) yr/v(255,156,0) y/v(255,217,0) r/s(184,28,16) yr/s(216,128,0) y/s(209,171,0) r/b(255,88,80) yr/b(255,168,40) y/b(255,216,40) and want separate data in each cell this. r/v 208 0 32 r/s 184 28 16 r/b 255 88 80 what function in excel can use case. thank in advance. kennytm's links dead , doesn't provide example here's how substrings: =mid(text, start_num, char_num) let's cell a1 hello . =mid(a1, 2, 3) would return ell because says start @ character 2, e , , return 3 characters.

c# - How would one find the item of a List<string> based on it's index -

i display text stored in list. have index number, , use index number item collection. thx you can use elementat : var item = list.elementat(3); or use indexer, like: var item = list[3];

How does one set the Id of a WorkflowApplication instance in Workflow 4.0 -

in workflow 3.0-3.5 explicitly set id of workflow start. feature particularly useful. cannot see way in workflow 4.0. know if possible? since id property read-only , there no overloaded constructor accepting id, possible mechanism see if there magic key used when passing idictionary object workflowapplication constructor. cheers, rohland in wf4 there no way , id generated workflowapplication. arguments dictionary isn't going there either. why want specify guid workflow instead of workflowapplication providing 1 you?

c# - My program has been "published", how can I change the installation path? -

i "published" c# solution in visual studio 2008 c:\deploy. when run setup.exe program, installs program c:\documents , settings\kevin\start menu\programs\myprogram is there way, within visual studio, set custom install path? instance, if wanted program install c:\program files\myprogram? publishing uses clickonce deployment. clickonce has advantage it's easy install , update, , doesn't require user have administrator privileges install application. if you'd more traditional next-next-next-next-finish installer, allows user specify target folder (and set/force default one), add "setup project" solution clicking file >> add >> new project..., in tree select other project types >> setup , deployment , double click setup project. when build setup project, create msi file (microsoft installer setup file) , bootstrapper exe file (in case user doesn't have microsoft installer or required .net framework, installs automatica...

iphone - observeValueForKeyPath not being called -

i have viewcontroller creating instance of uiview, , register observer instance, such that logoanimation = [[mainlogoanimation alloc] init]; [logoanimation addobserver:self forkeypath:@"patrociniodidload" options:(nskeyvalueobservingoptionnew|nskeyvalueobservingoptionold) context:nil]; then, in same file, have: - (void)observevalueforkeypath:(nsstring *)keypath ofobject:(id)object change:(nsdictionary *)change context:(void *)context { nslog(@"%@ \n %@ \n %@ \n ",keypath,object,change); } but, although have checked , double-checked logoanimation.patrociniodidload has changed, observevalueforkeypath never gets called... am missing something? thanks help! antonio solved it: setting patrociniodidload in logoanimation directly, without using standard getters , setters. in logoanimation, patrociniodidload = yes; didn't work, whereas self.patrociniodidload = yes; did!

xml - Host-file colums may be skipped only when copying into the server -

i want create xml file database bcp. the following code works in sql server 2008 not in sql express 2005. this code error: sqlstate = s1000, nativeerror = 0 error = [microsoft][sql native client] host-file columns may skipped when copying server these sql express info: microsoft sql server management studio express: 9.00.4035.00 microsoft data access components (mdac): 2000.085.1132.00 (xpsp.080413-0852) microsoft msxml: 2.6 3.0 4.0 5.0 6.0 microsoft internet explorer 8.0.6001.18702 microsoft .net framework: 2.0.50727.3615 so: 5.1.2600 this code: declare @filename varchar(150) declare @dataexport datetime declare @param varchar(8) set @filename = 'c:\backupsql\xmloutput.xml' set @dataexport = '20110122' set @param = 'xxx' declare @sqlcmd varchar(1800) select @sqlcmd = 'bcp ' + '"declare @xml xml; ' + 'declare @text varchar(max); ' + 'set @xml = (select ' + '(select ''' ...

c# - How to inspect cache policies inside System.Runtime.Caching.ObjectCache? -

i'm making use of new .net 4.0 caching namespace: system.runtime.caching . now, i'm doing prototype/fiddling new api, in order work out best fit real app. in line that, i'm trying create page (asp.net mvc) dumps out in cache, particularly following info: cache key cache object cache policy (expiry date, etc) cache dependencies (if any) however, can't seem except key/object. here's code i'm playing with: public actionresult index() { var cache = memorycache.default; // can list of cache keys this: var cachekeys = cache.select(kvp => kvp.key).tolist(); // can strongly-typed "cacheitem" this: cacheitem item = cache.getcacheitem("somekey"); } i have hoped "cacheitem" class expose information require (expiry, dependencies, etc - @ least "getters"). but doesn't. has properties key, value , region name. how can inspect items in cache , spit out information require? is there na...

flash - embed video object in html -

i embed video in html page swf file. running on local host when run on live server. dosent work properly. link flv video in swf file , embed in html. <script type="text/javascript"> ac_fl_runcontent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','600','height','338','title','testing','src','edit_video/9vi/home-page2','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?p1_prod_version=shockwaveflash','movie','edit_video/9vi/home-page2' ); //end ac code </script><noscript><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="600" height="338" title="testing"> <param nam...

c# - MySqlDateTime to System.DateTime conversion -

ok i'm new databases , c# in general, i'm using piece of code exports dataset data excel file, , taking issue date/time format. i'm using mysql connector rowtype mysql.data.types.mysqldatetime. there quick way convert system.datetime can slot straight case statement? here's link code used, copied verbatim i've not copied , pasted here. throws mysql.data.types.mysqldatetime not handled exception: code project in advance help. what do, format output in query c# date time format, , parse reults: mysql command select date_format(now(), '%y-%m-%d %t') 'date'; c# datetime x; datetime.tryparse(results["date"], out x); if need more explanation comment , ask :) update comment presuming appdate column date one: select appref, date_format(appdate, '%y-%m-%d %t') 'appdate' applications id > 810000

c++ - QMetaMethods for regular methods missing? -

i'm new in qt, , i'm testing out moc. given class: class counter : public qobject { q_object int m_value; public: counter() {m_value = 0;} ~counter() {} int value() {return m_value;} public slots: void setvalue(int value); signals: void valuechanged(int newvalue); }; i want list of methods in class, seem getting list of signals , slots, although documentation says should methods? here's code: #include <qcoreapplication> #include <qobject> #include <qmetamethod> #include <iostream> using std::cout; using std::endl; int main(int argc, char *argv[]) { qcoreapplication app(argc, argv); const qmetaobject cntmo = counter::staticmetaobject; for(int = 0; != cntmo.methodcount(); ++i) { qmetamethod qmm(cntmo.method(i)); cout << qmm.signature() << endl; } return app.exec(); } please beware best c/p, perhaps forgot include headers. my output: destroyed(qobject*) destroyed() deletelater() _q_reregistertimers(void...

c# - DataContractSerializer misses an object -

i using datacontractserializer deserialize xml list. the xml structure follows: <arrayofattributes> <attributes> <type></type> <value></value> <name></name> </attributes> </arrayofattributes> the attributes class has 3 string data members referenced through properties, are: [datamember(order=0)] type [datamember(order=1)] value [datamember(order=2)] name when wcf service returns more 1 attributes element in xml, name object gets populated if 1 attributes element returned, value of name remains null. does know i'm doing wrong ? seems datamember order wrong per pasted xml. try [datamember(order=0)] type [datamember(order=1)] name [datamember(order=2)] value other option [datamember] type [datamember] name [datamember] value try second one, work :)

java - OSGI classcast exception on felix -

i'm new osgi , trying functional proof of concept together. the setup common api created in bundle creatively named common-api.jar no bundle activator, exports it's interfaces. 1 of interest in situation databaseservice.java. i have second bundle called systemx-database-service. implements database service interface. works fine in activator of implementation bundle test connection database , select arbitraty values. register service want available other bundle's so: context.registerservice(databaseservice.class.getname(), new systemdatabaseserviceimpl(context), new properties()); the basic idea being when service reference database service you'll systemdatabaseservice implementation. when inspect service output this: -> inspect s c 69 system database service (69) provides services: ---------------------------------------------- objectclass = za.co.xxx.xxx.common.api.databaseservice service.id = 39 which lead me believe if in test bundle: contex...

c - Running daemon through rsh -

i want run program daemon in remote machine in unix. have rsh connection , want program running after disconnection. suppose have 2 programs: util.cpp , forker.cpp. util.cpp utility, our purpose let infinite root. util.cpp int main() { while (true) {}; return 0; } forker.cpp takes program , run in separe process through fork() , execve(): forker.cpp #include <stdio.h> #include <errno.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char** argv) { if (argc != 2) { printf("./a.out <program_to_fork>\n"); exit(1); } pid_t pid; if ((pid = fork()) < 0) { perror("fork error."); exit(1); } else if (!pid) { // child. if (execve(argv[1], &(argv[1]), null) == -1) { perror("execve error."); exit(1); } } else { // parent: nothing. } return 0; } if run: ./forker util forker finished quickly, , bash 'is not paused', , ut...

c# - MSMQ only tries 3 times to receive a message before an error occurs -

i have messages in queue. notice after 3 tries service host faults. normal behavior? 3 times comes from? thought came receiveretrycount. set 1 1. i got 20 messages in queue waiting processed. wcf operation responsible process message supports transaction if can't process message throw message stays in queue. i didn't think of fault servicehost after number of retry, part documented somewhere? i'm running msmq service on winxp machine. i'm more interested in documentation indicating service host fault after number of retry. part true? i think found reason why faults. there property on binding of msmq called receiveerrorhandling default set fault fault channel listener when receiveretrycount has been maxed out.

c# - How to write a clear and elegant code for a strategy pattern based application? -

i writing application compose musical freizes, little worried structure of classes , interfaces within code. here there signatures of classes wrote: interface iguidoformattable class note : iguidoformattable, icloneable class pause : iguidoformattable, icloneable class chord : list<note>, iguidoformattable, icloneable class key : iguidoformattable, icloneable class tempo : iguidoformattable, icloneable class meter : iguidoformattable, icloneable class fretpiece : list<iguidoformattable>, icloneable class fret : list<fretpiece> fretpiece represents muscial phrase, piece of complete freize. exposes properties key, tempo , meter, homonym types. more phrases put create freize, respresented fret class. every element within single phrase must formattable in accordance guido standard notation, hence has implement iguidoformattable interface. in namespace, mutation classes defined , inherit 1 of 2 abstract classes: class fretmutation class lambdafretmutation : fretm...

android - Using Shared preferences -

show example when user fill phone number , password in edit text , click submit information stored in database using shared preferences. shared preferences stored in file , not in database. sharedpreferences myprefs; myprefs = this.getsharedpreferences("preference", mode_private); edittext phonenumber_edit = (edittext) findviewbyid(r.id.phonenumber_edit); edittext password_edit = (edittext) findviewbyid(r.id.password_edit); button submit = (button) findviewbyid(r.id.submit); submit.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { sharedpreferences.editor prefseditor = myprefs.edit(); prefseditor.putstring("phonenumber", phonenumber_edit.gettext()); prefseditor.putstring("password", password_edit.gettext()); prefseditor.commit(); } }

java - Apache FOP generating blank page -

i trying generate pdf using apache fop , java. using valid xsl-fo file can create pdf using command line fop. my problem occurs when try run fop using apache fop libraries. running across java/php bridge. bride configured , java / php communicate. on java side have function takes in string containing xsl-fo , returns string contains pdf. when execute function , redirect output stdout file, or across java / php bridge, pdf appears blank , size double of correct pdf retrieve via command line. assume having kind of encoding problem. has seen issue before? here java code public string convertfotopdf(string fo) { // contain results after transformation. bytearrayoutputstream out = new bytearrayoutputstream(); // input string stringreader sr = new stringreader(fo); // should utf-8; string strencoding = charset.defaultcharset().name(); // resulting string. string pdfresult = ""; try { // instance of fop factory ...

javascript - How to discover Font Type? -

is there way determine type of given font (truetype, opentype, type 1, bitmap) using javascript? i'm not sure of help, it's worth try: detecting font used in web page

flash - Determine the centre/center of a circle using multiple points -

i wondering if me, can on pen , paper using compass, can't in actionscript 3. as title says, need find centre of circle using multiple points radius. you want equation circle 3 points . dr. math has some nice explanations on question. edit : i've implemented in javascript + svg; can see interactive result on website: http://phrogz.net/svg/3-point-circle.xhtml here's relevant code (i've created point class in actionscript .x , .y properties): function findcirclecenter(p1,p2,p3){ var d2 = p2.x*p2.x + p2.y*p2.y; var bc = (p1.x*p1.x + p1.y*p1.y - d2) / 2; var cd = (d2 - p3.x*p3.x - p3.y*p3.y) / 2; var det = (p1.x-p2.x) * (p2.y-p3.y) - (p2.x-p3.x) * (p1.y-p2.y); if (math.abs(det) > 1e-10) return new point( (bc * (p2.y-p3.y) - cd * (p1.y-p2.y)) / det, ((p1.x-p2.x) * cd - (p2.x-p3.x) * bc) / det ); } edit 2 : fun, instead of 3 points defining 1 circle, how 6 points defining 20? :) http://phrogz.net/svg/3-point-circle2.xhtm...

asp.net mvc - Difficulty to start up with basic unit test (Sample from my book -- SportsStore) -

i'm new in tdd and, actually, i'm trying follow sample book ( sportsstore -- pro asp.net mvc framework/steve sanderson/apress ). i'm on pages 103-105. although there more on this, new of this, i'm concerned following statements. productscontroller controller = new productscontroller(repository); var result = controller.list(2); //... regarding above statements, when write (as in book), var products = result.viewdata.model ilist<product>; i compiler error " system.web.mvc.actionresult" not contain definition viewdata ... " but, when remove list() statement, compiler error disapear. var result = controller.list(2);//doesn't work var result = controller;//it works is wrong there? checked apress website book, there nothing listed errata or issue. so i'm lost. thanks helping that because actionresult not contains definition viewdata howerver viewresult , viewresult actionresult can cast (viewresult) , viewdata ...

c++ - kill unsigned / signed comparison error -

in general, want warnings of unsigned vs signed. however, in particular case, want suppressed; std::vector<blah> blahs; for(int = 0; < blahs.size(); ++i) { ... i want kill comparison. thanks! (using g++) you should fix, not suppress. use unsigned type: for (size_t = 0; < blahs.size(); ++i) you can use unsigned , size_t more appropriate here (and may have different, larger, range). if you're using i iterate , don't need value in loop, use iterators instead: for (auto iter = blahs.begin(), end = blahs.end(); iter != end; ++iter) if compiler not support auto , replace auto t::iterator or t::const_iterator , t type of blahs . if compiler supports fuller subset of c++11, though, this: for (auto& element : blahs) which best of all. strictly speaking, above not "correct". should be: typedef std::vector<blah> blah_vec; blah_vec blahs; (blah_vec::size_type = 0; < blahs.size(); ++i) but can verbose, , ev...

Where is Java's Array indexOf? -

i must missing obvious, i've searched on , can't find method. there couple of ways accomplish using arrays utility class. if array not sorted: java.util.arrays.aslist(thearray).indexof(o) if array sorted, can make use of binary search performance: java.util.arrays.binarysearch(thearray, o)

jQuery AJAX and PHP session issue -

really hope makes sense , can point me in right direction. on registration page (parent page), when enter license code jquery ajax success function loads content page appended url include session id: success: function(data) { if (data=="registererror") { $("#error").show(); $("#processing").hide(); } else { $("#contain").load("download-software.php?sessionid=xxxx #req"); } } the page "download-software" has following php referrer check make sure content being requested registration page via session id , redirects if it's not: <?php $code = $_get['sessionid']; if(strcmp( $code , 'xxxx' ) != 0) { header("location: http://www.someotherpage.com"); } ?> that works fine. need in "download-software #req" content loaded parent page, have link when clicked replaces "download-software #req" content has been loaded inside...

graphics - How do I translate a point from one rect to a point in a scaled rect? -

i have image (i) that's been scaled original size (rectlarge) fit smaller rectangle (rectsmall). given point p in rectsmall, how can translate point in rectlarge. to make concrete, suppose have 20x20 image that's been scaled 10x10 rect. point (1, 1) in smaller rect should scaled point in larger rect (i.e. (2,2)). i'm trying achieve with: result.x = point.x * (destrect.size.width / srcrect.size.width ); result.y = point.y * (destrect.size.height / srcrect.size.height); however, points generated code not correct - not map appropriate point in original image. doing wrong? what language using? if c, , rect.size.height , ints, have major rounding problem. you're scaling point 10, 10 size 20x20 size 30x30 . calculations like: result.x = 10 * (30 / 20); this simplifies to: result.x = 10 * (1); the simplest way fix rid of parentheses: result.x = point.x * destrect.size.width / srcrect.size.width; result.y = point.y * destrect.size.height...

c# - How to do a quick inline method with conditional? -

this i'd do: string x = if(true) "string val" else "no string val"; is possible? what you're talking called conditional statement: string x = boolval ? "string val" : "no string val"; if want string have no value if bool false, change to: string x = boolval ? "string val" : null;

c# - Considerations when using lock -

i have 1 small confusion. using 1 static variable called status property in c# follows private static bool status; public static bool status { { return status; } set { status = value; } } now have started 2 threads separately first thread sets value using property variable status true/false second thread gets value using property variable status. here in scenario, thought happen if first thread tries update value of variable status while second thread tries read value of variable status whether need use lock statement variable status inside property handle thread synchronization or not needed? me clarifying doubt? from question understand thread 1 produces status value , thread 2 consumes value , work based on that. here there no lock required since reading primitive type thread safe (while reading data other thread wont corrupt that). lock required when have 2 or more writer threads want write data. eg if both thread going set status value lock b...

web services - How do I update with a newly-created detached entity using NHibernate? -

explanation: let's have object graph that's nested several levels deep , each entity has bi-directional relationship each other. a -> b -> c -> d -> e or in other words, a has collection of b , b has reference a , , b has collection of c , c has reference b , etc... now let's want edit data instance of c . in winforms, use this: var instanceofc; using (var session = sessionfactory.opensession()) { // instance of c id = 3 instanceofc = session.linq<c>().where(x => x.id == 3); } sendtouiandletuserupdatedata(instanceofc); using (var session = sessionfactory.opensession()) { // re-attach detached entity , update session.update(instanceofc); } in plain english, grab persistent instance out of database, detach it, give ui layer editing, re-attach , save database. problem: this works fine winform applications because we're using same entity throughout, difference being goes persistent detached persistent again. ...