Posts

Showing posts from May, 2011

jquery - Javascript access object variables from functions -

function init_exam_chooser(id,mode) { this.id=id; this.table=$("#" + this.id); this.htmlroworder="<tr>" + $("#" + this.id + " tbody tr:eq(0)").html() + "</tr>"; this.htmlrownew="<tr>" + $("#" + this.id + " tbody tr:eq(1)").html() + "</tr>"; $("#" + this.id + " tbody tr").remove(); //arxikopoiisi var rownew=$(this.htmlrownew); rownew.find("input[type='text']").eq(0).autocomplete({ source: function (req,resp) { $.ajax({ url: "/medilab/prototypes/exams/searchquick", cache: false, datatype: "json", data:{codename:req.term}, success: function(data) { resp(data); } }); }, focus: function(event,ui) { ...

c# - TcpClient send/close problem -

do need close connection have messages sent? because whether use send command or use network stream, messages don't processed until close connection. way it's supposed or missing something? ok here's code. private void connectbutton_click(object sender, eventargs e) { try { client = new tcpclient(); client.connect(ip, port); netstream = client.getstream(); } catch (exception ex) { messagebox.show(ex.message); } } private void disconnectbutton_click(object sender, eventargs e) { if (client != null) { if (client.connected) { client.close(); client = null; } } } private void sendbutton_click(object sender, eventargs e) { byte[] cmd = tobytearray("bla bla bla"); netstream.write(cmd, 0, cmd.length); netstream.flush(); } i don't think has method have look. public static byte[] tobytearray(string str) { system.text.asciiencoding encoding = new system.text....

android - View with visibility state GONE taking up space on screen -

i experiencing problem views visibility state of gone (undesirably) taking space on screen. problem occurs on api level <= 7 devices, on 8+ devices (after utilized asynctasks populate fields, per show progress bar when activity loading ) a bit of context: created custom view extending linearlayout contains "title" button , (user defined; in cases, it's few textviews, in others it's tablelayouts) "contents". purpose of view toggle view of contents onclick of title button (i don't believe there built-in widget this.. may wrong). in onlayout() explicitly set visibility state of child views except title gone, first time drawn: protected void onlayout(boolean changed, int l, int t, int r, int b) { if(initialdraw) { setcontentsvisible(false); initialdraw = false; } super.onlayout(changed, l, t, r, b); } public void setcontentsvisible(boolean visible) { for(int = 0; < getchildcount(); i++) { view child ...

html - Combine two content encodings sections in a single page -

i developed web application allows users modify existing web pages. when user type url of existing web page, read content of page , using ajax call, display content in div inside web application. problem content encoding of existing web page different web app (i use utf-8) there way load content using ajax call different content encoding 1 of main page? thanks, amir your option iframe (as alex said). encoding meta data unique each html document. if need 2 different encodings on page need 2 different html documents.

encryption - repetition in encrypted data -- red flag? -

i have base-64 encoded encrypted data , noticed fair amount of repetition. in (approx) 200-character-long string, base-64 character repeated 7 times in several separate repeated runs. is red flag there problem in encryption? according understanding, encrypted data should never show significant repetition, if plaintext entirely uniform (i.e. if encrypt 2 gb of nothing letter a, there should no significant repetition in encrypted version). according binomial distribution, there 2.5% chance you'd see 1 character set of 64 appear 7 times in series of 200 random characters. that's small chance, not negligible. more information, might raise confidence 97.5% close 100% … or find cipher text uniformly distributed. you "character repeated up to 7 times" in several separate repeated runs. that's not enough information whether cipher text has bias. instead, tell total number of times character appeared, , total number of cipher text characters. example, ...

Business layer: Looking for a complete reference? -

i'm studying business layer , need complete reference covers issues "how manage dependency between business layer , other layers", "how many ways there send data between layers" , important me "how group business logic , make business component , talk possible ways....". do know reference? edit: delighted if introduce e-book it. thank you the best (in opinion) approaches decoupling layers use message passing metaphor. way communication between layers done messages types contain information pertinent communication. these light weight types interpreted each layer see fit. in essence don't pass things not needed. if both layers need piece of information there high hood other entity should brokering access information (for example persisted data in db).

c++ - Efficiently summing log quantities -

working in c++, i'd find sum of quantities, , take log of sum: log(a_1 + a_2 + a_3 + ... + a_n) however, not have quantities themselves, have log'd values: l_1 = log(a_1), l_2 = log(a_2), ... , l_n = log(a_n) is there efficient way log sum of a_i's? i'd avoid log(s) = log(exp(l_1) + exp(l_2) + ... + exp(l_n)) if possible - exp becomes bottleneck calculation done many times. how large n? this quantity known log-sum-exp , lieven vandenberghe talks on page 72 of book . has optimization package uses operation, , brief look, seems if doesn't special there, exponentiates , adds. perhaps exponentiation not serious bottleneck when n small enough vector fit memory. this operation comes in modeling , bottleneck there sheer number of terms. magnitude of n=2^100 common, terms implicitly represented. in such cases, there various tricks approximating quantity relying on convexity of log-sum-exp. simplest trick -- approximate log(s) max(l1,l2,....,ln...

Restrict violation of architecture - asp.net MVP -

if had defined hierarchy in application. ex 3 - tier architecture, how restrict subsequent developers violating norms? for ex, in case of mvp (not asp.net mvc) architecture, presenter should bind model , view. helps in writing proper unit test programs. however, had instances people directly imported model in view , called functions violating norms , hence test cases couldn't written properly. is there way can restrict classes allowed inherit set of classes? looking @ various possibilities, including adopting different design pattern, new approach should worth code change involved. i'm afraid not possible. tried achieve of attributes , didn't succeed. may want refer past post on so . the best can keep checking assemblies ndepend . ndepend shows dependancy diagram of assemblies in project , can track violations , take actions reactively. alt text http://www.ndepend.com/res/ndependbig17.png

Javascript this points to Window object -

i have following code. expected see "archive" object on firebug console, see window object. normal? var archive = function(){} archive.prototype.action = { test: function(callback){ callback(); }, test2: function(){ console.log(this); } } var oarchive = new archive(); oarchive.action.test(oarchive.action.test2); oarchive.action.test2 gets reference function callback points to, function called using callback() , means not called method , hence this global object. key point this not bound function: it's determined how function called. in case explicitly make this point action object (but not archive object) using callback function's call or apply method: test: function(callback) { callback.call(this); }, to this archive object instead, you'll need pass archive object in: var archive = function(){} archive.prototype.action = { test: function(callback, archive){ callback.call(archive); ...

How cancel shutdown from a windows service C# -

i have windows service started (written in c# .net2.0). i want detect when computer shutdown/reboot , cancel it. after cancel want actions , restart windows. i have tried it, not working using microsoft.win32; partial class myservice: servicebase { protected override void onstart(string[] args) { systemevents.sessionending += new sessionendingeventhandler(onsessionending); } private void onsessionending(object sender, sessionendingeventargs e) { e.cancel = true; //do work... } } another test: partial class myservice: servicebase { protected override void onshutdown() { //do work... //base.onshutdown(); } } i wouldn't mess this. windows treat process hung process (unless go direct win32 api). my suggestion take note you're being shutdown, , perhaps schedule activities happen on startup? update: think you're going stuck here, because service won't know why windows be...

android - Force Close problem while Moving track ball on disabled EditText On HTC Hero Phone? -

i have small form four edittext fields in second edittext disable text editing. now when roll android phone ball move top bottom first time selects disabled edittext , third edittext , moves downward foruth edittext. but when try move upward on disabled edittext displays me error force close after selecting it. it happening in phone not in emulator. please guide how resolve issue? any appriciated. when move track ball , down after getting focus on disabled edittext second time receive force close problem in htc hero only. i have tested same problem on nexus 1 phone nothing happened. anyways in htc hero have found solution setting disabled editext selection false.

How can I make the compiler create the default constructors in C++? -

is there way make compiler create default constructors if provide explicit constructor of own? sometimes find them useful, , find waste of time write e.g. copy constructor, large classes. the copy constructor provided whether define other constructors or not. long don't declare copy constructor, one. the no-arg constructor provided if declare no constructors. don't have problem unless want no-arg constructor, consider waste of time writing one. iirc, c++0x has way of delegating construction constructor. can't remember details, allow define no-arg constructor specifying constructor, plus argument(s) pass it. might save typing data member initializers in cases. default no-arg constructor wouldn't have provided initializers either.

c# - What is the best way to sync multiple SqlServers to one SQL Server 2005? -

i have several client databases use windows application. i want send data online web site. the client databases , server database structure different because need add client id column tables in server data base. i use way sync databases; use application , use c# bulk copy transaction sync databases. my server database sql server busy , parallel task cannot run. i work on solution: use triggers after update, delete, insert save changes in 1 table , create sql query send web service sync data. but must send data first! huge data set (bigger 16mg) i think can't use replication because structure , primary keys different. have considered using ssis scheduled data synchronization? can data transformation , bulk inserts easily.

iphone - How to use NSScanner or componentsSeperatedByString -

i have {"red","blue","green","yellow"} returned string. how process add array ? #import <foundation/foundation.h> int main (int argc, const char * argv[]) { nsautoreleasepool * pool = [[nsautoreleasepool alloc] init]; nsstring* samplestring = @"{\"red\",\"blue\",\"green\",\"yellow\"}"; nsarray* components = [samplestring componentsseperatedbystring:@"\"{"]; [pool drain]; return 0; } updated code# nsstring* samplestring = @"{\"red\",\"blue\",\"green\",\"yellow\"}"; nsmutablearray *rows = [nsmutablearray array]; // newline character set nsmutablecharacterset *removecharacterset = (id)[nsmutablecharacterset charactersetwithcharactersinstring:@"{(,}"]; [removecharacterset formintersectionwithcharacterset:[[nscharacterset whitespacecharacterset] invertedset]]; // characters important pars...

php - Update "Properties" model when adding a new record in CakePHP -

i'm writing application in cakephp that, now, used make quotes customers. quote model. want have separate model/table "property," may used other models. each time user gets "add quote" action, want pull property called "nextquotenumber" or along lines, , automatically increment property, even if new quote isn't saved. don't think using autoincrement quote's id appropriate here - also, "quote number" different row's id. i know simple enough do, i'm trying figure out "proper" cakephp way of doing it! i'm thinking should have method inside property model, "getproperty($property_name)", pull value return, , increment value... i'm not sure best way of doing is, or how invoke method quotes controller. what should do? in advance! i ended doing bit more specific, making model 'sequence' rather more general 'property'. sequence has 3 fields: id, name, value. sin...

iphone - App crashes due to WebView -

in app using uiwebview display websites, whenever click button , start playing other parts in app, app crashes no reason. suspect webview causing issue because crashes when try open webview. i have used nsurlconnection load webview , have made webview, connection objects nil in view disappear method. @implementation newswebsiteviewcontroller @synthesize connection,rcvddata,spinner1,currentsite,webview,newswebsite; - (void)viewdidload { [super viewdidload]; @try { self.webview.delegate=self; [uiapplication sharedapplication].networkactivityindicatorvisible=yes; self.title= self.newswebsite.title; self.webview.backgroundcolor =[uicolor grouptableviewbackgroundcolor]; self.spinner1 = [[uiactivityindicatorview alloc] initwithactivityindicatorstyle:uiactivityindicatorviewstylewhitelarge]; cgrect center = [self.view bounds]; cgsize wincenter = center.size; cgpoint pont = cgpointmake(wincenter.width/2,wincenter....

php - Is JSON.stringify() reliable for serializing JSON objects? -

i need send full objects javascript php. seemed pretty obvious json.stringify() , json_decode() on php end, allow strings ":" , ","? need run escape() function on big user input strings may cause issue? escape function be? don't think escape works purposes. are there downsides json.stringify() need know about? thanks yes, it's reliable in decent implementation (like crockford's ), , no, don't have run through escape first (if that, php pretty confused @ other end). browsers starting own implementations of json stuff (now it's in 5th edition spec ), now, may best off using crockford's or similar.

javascript - The Web 2.0 Ecosystem/Stack -

being new front-end website development, can understand stuff, things routes, orm, etc. don't understand how play together. understanding is, there bunch of components website built pyramid/django etc: a templating engine: abstract away html code. makes sense. sqlalchemy et al: orm. fine. a renderer. no idea. js libraries: jquery et al: no idea use these except adding pretty effects. how interact templating engine? how interact entire framework? can write code jquery in pyramid, or write js separately, plug in js file template or...? form templating libraries (formish, formalchemy et al): how these relate big picture? plug in? any other important components i'm missing? so, me out , explain stack? 1) templating engine: abstract away html code. makes sense. there's several of these available. mako tries utilize many common python idioms in templates avoid having learn many new concepts. jinja2 similar django, more functionality. genshi if x...

database - How do I add a one-to-one relationship in MYSQL? -

+-------+-------------+------+-----+---------+-------+ | field | type | null | key | default | | +-------+-------------+------+-----+---------+-------+ | pid | varchar(99) | yes | | null | | +-------+-------------+------+-----+---------+-------+ 1 row in set (0.00 sec) +-------+---------------+------+-----+---------+-------+ | field | type | null | key | default | | +-------+---------------+------+-----+---------+-------+ | pid | varchar(2000) | yes | | null | | | recid | varchar(2000) | yes | | null | | +-------+---------------+------+-----+---------+-------+ 2 rows in set (0.00 sec) this table. pid id of user. "recid" recommended song user. i hope have list of pid's, , recommended songs each person. of course, in 2nd table, (pid, recid) unique key. how do one-to-one query ? # retrieve songs associated given user select songs.* user inner join songs on (user.pid = songs.pid) user.pi...

Changing the default Windows language with Java application -

can change default language of host system (windows xp) java application? if yes, how can it? you can set default input language using windows systemparametersinfo api. bool winapi systemparametersinfo( __in uint uiaction, __in uint uiparam, __inout pvoid pvparam, __in uint fwinini ); using jna easier using jni. invoke api function in user32.dll using jna, create interface: public interface user32 extends stdcalllibrary { user32 instance = (user32) native.loadlibrary("user32", user32.class); bool systemparametersinfo(int uiaction, int uiparam, int[] pint, int fwinini); } you determine lcid of language want change to. ( here's list msdn.) example, english 0x409. use lcid in call systemparametersinfo : int lcid = 0x409; final int spi_setdefaultinputlang = 90; user32.instance.systemparamtersinfo(spi_setdefaultinputlang, 0, new int[] { lcid }, 0); and thenn default input language has been changed!

java - The method split(String) is undefined for the type String -

i using pulse - plugin manager eclipse , installed. have eclipse 3.5 mobile development(pulsar) profile couple other profiles. i realized split() method called on string code such below: string data = "one, two, three, four"; data.split(","); generates error: "the method split(string) undefined type string". aware split() method did not exist before java's jre 1.4 , perhaps cause of problem. problem don't think have jre/sdk versions installed. perhaps there's 1 in-built pulsar profile , needs editing - couldn't tell settings (and where) needs tweaking. have checked windows>preferences>java>installed jres , it's set >= jre1.4. i note "eclipse 3.5 mobile development". maybe tool expects run j2me, believe several issues behind j2se. this page gives links javadoc various apis in jme. there several versions, (follow links under cldc , cdc , java.lang.string) far can tell none of them define string....

c# - How to customize the Error screen in an MSI installer? -

in vs 2008 setup/deployment project, there way add custom error dialog (or customize existing one) handle errors encountered during installation process? if understand correctly: not software but, can handle errors software's prerequisites cause errors of time. must first go location of prerequisite package file. normally, "c:\program files\microsoft sdks\windows\v6.0a\bootstrapper\packages\". find package folder, move in, there folder named "en" , inside there xml file named "package.xml". open text editor , see: <installchecks> <registrycheck property="dotnet35sp" key="hklm\software\microsoft\net framework setup\ndp\v3.5" value="sp" /> </installchecks> <!-- defines how invoke setup .net framework redist --> <commands reboot="defer"> <command packagefile="dotnetfx35setup.exe" arguments=' /lang:enu /passive /norestart' ...

java - Converting/writing a BufferedImage to postscript -

i know how draw simple shapes using postcript i'm looking how draw content bufferedimage (width*height) postscript page (x,y,width,height) without external library (fop,pdfbox...). do have hint/code/algorithm ? thanks ! :-) one has use image or colorimage operators. unlike simple linedrawing , show text operator, these complex operators take several parameters. i putting sample postscript snippet renders 8 x 8 image using 7 parameter colorimage operator. take notice 5th parameter callback procedure, may called several times colorimage operator, each time returning of image data in string. in example, return whole image data @ once. in example, data ascii encoded each byte being represented 2-digit hexadecimal number. more efficient encodings possible, postscript can decode base64, base85 , rle encoding in runtime. this parameter might single string instead of callback procedure, in case, binary data have escaped in octal, preceding slash (like \377) decima...

asp.net mvc - jQuery Mobile and Unobtrusive Validation -

i'm creating jquery mobile (alpha 3) based asp.net mvc 3 application utilizing unobtrusive validation comes mvc3. when page accessed directly (no hash in url), validation works perfectly. however, when navigate page, jquery mobile uses ajax navigation dynamically load (displaying hash in url) , validation stops working. here sample of code in use: model: [required(errormessage = "missing value")] [displayname("property display name")] public int? propertyname { get; set; } view (razor): @html.labelfor(model => model.propertyname) @html.textboxfor(model => model.propertyname) @html.validationmessagefor(model => model.propertyname) generated html: <label for="propertyname">property display name</label> <input data-val="true" data-val-number="the field property display name must number." data-val-required="missing value" id="propertyname" name="propertyname" type...

How to get number of likes from facebook like button? -

how number of likes facebook button? there possible way this? there 2 ways number of facebook likes. graph api http://graph.facebook.com/?ids=http%3a%2f%2ffacebook.com result json: (for reason 'likes' called 'shares') { "http://facebook.com": { "id": "http://facebook.com", "shares": 35641554, "comments": 339 } } fql http://api.facebook.com/method/fql.query?query=select+total_count+from+link_stat+where+url= " http://facebook.com "' result: <?xml version="1.0" encoding="utf-8"?> <fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" list="true"> <link_stat> <total_count>35641554</total_count> </link_stat> </fql_query_response>

version control - git (any SCM) and compiling object files, switching branches, physiology thereof -

if compile branch a, switch branch b, compile, , switch branch a. all object files touched compile of branch b have recompiled! normally 1 not check-in object files, there seems little choice here. what ideal working practices here? only object files dependencies differ between 2 branches need rebuilt. when switching branches git doesn't touch files don't differ between 2 branches. so long have appropriate dependencies expressed or deduced in build system, incremental build after branch switch work , reasonably efficient. in many of projects switch branches , incremental builds fast , reliable. if want work on 2 branches without wanting rebuild @ when switching branches should use second clone , work in independent working areas. checking in object files same repository source creates them bad idea. start, allows possibility of checking in input , output inconsistent.

asp.net - asp buttonimage alternate text not visible -

i've problem asp:image , asp:imagebutton alternate text: it's not visible when move mouse on image. declared object in way: <asp:imagebutton id="buttonstatus" imageurl='<%# iif(eval("active")=1,"../images/folders/actived.png","../images/folders/deactivate.png")%>' commandname="changestatus" commandargument='<%# eval("id_repository") %>' oncommand="foldercommand" enabled = '<% #iif(mysecurity.admin=1, "true", "false") %>' width="24px" alternatetext="change status" runat="server" /> and asp:image <asp:hyperlink runat="server" id="url_groups" navigateurl="~/action/group_manager.aspx?action=2"> <asp:image id="img_groups" runat="server" imageurl="~/images/folders/group_config.png" alter...

iphone - How can a web application send push notifications to iOS devices? -

i'm working on web app. how can send push notifications ios users when there new content? to more specific, in order web application send push notifications mobile device, such iphone, mobile device must have registered receive push notifications particular application. registration push notification done through native app , can performed through native app. once native app registered push notification, can send authorization token server, can used in conjunction certificate used provision native client, send push notifications mobile device. as specified in answer, 1 option 'wrap' web application in native application. meaning create native application presents uiwebview (for iphone dev) user showing web application. while pretty functions in same manner native browser, able add ability register push notifications using native controls. it beneficial review apple's push notification document provides pretty information on how push messaging functio...

objective c - Undoing Core Data insertions that are performed off the main thread -

i'm working on code uses nsoperation import data. i'd user able undo nsmanagedobject instances created during import operation. from can tell, it's impossible use nsmanagedobjectcontext -undomanager operations performed off of main thread. core data programming guide section on use thread confinement support concurrency , have these 2 conditions: only objectid should passed between managed object contexts (on separate threads) managed objects must saved in context before objectid can used. this makes sense since managed objects need moved private storage ( nsmanagedobjectcontext ) public storage ( nspersistentstore ) before can shared. unfortunately, -save: message causes managed objects in undo stack removed. memory management using core data section of same guide: managed objects have pending changes (insertions, deletions, or updates) retained context until context sent save:, reset , rollback, or dealloc message, o...

DNN Database Schema Diagram -

i need database schema diagram dotnetnuke (erd) if have idea. have searched on internet have found link contains lots of documentations dnn. need er diagram dnn database. thanks. have @ link ri website 5.2.2 ce later versions l have thought have not changed significantly. company release erd's time time worth checking every often.

iphone - How to use libz.dylib to unzip zip file? -

in program have unzip downloaded file ... read libz.dylib used didn't find documentation or examples how that..? any 1 know this... thanks in advance.... i'm not answering question, use zipkit . obj-c framework using zip files.

code injection - Using springs component-scan and injecting beans -

im using spring 2.5 , writing dispatcherservlet. in context file servlet im using component-scan , giving location of class controllers are. classes use @controller("bean name") annotation. how can inject properties bean? thanks also remember can inject beans defined in main application context beans defined in application context servlet, not vice-versa. these contexts aren't merged, form parent-child relationship.

php - Class Inheritance Problem -

i have a.php , b.php a.php <?php error_reporting(e_all); ini_set("display_errors",1); class myclass { function hello() { return 'hello'; } } ?> b.php <?php error_reporting(e_all); ini_set("display_errors",1); require_once('/a.php'); $a = new myclass(); testing(); function testing() { echo $a ->hello(); } ?> b.php inherits a.php , if run b.php,but show "fatal error: call member function hello() on non-object." so question simple, how can correct ,but "$a = new myclass();" not inside function, since in .net world can this, believe php possible. and 1 more question is, modify of function in a.php ,if have not state private/public/protected? a couple of things change here, i'll explain in moment. a.php <?php error_reporting(e_all); ini_set("display_errors",1); class myclass { // here, access modifier. public function hello() { return ...

flex - how can i use cookies information in flex3 -

can use cookie information in flex? suppose user logs in first time in login form (designed in flex) , when logs in again need show users name in dropdown cookies, possible in flex? there way can please suggest me in advance. you can create sharedobject store session data on users computer. var so:sharedobject = sharedobject.getlocal("saveddata"); if shared object name specified doesn't exist, 1 created. check out live docs more info: http://help.adobe.com/en_us/as3lcr/flash_10.0/flash/net/sharedobject.html

java - Where can i download the iLOCOi2 mobile app source code? -

i newbie kind of development. creating mobile application involves tracking, , download source codes of iloci2 mobile application references. pls me. i don't think available download. why not try tutorial using gps? http://www.firstdroid.com/2010/04/29/android-development-using-gps-to-get-current-location-2/

WiX: Extracting Binary-string in Custom Action yields string like "???good data" -

i found weird behavior when attempting extract string binary table in msi. i have file containing hello world , data ???hello world . (literary question mark.) is intended? 3 characters in beginning? sample code: [customaction] public static actionresult customaction2(session session) { view v = session.database.openview("select `name`,`data` `binary`"); v.execute(); record r = v.fetch(); int datalen = r.getdatasize("data"); system.io.stream strm = r.getstream("data"); byte[] rawdata = new byte[datalen]; int res = strm.read(rawdata, 0, datalen); strm.close(); string s = system.text.encoding.ascii.getstring(rawdata); // s == "???hello world" return actionresult.success; } wild guess, if created file using notepad, couldn't byte order mark ?

How do I find latex source-code? -

does know find code latex uses typeset inside tabular environment? in past have looked in style files don't know find intrinsic latex commands. see pdf file of latex sources , chapter lttab.dtx .

cocoa - Iterate through NSManagedObjectContext objects? -

i want iterate through of objects in nsmanagedobjectcontext, , update them manually. then, every managed object should updated. what's best way this? theoretically iterate through entity descriptions in managed object model, build no-predicate fetch request them, loop on returned objects , update. example: // given nsmanagedobjectcontext *context nsmanagedobjectmodel *model = [[context persistentstorecoordinator] managedobjectmodel]; for(nsentitydescription *entity in [model entities]) { nsfetchrequest *request = [[[nsfetchrequest alloc] init] autorelease]; [request setentity:entity]; nserror *error; nsarray *results = [context executefetchrequest:request error:&error]; // error-checking here... for(nsmanagedobject *object in results) { // updates here } } note can cast nsmanagedobjects returned necessary either testing class equality (using iskindofclass: or related method) or figuring out cla...

installer - WiX - Passing parameters to a CustomAction (DLL) -

i've got dll old wise installer i'm trying working in wix, i'm pretty sure dll works msi-based installers. here definition: <binary id="setupdll" sourcefile="../tools/setup.dll" /> <customaction id="readconfigfiles" binarykey="setupdll" dllentry="readconfigfiles" /> and usage: <publish dialog="installdirdlg" control="next" event="doaction" value="readconfigfiles" order="3">1</publish> my c++ function looks this: extern "c" uint __stdcall readconfigfiles(msihandle hinstall, char * szdirectory) where can pass in parameters? you can't pass parameters directly because in order work, function has exported right footprint. when call readconfigfiles in custom action dll, should have footprint this: extern "c" uint __stdcall readconfigfiles(msihandle hinstaller); you can use hinstaller parameter read pr...

spring - Can .hbm files be used in a JPA application with Hibernate as JPA provider? -

i'd replace custom bpm implementation activiti or jbpm-5 in product uses hibernate (no jpa) spring persistent layer implementation. unfortunately, both activiti , jbpm5 require jpa(according documentation) , not possible migrate existing hibernate implementation jpa in product. is there way configure jpa 2.0(jpa provider hibernate) spring 3 without migrating hibernate implementation jpa (i.e. retain .hbm files) ? note: i'm aware application not compliant jpa , jpa provider can not used. if there way, assume spring jta transaction manager configured proper settings. can application logic , bpm workflow logic executed in single spring transaction? regarding transactions see activiti spring transaction docs. if cannot port application use jpa, option layer facade on hibernate domain. activiti allows invoke methods on spring managed beans, create facade or utilize existing service layer. take @ sample applications ship activity see how spring integration ...

php - How to manage gradual deployment of a web app -

i developing web app , want able stagger deployment of new builds , versions across our users. example... deploy new version of app , migrate couple of test accounts testing when testing happy, move 5% of customers new version , monitor support problems , server load problems customers. if still going ok, gradually move more , more customers on new version until updated. fogbugz , kiln fogcreek using deployment system this. can read here... the problem trying solve @ moment that different accounts on system can using different versions of code . what way of managing , controlling this? can apache of heavy lifting here? want avoid overhead, or weird loader scripts work out send request. how web apps fogbugz on demand deal problem? there recognised design pattern this? the users identified via domain name (eg user1.example.com, user-bob.example.com, etc). there hundreds of ways accomplish this; let's think @ high level without talking specifics of architec...

c - Pointer/address type casting -

i have following variables: char *p; int l=65; why following casts fail? (int *)p=&l; and: p=&((char) l); the result of type conversion rvalue . rvalue cannot assigned to, why first expression doesn't compile. rvalue cannot taken address of, why second expression doesn't compile. in order perform correct type conversion, have to follows p = (char *) &l; this proper way tried in second expression. converts int * pointer char * type. your first expression beyond repair. can do *(int **) &p = &l; but in end not conversion , rather reinterpretation of memory occupied char * pointer int * pointer. ugly illegal hack of time has little practical value.

plot - rs232 communication, general timing -

i have piece of hardware sends out byte of data representing voltage signal @ frequency of 100hz on serial port. i want write program read in data can plot it. know need open serial port , open inputstream. next part confusing me , i'm having trouble understanding process conceptually: i create while loop reads in data inputstream 1 byte @ time. how while loop timing there byte available read whenever reaches readbyte line? i'm guessing can't put sleep function inside while loop try , match hardware sample rate. matter of continuing reading inputstream in while loop, , if it's fast won't (since there's no new data), , if it's slow accumulate in inputstream buffer? like said, i'm trying understand conceptually guidance appreciated! i'm guessing idea independent of programming language i'm using, if not, assume use in java. if using java communications api not polling @ all. instead implement serialporteventlistener , receive ca...

asp.net - How do you clear a CustomValidator Error on a Button click event? -

Image
i have composite user control entering dates: the customvalidator include server sided validation code. error message cleared via client sided script if user alters teh date value in way. this, included following code hook 2 drop downs , year text box validation control: <script type="text/javascript"> validatorhookupcontrolid("<%= ddlmonth.clientid%>", document.getelementbyid("<%= customvalidator1.clientid%>")); validatorhookupcontrolid("<%= ddldate.clientid%>", document.getelementbyid("<%= customvalidator1.clientid%>")); validatorhookupcontrolid("<%= txtyear.clientid%>", document.getelementbyid("<%= customvalidator1.clientid%>")); </script> however, validation error cleared when user clicks clear button. when user clicks clear button, other 3 controls reset. avoid post back, clear button regular html button onclick event resets 3 controls. unfo...

c - Rounding positive number up two places -

hey guys, i'm trying write program take positive number fractional part , round 2 places.for example 32.4851 round 32.49, , 32.4431 round 32.44. i lost on 1 , hoping guys me out little bit. have written code , need feedback (won't compile using gcc) using stdio.h , math.h #include <stdio.h> #include <math.h> double x; int rounded_x; int main (void) { printf ("enter number rounded \n\n\n\n\n"); scanf ("&lf", &x); rounded_x=(int) (x+0.5); return 0; } double scale (double x, int n) { double scale_factor; scale_factor = pow(10, n); return (x*scale_factor); } the multiply 100, divide 100 solution right. can end deceiving results because of nature of floating-point datatypes. nice round numbers in base-10, "1.23" not translate base-2 floating point storage format. may find rounding "1.2345" ends "1.23" expected, "1.1234" end ...

php - PDO bindParam behaving strangely -

i having problem getting pdo bindparam work correctly. using code: $foo = "bar"; $stmt_1 = $db->prepare("select * table foo = $foo"); $stmt_1->execute(); $results_1 = $stmt_1->fetchall(); $stmt_2 = $db->prepare("select * table foo = ?"); $stmt_2->bindparam(1, $foo, pdo::param_str); $stmt_2->execute(); $results_2 = $stmt_2->fetchall(); $stmt_3 = $db->prepare("select * table foo = :foo"); $stmt_3->bindparam(":foo", $foo, pdo::param_str); $stmt_3->execute(); $results_3 = $stmt_3->fetchall(); $results_1 contains row(s) foo = bar, $results_2 empty, , $results_3 contains every entry in "table" bindvalue has exact same problem, too. know what's going on here or i'm doing wrong? (i'll new answer because misunderstood question in other one.) by default pdo silently ignores errors , returns empty results. explain #2. example, if table called "table" , didn...

wpf - Change data context when using UserControls -

i'm using simple main window contains 2 custom user controls (that i've created) user controls has modelview code file each (im using mvvm pattern). each modelview file contains single command (and command implementation of execute , canexecute). problem when need active each command (through mainwindow cause main window holds custom user controls) need change datacontext of main window viewmodel of control in focus otherwisw cant execute command (the command binding inside usercontrol.xaml cant find command). think tracking after focused usercontrol in order change mainwindow datacontext not way. faced kind of problem before ?? thanks. a way of solving creating viewmodel main window , add 2 properties vm, 1 each viewmodel created before. this way can assign new vm datacontext of window , bind datacontext of each user control 1 of properties. put commands on correct vm want use it. make sense? btw: call modelview i'd call viewmodel.

windows - qt in windows7 environment -

i having problem running example qt uses win32 libraries. when compile don't errors when run not able open application (.exe) file in windows 7. when compile example in windowsxp works fine. can let me know whether need change .pro file in order worked under windows 7? here .pro file: # ------------------------------------------------- # project created qtcreator 2010-04-16t11:45:43 # ------------------------------------------------- qt += network qt += xml qt += opengl target = application template = app sources += main.cpp \ mainwindow.cpp \ tools.cpp \ objects.cpp headers += mainwindow.h \ tools.h\ objects.h unix { objects_dir = .obj moc_dir = .moc } # unix installation isempty(prefix):prefix = /usr/local unix { headers.path = $$prefix/include/zip headers.files = $$headers target.path = $$prefix/lib installs += headers \ target } !mac:x11:libs += -ldns_sd win32:libs += -ldnssd libpath = c:/temp/mdnsresponder-1...

Lisp's "some" in Python? -

i have list of strings , list of filters (which strings, interpreted regular expressions). want list of elements in string list accepted @ least 1 of filters. ideally, i'd write [s s in strings if (lambda f: re.match (f, s), filters)] where defined as def (pred, list): x in list: res = pred (x) if res: return res return false is available in python, or there more idiomatic way this? there function called any want want. think looking this: [s s in strings if any(re.match(f, s) f in filters)]

Google translation API not responding sometimes -

i using http://ajax.googleapis.com/ajax/services/language/translate translate pages on fly. happens no response google , page displays blank. possible service doesn't respond in timely fashion? there way overcome when no response google? i using php. thanks if using url limited 2k characters, gives (at least me) 360 letters of encoded text. if using post (should) have 5k letters. if go on limit google's behaviour describe it. i have posted javascript code version.

c# - Sones GraphDB Query Returning Error -

i following tutorial here: http://developers.sones.de/wiki/doku.php?id=quickreference:fiveminuteguide but when copy , paste command in webshell create vertices abstract entity attributes (string name), university extends entity attributes(set<student> students), city extends entity attributes(set<university> universities), student extends entity attributes(integer age) backwardedges(university.students studiesat) the output generates error: graphdb@localhost [gql-mode] > create vertices abstract entity attributes (string name), university extends entity attributes(set<student> students), city extends entity attributes(set<university> universities), student extends entity attributes(integer age) backwardedges(university.students studiesat) { "query": "create vertices abstract entity attributes (string name), university extends entity attributes(set students), city extends entity attributes(set universities), student ...

gtk - What does GTK_WINDOW(window)->allow_shrink = TRUE mean in c? -

i'm getting started gtk,anyone knows means? gtk_window(window)->allow_shrink = true; it means user can resize window smaller dimensions specified on creation of window. gtk+ has excellent reference, a quick search need .

c# - Entity Framework - ContextBuilder namespace -

possible duplicate: where entityconfiguration in ef4 vs 2010 rtm? i apologize if seems excessively dumb question. i trying use contextbuilderclass generate context. unable find proper assembly , namespace use though. just reference on full install of vs 2010 pro. i asked team , here response: right entity framework feature ctp contains latest bits of code-first , compatible ef4 rtm. please, find here: http://www.microsoft.com/downloads/details.aspx?familyid=af18e652-9ea7-478b-8b41-8424b94e3f58&displaylang=en .

php - can't include("absolute_path") -

i can't figure out why won't work. $docroot = getenv("document_root"); include_once($docroot."/conn/connection.php"); include_once($docroot."/auth/user.php"); it works locally through wamp, won't work on live server. tried this: if(!include_once($docroot."/auth/user.php")){ session_start(); $debug = array(); $debug["docroot"] = $docroot; $debug["inc_path"] = $docroot."/auth/user.php"; $debug["file_exists"] = file_exists($debug["inc_path"]); $_session['debug'] = $debug; // exit header("location:debug.php"); exit(); } the debug page echoes array , shows correct absolute paths , indicates file in fact exist. why didn't include_once() work? server (a dv account on mediatemple server) has not been configured @ all, wonder if there apache or php setting messing me. ultimately, want here way refer file in such way if move...

How to make css smaller? -

i have css file styles entire page, , it's getting gzipped , it's minified, it's still 200kb. there else can do? i took @ @ profile , found www.charliecarver.me, took @ , found css file. if website , css file talking about, repeat lot of statements. example, line 1 13 of css file looks this: body { /** css code... **/ } line 15 17 looks this: body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,input,textarea,p,blockquote,th,td { /** css code... **/ } line 432 434: html>body #content { /** css code... **/ } line 826 828: body,td,th,.metadata a:link,.metadata a:visited,.navigation a:link,.navigation { /** css code... **/ } all done 1 block of code referencing body. so, reduce amount of repeats have. give idea of what's repeating: the elements: "div" appears 35 times "dt" appears 50 times "dd" appears 30 times "ol" appears 49 times "li" appears 6 times "yui" appears...

php - Should I Abandon Adobe Flash for HTML5 and <canvas>? -

i'm looking developing facebook applications , planning on using flash basis of application, have test built simple php facebook applications , know enough action-script 3 start me on way, api facebook development in looks far more tedious php one. my question able create interactive graphics (games) see across web in html5 canvas class? , simpler? html5 doesn't exist yet outside of basic support in various browsers. we're couple of years off true saturation since won't until ie9 , ff4 released , adopted. you use google code project enable canvas support in ie until then: http://code.google.com/p/explorercanvas/ and yes, able create interesting games canvas. believe in short term you'd have wider array of options flash. http://www.canvasdemos.com/

c# - Possible values for ManagementObject.GetMethodParameters method? -

i know of them such "createvirtualdirectory" , "setdatabaseconnection" etc can list of possible values(method names) managementobject.getmethodparameters method? thanks. the managementclass.methods property returns them, there's example in msdn library topic it. have found wmicodecreator yet?

flex - Flex4: Detect source Video size VideoPlayer? -

is possible in flex 4's videoplayer control (spark.components.videoplayer) detect attributes of source video? in case, it's local file. need detect original width , height of input source video (an h264 f4v). thanks you can info videowidth , videoheight properties of video object contained within video player, example: //assuming have videoplayer object id of "videoplayer" videoplayer.videoobject.videowidht; videoplayer.videoobject.videoheight; hope helped.

Having a thread using Hibernate and C3p0 with database on Tomcat -

i using hibernate , c3p0 manage connections. have thread database operations. the problem when undeploy webapp tomcat, thread exits correctly, connection pool still remains, there still connections in mysql, think managed c3p0. is there way force c3p0 shutdown these connections? thanks check pooleddatasource object, has method called hardreset . it's spec says destroys pooled , checked-out connections associated datasource immediately. pooleddatasource reset initial state prior first connection acquisition, no pools yet active, ready requests. i assume should asking for.

how to order 2 SQL Fields in asc and desc dynamically -

i want order sql select query there's 2 fields in order by. need decide if 1 descending , other ascending. how done i want like: select * customer order date @asc_or_desc_date, name @asc_or_desc_name anyone got ideas? i have tried seems fail select customer_id, name, age #customer order case when @fieldsort ='name' row_number() on (order name) * case when @directionofsort = 'a' 1 else -1 end, row_number() on (order age) * case when @directionofsort = 'a' 1 else -1 end, end anyone know how sort this? you have create sql statement dynamically in order use variable: declare @asc_desc varchar(4); set @asc_desc = 'desc'; declare @sql nvarchar(1000); set @sql = 'select * customer order date ' + @asc_desc + ', nam...

git - How to clone and deploy a historical commit -

i have been using git not advance level because it's me pushes commit github server , know conflicts arises if any. there's developer working in part of world pushed updates github repository. my problem of work not yet production-ready want go last commit , push updates there when capistrano deploy , i'll quite sure code production-ready. how can this? you can checkout particular commit using command: git checkout <commit-id> now, if want more commits on this, you'll need create new branch: git checkout -b <branch-name> <commit-id>

php find replace -

this more of "best practices" question. i have few email templates, have several tags need find , replace. for example: dear [[customername]], blah blah blah blah, , more blah. invoice.... ---------------------------------------------------------- order status: [[orderstatus]] order number: [[orderid]] date ordered: [[dateordered]] payment method: [[paymentmethod]] billing statement: [[billingstatement]] anyway, have several of these tags inside double brackets. i'm using simple: $text = str_replace($oldword , $newword , $text); i'm sure normal way this, curious if has thoughts on different way. otherwise, i'll stick i'm doing. you can use arrays str_replace: $oldwords = array('[[customername]]', '[[orderstatus]]' ); $newwords = array($customername, $orderstatus ); $newtext = str_replace($oldwords , $newwords , $text); you use preg_replace array...