Posts

Showing posts from August, 2014

activerecord - Rails tip - "Use model association" -

so, i've read in book tip "use model association", encourages developers use build methods instead of putting ids via setters. assume have multiple has_many relationships in model. what's best practise creating model ? for example, let's have models article, user , group. class article < activerecord::base belongs_to :user belongs_to :subdomain end class user < activerecord::base has_many :articles end class subdomain < activerecord::base has_many :articles end and articlescontroller: class articlescontroller < applicationcontroller def create # let's have methods current_user returns current user , current_subdomain gets current subdomain # so, need here way set subdomain_id current_subdomain.id , user_id current_user.id @article = current_user.articles.build(params[:article]) @article.subdomain_id = current_subdomain.id # or dogbert's suggestion @article.subdomain = current_subdomain @arti...

c - An algorithm to group cells into rectangles -

Image
imagine picture above represents 6*6 array of ints 0 black. there quick algorithm split non 0 cells rectangles? ideally check contained within loop, without creating other arrays . for(x = 0; x < 6; x++) for(y = 0; y < 6; y++) if(cellisbottomrightofrect(x,y)) { left = getleft(x,y); top = gettop(x,y); printf("rect: %d,%d %d,%d \n", left, top, x, y); } how using recursive method calls everytime encounters color different 1 trying group @ moment?

c# - Trying to define a 'View' for a control by using a scrollviewer. Different results between Silverlight but not WP7? -

i’m trying create simple image rotator control user can click arrow , image slide one. i’m doing stackpanel of images inside of scrollviewer. n silverlight, following code works expected: <grid x:name="rootlayout" margin="200" width="480"> <grid.rowdefinitions> <rowdefinition height="50" /> <rowdefinition height="50" /> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="50" /> <columndefinition width="50" /> </grid.columndefinitions> <scrollviewer grid.row="0" grid.column="0" horizontalscrollbarvisibility="hidden" verticalscrollbarvisibility="hidden"> <stackpanel orientation="horizontal"> <stackpanel.rendertransform> <translatetransform x:name="tt" /> ...

php - Inserting an array into mysql database -

this needs adding multiple rows database it's adding first question in array. ideas? function addnewapp($question, $type, $username, $servername){ $time = time(); $q = "insert ".tbl_applications." values ('0', '$username', '$servername', '', $time)"; if(mysql_query($q, $this->connection)){ return true; }else{ return false; } ($x=0; $x<count($question); $x++) { $q2 = "insert ".tbl_questions." set `text`='".mysql_real_escape_string($question[$x])."', `id`='0', `servername`='$servername', `type`='$type[$x]'"; if(mysql_query($q2, $this->connection)){ return true; }else{ return false; } } } you returning true within loop. if(mysql_query($q2, $this->connection)){ return t...

c# - WatiN - Waiting for Cookies -

i have been assigned create 'kind of' web creeper. tasks go on websites, enter piece of data submit data receive result. i have found watin great tool @ getting data it's open source , has functionality need - if misuse of testing api (is misuse?). anyway - real question is, browser.waitforcomplete(); does not wait load. seems waits last body tag returns. believe cookie not generated when page finished loading it's being generated asp.net end - seems load after interactive object looks ajax or along them lines. i not own or host web site therefore can gather information based on see browser , other tools @ disposal. is there way watin wait cookie updated? thanks in advanced. john. edit: as example of i'm doing fix issue @ minute (which bit unorthodox it's fixing minute). browser.waitforcomplete(); browser.waitforcomplete(); browser.waitforcomplete(); browser.waitforcomplete(); browser.waitforcomplete(); browser.waitforcomplete(); ...

java - Swing App with Spring DM startup problem -

i'm starting osgi spring dm based swing application. app should start , show when bundle loaded. know can achieved activator class configured manifest.mf file. my problem: how can inject bean references/services activator class using spring activator not configured in spring context? should not use osgi activator? how can spring startup application on bundle start? any kind of remarks apreciated i'm new osgi spring dm. cheers, sven you not need activator. spring-dm has "extender" bundle automatically scans bundle 2 things: one or more .xml files in meta-inf/spring folder of bundle; a spring-context header in manifest.mf, points 1 or more .xml files may anywhere inside bundle. if finds either of these (and if bundle in active state) load spring application context using declared xml files.

c++ - Segmentation fault in overloaded operator>> -

i'm trying write code orthogonal linked sparse matrix. here's question: alternative linked representation sparse matrices uses nodes have fields down, right, row, col, , value. each non-zero entry of sparse matrix represented node. 0 terms not explicitly stored. nodes linked form 2 circular lists. rst list, row list, made linking nodes rows , within rows columns using right field. second,list, column list, made linking nodes via down field. in list, nodes linked columns , within columns rows. these 2 lists share common header node. in addition, node added dimensions of matrix. the input file looks this: // matrix 4 4 7 1 1 2 1 4 1 2 2 7 3 1 9 3 3 8 4 2 4 4 3 5 // matrix b 4 4 5 1 3 4 2 1 6 2 3 3 3 2 5 4 4 9 this code operator>>: istream& operator>>(istream& in, orthogonallinkedsparsematrix& x){ in >> x.numrows >> x.numcols >> x.numterms...

c++ - Can massive nested loops cause the linker to run endlessly when compiling in Release-Mode? -

