Posts

Showing posts from January, 2013

r - Converting xts to ts: Error in Round(frequency) -

i have imported csv data have turned xts object. if try convert ts object (with end goal of using functions acf) get: "error in round(frequency) : non-numeric argument mathematical function" the code convert is: library("zoo") #working milliseconds op <- options(digits.secs=3) #rename function clean_perfmon = function(x, servername) { names(x)[names(x)=="x.pdh.csv.4.0...coordinated.universal.time..0."] <- "time" x$time = strptime(x$time, "%m/%d/%y %h:%m:%os") return(x) } web02 = read.csv("/home/kbrandt/desktop/shared/web02_2011_07_20_1.csv") web02 = clean_perfmon(web02, "ny.web02") web02ts = xts(web02[,-1], web02[,"time"]) the time regular, variation in ms: time(web02ts)[1:3] [1] "2011-07-20 11:21:50.459 edt" "2011-07-20 11:21:51.457 edt" "2011-07-20 11:21:52.456 edt" some of data has na points: > web02ts[1:3,1] x...

iphone - Force Reload Table View -

all, how force reload table view (within view controller) every 5 seconds fifteen seconds when button pressed? thanks, james first create timer when press button, nstimer *timer = [nstimer scheduledtimerwithtimeinterval:5.0 target:self selector:@selector(updatemethod) userinfo:nil repeats:yes]; then in method fires every 5 seconds - (void) updatemethod { [self.tableview reloaddata]; }

iis 7.5 - How to edit Aspnet_isapi.dll mapping in IIS 7.5? -

i trying host wcf service svc files on iis. whenever browse svc files through iis hosting shows text contained in svc files in browser. went through few msdn links change mapping of dll documents iis 6.0 , before. first time working on iis , not getting how add view dll mapping in iis 7.5 manager. http://msdn.microsoft.com/en-us/library/aa751792.aspx follow windows vista part enable windows communication foundation activation components under .net framework 3.5.1.

ios - Have 4.3 SDK only, want 3.x as well -

i know has been discussed before, didn't quote understand of answers. can tell other questions on here, i'm complete newbie when comes app creation using xcode. have sdk ios 4.3. a friend of mine wants app, has iphone 3. has not upgraded ios4. don't see reason app couldn't run @ lower ios version, it's pretty simple. so i'd know how can add previous sdks xcode library? download previous version of xcode w/ it's sdk , install that? brick xcode? if so, then? there can do, i'd written 3.x , above in mind. the simple , more straight forward answers without jargon extremely appreciated! thank you! if have ios 4.3 sdk, can target ios version preceding it. in xcode project build settings, make sure base sdk set highest have (in case 4.3) change deployment target whatever ios version want (try not go lower 3.0). make sure test though, sure not using features not present in sdk version targeting.

Ant load property file and pass value as arg when exec java file -

how can load value property file , pass arg when want execute java file? the content file of aa.properties: home_path=c:/myhome/apps the ant: <target name="tst"> <property file="aa.properties"/> <property name="homepath" value="${home_path}/"/> <java classpathref="clspath" classname="com.mytest.myapp" fork="true"> <arg value="${homepath}"/> </java> </target> you pass other argument java task via nested arg values or arg line note vmargs f.e. -dwhatever=foobar passed jvmarg java task f.e. propertyfile aa.properties looks : vmarg.foo=-dsomevalue=whatever arg.key=value arg.foo=bar ... ant then <target name="tst"> <property file="aa.properties"/> <property name="homepath" value="${home_path}/"/> <java classpathref="clspath" classname="com....

oracle - How to run this stored procedure -

i have check procedure im giving following values parameters 34220, 2815,'7/20/2011', 32760, 100, 'pmnt_check', 1, null, "", false, null, null declare p_app_id number; p_user_id number; p_date date; p_inv_ids wb_prod.wb_pck_types.t_ids; p_amnts wb_prod.wb_pck_types.t_numbers; p_pmnt_method varchar2(15); p_bank_ac_from number; p_check_numbers wb_prod.wb_pck_types.t_numbers; p_memo varchar2(1000); p_pay_multiple number; p_crd_ids wb_prod.wb_pck_types.t_ids; p_crd_amounts wb_prod.wb_pck_types.t_prices; o_py_id number; begin p_app_id := 34220; p_user_id := 2815; p_date := '7/20/2011'; -- modify code initialize variable p_inv_ids := 32760; -- modify code initialize variable p_amnts := 100; p_pmnt_method := 'pmnt_check'; p_bank_ac_from := 1; -- modify code initialize variable --p_check_numbers := null; p_memo := ''; p_pay_multiple := false; -- modify code initialize variable -- p...

