Posts

Showing posts from April, 2011

Loading data from file into MySQL table with foreign key constraint -

i need load data file table foreign key constraint. if have parent table populated , want populate child how find appropriate foreign key child. i.e. if have department , employee table employee contains fk_department_id no other identifying information department, how know department employee belongs to. thinking of using temporary tables contained identifying information department (like department name) in employee table , using join appropriate fk's. put info without identifying columns database, don't think best way it. first load data department table, , after execute following using department name in employee csv, ex.: department csv: deptname, manager ("finance","ted smith") department table: de_id, de_name, de_manager emplstrong textoyee csv: name, surname, deptname ("tom", "smith", "finance") employee table: em_id, em_name, em_surname, em_de_id load data low_priority local infile 'c:\\temp\\empl...

.net - How can I embed an configuration-specific manifest file in my c# app? -

i'd embed platform-specific manifest file in c# app. there easy way in visual studio 2008 without using external script called after build finished? in creating c# app, configuration , platform dropdowns disabled application tab, preventing me selecting architecture or configuration specific manifest embed app. i'm forced use 1 manifest whole application. i thought of using post build event call little script embed right manifest based on $(configuration) macro variable, , works, want without calling other script , want know if it's possible without using build events. can embed x86 , x64 assembly references in same manifest file , run time load correct one? you need add app.manifest file. right-click project, select "add" -> "new item...". select "general" entry on left tree view under "visual c# items". "templates" list, locate , select item call "application manifest file". click add. ...

Inserting PHP inside HTML code, ie. inside < ... value="PHP CODE HERE" /> - workaround? -

i have custom fields defined on wordpress in have entered episode number each post have written. want use value in form, need keep form code same , call using shortcode in each post since there way many posts edit manually. i have tried <input type="hidden" name="episode" value="<?php the_meta(); ?>"/> to set value of episode inside form value specific post, php code still able seen on page source code not going through. there workaround? you have echo response. <input type="hidden" name="episode" value="<?php echo the_meta(); ?>"/> of course can use print functions.

php - query not resolving right, how to? -