i'm compiling small win32 command-line application in vs2010 release-mode, speed optimizations turned on ( not memory optimizations). this application designed serve single purpose - perform single pre-defined complex mathematical operation find complex solution specific problem. algorithm functional (confirmed) , compiles , runs fine in debug-mode. however, when compile in release-mode (the algorithm large enough make use of optimizations), link.exe appears run endlessly, , code never finishes linking. sits @ 100% cpu usage, no changes in memory usage (43,232 k). my application contains 2 classes, both of pretty short code files. however, algorithm comprises 20 or nested loops inline function calls within each layer. linker attempting run though every possible path through these loops? , if so, why debug-mode linker not having problems? this tiny command-line application (2kb exe file), , compiling shouldn't take more couple minutes. i've waited 30 minutes far, ...

visual studio - Understanding .NET assemblies -

when build project in solution in visual studio (it can c# vb.net f# or else) suppose 1 assembly per project generated right? so if have solution containing project 1 2 3 , 4 when build 1 one each project 4 assemblies right? however, there possibility let builder/compiler generate 1 assembly entire solution? or 2 projects compiled together? i mean calling compiler using command line , setting target assembly... by default there 1 1 correspondence between projects , assemblies. can use tool ilmerge create 1 assembly several.

Writing content of an array to a textbox using foreach loop C# -

so, wanna know how write entire content of array textbox using foreach loop in c#. code looks this: i generate series of random numbers stored in array: int[] idata; now want write stored data in array textbox using foreach loop this: foreach (int myint in idata) { txtlisting.text = myint.tostring(); } this write last generated number in array textbox, question how write of them tekstbox. i know, how listbox , forloop. there way can done textbox , foreach loop? try using appendtext method instead: foreach (int myint in idata) { txtlisting.appendtext(myint.tostring()); } another option join elements string: textlisting.text = string.join(string.empty, idata); ...or if want delimiter: textlisting.text = string.join(", ", idata);

is it possible to retrieve a password from a (partial) MD5 hash? -

suppose have first 16 characters of md5 hash. if use brute force attack or rainbow tables or other method retrieve original password, how many compatible candidates have expect? 1? (i not think) 10, 100, 1000, 10^12? rough answer welcome (for number, please coherent hash theory , methodology). the output of md5 16 bytes (128 bits). suppose talking hexadecimal representation, hence 32 characters . thus, "16 characters" means "64 bits". considering md5 output truncated 64 bits. md5 accepts inputs 2 64 bits in length; assuming md5 behaves random function, means 2 18446744073709551616 possible input strings map more or less uniformly among 2 64 outputs, hence average number of candidates given output 2 18446744073709551552 , close 10 5553023288523357112.95 . however, if consider can find @ least 1 candidate, means space of possible passwords consider reduced. rainbow table special kind of precomputed table accepts compact representation (at expens...

php - sending an image and return it using json? -

im trying send image webservice in php using json, client cnt read image.. when return back!! <?php //recieve image $media = json_decode($_post['media']); header('content-type: image/jpeg'); $image = imagecreatefromjpeg($media); imagefilter($image,img_filter_grayscale); imagefilter($image,img_filter_colorize,100,50,0); imagejpeg($image, '', 90); imagedestroy($image); //return image $response = array( 'image' => $image ); echo json_encode($response); ?> from code, there i'm doing wrong? thanks!!! :)) the json mime type application/json , can't send image/jpeg . i think easier send path image, , have javascript make request image. otherwise, i'm not sure how going recreate on client. date uris recommended base64 encoded, if insist on doing this, please call base64_encode() first on it.

nsview - Cocoa working with a texture atlas -

i'm loading texture atlas app using drawrect of nsview subview: nsimage *imagefrombundle = [nsimage imagenamed:@"sheet1.png"]; [self setneedsdisplay:yes]; nssize isize = [imagefrombundle size]; [imagefrombundle drawinrect:[self bounds] fromrect:nsmakerect(0.0, 0.0, isize.width, isize.height) operation: nscompositecopy fraction:1.0]; this works fine displays whole texture atlas. how zone in on specific part of image? image 1800x1200 pixels, each image 180x250pixels, image 1 x=0, y=0, w=180, h=250, 2 x=180, y=0, w=180, h=250, , on. i tried changing x, y, w, h in above output black image. appreciated. edit: solved it, though i'm not sure if correct: i changed file 1100x1100 (this has no effect on solution reflect in answer wanted note it. , targeting wrong area (x,y) of image , passing wrong size target. new code looks so: [imagefrombundle drawinrect:[self bounds] fromrect:nsmakerect(0.0, 950.0, 175.0, 250.0) operation: nscompositecopy fraction:1.0]; i...

model view controller - MVC Frameworks (PHP in this case) -

possible duplicate: how implement mvc scratch in php? let me straight: model = database table name controller = middle man between user interaction , application logic view = ?? so view dynamic php page or fragment of html? i'm hoping can head around mvc's because want implement them soon the following explanation of mvc taken codeigniter user guide. the model represents data structures. typically model classes contain functions retrieve, insert, , update information in database. the view information being presented user. view web page. view can page fragment header or footer. can rss page, or other type of "page". the controller serves intermediary between model, view, , other resources needed process http request , generate web page. http://codeigniter.com/user_guide/overview/mvc.html edit: example of may include in each entity controller (this file targeted browser) <?php //assuming database has been conn...

c# - Start and stop(forced) a threaded job -

i want know proper way start , stop threaded job forced , unforced. proper way stop thread? public class processdatajob : ijob { private concurrentqueue<byte[]> _dataqueue = new concurrentqueue<byte[]>(); private volatile bool _stop = false; private volatile bool _forcestop = false; private thread _thread; private int _timeout = 1000; public void start() { _stop = false; _forcestop = false; _thread = new thread(processdata); _thread.start(); } private void processdata() { while (!_stop || _dataqueue.count > 0) { if(_forcestop) return; byte[] data; if(_dataqueue.trydequeue(data)) { //process data //.....// } } } public void stop(bool force) { ...

regex - Using regular expression to findi any character or no character? -

i'm trying create regular expression find lines contain specific character example "a". using ^(.+)a will render lines don't start character "a", contain them. there way express characters or no characters? i think regex a should work in line-by-line matchers. see linepogl's answer character-matching whole line.

c - Return value range of the main function -

what standard main return values range? 255? because int main(void){ return 256; } echo $? ; # out 0 the standard doesn't say. 0 , exit_success , exit_failure have (sort of) specified meanings. else depends on implementation. at present time, unix-based systems support 8-bit return values. windows supports (at least) 32-bit return value. haven't checked whether 64-bit windows supports 64-bit return value, rather doubt it, since 64-bit windows still uses 32-bit int.

java - Make the default android emulator faster -

the default android emulator ridiculously slow , resource hungry, makes impractical solution. how can speed default emulator? android emulator slow? got 2 solutions you.. optimize , upgrade system find junk pc, install android x86 optimize , upgrade system: install latest drivers , updates system , os install latest builds of java, eclipse , adt cleanup system junk/temp files (usually in windows root drive). use tools ccleaner ensure atleast have 2gb of ram, 1gb emulator alone. change settings while creating emulator, disable hardware don't use gps, gyroscope or whatever. increase device ram size , cache partion size give ample ammount of time emulator ready tools.android.com/recent/emulatorsnapshots try emulator snapshots, works fine well. 10-50% boost of performance. find junk pc, install android x86 if have or can afford old pc, pentium 4 1ghz or more give shot. open cpu box, pull out unnecessary hardware modems , add-in cards clean l...

How to change a constant's value in perl -

our $test; *test = \100; $test =200 i want change test 's value 200 specific reasons. possible change it? you can use same syntax : *test = \200 btw, may want @ const::fast .

Django/JavaScript: how to share code between the two? -

i've got django application makes heavy use of javascript, , want know best practice sharing code between two. specifically, have page works both , without javascript: with javascript enabled, uses jquery autocomplete on input field, , generates table of results on autocomplete, in client-side javascript. with javascript, if type input field , submit form, same table of results returned, django view/template. to this, i'm duplicating quite lot of code: both static html table header/footer, , code each row, generated using loop. (in pseudocode: for result in results: output '<td>result.title</td><td>result.author</td>' etc.) how can avoid duplicating code, , instead share nicely between django , javascript? thanks! you can pass json client, , render client-side templating engine. example jquery templating engines

php - preg_replace div (or anything) with class=removeMe -

just trying remove elements preg_replace can't work consistently. remove element matching class. problem element may have id or several classes. ie element be <div id="me1" class="removeme">remove me , parent</div> or <div id="me1" class="removeme" style="display:none">remove me , parent</div> is possible this? any appreciated! dan. while still doable regular expression, it's simpler e.g. querypath : print qp($html)->find(".removeme")->parent()->remove()->writehtml();

google play - I can not let my app available on market of honeycomb(xoom) -

i have app, , have changed app according tutorial of google http://developer.android.com/guide/practices/optimizing-for-3.0.html . this mainfest xml: <uses-permission android:name="android.permission.internet" /> <!--uses-permission android:name="android.permission.read_phone_state"/--> <uses-permission android:name="android.permission.read_contacts" / > <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.wake_lock" /> <uses-permission android:name="android.permission.send_sms" /> <uses-permission android:name="android.permission.read_logs" /> <uses-permission android:name="android.permission.vibrate" /> <uses-permission android:name="android.permission.get_accounts" /> <uses-sdk android:minsdkversion="7...

How can I learn Oracle JDeveloper? -

how can start programming in oracle jdeveloper? have understanding of concepts in java , have worked in netbeans 6.8 ide, how practice in jdeveloper? difficult begin on ? i have book of jdeveloper , tried more once failed. are planning learn how use ide or want learn adf? if want learn jdeveloper ide, best way install jdeveloper and... start writing java code! embedded pretty if face issues, place ask questions oracle jdeveloper , adf forum . if plan learn adf, please refer oracle jdeveloper , adf documentation page contains lots of information. start checking out/running/tweaking sample applications built jdeveloper , proceed reading java ee developer's guide oracle adf . there number of nice blogs on adf , such dive adf , shay shmeltzer's blog can find topics levels (beginner advanced). , again, visit oracle jdeveloper , adf forum questions may have on adf. hope helps!

ruby on rails 3 - Problems parsing generated JSON -

i got json object have generated via rails 3 (via api). need either put named surrounding tag around or loose first "layer". know sounds strange, cannot loop in client. this parsing code: @results = restclient.get "http://localhost:5000/emails?token=#{get_token}", :accept => :json @array = json.parse(@results); turn this: [ { "email": { "created_at": "2011-03-02t12:23:59z", "updated_at": "2011-03-02t12:23:59z", "value_1": "intevisa@sss.com", "value_2": null, "id": 4, "value_3": null, "user_id": 1, "value_4": null, "desc": "intevisa", "privacy": null } }, { "email": { "created_at": "2011-03-02t15:19:39z", ...

java - Eclipse Equinox, how to configure auto load the bundles in plugin folder -

i've followed http://www.eclipse.org/equinox/documents/quickstart-framework.php seems old , not valid. there no such bundles described org.eclipse.update.configurator_3.2.100.jar i tried org.eclipse.equinox.simpleconfigurator_1.0.200.v20100503, doesn't work. anyone can tell me how make equinox auto load bundles inside plugins folder? simplest approach use apache felix file install . works fine equinox, need put file install configuration parameters configuration/config.ini. note though if launch equinox via launcher jar or via binary, working directory parent of configuration/ or plugins/ directory. excerpt our project config.ini: # start file install osgi.bundles=reference\:file\:org.apache.felix.fileinstall_3.1.0.jar@1\:start # name of directory watch felix.fileinstall.dir=./plugins # regular expression used filter file names # have bundles in plugins/ directory, regexp # forbids monitoring bundles started via osgi.bundles property felix.fileinstall...

Can you defer ajax setup in jquery 1.5? -

i have this $.ajaxsetup({ cache: false }); i wonder can ajaxsetup can $.ajax var jqxhr = $.ajax({ url: "example.php" }) .success(function() { alert("success"); }) .error(function() { alert("error"); }) .complete(function() { alert("complete"); }); so do var = $.ajaxsetup({ cache: false }) then a.success(function() { alert("success"); }) i have not had chance try out yet. once have few minutes going try if knows too. don't see in documentation. afaik, no won't able - .ajaxsetup() isn't defered object , unlike .ajax() as of jquery v1.5 . error saying object doesn't have methods. if trying setup things happen every .ajax() call ( .ajaxsetup() sets defaults .ajax() calls) . can access global ajax callbacks like: $.ajaxcomplete(function(){alert("complete");}) $.ajaxerror(function(){alert("error");}) $.ajaxsuccess(funct...

C++ Is the copy constructor called here? -

suppose have functions this: foo foo() { foo foo; // more lines of code return foo; // copy constructor called here? } foo bar() { // more lines of code return foo(); // copy constructor called here? } int main() { foo = foo(); foo b = bar(); } when of functions return, copy constructor called (suppose there one)? it might called, or might not called. compiler has option of using return value optimization in both cases (though optimization bit easier in bar in foo ). even if rvo eliminates actual calls copy constructor, copy constructor must still defined , accessible.

apache - mod_rewrite to serve static cached files if they exist and if the source file hasn't changed -

i working on project processes images, saves processed images in cache, , outputs processed image client. lets project located in /project/, cache located in /project/cache/, , source images located wherever else on server (like in /images/ or /otherproject/images/). can set cache mirror path source image (e.g. if source image /images/image.jpg, cache image /project/cache/images/image.jpg), , requests project /project/path/to/image (e.g. /project/images/image.jpg). i serve images cache, if exist, efficiently possible. however, want able check see if source image has changed since cached image created. ideally, done mod_rewrite php wouldn't need used of work. is possible? mod_rewrite rules need work? alternatively, seems fine compromise have mod_rewrite serve cached file of time send 1 out of x requests php script files cached. possible? you cannot acces file modification timestamp rewriterule , there no way around using php or programming language task. on othe...

Execute .sql files that are used to run in SQL Management Studio in python -

as part of artifacts delivery, our developers give data , structure scripts in .sql files. "double click" on these files open in "microsoft sql server management studio". management studio prompt me entering database server , user/pwd. enter them manually , click on execute button execute these scripts. these scripts contain structure , data sql commands. each script may contain more 1 data command (like select, insert, update, etc). structure , data scripts provided in separate .sql files. these scripts contain stored procedures , functions, etc. contain comments / description. i want automate execution of these scripts through python. looked @ pyodbc , pymssql dont solve issue. through pyodbc, need read each .sql file , read sql commands , execute them 1 one. files may have comments / description / sps / etc, reading files little difficult. can give suggestion on how automate this? thanks in advance. you run them using sqlcmd. sqlcmd command...

java - Setting tab title colors on JTabbedPanes -

on jtabbedpane, how set color of tab titles both selected , unselected states? it seems want setforegroundat , setbackgroundat methods in jtabbedpane .

iis 7 - How to create Web Deploy 2.0 projects in Visual Studio 2010? -

we using visual studio 2010 publish iis using web deploy. have upgraded web deploy 2.0 on client, , server (by uninstalling old version , installing new version). from visual studio, still seams creating web deploy 1.0 packages. confused. how visual studio integrate web deploy? how visual studio create web deploy 2.0 packages? thanks post. i found doc might help, illustrates installation , enabling of web deploy: http://weblogs.asp.net/scottgu/archive/2010/09/13/automating-deployment-with-microsoft-web-deploy.aspx moreover, think web deploy more relevant asp.net, , if can post thread at: http://forums.asp.net/26.aspx?configuration+and+deployment i believe can more useful information. hope can help.

c# 4.0 - C# Calling an overriden method within the superclass -

hey there. picked c# learn game programming xna, have experience in java. here's code, in essence: public class { public rectangle getrectangle() { return [some rectangle]; } public bool collision(a other) { rectangle rect1 = getrectangle(); rectangle rect2 = other.getrectangle(); return rect1.intersects(rect2); } } public class b : { public rectangle getrectangle() { return [some other rectangle]; } } the problem arises when try this: a a; b b; if(a.collision(b)) ... where b's version of rectangle never called, far can tell. tried solution 1 suggested here message "b.getrectangle() hides inherited member a.getrectangle(). use new keyword if intended." i appreciate in advance receive. i'm thinking past java experience getting in way of understanding how c# different. guess if knows of link explains differences between c# , java or how c# works in respect suffice. ...

mysql - Find Rows Using Nested Count, Join, or Having -

i have data in table might so: id | streetnum | name | item ----------------------------- 1 | 100 | | 0 2 | 100 | b | null 3 | 100 | c | null 4 | 101 | d | null 5 | 101 | e | null 6 | 102 | f | 1 i'm trying put query identify identical streenum's item column has both value , 1 or more null's. in example above, query's result should be: 100 my first instinct put nested query involving count(*) want see other ideas guys come with. also possible self join: select distinct streetnum atable a1,atable a2 a1.streetnum=a2.streenum , a1.item null , a2.item not null;

c# - How do I update a page during an asynchronous postback? -

i'm stumped. attempting show progress bar while site executes query. query takes anywhere 4-6 minutes. progress bar gets value database, oracle has built-in query provide values progress bar. i'm using essentialobjects' progressbar . set "value" integer between 1 , 100. here simplified version of code: page: <asp:updatepanel id="upquery" runat="server"> <contenttemplate> <asp:button id="btnexecute" runat="server" onclick="btnexecute_click" /> </contenttemplate> </asp:updatepanel> <asp:updatepanel id="upprogress" runat="server"> <contenttemplate> <asp:timer id="tmr" runat="server" enabled="false" ontick="tmr_tick" interval="3000"></asp:timer> <eo:progressbar id="pbr" runat="server" ></eo:progressbar...

python - Consume SOAP webservices using escaped xml as attribute -

i using suds consume soap web services way: from suds.client import client url = "http://www.example.com?wsdl" client = client(url) client.service.example(xml_argument) if call method using xml works: <?xml version="1.0" encoding="utf-8"?><a><b description="foo bar"></b></a> but if add quote (escaped) this: <?xml version="1.0" encoding="utf-8"?><a><b description="foo &quot; bar"></b></a> i following error (from webservice): attribute name "bar" associated element type "b" must followed ' = ' character. i using version: 0.4 ga build: r699-20100913 am not using suds.client in proper way? suggestions? update: i have contacted customer support, emailed them escaped xml , told me works them, caused due bad use suds in side. i'll give try pysimplesoap . mine guess, error quotin...

c# - Properly Formed HTML as String in Div on .Net Web Form is Rendering Well Beyond Extremely Slow -

i have evidently inadvertently created beast appreciate ideas on alternatives or how might identify problem. (this c# .net 3.0 app.) i have master page contains 4 textboxes. when user enters text in 1 of text boxes triggers javascript call refresh search results page inside iframe on master page. when search results page loads call made property '<%=results %>' calls search function. search function retrieves xml string sql server database, loads xmldocument, , transforms output xlst stringwriter property "results". the xslt output table 24 columns, javascript on row click highlighting row, , links on each row going new screen edit selected record. it works in timely fashion 100 rows. when reaches 200 table rows lag time becomes noticable. @ 500 rows takes 12 - 15 seconds render, , @ 1000 rows takes 90 seconds. there 3000 records possible , user able have option return rows sorting, analyzing, , possibly exporting; so, need better mouse trap. ...

distributed system - Fault tolerance through replication of SQL databases -

suppose middle tier servers replicated 3 way , backend database (mysql, postgresql, etc...) replicated 3 way. user request ends creating user data in middle tier servers , commit backend database in way resilient failures. a candidate attempt solution, example, if send data 1 sql database , have replicate data other databases if 1 sql database has harddrive crash before can replicate data, data lost. what best practice solution fault tolerance used in actual real world. many databases have option clustering, out-of-the-box solution requirement sketch. i'd recommend using out-of-the-box solution, rather rolling own - there nasty problems kind of solution don't want solve on own. a classic example primary keys - if have 3 back-end servers receive "create new record in table x" instruction middleware servers, , want replicate data, have ensure there no clashes in primary key. if use integers primary key data type, have make sure db server 1 doesn't...

iphone - Multiple component picker view -

i working on project picker view. have 2 components in it. want have second component contents loaded based selection made in first view. your pickerview:numberofrowsincomponent: , pickerview:titleforrow:forcomponent: when called second component have check value of first component determine return. pickerview:didselectrow:incomponent: when called first component have call reloadcomponent: on picker tell reload data second component.

c++ - what does default constructor do when it's empty? -

i wonder if explain default ctor after memory allocated, how initializes allocated memory? i don't know languange asked question for, try answer anyway c++ , java in c++, : leaves built-in types ( int , float , pointers, etc.) uninitialized value calls default constructor on class members in java, think class members initialized default value (0 or null).

filter - Extjs 4 FiltersFeature vs stateful grid -

i have grid columns filters. columns defination: columns:[{ text: "number", dataindex: 'clientreference', width: 200, filter: true, sortable: true }, here filter feature defination features: [{ ftype: 'filters', encode: true, local: false }], the problem is: when i'm trying save state of grid, filters not working: when adding code grid: stateful: true, stateid: 'documentsgrid', i refresh page , works fine, because dont have state in cookies. when refresh page second time - state loads cookies , filters not working. if remove stateful: true , refresh page, filters working fine. suggestions? noticed, examples in extjs site filters or stateful grid, there no 1 example both. updated: useful way making own method saving state of elements need , restore it. i think specifying fe...

unix - saving stdout, stderr and both into 3 separate files -

i using ksh. on link http://www.shelldorado.com/shelltips/advanced.html#redir , there example saving stdout, stderr , both 3 separate files. ((./program 2>&1 1>&3 | tee ~/err.txt) 3>&1 1>&2 | tee ~/out.txt) > ~/mix.txt 2>&1 i tried getting below error: ksh: syntax error: `(' unexpected please advice. pretty works me: $ ksh $ ps | grep "$$" 6987 pts/6 00:00:00 ksh $ cat program.sh #!/bin/sh echo "err" 1>&2 echo "out" $ ((./program.sh 2>&1 1>&3 | tee err.txt) 3>&1 1>&2 | tee out.txt) > mix.txt 2>&1 $ cat out.txt out $ cat err.txt err $ cat mix.txt err out

Java implemented algorithm for scheduling -

i want use algorithm implemented in java if exists, allow me schedule work in company employees can leave company serve client, customer request come company every day , algorithms can take old customer request. quartz job scheduler should fine. can configure jobs using cron expressions. product used enterprises everywhere. quartz scheduler home page is algorithm need school project or work? why re-invent wheel when don't have to?

monodevelop - Mono: problems trying to read a connectionString from web.config -

i'm familiar .net side of things, , trying little coding mono. i used reading in connection strings web.config using configurationmanager.connectionstrings["index"] in .net , trying figure out way in mono. apparently there no configurationmanager in mono? have system.configurtationsettings, closest can there appsettings, , monodevelop tells me it's obsolete. am missing here how read things out of web.config in mono web application?

c# - Read dox,docx files with the same style -

i use below code read doc,docx files , show them in richtextbox way can't show files same style.for example if text red color richtextbox show black color should ? microsoft.office.interop.word.application app = new microsoft.office.interop.word.applicationclass(); object nullobj = system.reflection.missing.value; object file = openfiledialog1.filename; microsoft.office.interop.word.document doc = app.documents.open(ref file, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj); doc.activewindow.selection.wholestory(); doc.activewindow.selection.copy(); idataobject data = clipboard.getdataobject(); string text = data.getdata(dataformats.text).tostring(); console.writeline(text); doc.close(ref nullobj, ref nullobj, ref nullobj); app.quit(ref nullobj, ref n...

Flex focusOut event on TextInput and pop-up does not remove focus? -

i have flex app several fields , 1 text field focusout event: <mx:formitem label="last" x="226" y="1"> <s:textinput id="lastnameclienttextinput" text="@{_currenteditclient.lastname}" change="textfieldchangecapitalize(event)" focusout="lastnameclienttextinput_focusouthandler(event)"/> </mx:formitem> as expected, when tab or click out of field after typing value executes "lastnameclienttextinput_focusouthandler" method pops-up new window: protected function lastnameclienttextinput_focusouthandler(event:focusevent):void { clientsearchpopup = new clientlistwindow(); popupmanager.addpopup(clientsearchpopup, this, true); popupmanager.centerpopup(clientsearchpopup); } that window "popupmanager.removepopup(this);" when user clicks close button. however, problem when window closes, fo...

python - SQLAlchemy: Hybrid Value Object, Query Tuple Results -

i trying follow examples documentation on building custom comparators using hybrid value objects, class caseinsensitiveword(comparator): "hybrid value representing lower case representation of word." def __init__(self, word): if isinstance(word, basestring): self.word = word.lower() elif isinstance(word, caseinsensitiveword): self.word = word.word else: self.word = func.lower(word) def operate(self, op, other): if not isinstance(other, caseinsensitiveword): other = caseinsensitiveword(other) return op(self.word, other.word) def __clause_element__(self): return self.word def __str__(self): return self.word key = 'word' "label apply query tuple results" i don't understand, however, why added end of class definition: key = 'word' "label apply query tuple results" what for? while it...

iphone - Programatically Control UIScrollView -

is there method of programatically controlling uiscrollview? in, getting value location, how far along scrolled , things , change position, scroll programatically? hope can help, thanks. i don't know either of @alexandergre or @jagostoni talking about. scrolling in uiscrollview easy. i suggest take @ documentation uiscrollview: http://developer.apple.com/library/ios/#documentation/uikit/reference/uiscrollview_class/reference/uiscrollview.html to scroll uiscrollview, use - (void)scrollrecttovisible:(cgrect)rect animated:(bool)animated example: [myscrollview scrollrecttovisible:cgrectmake(20, 20, 320, 480) animated:yes]; that scroll uiscrollview animation 20 on x axis, 20 on y , 320x480 height , width. if want information of view self(for example frame visible) should use methods , properties uiview, it's uiscrollview's parent. check out uiview documentation at: http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/ui...

Ruby 1.9.1 and Aptana Studio 3 Cant get debug to work (Windows) -

so last few weeks ive been reading posts on , other sites ruby ide's, support ruby 1.9. aptana/radrails plugin looks amazing im used eclipse environment, thought id give try. i installed ruby 1.9.1 ruby installer , installed devkit , aptana studio 3. cant debug in aptana following error: c:/ruby191/lib/ruby/site_ruby/1.9.1/rubygems.rb:323:in `bin_path': can't find gem ruby-debug-ide ([">= 0"]) (gem::gemnotfoundexception) <internal:gem_prelude>:346:in `method_missing' c:/ruby191/bin/rdebug-ide:19:in `<main>' so tried gem install ruby-debug-ide , following: building native extensions. take while... error: error installing ruby-debug-ide: error: failed build gem native extension. c:/ruby191/bin/ruby.exe mkrf_conf.rb building native extensions. take while... gem files remain installed in c:/ruby191/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16 inspection. results logged c:/ruby191/lib/ruby/gems/1.9.1/gems/ruby...

javascript - jQuery scrollTo plugin initial error -

i'm building neat little photo gallery, strugglig jquery scrollto plugin. i've used before, i'm getting error in plugin (o not defined).. i'm sure it's i've done wrong! here's link: http://alexcoady.co.uk/coad/nature see think! fyi - it's thumbnails under main image - horribly coloured rectangles @ either side. :) also - actual scroll variables testing here - it's not supposed work yet! cheers.

asp.net mvc 3 - Getting URL for FileDoesNot Exist with MVC3 and .Net error handling? -

using following error handling in application_error(): protected void application_error() { exception exception = server.getlasterror(); response.clear(); httpexception httpexception = exception httpexception; if (httpexception != null) { string action; switch (httpexception.gethttpcode()) { case 404: // page not found action = "httperror404"; break; case 500: // server error action = "httperror500"; break; default: action = "general"; break; } // clear error on server server.clearerror(); response.redirect(string.format("~/error/{0}/?message={1}", action, exception.message)); } } prior a...

php - Doctrine 2 + zf 1.11 -

i'm trying set doctrine 2 play zf 1.11 while. have managed resolve errors except one: php fatal error: class 'doctrine\orm\configuration' not found in c:\development\porjects\application\bootstrap.php on line 258 below _inidoctrine() function in bootstrap.php file line 258 referred error message: protected function _initdoctrine() { $this->bootstrap('autoload'); require_once('doctrine/common/classloader.php'); // create doctrine autoloader , remove spl autoload stack (it adds itself) require_once 'doctrine/common/classloader.php'; $doctrineautoloader = array(new \doctrine\common\classloader(), 'loadclass'); spl_autoload_unregister($doctrineautoloader); $autoloader = zend_loader_autoloader::getinstance(); // push doctrine autoloader load doctrine\ namespace $autoloader->pushautoloader($doctrineautoloader, 'doctrine'); $classloader = new \doctrine\common\classloader('entities', realpath(__dir__ . '/mod...

c++ - compiling wxWidgets with c++0x flags -

while trying compile wxwidgets-2.9.1 source c++0x flags using gcc-4.6 . came across error narrowing conversion of '128' 'int' 'char' inside { } [-fpermissive] in file src/gtk/dcclient.cpp . error comes following files: src/gtk/bdiag.xbm src/gtk/cdiag.xbm src/gtk/fdiag.xbm src/gtk/horiz.xbm src/gtk/verti.xbm src/gtk/cross.xbm this known bug. http://trac.wxwidgets.org/ticket/12575 did required , program compiling okay. basically, there 2 kinds of fix diff file has //in file dcclient.h hatches[i] = gdk_bitmap_create_from_data(null, bdiag_bits , bdiag_width, bdiag_height); hatches[i] = gdk_bitmap_create_from_data(null, reinterpret_cast< const char* >(bdiag_bits) , bdiag_width, bdiag_height); //in file bdiag.xbm , similar fixes in *.xbm files static char bdiag_bits[] = { static unsigned char bdiag_bits[] = { 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, ...

c++ - Intel TBB Parallelization Overhead -

why intel threading building blocks (tbb) parallel_for have such large overhead? according section 3.2.2 automatic chunking in tutorial.pdf around half millisecond. exert tutorial: caution: typically loop needs take @ least million clock cycles parallel_for improve performance. example, loop takes @ least 500 microseconds on 2 ghz processor might benefit parallel_for. from have read far tbb uses threadpool (pool of worker threads) pattern internally , prevents such bad overheads spawning worker threads once (which costs hundreds of microseconds). so taking time? data synchronization using mutexes isn't slow right? besides doesn't tbb make use of lock-free data structures synchronization? from have read far tbb uses threadpool (pool of worker threads) pattern internally , prevents such bad overheads spawning worker threads once (which costs hundreds of microseconds). yes, tbb pre-allocates threads. doesn't physically create , join worke...

Treat the node nids as a field (for display only in a content type) in drupal 7 -

i need use nid of node field in content type: need choose print (put before fields after others) , format wish. thing think create "fake" custom field no widget insert buth theme formatter display seems me little complicated. how should it? if understand correctly, want expose data node view. easy using hook_node_view() module? with that, can set 'fake' field sent out content array of node, can access in node template. from drupal.org: <?php function hook_node_view($node, $view_mode, $langcode) { $node->content['my_additional_field'] = array( '#markup' => $additional_field, '#weight' => 10, '#theme' => 'mymodule_my_additional_field', ); } ?>

Cannot run Jruby generated .war file on Tomcat (Windows) -

i did command 'jruby -s warble' generated .war file. , deployed tomcat server. when run application got error messages below. please let me know need do. regards, application initialization failed: no such file load -- rack file:/c:/program%20files/apache%20software%20foundation/tomcat%207.0/webapps/rouge/web-inf/lib/jruby-rack-1.0.7.jar!/vendor/rack.rb:7 file:/c:/program%20files/apache%20software%20foundation/tomcat%207.0/webapps/rouge/web-inf/lib/jruby-rack-1.0.7.jar!/vendor/rack.rb:28:in require' file:/c:/program%20files/apache%20software%20foundation/tomcat%207.0/webapps/rouge/web-inf/lib/jruby-rack-1.0.7.jar!/jruby/rack/booter.rb:28:in boot!' file:/c:/program%20files/apache%20software%20foundation/tomcat%207.0/webapps/rouge/web-inf/lib/jruby-rack-1.0.7.jar!/jruby/rack/boot/rack.rb:10 file:/c:/program%20files/apache%20software%20foundation/tomcat%207.0/webapps/rouge/web-inf/lib/jruby-rack-1.0.7.jar!/jruby/rack/boot/rack.rb:1:in `load' :1 run jr...

javascript - html parsing iPhone sdk? -

i want parse html iphone application. tuts help thanks libxml2.2 in sdk , includes libxml/htmlparser.h html 4.0 parsing using api use parse xml.

security - How do you password protect entering the vba code editor from a sheet? -

i want method password protect vba code, users in sheet won't able go code editor without entering it. you can protect vba code password described here: http://www.ozgrid.com/vba/protect-vba-code.htm but not secure way protect code, see thread more information: lock down microsoft excel macro

how to make user sceens in android and how to navigate between different screens -

i new in android development.i want know how can make user screens , how navigate between them. yes can make user screen xml layout... and navigate.. intent intent = new intent(currentclass.this, destinationclass.class); startactivity(intent);

iphone - set image in UIImageview Programmatically -

i have build 1 application. in application set image in uiimageview @ button's clicked action. , next time clicked on button image changed, operation done. after sometime button clicked image not changed in uiimageview , print following message on console: imageio: cgimageread_mapdata 'open' failed '/users/username/library/application support/iphone simulator/4.2/applications/02fe7a45-261f-4aed-ab37-592a228876fc/appname.app/imagename.png' error = 24 (too many open files) i can use following code set image in uiimageview nsstring *path = [[nsbundle mainbundle] pathforresource:strque oftype:@"png"]; uiimage *img = [[uiimage alloc] initwithcontentsoffile:path]; [img1 setimage:img]; where img1 object of uiimageview , strque name of image imageio: cgimageread_mapdata 'open' failed '/users/username/library/application support/iphone simulator/4.2/applications/02fe7a45-261f-4aed-ab37-592a228876fc/a...

architecture - Which is a better approach to load data from reader into objects -

have @ below code load list while (datareader.read()) { city city; if (city.tryload(datareader, out city)) { defaultcities.add(city); } } tryload reads reader , loads dataobject , returns true when successful , false when unsuccessful. benefit of this, told, code not throw error if code fails reason when loading object. if 1 row of data corrupt, not added default connection. moreover, in try load can log particular row threw , error , fix that. on other hand approach followed earlier loading objects , adding them collection. while (datareader.read()) { city city = new city(); city.name = reader["name"].tostring(); . . defaultcities.add(city) } while second approach may fail due corrupt value in database, wouldn't want t...

asp.net - How to increase thickness of lines in Line Charts? -

how can increase thickness of lines in line charts ( system.web.ui.datavisualization.charting )? tried change font property of series , found it's read-only. chart1.series["default"].borderwidth = 2; very helpful collection of examples: http://code.msdn.microsoft.com/samples-environments-for-b01e9c61

Export into MS-Word using PHP -

i want export data ms word file using php on windows , linux operating system. have written following code. header("content-type: application/vnd.ms-word"); header("content-disposition: attachment;filename=document_name.doc"); echo "<html>"; echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1252\">"; echo "<body>"; echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">'; echo '<tr><td>test data</td></tr>'; echo '</table>'; echo "</body>"; echo "</html>"; i have ms word file without table border when opened ms office 2007. but, if open ms office 2003 have ms word file table border = '1'. how can fix problem? you indicating via http headers you're sending word document (mime type applciation/vnd-ms-...

windows xp - How can I add totals from a file in a dos batch -

i want add totals lines in text file. my file.txt looks this: totals: 7 passed, 0 failed, 0 skipped totals: 10 passed, 0 failed, 0 skipped totals: 6 passed, 0 failed, 0 skipped totals: 9 passed, 0 failed, 0 skipped totals: 4 passed, 0 failed, 1 skipped totals: 31 passed, 0 failed, 0 skipped totals: 10 passed, 0 failed, 0 skipped totals: 4 passed, 0 failed, 0 skipped totals: 8 passed, 0 failed, 0 skipped so when run sumtotals.bat file.txt want this: passed : xx failed : 0 skipped: x you can this: @echo off set passed=0 set failed=0 set skipped=0 /f "tokens=2,4,6 delims= " %%a in (%1) call :add %%a %%b %%c echo passed=%passed% echo failed=%failed% echo skipped=%skipped% goto :eof :add rem echo %1 %2 %3 set /a passed=%passed%+%1 set /a failed=%failed%+%2 set /a skipped=%skipped%+%3 :eof result: c:\temp>sumtotals.bat file.txt passed=89 failed=0 skipped=1