Import email contacts (Gmail Yahoo Hotmail) using CakePHP -

is there ready use cakephp plugin or component import gmail, yahoo , hotmail contacts, can send invitations user's friends? if not, easy way it, novice cakephp so, step step tutorial appreciated! you might want start taking @ openinviter cakephp . alternatively, hosted solutions: invitebox (beta, can request invite) free tell-a-friend

php - Session under class -

hello stuck in syntax, can me next code? class user { protected $userid = preg_replace('#[^0-9]#i', '', $_session['user_id']); protected $useremail = preg_replace('#[^a-za-z0-9@_.-]#i', '', $_session['user']); protected $userpassword = preg_replace('#[^a-za-z0-9]#i', '', $_session['user_password']); public function checkuserlogin(){ if(!isset($_session['user'])){ header("location: login.php"); exit(); } //try find user session data in database $sql = "select * users id = '$this->userid' , email = '$this->useremail' , password = '$this->userpassword' limit 1"; $res = mysql_query($sql) or die(mysql_error()); $usermatch = mysql_numrows($res); if ($usermatch == 0) { header("location: login.php"); exit(); } } } first of all, note when declaring property, c...

php - How to check whether dropbox item is selected? -

i have mysql database 2 tables: table1 (id, name, emailid) table2 (id, email) emailid relationship table2.id i'm trying make html form lists contents of table1 dropdown box user select email field. email field populated <options> table2 . my question is: how check value selected emailid , make selected item in dropbox when form loads selected="selected" ? i've gotten 1 solution work don't think proper way , looking best practices method. the way doing work 1 item pulled table1 not if there more 1. here code far: this data make form: <?php $sql = "select table1.id table1id, table1.name, table2.id table2id table1 inner join table2 on table1.emailid = table2.id table1.id = {$id}"; $result = mysqli_query($link, $sql); $row = mysqli_fetch_array($result); $items1 = array('table1id' => $row['table1id'] 'name' => $row['table1.name'] ...

java - Working out a Google App engine entity's property data type -

i have entity - i'm trying determine type of properties - in google app engine's internal data-types preferred (as opposed java data types). below code simplified. in reality not know entity's properties or else it. final datastoreservice dss = datastoreservicefactory.getdatastoreservice(); final query query = new query("person"); final preparedquery pq = dss.prepare(query); (entity entity : pq.asiterable()) { final object property = entity.getproperty("some_property"); // here want determine data type 'property' represents - gae-wise. } in app engine's java code i've found hints: datatypetranslator datatypetranslator.typemap (internal private member) property.meaning.gd_phonenumber i'm unable link need - sort of reflection. i wish able this: entity.getpropertytype("some_property"); does know better? datatypetranslator source code here edit #1: << ingore one. it's me put thes...

Reusing an HTTP connection in Android -

i trying re-use connection in android, , quick google search finds this: http://foo.jasonhudgins.com/2010/03/http-connections-revisited.html however, tried that, , if use wireshark, can see still getting http fin-ack after each of 3 consecutive calls, furthermore, http calls going different ports. any ideas on might doing wrong here? if want use persistent connection server have add keep-alive request urlconnection object so: myurlconnection.setrequestproperty("connection", "keep-alive"); see here

java - Any way to remove logging calls without using ProGuard optimization? -

i have wrapper class making log calls during development. makes easy turn logging on or off @ given time (plus other nifty features). used specific proguard optimization remove class during release, removed calls class's static methods (so no log strings left behind). unfortunately because of this , have disable proguard's optimization feature. while can turn off logging, of log strings still visible in resulting apk, , unless i'm missing something, there no other way in proguard remove them. is there other way remove these strings when building release package in eclipse gui? (not ant) i don't know string literals etc. simulate ifdef debug statement similar this may trivial if can wrap affected inner class/method/var's of debugging class in such statement. apparently compiler removes finds in block more or less dead code, or have read, never checked out though.

android - String.Format (.NET) equivalent in Java? -

the string.format in .net (maybe vb.net) convert {0}, {1}, ... determined string, example: dim st string = "test: {0}, {1}" console.writeline(string.format(st, "text1", "text2")) i've tried search in both google , stackoverflows, return number-string format. the other suggestions good, more in style of printf , lineage more recent additions java. code posted looks inspired messageformat . string format = "test: {0}, {1}" system.out.println(messageformat.format(format, "text1", "text2")) i'm not 'return: statement doing though.

How to detect mobile (iOS and Android) using JSP/Java? -

just wondering if has come across this? basically, im looking detect ios , android using jsp , able conditionally add css , js files page. any ideas? best way user agent string. there's pretty similar question on already, @ least ios/safari. note there other browsers on ios need user agent strings well. alot of ua strings listed on this site . how detect mobile safari server side using php?

c# - Entity Framework in n-Tier -

using simple example: presentation tier : aspx , code behind. business tier: wcf related logics data access tier: wcf entity framework when want populate grid view, there need call method form business logic, in turns call data access tier's method. the methods , related logic follow. data access tier: public sampleentity[] loadsampleentity() { //retrieve sampleentity database. } business logic tier: public sampleentity[] getsampleentity() { //call proxy access data access tier //call loadsampleentity() } presentation tier: protected void btn_onclick() { //call proxy access business logic tier //call getsampleentity() //sampleentity[] sampleentity=businesslogic.getsampleentity(); //gridview.datasouce = sampleentity //gridview.databind(); } given structure, if sampleentity modified, 3 tiers require re-compiling. there way reduce need of re-compiling when new property/column added sampleentity . one way have worked on convert sa...

iphone - Backup core data -

i want backup core data database. i've read need save sqlite file. i'm still not sure if that's though. either way, i've been trying save sqlite file i'm not sure how that. think can using code below. not sure go next. groupappdelegate *appdelegate= (groupappdelegate *)[[uiapplication sharedapplication] delegate]; nsurl *storeurl = [[appdelegate applicationdocumentsdirectory] urlbyappendingpathcomponent:@"group.sqlite"]; nsdata *sqlitedata = [[nsdata alloc] initwithcontentsofurl:storeurl]; how save file? do have make nsdata? i have setup connect dropbox , need save core data there. if have nsurl handle sqlite file, don't need convert nsdata or anything. there various ways retrieve file device: a) have emailed attachment. (look @ mfmailcomposeviewcontroller) b) transfer file using dropbox apis dropbox account. @ dropbox apis c) transfer file using itunes. there's way of doing this, don't have reference @ moment.