i have query should return 40 results: $test = mysql_query(" select fname online_all verify_status = 'v' limit 40 "); if (!$test ) {print " - mysql error - ";echo fns_et_mysql_error(mysql_error());} if echo mysql_num_rows($test); 40 . means results when print_r $roww = mysql_fetch_array($test); 1 result. there no php errors. you have loop through results with: while($row = mysql_fetch_array($test)) { // awesomeness $row }

c++ - boost::variant & STL containers - Am I doing it wrong? -

i'm scratching head on one. i'm trying use boost::variant store vector of values of type determined @ run time. vector's internal type doesn't change once known. trying create interface code can add value vector , later retrieve values vector. code not compile. approach wrong? should using polymorphism job? code follows (does not compile): template <typename t> class record_value_visitor : public boost::static_visitor<void> { public: record_value_visitor(t v) : _val(v) {} void operator()(vector<t>& vec) const { vec.push_back(this->_val); } private: t _val; }; class monitor { public: monitor(int type) { switch (type) { case 1: this->_values = vector<int>(); break; case 2: this->_values = vector<string>(); break; default: throw new exception("invalid type...

routing - how to do testing of rails layouts, when they call url_for -

i have test case tests layout. looks see if links present or absent different kinds of users (admin links, instance). worked fine until started localize of our interface. describe "layouts/application" include devise::testhelpers fixtures :users "renders admin link admin user" @admin = users(:admin) sign_in(@admin) @locale = 'en' render rendered.should match(/administration/) end end the layout contains call <%= toggle_language %>, uses url_for generate url current one, :locale parameter changed: def toggle_language case locale when :fr other=:en when :en other=:fr else other=:fr end link_to t(:other_language), url_for(:locale => other) end the problem since have no controller called "layouts", url_for can't generate needs. 1) layouts/application renders admin link admin user failure/error: render actionview::template::error: no route matches {:controller=>...

c# - Openxml Add another different footer to an existing docx -

i trying add different footer after each altchunk added. code changes footers , on last page there 2 footers. adding section break prior adding new footer different text. (c# , openxml) public static void appendfooter(string sfttext, string sfile) { using (wordprocessingdocument wddoc = wordprocessingdocument.open(sfile, true)) { maindocumentpart mypart = wddoc.maindocumentpart; footerpart newftpart = mypart.addnewpart<footerpart>(); string ft_id = mypart.getidofpart(newftpart); makefooterpart(sfttext).save(newftpart); foreach (sectionproperties sectproperties in mypart.document.descendants<sectionproperties>()) { footerreference newftreference = new footerreference() { id = ft_id, type = headerfootervalues.default }; sectproperties.append(newftreference); } // save changes ...

java - [TestNG][Jar] Set Classpath in Manifest (Class-Path) -- classpath is ignored? -

i'm trying run simple testng test case residing within jar file, contains test , manifest: ex.) test.jar contains: { meta-inf\ meta-inf\manifest.mf tests\ tests\test01.class } i trying run using command: java org.testng.testng - testjar test.jar testng.xml where folder contains (all in same directory): test.jar testng.xml testng-6.1.1.jar and manifest contains (w/ line-break @ end): manifest-version: 1.0 created-by: willie owens class-path: testng-6.1.1.jar test.jar . and noclassdeffounderror: org/testng/testng. not find main class. if specify classpath using -cp after "java" (ex. java -cp testng-6.1.1.jar;test.jar org.testng.testng -testjar test.jar testng.xml) works, want information in manifest. doing wrong here? also, i've tried every variation think of when typing in class-path, such as: ./testng-6.1.1.jar .\testng-6.1.1.jar ...etc.. help executing test-jar not complex testng please refer [1] more detail. lease let me know if find p...

c++ - Difference between putback() and unget() -

i'm using standard iostream input file, , i'm confused unget() versus putback(character) . seems me documentation these functions identical, unget() remembers character put in, i'm nervous. i've used putback(character) , character last read character , i've been thinking changing unget() . putback(character) identical unget() , if character last read character? you can't lie unget() . "ungets" last-read character. can lie putback(c) . can "putback" character other last-read character. putting character other last-read character can useful. also, if underlying read buffer have buffering capability, can "putback" more 1 character. think ungetc() limited 1 character. edit nope. looks unget() can go far putback() .

java - Setting HTML tags with GWT -

i'm running test automation software rely on "id" tags recognize controls. i'm developing in java on eclipse using gwt plugin , have tried using both of below methods set id tag button "add". add.setid("addid"); dom.setelementattribute(add.getelement(), "id", "addid"); neither of these modifying id property correctly. have had problem before or know workaround? thank help! jerry if remember correctly, several browsers (or internet explorer) won't let set dom element's id after has been appended dom. limitation there if directly doing hand coded javascript. browser won't show error on setting id attribute won't update attribute either. so need set id before appending element dom. edit from discussion below appears assuming setting id on button widget's dom element set id on <input type="button"> dom element. assumptions not proving correct because button widget...

iphone - How To Add Edit Mode To UITableView? -

i have table lets swipe delete. want have edit button in nav bar user can change cell's title text. i have far nothing happens uibarbuttonitem * editbutton = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemedit target:self action:@selector(setediting:animated:)]; [self.navigationitem setleftbarbuttonitem:editbutton]; [editbutton release]; - (void)setediting:(bool)editing animated:(bool)animate { [super setediting:editing animated:animate]; if(editing) { nslog(@"editmode on"); } else { nslog(@"done leave editmode"); } } -(void)tableview:(uitableview *)tableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath { if (editingstyle == uitableviewcelleditingstyledelete) { // delete managed object given index path nsmanagedobjectcontext *context = [self.fetchedresultscontroller managedobjectcontext]; ...

Is there a plug-in sample for Firefox 5 written in C++? -

i've seen several examples, libraries gecko 1.9.2 or earlier, how create plugin firefox 5 in c++? the strange thing official website gives me examples firefox v. 1.5 through v. 3.6 why have experienced difficulty. you're better off using ctypes .

Django - counting 'depth' of 'select_related' to get know how many nodes has object to top object -

for example if have model class this: class category(models.model) parent = models.manytomanyfield('self', symmetrical=false, blank=true) and have instance of category have parent parent has albo has parent, there possibility value of children instance top category? , there possibility count somehow depth of deepest related object of of category instance? if need trees of model instances, take @ django-mptt or django-treebeard . both provide lot of convenience.

.net - C# Struct method doesn't save value if accessed by a property -

i need create structure looks int (but has field need...), created new structure named teststruct added 1 method (test()) needed , overloaded operators, , seemed working well... the sample below shows problem. if structure test() method executed val property val property seems lose value, if method executed on val2 variable, 1 seems keep right value... why happen? static class program { /// <summary> /// main entry point application. /// </summary> [stathread] static void main() { new testclass(); } } public class testclass { public teststruct val { get; set; } private teststruct val2; public testclass() { val.test(); console.writeline(val + "-> why not 10?"); //direct assignment works well... val = 123; console.writeline(val + "-> direct assingment works.."); //this way works too. why doesn't work "get;" , "set;...

How to convert euler xyz to euler zxy using javascript -

i trying convert euler rotation order existing xyz zxy. please me in doing this? thanks. edit: found useful article, thinking may others on same path - http://knol.google.com/k/matrices-for-3d-applications-translation-rotation#rotation_matrices_for_euler_angles(c2)(a0)_(28)rotation_round_x(2c)y_and_z_axis(29 ) see link: http://en.wikipedia.org/wiki/euler_angles#matrix_orientation . make 9 equations xyz zxy matrix , solve them.

Delphi: 32-bit image does not display correctly on Glass Form -

Image
i have png (32-bit) image in timage. form has glass frame. picture's background black, not transparent. how fix it? delphi 2010. thanks. as workaround can change bits of png image 32. check sample the left image png of 8 bits , other of 32 bits.

function - What does this JavaScript snippet mean? -

this question has answer here: what (function() { } )() construct in javascript? 18 answers i have not met type of grammar before. mean? technique related? (function(fun) { })(myfunkyalert); this anonymous function run declared. parameter myfunkyalert , inside function referenced fun variable. the reason write function avoid conflicts, due scoping. example: var myfunkyalert = "the funky alert"; (function(fun) { alert(fun); })(myfunkyalert); this result in alert message "the funky alert".

What is the equivalent datatype of SQL Server's Numeric in C# -

in sql server can write data numeric(15,10) .. equivalent of in c#? i know numeric 's equivalent decimal how represent numeric(15,10) ? there isn't direct equivalent, in there no built-in .net types allow specify precision/scale explicitly far i'm aware. there's no fixed -point type numeric. decimal , double common floating point types in .net, decimal implementing decimal floating point (like numeric in t-sql) , double implementing binary floating point behaviour (like float , real in t-sql). (there's float well, smaller binary floating point type.) you should choose between decimal , double based on values you're going represent - typically think of "man-made", artificial values (particularly money) being appropriate decimal , , continuous, natural values (such physical dimensions) being appropriate double .

graphics - Is there some well-known algorithm which turns user's drawings into smoothed shapes? -

Image
my requirements: user should able draw hand. after takes off pen (or finger) algorithm smooths , transforms basic shapes. to started want transform drawing rectangle resembles original as possible. (naturally won't work if user intentionally draws else.) right i'm calculating average x , y position, , i'm distinguishing between horizontal , vertical lines. it's not yet rectangle kind of orthogonal lines. i wondered if there well-known algorithm that, because saw few times @ touchscreen applications. have reading tip? update: maybe pattern recognition algorithm me. there phones request user draw pattern unlock it's keys. p.s.: think question not related particular programming language, if you're interested, build web application raphaelgwt. the douglas-peucker algorithm used in geography (to simplify gps track instance) guess used here well.

php - Display output by one sql from two tables -

family table familynumber fistname lastname 10001 b 10002 c d 10003 e f 10004 g h phone table familynumber phonenumber description 10001 111 mobile 10001 222 home 10001 333 text 10002 444 text 10003 555 work 10003 666 mobile i need output as familynumber phonenumbers 10001 111, 222, 333 10002 444 10003 555, 666 i know can done folowing code $families = mysql_query("select * family") while($family = mysql_fetch_assoc($families)) { extract($family); echo "<td>$familynumber</td>"; echo "<td>"; $phones = mysql_query("select * phone familynumber = '$familynumber'"); while($phone = mysql_fetch_assoc($phones)) { extract($phone); echo $phonenumber . ", "; } echo "</td>"; ...

java - Alphablending without buffered image -

i'd draw shape on graphics2d , colour part of different if intersects range. managed drawing 2 shapes bufferedimage (the original shape , area cause change of colour) using alphacomposite , alphacomposite.src_in. problem if canvas scrolled, screen becomes laggy every time paint method called, buffered image created. is there way of achieving same effect (2 shapes overlapping, 2nd shape's overlap area coloured) without using buffered image object? cheers, max i'm not sure undertand you're trying do, shouldn't create buffered image each time paint method called; when changed in objects display.

javascript - load Content with jQuery without refresh -

i want load content(is html) jquery. why following code not worked me? use of tutorial: http://net.tutsplus.com/tutorials/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/ html: click on each of link load page it(href). <div id="icon"> <a href="http://localhost/test/test2.php" id="delete_icon"></a> <a href="<?=base_url();?>admin/tour/insert_foreign" id="add_icon" ></a> <a href="http://localhost/test/1st.htm" id="edit_icon" ></a> <a href="http://localhost/test/index1.php" id="print_icon"></a> </div> js: var hash = window.location.hash.substr(1); var href = $('#nav li a').each(function () { var href = $(this).attr('href'); if (hash == href.substr(0, href.length - 5)) { var toload = hash + '.html #content'; $('#content').load(toload...

bash - How to remove a line that match a pattern of sepific occurance? -

here delete line match <li><p><a href="anti\/recent.html"> fourth occurance i asked here before bit different, @ time have match <ul> at time answer: awk '/<ul>/ {ul++} ul == 6 { getline } 1' file however , can not applied <li><p><a href="anti\/recent.html"> and in other post have got answer: awk '/<li><p><a href="anti\/recent.html">/ {a++} == 4 { getline } 1' file the awk seems have bug ^i^i^i^i^i^i^i^i^i<li><p><a href="anti/recent.html">4 jul 2011 - fraudulent email purporting related standard chartered bank (hong kong) limited</a></p></li>$ <!--<li>there no phishing attack @ moment.</li>-->$ ^i^i^i^i^i^i^i^i </ul>$ for example delete </ul> although on different line? it somehow works delete fourth item after delete many line...

java - from file to arraylist, from arraylist to array[] -

i have text file contains this: 1 1 0 0 1 2 0 0 1 0 1 0 1 0 2 0 1 0 0 1 1 0 0 2 2 1 0 0 2 2 0 0 2 0 1 0 2 0 2 0 2 0 0 1 2 0 0 2 then, put contents in arraylist. result same in file. next, want process data 1 1 , put each row of content in array[][] the data seperated row. result this: output[0][]={1 1 0 0} output[1][]={1 2 0 0} output[2][]={1 0 1 0} output[3][]={1 0 2 0} .... .... .... question, how can take string in arraylist become separated data? code in java thanks you can use " public string[] split(string regexp)" method split string in array specifying character split in argument. e.g. string temp = "1 2 3 4"; temp.split(" "); split blank space in case..

jquery - Treegrid with JSON data in jqgrid -

Image
i testing trees in jqgrid, far able create below i want have jqgrid demo page i came below code, no idea how should go expanding each row in tree given json format $('<table id="list2" cellspacing="0" cellpadding="0"></table></div>').appendto('#topics'); var grid = jquery("#list2"); grid.jqgrid({ datastr:topicjson, datatype: "jsonstring", height: "auto", pager: false, loadui: "disable", colnames: ["id","items","url"], colmodel: [ {name: "id",width:1,hidden:true, key:true}, {name: "elementname", width:150, resizable: false}, {name: "url",width:1,hidden:true} ], treegrid: true, caption: "jqgrid demos", expandcolumn: "elementname", autowidth: true, //width: 180, rownum: 200, //expandcolclick: true, treeicons...

How can I compare two images in Java? -

i have 5 images default in program, , allow user choose image desktop. program determine image between 5 images closest 1 user image. can me , take me start of idea? you can try use feature extraction algorithm sift , surf etc. compare extracted features database. can select best matching image based on number of correct matches. generally sift works fine 2d objects, picture of label or advertisement board. rotation on 2d plane or scale wont matter if using sift. surf supposed improvement of sift not have experience on it. these algorithms said bit heavy. anyway if matching 5 images wont of problem.(or can calculate descriptors(features) of images before hand , store them. @ run time have descriptor of user image , compare it) still if trying match images of basic shapes squares , circles, using square detection or circle detection might efficient performance wise.

Android mapview partially loading tiles -

i have built android application has single mapview. i have bug map view has missing tiles. map view not blank tiles appear not of them. answers here relate api keys or issues having multiple mapviews in 1 app. not problem. it occurs intermittently, approximately 1 in every 5 times start application after clearing data out of app. typical seen on new installations. it occurs on android 2.2 devices (samsung galaxy s definately) note logs show: 07-21 17:11:52.274: info/mapactivity(25951): handling network change notification:connected 07-21 17:26:25.629: error/mapactivity(26064): couldn't connection factory client when tiles fail load zooming in , out or restarting not refresh tiles. solution go settings->manage applications->[select app]->clear data restart app. anyone seen before , know of cause or workaround? cheers. i can guess can see partial tiles may internet connection problem. check internet connection weather displays 3g icon in em...

What mistake am I making in this code (Perl)? -

use strict; use warnings; %hash = ("no1"=>1, "no2"=>2, ); @array = %hash; print @array; #output: no11no22 print "\n"; $string = print @array; print $string; #output: no11no221 why $string not same @array? why getting 1 @ end? mistake making? the main problem print doesn't return string, rather prints out string filehandle (see perldoc -f print ). instead, can let my $string=join('',@array);

php - $_post Problem (How to pass the value of $_post) -

i have following code works well. the code display data database in input text field format. user able edit , update details clicking update button @ end of each row update specific row. instead of clicking update buttons 1 one (if user wants edit , update more 1 row), create hyperlink update data @ once. the problem dunno how pass value of $_post "update.php" since have <form name="form1" action="submitaction.php" method="post"> i not sure possible so. or there other alternative ways? <html> <script language="javascript" > <!-- hide function submitrequest(id) { document.forms[id].submit(); } // end hide --> </script> <!-- javasript (onclick) remove readonly attribute--> <script language="javascript"> function removealignment(id){ document.getelementbyid("projectname_"+id).removeattribute("readonly",0); document.getelementbyid("devicety...

javascript - Get id of div from its class name -

how can find id based on class using javascript. know this easy jquery solution.. using getelementsbytagname ? document.getelementsbyclassname('myclassname')[0].id or document.queryselector('.myclassname').id

android - Viewport on Opera Mini & WM6.1 does not match 100% of the `device-width` -

sample page: 256.cz/test/ code: meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi" same css style mobile view , normal view latest opera mini android market (android version 2.1) - scale not 100% :-( latest opera mini site opera (windows mobile 6.1, native opera mini, not java) - scale not 100% :-( latest opera mini site opera (sony ericsson w995) - scale 100% :-) latest opera mini site opera (blackberry) - scale 100% :-) how achieve proper display (scale 100%) on mobile devices? opera mini set device-width makes sense, considering font size , on. e.g. on htc desire, default zoom level 170%, resulting in device-width of 282px (480px/1.7). target-densitydpi=device-dpi supported opera mobile, not opera mini. in other words, @ present, there no way force 1 css pixel equals 1 device pixel on opera mini.

python - Why is my xlabel cut off in my matplotlib plot? -

i plotting dataset using matplotlib have xlabel quite "tall" (it's formula rendered in tex contains fraction , therefore has height equivalent of couple of lines of text). in case, bottom of formula cut off when draw figures. changing figure size doesn't seem this, , haven't been able figure out how shift x-axis "up" make room xlabel. reasonable temporary solution, nice have way make matplotlib recognize automatically label cut off , resize accordingly. here's example of mean: import matplotlib.pyplot plt plt.figure() plt.ylabel(r'$\ln\left(\frac{x_a-x_b}{x_a-x_c}\right)$') plt.xlabel(r'$\ln\left(\frac{x_a-x_d}{x_a-x_e}\right)$') plt.show() while can see entire ylabel, xlabel cut off @ bottom. in case machine-specific problem, running on osx 10.6.8 matplotlib 1.0.0 use: import matplotlib.pyplot plt plt.gcf().subplots_adjust(bottom=0.15) to make room label. edit: since gave answer, matplotlib has ad...

javascript - What are ECMAScript 6 WeakMaps? -

after reading description: http://wiki.ecmascript.org/doku.php?id=harmony:weak_maps i'm trying hang of it, not overall picture. about? seems supported in firefox 6: http://kangax.github.com/es5-compat-table/non-standard/ weakmap weakmaps allow have hashtable key isn't string. so can set key be, i.e. [1] , can map.get([1]) example mdn: var wm1 = new weakmap(), wm2 = new weakmap(); var o1 = {}, o2 = function(){}, o3 = window; wm1.set(o1, 37); wm1.set(o2, "azerty"); wm2.set(o1, o2); // value can anything, including object or function wm2.set(o3, undefined); wm2.set(wm1, wm2); // keys , values can objects. weakmaps! wm1.get(o2); // "azerty" wm2.get(o2); // undefined, because there no value o2 on wm2 wm2.get(o3); // undefined, because set value wm1.has(o2); // true wm2.has(o2); // false wm2.has(o3); // true (even if value 'undefined') wm1.has(o1); // true wm1.delete(o1); wm1.has(o1); // false the reason exista...

c++ - lambda: should capturing const reference by reference yield undefined behaviour? -

i found nasty bug in code because captured const reference string reference. time lambda run original string object long gone , referenced value empty whereas purpose contains value of original string, hence bug. what baffles me did not invoke crash @ runtime: after all, shouldn't undefined behaviour since afaik there dangling reference? when looking @ id under debugger, doesn't garbage constructed empty string. here's test case; prints empty line: typedef std::vector< std::function< void() > > functions; void addfunction( const std::string& id, functions& funs ) { funs.push_back( [&id] () { //the type of id const std::string&, there //is no object reference. ub? std::cout << id << std::endl; } ); } int main() { functions funs; addfunction( "id", funs ); funs[ 0 ](); } undefined behavior means there no requirement should happen. there no requirement should crash. wha...

camera - Use Desktop webcam on Android AVD -

i'm developing android app needs capture camera picture, is there way configure avd use conputer webcam on emulator? when open default camera app shows me squareanymation, can use/configure emulator/avd use computer webcam? i can't think of way this. i following: during development, when debugging on actual device under adb, use camera normal. while debugging on avd, comment out camera code , pre-taken png app resembles/emulates photo camera have taken. let work on picture analysis regardless of camera, , finish app without actual adb device, avds. 1 ahold of real device can finish up. on note, if ready go poking around in vms, android kernels, , hals, follow article (http://bytecruft.blogspot.com/2011/05/alternative-to-android-emulator-and.html) tells how setup android x86 under vmware or virtualbox adb device. i'm sure setting host machine's webcam camera easier bay (vmware device bridging comes pretty close). hope helped.

camera - android.intent.action.CAMERA_BUTTON not broadcasting on Desire Z (Froyo)? -

i have hard time intercepting hw camera button on desire z (froyo). wrote sample runs fine on g1 (1.6) not on aforementioned phone. androidmanifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.company" android:versioncode="1" android:versionname="1.0"> <uses-sdk android:minsdkversion="4" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".camerareceivertestactivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <receiver android:enabled="true" android:exported="true" android:name=".cam...

iphone - Can we create the Custom Cell with the UIPickerView? -

i have create custom tableview picker control in multiple rows,can me on this? you can add uipickerview subview of uitableviewcell . [cell.contentview addsubview:pickerview]; don't forget return appropriate height heightforrowatindexpath: method. if (cellcontainspickerview) return 200.0; // height of picker view

objective c - iPhone:navigation bar "back" button clickable = NO? -

i know can hide navigation bar "back" button. dont whant hide ! there way make not clickable ? try this self.navigationitem.leftbarbuttonitem.enabled=no; self.navigationitem.backbarbuttonitem.enabled=no; update: it seems apple doesn't allow button enable / disable. instead of can hide it. self.navigationitem.hidesbackbutton = yes;

copy - iOS: Copying file from bundle on application start-up -

when user first uses application, should copy configuration file bundle folder. user can fiddle file, , if mess can press ' restore ' delete file , copy again bundle. - (void) resetpresets { log_( @"copying tunings file original..." ); // copy default tunings -> curr tunings file nsstring* appsupportdir = [nsfilemanager appsupportdir]; nsstring* tuningspath = [appsupportdir stringbyappendingpathcomponent: @"tunings.txt"]; nsbundle* bundle = [nsbundle mainbundle]; nsstring* origtuningspath = [bundle pathforresource: @"tuningsoriginal" oftype: @"txt" ]; nsfilemanager* filemanager = [nsfilemanager defaultmanager]; nserror* error = nil; if( [filemanager fileexistsatpath: tuningspath] ) { [filemanager removeitematpath: tuningspath error: & error ]; if( error ) log( @"\...

php - Displaying values from a database (using mySQL) on a Flot graph -

i'm trying read in values db using php (mysql) have them show on graph in flot. know values read in correctly , i'm not getting errors graph won't show. little help? thanks in advance. <?php while ($row = mysql_fetch_array($result, mysql_num)) { $graphdata[] = array( (int)$row[0], (int)$row[1] ); } ?> ///// <div id="placeholder" style="width:600px;height:300px"></div> <script language="javascript" type="text/javascript"> var dataset1 = <?php echo json_encode($graphdata);?>; var data = [ { label: "random values", data: dataset1 } ]; var plotarea = $("#placeholder"); $.plot( plotarea , data); </script> the contents of pastebin show json string you're outputting invalid json. var data = [{ label: "random values",data: dataset1}]; will validate if it's changed to: ...

How to change a value in a column on a SQLite database? -

i have sqlite database format: table users | |---------name - text | |---------avatar - text | |---------password - text | |---------userdir - text | |---------role - numeric i want change number of role . how change it? (i mean, query?) i'm using php if needs it. thanks! update users set role=99 name='fred'

php - How do I encode a query string containing forward slashes? -

i need pass path parameter url e.g. /controller/action/my-path my-path contains forward slash e.g. /dir1/dir2/file.php there way of passing path single parameter or need break path down /controller/action/param1/dir1/param2/dir2/param3/file.php. sample code appreciated tia ephraim you can use url view helper, e.g.: echo $this->view->url( array( 'controller' => 'somecontroller', 'action' => 'someaction', 'path'=>'/dir1/dir2/file.php') ); this result in: public/somecontroller/someaction/path/%2fdir1%2fdir2%2ffile.php url view helper automatically uses url_encode encode parameters (see other anwser).

c# - How can I change the background color of the Infragistics' UltraGrid filter row? -

Image
currently looks like: i'd change blue color, don't know property change. i've tried changing think property magenta or stands out in attempt find out property need, far no dice. any ideas? use "ultragrid.displaylayout.override.filtercellappearance" that.

c++ - Creating a Static Library - Eclipse CDT -

my project ready building , i'd generate static .a files, go project properties , check c/c++ build settings. under build artifact tab have option create either executable or shared library. static option missing. am missing fundamental?

php - Zend_Validate_EmailAddress versus filter_var(..., FILTER_VALIDATE_EMAIL) -

of zend_validate_emailaddress , filter_var(..., filter_validate_email) , better when validating email address , why? both can used validate email address, zend_validate_emailaddress more powerful. while filter_var simple yes or no validator, there many options can change how strict zend_validate_emailaddress is. you can choose parts validate, rules validating parts, , validate mx records. finally, zend_validate_emailaddress can readily used in combination zend_filter_input , zend_form filter_var can't.

sql server - SQL Query to bring back fields that only contain numbers (specifically an IP address) -

i have quite few tables field called company can either have in them: "fake company" or "5.5.5.5" the numerical address above of course being ip address. i'm not sure how i'd go writing select query brings rows have ip address in them , not text. ideas? you use regularexpressions on sql-server, example: insert tip values('fake company'); insert tip values('5.5.5.5'); insert tip values('192.168.5.8'); insert tip values('192.168.5.88'); declare @regexpattern varchar(100); set @regexpattern='([0-9]{1,3}\.|\*\.){3}([0-9]{1,3}|\*){1}'; select * tip dbo.regexmatch( tip.ip, @regexpattern ) = 1 and here function: create function [dbo].[regexmatch](@input [nvarchar](4000), @pattern [nvarchar](4000)) returns [bit] execute caller external name [regexlib].[regexlib.userdefinedfunctions].[regexmatch] regularexpressions on sql-server: http://msdn.microsoft.com/en-us/magazine/cc163473.aspx how integra...

Connect and modify SQL server from Selenium using Ruby (no Rails) -

i guess selenium isn't important question thought i'd add in. also, i'm not using rails. i need access sqlserver , delete records using ruby. nothing crazy. i've found information online know recommend best way this. i've come across dbi , sequel gems unsure amount of time i'll need invest , running. also, there better alternatives? thank you you might want try tiny_tds see if fits needs. it's pretty bare-bones without orm.

Rails 3 can't get beginning_of_week -

have publish_on datetime field. just trying begining_of_week publish_on. tried helper def start_week(publish_on) datetime.parse(publish_on).beginning_of_week end and in view <%= start_week(@survey.publish_on) %> tried in model def set_start_week publish_on.beginning_of_week end hell, tried helper def this_should_work datetime.now.beginning_of_week end but returns invalid date view. works in irb, why not in view? edit module surveyshelper require 'date' require 'time' def this_should_work datetime.now.beginning_of_week end end take_survey.html.erb <%= this_should_work %> error invalid date in rails 3.0.9 got undefined method `at_beginning_of_week' wherever put it, alternative solution is: def somemethodputanywhere ... @datey = date.today @monday = @datey - @datey.wday + 1 #@monday monday of current week. #remove constant '+1' if week begins sunday... ... end

Looking for a design pattern to handle asp.net sub projects -

i'd re-design site 1 asp.net solution, , project each of main areas of site. layout this: main project masterpage -- legal section project --- legal main page (uses main masterpage) --- legal sub page (uses main masterpage) -- administration section project --- main admin (uses main masterpage) --- second admin (uses main masterpage) --- third admin (uses main masterpage) the way i'd site work if menu item master page gets triggered, sub pages if in different project, able handle first, perhaps asking user save before event master page gets handled. any samples out there that? asp.net 2.0 or 3/3.5 fine. mvc or mvp work this? either mvc or webforms this. have manage stuff manually in file system. with mvc, there concept of area, out-of-the-box, areas must in same project. recommend mvc this.

WPF - Checkbox in cell row readonly possible? -

i have listview bind dynamically list of object of same type. the object have boolean value. there listview column display checkbox instead of "true" , "false" normal value specific property. is there way set checkbox readonly ? otherwise there way tell click coming specific row in events "checked" , "unchecked" execute method in code behind ? thanks! you can make control readonly setting ishittestvisible , focusable false. xaml: <window x:class="wpfapplication1.window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wpfapplication1="clr-namespace:wpfapplication1"> <stackpanel> <listview itemssource="{binding}"> <listview.view> <gridview> <gridviewcolumn header="name" displaymembe...

Conditional sum in SQL Server -

i have table in mssql: id op1 op2 op3 330 0 0 1 331 1 0 0 332 3 2 0 op's options. there can go 1 9, 0 means question not answer. how can "sum" in column called "answered", so: id op1 op2 op3 t 330 0 0 1 1 331 1 0 0 1 332 3 2 0 2 a value on 0, means answered. i try case when, if stateme use case : select id, op1, op2, op3, (case when op1 > 0 1 else 0 end + case when op2 > 0 1 else 0 end + case when op3 > 0 1 else 0 end) t mytable

ajax - Set default response type in WCF Web Api -

i've set of services hosted wcf web api , communicate them in json javascript. in cases i'm okay modifying accepts bit of header require json response there cases arising can't this. due the javascript framework i'm using (ext js). things lets me specify url , not proxy defaults such headers. this isn't ext js question however. web api seems default returning xml, , i'd know whether it's possible change default can return json instead. in advance! a bit of experimentation seems indicate order of configured formatters matter (which quite intuitive). by default, when create instance of httpconfiguration , formatters collection contains these formatters: xmlmediatypeformatter jsonvaluemediatypeformatter jsonmediatypeformatter formurlencodedmediatypeformatter the reason why xml default formatting because it's first formatter. make json default value, can reorder collection this: jsonvaluemediatypeformatter jsonmediatypeforma...

iphone - RemoteNotifications not registering/not doing anything -

i have followed tutorial: http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 fully, , after seing had issues app created same app did, simplest possible still no luck. my problem: [[uiapplication sharedapplication] registerforremotenotificationtypes: (uiremotenotificationtypebadge | uiremotenotificationtypesound | uiremotenotificationtypealert)]; in applicationdidfinishlau... , write 2 methods didregister , didfail never response neither of them (having written stuff in nslog in both of them). running of iphone 4 wifi activated , internet's fine... internet slow here in france after waiting long time still nothing... not didfail.. thanks help i fixed it, because in france have no cellular network enabled , push notifcations not seem work, @ least first time, when cellular data , 3g disabled in phone.

java - Observer pattern in non Swing applications -

observer pattern commonly used in swing based applications. can give practical example of pattern can used in non swing, pojo applications? in java libraries, interfaces of form listener (including awt listeners , there others) point use of observer pattern. there's basic implementation in java.util.observable / observer , , in java.beans.propertychangesupport

C++ Virtual Method -

if create struct: struct joinpoint_exception: exception { virtual const char* () const throw (); }; what what () const throw () means in context? what virtual member function returning pointer constant char constant , throws nothing. virtual const char* () const throw (); |-----| <- virtual member function |---------| <- returning pointer constant chars |-----| <- named |---| <- constant |-------| <- not throw (technically function can still throw, if does, goes directly std::unexpected , defaults calling std::terminate )

CodeIgniter - Displaying and entering dynamic meta data -

i have started using codeigniter ... im finding quite good, although have bit of issue. whats best way handle meta data? ... in views folder, have created folder called 'includes' in there have added header, footer, nav views. so i'm taking each controller meta data needs entered , passed header view. if examples of how go this, fantastic. cheers, create new file in libraries folder: <?php if ( ! defined('basepath')) exit('no direct script access allowed'); class view_lib { public function __construct() { $this->ci =& get_instance(); } public function load_view($template, $data = null) { $this->ci->load->view('header', $data); $this->ci->load->view($template); $this->ci->load->view('footer'); } } /* end of file view_lib.php */ /* location: ./system/application/libraries/view_lib.php */ then load library in controller: $this->load->library(...