python - Regex for word exclusion -

i'm trying write regex match first , third words in string: term1 , term2 my first attempt [^(\s|(and))]+ , fails because term1 anbd term2 gives me these 3 matches: ['term1','b','term2'] whereas want return ['term1','anbd','term2'] match first , third words: (\s+)\s+\s+\s+(\s+) edit: if mean 'match words except word "and"' then: \b(?!and\b)\s+\b

osx - Lost connection to MySQL server at 'reading initial communication packet', system error: 61 -

3 days on , have hit wall. i'm running mac os x. have installed mysql-5.5.14-osx10.6-x86_64.dmg. as far context, need install mysql gem use ruby on rails , won't install unless there valid instance of mysql running. i've tried using /library/startupitems/mysqlcom/mysqlcom [start|stop|restart] method start mysql server , comes no errors, when try connect localhost via mysql workbench, says: "your connection attempt failed user 'root' host server @ localhost:3306: lost connection mysql server @ 'reading initial communication packet', system error: 61 ". i have no path on system of /var/mysql, indicates bundled mysql non existant? other solutions i've found indicate need comment out bind-address in my.cnf unable find such file on system. i'm thinking maybe there conflicts between .dmg that's installed , manual builds i've attempted. also, have gut feeling in $path screwing things, thing don't understand (the $path t...

Integrating eBay and PayPal inventory -

say have item sale on ebay, , same item sale on site via paypal. possible have sales on 1 site reflected in inventory other site, , vice-versa? in other words, if have ten items sale, , buy 1 on either site, should show there 9 items left on both sites. i know paypal has api setting inventory level of item associated button. ebay has api controlling item's inventory. i'm wondering if has tried integrate them. webgility ecc http://www.webgility.com/ can sync orders , inventory between ebay, quickbooks, , popular shopping carts such magento, cs-cart , more. if you're running ecommerce site plus selling on ebay can keep financials , inventory synced up.

android - How can I modify the layout of slidingtab in the lockscreen?,is -

in lockscreen ,the layout of slidingtab vertical,how can modify "horizontal"? i set : <com.android.internal.widget.slidingtab android:id="@+id/tab_selector" ***android:orientation="horizontal"*** android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignparentbottom="true" android:layout_marginbottom="25dip" /> but draw of slidingtab not modify,is vertical.

rewrite - How to update the slug and change the Wordpress permalink? -

i have problem permalinks. in site, register custom post type name ' product ' , taxonomy ' type ' . in taxonomy ' type ', added terms : food food a food b drink drink a drink b with each product, added 1 term, i.e. product1 in food , etc. the permalink this: product : http://abc.com/product/product1 taxonomy : http://abc.com/type/food http://abc.com/type/food-a but want permalink changed this: product : http://abc.com/product-type/food/food-a/product1 taxonomy : http://abc.com/product-type/food http://abc.com/product-type/food/food-a i tried configure .htaccess file can't change anything. found in wordpress answers solution change " rewrite " in register_taxonomy function can't change again. 'rewrite'=>array('hierarchical' => true,'slug' => 'product-type') i added products, , can't find way change permalinks. hope can me solve problem. thanks ...

javascript - compute data from an array -

i have (simple) question regarding array. trying total of board-feet entered in html. here's running sample code: click here (thanks askaiser code). now, want everytime click go button, automatically compute total board-feet being entered in array. so, everytime input in form , clicked go, data go array , total of board-feet displayed in input box below. change add data array. i can't work , have nan value total. see this: http://jsfiddle.net/ghostoy/8xffh/195/

ios4 - Smooth points OpenGL ES 2.0 using shaders -

i drawing points using gldrawarrays(gl_points, ...) , make them smooth round points instead of squares. know there no fixed function pipeline in opengl es 2.0 wondering if there easy way of doing fragment shader? thanks in advance, extremecoder i render point textured quad. straight forward, job, works on oldest opengl versions , faster shader.

javascript - Why is this node.js code blocking? -

i tried play bit node.js , wrote following code (it doesn't make sense, not matter): var http = require("http"), sys = require("sys"); sys.puts("starting..."); var gres = null; var cnt = 0; var srv = http.createserver(function(req, res){ res.writeheader(200, {"content-type": "text/plain"}); gres = res; settimeout(output,1000); cnt = 0; }).listen(81); function output(){ gres.write("hello world!"); cnt++; if(cnt < 10) settimeout(output,1000); else gres.end(); } i know there bad things in (like using gres globally), question is, why code blocking second request until first completed? if open url starts writing "hello world" 10 times. if open simultaneous in second tab, 1 tab waits connecting until other tab finished writing "hello world" ten times. i found nothing explain behaviour. surely it's overwriting of gres , cnt ...

.net - Does ObjectContext keep track of already fetched entities when refetching them -

i fetch object database (poco object proxy) i modify property without saving changes i fetch later on again database (i use same object context) what value of property? for example if have object context collection users result of following: objectcontext o = ....; user u = o.users.first(u=>u.id == 1); console.writeline(u.lastname); // 'test' example u.lastname = 'somethingelse'; u = o.users.first(u=>u.id == 1); console.writeline(u.lastname); // result?? if result of last statement not string "somethingelse" there way achieve funcionality? that core feature of orm tools called identity map pattern . entity unique key can materialized once per context second query default use same instance without changing values. you can force query refresh values either: objectcontext o = ....; user u = o.users.first(u=>u.id == 1); console.writeline(u.lastname); // 'test' example u.lastname = 'somethingelse'; o.users.merge...

asp.net - send array via jQuery to Ajax-enabled WCF -

my js code: var = ["asdfa", "asdfa", "aaa"]; var data = []; (var in a) data.push({ name: 'keys', value: a[i] }); $.post('<%=resolveurl("~/svc/aja.svc/getmultiple") %>', $.param(data), function(d) { //do stuff }); my ajax enabled wcf [servicecontract(namespace = "")] [aspnetcompatibilityrequirements(requirementsmode = aspnetcompatibilityrequirementsmode.allowed)] public class aja { [webinvoke(method="post")] [operationcontract] public ienumerable<idcontent> getmultiple(string[] keys) { return keys.select(o => new idcontent { id = o, content = o + o }); } i tried debugging , method getmultiple doesn't hit,(i error 500) if sending simple string not array, works this message result in firebug : {"exceptiondetail":{"helplink":null,"innerexception":null,"message":"the incoming message has unexpected mes...

jQuery click function not triggered when unchecking checkbox -

this doing head in, have googled life out of it, below code, simple, not click event triggered when unchecking checkbox?? $('#filterstardiv #hotelfilterform #star0').click( function() { alert('checkbox 0 clicked');}); <div id="starsremoved" style="display:none">no stars removed</div> <div id="filterstardiv"> <h6>click on star ratings below add or remove hotels in category</h6> <form:form id="hotelfilterform" action="" acceptcharset="utf-8"> <input type="checkbox" id="star0" name="star0" value="0 star" checked="checked" /> 0 star<br /> <input type="checkbox" id="star1" name="star1" value="1 star" checked="checked" /> 1 star<br /> <input type="checkbox" id="star2" name="star2" value="2 star" ...

flex - how to see this class CairngormEvent source code? -

import com.adobe.cairngorm.control.cairngormevent; public class configurationevent extends cairngormevent { i can not see cairngormevent.swc don't know .swc file add in lib? thanks. it not obvious in particular asking i'll try answer possible questions (as far can see). first of guess you're using cairngorm 2 in project. ok. in case of absence of cairngorm library (i mean cairngorm.swc ) contains cairngormevent class can download here . need choose binary package , place libs folder of project. to have possibility view class' source code need download zip archive sources , attach them cairngorm.swc . unpack them somewhere first. got project's properties > flex build path > library path select cairngorm.swc , expand it, select source attachment item , point unpacked folder sources. can press f3 , navigate sources.

google play - Android Market return CANCELED code for all purchase request? -

i build "in-app purchase" application. don't know why android market return canceled code purchase request? purchase request sent ok, receive data ok, android market return canceled. last 2 days, work fine :( in project, have 2 android device use same "test account" , 1 android developer account. can me? thanks :) i found in-app billing doesn't support country(vietnam). in-app billing available countrys: http://www.google.com/support/androidmarket/developer/bin/answer.py?answer=150324 read "in-app billing availability , policies" before want build in-app billing application: http://www.google.com/support/androidmarket/developer/bin/answer.py?answer=1153481

Combining SQL `raiserror` with `select` in C# -

i want know if there way of using both sql raiserror , retrieving selected result in c#. executereader() in c# throw exception when raiserror occurs, still want use reader capture data returned. below simplified example. if not possible use raiserror general cases , select specific cases. if (some-error) begin select @message = 'error: script made booboo', @state = 'state info' raiserror (@messsage, 16, 1) goto exit_sp end exit_sp: select @message 'message', @state 'state' if lower severity 10 or below (from memory) not raise exception, available via infomessage event on connection . note, however, because of how tds works, should ensure read() etc end of all results; example, if have multiple select s , then raiserror , , read first select before dropping data-reader, there chance won't see message (the tds killed).

c++ - force key type of a std::map not to be const -

c++ references tells std::map typedef pair<const key, t> value_type; is possible force key type not const ? need in template method template<class t> // t represent map in general (std::map, boost::unordered_map or whatever..) void foo(const t& m) { typename t::value_type::first_type x; x=0; // wrong because x const ... } no, it's not. this because map performs internal ordering based on key. if modify key yourself, willy-nilly, hell break loose. you should use provided api functions; use of 1 results in changing key value (actually don't think do), appropriate internal re-ordering may take place. think of getters , setters, , use in providing alternative messy/dangerous direct member access. however, write this: template<class t> void foo(const t& m) { typename t::key_type x; x = 0; } std::map type aliases key_type key mapped_type t value_type pair<const key,t...

spring - Component Scan not finding @Component's in a JAR in Tomcat webapp -

i filed bug in spring bugsystem ( https://jira.springsource.org/browse/spr-8551 ), still unsure if missing something i tracked down problem <context:component-scan/> statement. given 2 following classes in same jar in web-inf/lib of web application (the jar file has directory structure): test/thebean.java: package test; @component public class thebean{ } test/beansearcher.java: package test; public class beansearcher{ public void init(){ annotationconfigapplicationcontext ctx = new annotationconfigapplicationcontext(); ctx.scan("test"); ctx.refresh(); thebean b= ctx.getbean(thebean.class); // value of b? } } if run new beansearcher().init() in junit test case or other type of standalone application, b getting assigned instance of thebean, if run it, say, in jsp, ctx.getbean() returning null. so, doing wrong or not taking account, bug...? edit 8/8/2011: seems work tried simplify problem, still, when try make work, i...

asp.net - Add a custom class to a pipeline using a .config and patch attribute -

i want line <processor type="estate.packages.modificationdate.setmodificationdate, estate.packages" /> beneath <processor type="sitecore.pipelines.httprequest.executerequest, sitecore.kernel" /> in web.config. tried adding .config file in app_config/include folder website. <configuration http://www.sitecore.net/xmlconfig/"> <sitecore> <pipelines> <httprequestbegin> <processor x:after="*[@type='sitecore.pipelines.httprequest.itemresolver, sitecore.kernel']" type="sitecore.packages.modificationdate.setmodificationdate, sitecore.packages" /> </httprequestbegin> </pipelines> </sitecore> </configuration> however, ain't working. if add line in web.config beneath executerequest pipeline working correctly. when use .config file nothing happens. (no error message either) got clue of i'm doing wrong? i sug...

windows phone 7 - customize listbox in wp7 -

this maybe easy have no clue start. parse xml value , bind them listbox; better interface, want item display in different background colors. item1 has background color green, item2 has background color white, item3 has bg green, item4 white , on. listbox item1: bg green item2: bg white item3: bg green item4: bg white what approach should take achieve this? code below: <listbox name="listbox1" height="502" width="448"> <listbox.itemtemplate> <datatemplate> <stackpanel orientation="horizontal" margin="15,10,25,10" opacitymask="#ff33a82d" background="#ffbeffbe" width="480"> <image x:name="imageav" source="images/album_art_default_small.png" height="100" width="100" ...

Is it possible to restrict operations on Amazon S3 objects based on their Last-Modified date? -

here's i'm trying achieve: want create iam policy s3 doesn't allow user delete in general, allows them rename objects , give them prefix trash/ . want allow them delete objects trash/ prefix, if last-modified date sufficiently far in past. the idea limit damage done if key compromised, while still allowing deletes. from reading of documentation, don't think possible thought i'd check wisdom of teh internets first. update: it should possible achieve close original aim using amazon's new object expiration policies: http://docs.amazonwebservices.com/amazons3/latest/dev/objectexpiration.html you're right, doesn't possible restrict actions last-modified date although don't know sure. why don't try this. prevent users deleting objects via iam policy implement whatever psuedo delete like. eg rename files, move bucket etc. (possibly preventing users seeing these files) have automated/scheduled task (eg once day) deletes thes...

php - Is there a way to identify when a facebook application runs through a fanpage page -

lets assume have created facebook app.so who(admin) have facebook fan pages can add app fan page , run app through fan page .i need identify when run app through fan page. assume index.php file //index.php <?php include_once "fbmain.php";//here facebook authentication parts ?> <html> <body> <form action="http://localhost/test/test.php" method="post"> <input type="submit" value="upload"/><br/> </form> </body> </html> when user click "upload" button,'test.php' file loaded.in 'test.php' file i want display id of fan page , //test.php <?php echo "hello".$id_of_the_fan_page; ?> //output eg: hello 228276387189141 can tell me there way this?(i using graph api , php develop app) when app running page tab, encoded signed_request parameter sent app, includes details page app installe...

java - Recursively create directory -

does know how use java create sub-directories based on alphabets (a-z) n levels deep? /a /a /a /b /c .. /b /a /b .. .. /a /b /c .. /b /a /a /b .. /b /a /b .. .. /a /b .. .. /a /a /b .. /b /a /b .. .. /a /b .. public static void main(string[] args) { file root = new file("c:\\so"); list<string> alphabet = new arraylist<string>(); (int = 0; < 26; i++) { alphabet.add(string.valueof((char)('a' + i))); } final int depth = 3; mkdirs(root, alphabet, depth); } public static void mkdirs(file root, list<string> dirs, int depth) { if (depth == 0) return; (string s : dirs) { file subdir = new file(root, s); subdir.mkdir(); mkdirs(subdir, dirs, de...

javascript - Jquery function to find out max height of <li> -

i want find out out of given <li> li has maximum height? how write such function? if there n <li> elements of different size, content , height. want figure out maximum height of biggest <li> element. try this: var max = -1; $("li").each(function() { var h = $(this).height(); max = h > max ? h : max; }); alert(max);

objective c - Unable to read values from Settings.bundle -

this first post hello , please bear me should make blunders in regard regarded etiquette here. i've been passively using site time , have read faq hope able keep these @ minimum. i've question settings.bundle files in objective-c. i've been using following guides implement 1 of those: how create iphone preferences file ios application programming guide - implementing application preferences i'm using both xcode 4.1 , latest xcode 3. used version 3 create settings.bundle , plist found xcode 4's plist editor buggy. these contents of root.plist: <?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <dict> <key>stringstable</key> <string>root</string> <key>preferencespecifiers</key> <array> <dict> <key>type...

Rails: how to write a better association condition? -

in rails 2.3.8 have 2 models news , user. in app i'd able show each registered user news has not still read . in homepage each piece of news should presented in box , user should able click on "x" , hide news forever (just profile). one way have user_news model and, each time piece of news created generate record in user_news model each user , update linking record each user "read" field set true. create association in user model like: class user < activerecord::base has_many :unread_news, :through => :user_news, :source => :news, :conditions => 'read not true' the problem approach if have thousands of users in app, each time publish piece of news need create thousands of records in user_news table. my question is: possible write association between user , news model tells rails like: "unread news each user every existing news except ones appear in user_news table"? anyway how approach goal? thanks, augusto ...

java - StringBuffer is obsolete? -

in book "effective java", josh bloch says stringbuffer largely obsolete , should replaced non-synchronized implementation 'stringbuilder' . but in experience, i've still seen widespread use of stringbuffer class. why stringbuffer class obsolete , why should stringbuilder preferred on stringbuffer except increased performance due non-synchronization? it's obsolete in new code on java 1.5 should use stringbuilder - it's very rare need build strings in thread-safe manner, why pay synchronization cost? i suspect code see using stringbuffer falls buckets of: written before java 1.5 written maintain compatibility older jdks written people don't know stringbuilder autogenerated tools don't know stringbuilder

tiles2 - Tiles 2 + Spring: Attribute not found -

i'm working on integrating tiles 2 spring, have problem. have simple tiles.jsp page. rendering tiles view produce error: org.apache.tiles.template.nosuchattributeexception: attribute 'title' not found. my configuration , files below. tiles config: <bean id="viewresolver" class="org.springframework.web.servlet.view.internalresourceviewresolver" p:order="1"> <property name="viewclass" value="org.springframework.web.servlet.view.jstlview" /> <property name="prefix" value="/web-inf/pages/" /> <property name="suffix" value=".jsp" /> </bean> <bean id="tilesviewresolver" class="org.springframework.web.servlet.view.urlbasedviewresolver" p:order="0"> <property name="viewclass" value="org.springframework.web.servlet.view.tiles2.tilesview"/> <property name="prefix...

c# - String Manipulation with regular expression -

i have seen in forum, many of people doing string manipulation using regular expression. there performance benefit on regex rather normal indexing manipulation? it helpful, if explain how or provide link explaining it. it's not performance thing; people use regular expressions because easy-to-use yet ultra-flexible tool sorts of string manipulations. once master syntax, regular expressions allow express quite complex string manipulations, , since regular expression string, can store regular expressions in variables, files, databases, , bunch of other things. consider simple regex: /\ba[a-z]*\b/ , finds whole words start capital 'a', followed lowercase letters (e.g., running on "and good" yield ["and", "all"]). write function same (in language of choice) using standard string manipulations. you'll see advantages of regular expressions.

c - Segfault after launching a new thread -

i writing stock market system uses several threads process incoming orders. the project going fine until added 1 more thread. when launch said thread program segfaults. segfault generated in above thread invalid memory read. this segfault generated only when program compiled optimization -o2 , above. after compiling programming debug info using -g3 , running valgrind using valgrind ./marketsim and following output segfault ==2524== thread 5: ==2524== invalid read of size 4 ==2524== @ 0x402914: limitworker (limit.c:4) ==2524== 0x4e33d5f: start_thread (in /lib/libpthread-2.14.so) ==2524== address 0x1c not stack'd, malloc'd or (recently) free'd ==2524== ==2524== ==2524== process terminating default action of signal 11 (sigsegv) ==2524== access not within mapped region @ address 0x1c ==2524== @ 0x402914: limitworker (limit.c:4) ==2524== 0x4e33d5f: start_thread (in /lib/libpthread-2.14.so) the thread launched this pthread_t limit_thread; pthr...

multithreading - How to pause/resume thread in Android? -

i have thread running activity. don't want thread continuos running when user click home button or, example, user receive call phone. want pause thread , resume when user re-opens application. i've tried this: protected void onpause() { synchronized (thread) { try { thread.wait(); } catch (interruptedexception e) { e.printstacktrace(); } } super.onpause(); } protected void onresume() { thread.notify(); super.onresume(); } it stops thread don't resume it, thread seems freezed. i've tried deprecated method thread.suspend() , thread.resume() , in case activity.onpause() thread doesn't stop. anyone know solution? use wait() , notifyall() using lock. sample code: class yourrunnable implements runnable { private object mpauselock; private boolean mpaused; private boolean mfinished; public yourrunnable() { mpauselock = new object(); mpaused = false; mfinished = false; ...

php - Mysql Select Code Doesn't work -

i have php/mysql select code doesn't return result have expected after execution of code. code: [select] $sql="select *from advert ad_type = '%{$service}%' , ad_street_no '%{$location}%' or ad_street_name '%{$location}%' or ad_suburb '%{$location}%' or ad_postcode '%{$location}%' or ad_state '%{$location}%'"; the user search on location , type of service available using parameters street name,suburb, postcode and/or state in 1 textfield , select type of service dropdown menu. example : "select records table 'advert' type of service = 'e.g. hauling,digging,' located @ e.g. cardiff nsw". " that. i have 2 records right on database : 1. service: hauling, location: cardiff nsw 2. service: digging , location: cardiff nsw now problem is: you search "hauling" service in "cardiff" , return 2 records (...

Moving files to Trash Can in Linux using C++ -

i'm trying move (delete) file trash can (in linux) using c++ (also using qt4 gui). unfortunately seems quite difficult , far can tell there isn't unified api it. i application run not on kde on gnome, xfce , other linux desktop environments. that's why i'm searching more universal approach. the best find far is: send2trash - that's using python/qt4 , not c++/qt4 trash-cli - has drawback of being stand alone command line program , not library i happy approach requires little desktop environment specific code possible. or in other words that's independent kde/gnome/xfce components possible. any in finding solution (if there one) appreciated. the answer in http://www.freedesktop.org/wiki/specifications/trash-spec for every user “home trash” directory must available. name , location $xdg_data_home/trash you need write c++ code move file such directory. you can move files using boost file system , can retrieve xdg_data_home va...

Tomcat 6.0.23 and Eclipse Indigo - server not working through eclipse while working from standalone -

when i'm trying load server eclipse not deploying it, start quite fast (without exception). while start same app through tomcat server , working fine. idea i'm doing wrong? thanks, gal from understand ,the apache tomcat plugin supports version 3.6 (helios) of eclipse , not 3.7 (indigo). maybe wrong.

How to embed mongodb in a java program instead of running a daemon -

is there way embed mongodb in java application instead of running daemon. i have downloaded mongodb jdbc drivers , added them classpath. you can not embed mongodb in java process. separate process. you can start , stop when program starts/stops spawning process. not suggested mongodb meant run background server; if best pick random port start on doesn't affect other mongodb instances. need make sure include correct binaries platform java app deployed on since requires more jvm.

iphone - how to change nsdate in nsdictionary -

i trying increment nsdate. have nsdictionary, trying increment nsdate content in it. nsdate 2011-07-11, want increment nsdate content in it. got { conditiondatenew = "2011-07-21 13:31:46 +0000"; yesterday = "2011-07-20 13:31:46 +0000"; city = #; condition = "isolated thunderstorms"; country = #; "day_of_week" = sun; high = 86; icon = "chance_of_storm.gif"; low = 68; state = #; } i want date 2011-07-22 in conditiondatenew in next dictionary loop. how can it? create new date object, , replace old value in dictionary. dates immutable. nsdate *newdate = [nsdate date]; [dictionary setobject:newdate forkey:@"conditiondatenew"]; [nsdate date] set "now." the easiest way add day add 24 hours. works long dst never issue, , "increment day" mean "increment 24 hours." if work exclusively in utc, that's fine. nsdate *newdate = [ol...

c - jpeg file format question -

i'm trying write jpeg/jfif encoder , decoder scratch using c. experimented writing sample jpeg file, seems cannot open using ms paint, firefox. can decode using jpegsnoop ( http://www.impulseadventure.com/photo/jpeg-snoop.html?ver=1.5.2 ) , http://nothings.org/stb_image.c . think sample jpeg file complies jpeg/jfif standard, don't know why applications ms paint , firefox cannot open it. here how sample jpeg looks like: soi app0 segment dqt segment (contains 2 quantization tables) com segment sof0 segment dht segment (contains 4 huffman tables) sos segment huffman encoded data eoi the sample jpeg file has 3 component y cb cr. no subsampling cb cr component. 2 quantization tables filled ones. 4 huffman tables in dht segment identical, looks this [0 0 0 0 0 0 0 255 0 0 0 0 0 0 0 0] [0,1,2, ... , 254] that means codes 8bits, huffman encoding not compress data. the huffman encoded data th...