Posts

Showing posts from April, 2013

bash - How do I prevent this infinite loop in PowerShell? -

say have several text files contain word 'not' , want find them , create file containing matches. in linux, might do grep -r not *.txt > found_nots.txt this works fine. in powershell, following echos want screen get-childitem *.txt -recurse | select-string not however, if pipe file: get-childitem *.txt -recurse | select-string not > found_nots.txt it runs ages. ctrl-c exit , take @ found_nots.txt file huge. looks though powershell includes output file 1 of files search. every time adds more content, finds more add. how can stop behavior , make behave more unix version? use -exclude option. get-childitem *.txt -exclude 'found_nots.txt' -recurse | select-string not > found_nots.txt

Are there any open source resources for SQL schema design patterns? -

i can barely count number of times i've created "users" table, similar "computers" , "customers". i've tried looking around, haven't ever seen resource modeling these schema see on , on again. seems of these objects should some-kind-of-solved now. there this? i have never seen either , i'm not sure it's necessary. yes, there lot of similarities every application different. @ 1 point had built internal library of of more "standard" tables (user example) use jumping point, have yet create 2 identical tables different systems. thus, have yet ever use library built because can write new table quicker , more error free can modify existing example work current project.

c# - Delving into the world of XML (Windows Phone) Error I dont understand (The ' ' character, hexadecimal value 0x20, cannot be included in a name.) -

so starting learn how use xml data within app , decided use free data cannot life of me working code far. (i have done few apps static data before hey apps designed use web right? :p) public partial class mainpage : phoneapplicationpage { list<xmlitem> xmlitems = new list<xmlitem>(); // constructor public mainpage() { initializecomponent(); loadxmlitems("http://hatrafficinfo.dft.gov.uk/feeds/datex/england/currentroadworks/content.xml"); test(); } public void test() { foreach (xmlitem item in xmlitems) { testing.text = item.title; } } public void loadxmlitems(string xmlurl) { webclient client = new webclient(); client.openreadcompleted += (sender, e) => { if (e.error != null) return; stream str = e.result; xdocument xdoc = xdocument.load(str); ***xmlitems = (from ite

c# - About Jamaa SMPP Asynchronous operation -

i have implemented application using jamaa lib , jamaa net. developers. but facing problem when use asynchronous sending operation. unhandled exception being raised continuously. highly appreciated if can me figure out problem. please noted. receiving , sending sms using same application. need send on average 100,000 sms per day. simultaneously receiving sms smsc also. in advance. my code snippet namespace transciever { class program { static void main(string[] args) { smppclient client = new smppclient(); mysqlconnect con = new mysqlconnect(); textmessage msg = new textmessage(); settings settings = new settings(); smppconnectionproperties properties = client.properties; string sysid = configurationmanager.appsettings["systemid"]; string pswd = configurationmanager.appsettings["password"]; string hst = configurationmanager.appsettings["host"]; int port = int32.pa

compilation - What program/s or application can compile my Java Server Code, Android Client Code and Asynctask code? -

assuming have java server code, android client code , asynctask code, program or application can compile / write codes? what program can run code in java server, android client, , asynctask? found codes on google don't know paste it. i'm missing program/application. / suitable application(s) can job? i'm not sure mean asynctask code part of android code. anyway, android code can run eclipse need android sdk , adt plugin eclipse. details of can found here . there other ides used , if beginner @ android google has documentation eclipse make things easier. as java server, can run in eclipse, there lots of other browsers can used, netbeans example.

javascript - Enable/Disable debug code dynamically -

i'm writing decent sized javascript animation library, include debugging code in. check : if(mylib.debugger){ console.warn('warning message'); } however if runs couple thousand times second, cause performance issues. add in few more checks throughout code , effect more noticeable. what i'm wondering if possible check onload if debugger should enabled, , if so... turn this: //debugger if(!this.name) console.warn('no name provided'); into: if(!this.name) console.warn('no name provided'); leaving code commented if not enabled, , uncommenting if is, removing possible performance issues. done somehow regular expression on entire script if loaded in through ajax? i'm trying avoid need 2 versions of same code, lib.dbug.js , lib.js. cross browser compatibility not of great importance (i'm worried new browsers), see nice have item. if possible however, great thing have. any insight appreciated. the simplest way check if d

Android compare two fragments -

when change fragment compare new 1 current one. if same, not necessary replace them. i tried public void displayfragment(fragment fragment){ fragmentmanager fm = getsupportfragmentmanager(); fragment currentfragment = fm.findfragmentbyid(r.id.content_frame); if(!currentfragment.equals(fragment)) getsupportfragmentmanager().begintransaction().addtobackstack(null).replace(r.id.content_frame, fragment).commit(); } but not work , fragment changed if new 1 same a solution ? thanks edit the solution : public void displayfragment(fragment fragment){ fragmentmanager fm = getsupportfragmentmanager(); fragment currentfragment = fm.findfragmentbyid(r.id.content_frame); if(!fragment.getclass().tostring().equals(currentfragment.gettag())){ getsupportfragmentmanager() .begintransaction() .addtobackstack(null) .replace(r.id.content_frame, fragment, fragment.getclass().tostring()) // add , tag new fragment .comm

dataframe - Divide a Column based on two Data Frames in R -

suppose have 2 data frames, df , df2, like: df user lab score 1021 12 1022 10 1024 15 b 1021 9 b 1022 9 b 1023 14 c 1024 10 df2 lab score 1021 15 1022 10 1023 15 1024 15 i want divide score column in df score column in df2, depending on lab. therefore want end data frame looks like: user lab score 1021 0.8 1022 1.0 1024 1.0 b 1021 0.6 b 1022 0.9 b 1023 0.93 c 1024 0.67 where 12/15 = 0.8, 10/10 = 1.0, 15/15 = 1.0,9/15 = 0.6, 9/10 = 0.9, 14/15 = 0.9333, 10/15 = 0.6667 just match labs this: df$score <- df$score / df2$score[ match( df$lab , df2$lab ) ] # user lab score #1 1021 0.8000000 #2 1022 1.0000000 #3 1024 1.0000000 #4 b 1

svn:mergeinfo is not being cherry-picked properly between branches -

i created ^sandbox/feature-branch ^trunk staging area proof of concept. but don't want reintegrate merge feature branch ^trunk because of sandbox in name. i'd create ^branches/feature-branch , cherry-pick changes 1 one ^sandbox/feature-branch . and reintegrate merge nicer named ^branches/feature-branch down ^trunk . in testing can acquire change set svn:mergeinfo not expect. not include svn:mergeinfo entries added ^sandbox/feature-branch commits. creation scenario working copy: ^sandbox/feature-branch cherry pick code ^branches/another-feature-branch this gives commit changes , adds svn:mergeinfo entry this: /branches/another-feature-branch:1234 cherry pick scenario working copy: ^branches/feature-branch cherry pick code ^sandbox/feature-branch this takes change svn:mergeinfo change not expect: /sandbox/feature-branch:2345 but there no mention change came ^branches/another-feature-branch:1234 is there way original merge path included w

javascript - unexpected behaviour in if statement in php code -

the console in html file calling php code shows following results when php code executed: php processing: debug 3: test if: in if php processing: debug 4: false however, i'd expect the first console result php processing: debug 3: test if: in else . e.g., seems according console wrong (if) part of if-else statement executed , don't understand why (for simple code)??? any suggestions? php code: //test code if($productselected_form[0] == true) { $response_array['debug3'] = 'test if: in if'; } else { $response_array['debug3'] = 'test if: in else'; } $response_array['debug4'] = $productselected_form[0]; //send response echo json_encode($response_array); //end test code javascript code (console.log in ajax call php code): console.log("php processing: debug 3: "+msg.debug3); console.log("php processing: debug 4: "+msg.debug4); the problem you're comparing string value boolean

Header files inclusion and performance considerations c++ -

assuming headers have include guards set appropriately, there means of improving run time performance of application altering these headers? is there difference, performance wise, between application has needed headers in 1 file , application doesn't? run-time efficiency the sets of headers included or not included have no effect on efficiency of resulting application @ run time. should include headers declare functions use. if headers provide inline function definitions, example, may performance boost comparison (hypothetical alternative) headers don't provide inline function declarations, still need include header controlled people providing headers. compile-time efficiency i first assumed you're after, in part because of mention of header include guards purely compilation-related issue. if headers set include guards, can still improve efficiency of compilation (with no effect on product) following rules below: don't include same header twi

android - Skipping disabled EditText's when pressing Next IME button on soft keyboard -

i have linearlayout several edittext 's, of them created programmatically (not xml layout), , in particular without ids. when i'm typing in 1 of edittext 's, , next 1 (respective focus) disabled, , press next ime button on keyboard, focus advances disabled edittext , can't type in it. what expecting focus advance next enabled edittext . tried, in addition making edittext disabled via edittext.setenabled(false) , disable focusability via edittext.setfocusable(false) , edittext.setfocusableintouchmode(false) , , set type_null input type, no avail. any hints? thanks ;) solved examining how next focusable found keyboard this blog post , subclassing edittext : import android.content.context; import android.util.attributeset; import android.view.view; import android.widget.edittext; public class myedittext extends edittext { public myedittext(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); }

javascript - "undefined" in the URL when transitioning to a route -

from controller i'm transitioning route this: this.transitiontoroute("posts.dynamicfinder", app.response.find(obj)); the route looks this: this.route("dynamicfinder", { path: ':some_id' }); everything works fine except url shows "undefined". my guess because of :some_id . don't have pass model ( api.response.find(obj) ). if remove :some_id can't seem pass model along ... how can rid of "undefined"? have pass model in transitiontoroute . here jsbin example: http://jsbin.com/ocayoyo/41/ recreate issue, type "5" in text box , click submit just create route custom model id implementation. app.postsdynamicfinderroute = ember.route.extend({ serialize: function(model) { return { 'some_id': 'dynamic' }; } });

css - How can one import only variables and mixins from Scss stylehsheets? -

i'm using zurb foundation 4 (s)css framework, , i'm running issue of massively duplicated styles. because in every file @import 'foundation' in, styles foundation imported (rules body , .row , .button , friends). leads long scss compile times, , hard navigate web developer console in chrome, of zurb's styles declared 4 or 5 times. to mitigate this, i've created globals scss file, contains overrideable variables foundation uses (it's copy-pasted foundation_and_overrides.scss , foundation_and_overrides import globals). importing globals.scss file gets rid of duplication in files don't make use of foundation mixins. it's in files make use of foundation mixins: can import mixins scss file, without importing concrete foundation styles? imports or nothing thing. that's in file get. if through source of foundation, though, there variables can modify suppress emitting styles (eg. in buttons , setting $include-html-button-classes

php - Preg_Replace Options -

i'm trying add in middle of text, that. privateimg-0123456789_[i wanna add here something].jpg and don't know function or way should use. i wondering function preg_replace , don't know if can make function replace specific text in position. just use str_replace() ? $string = "privateimg-0123456789.jpg"; echo str_replace(".jpg", "[whateveryouwant].jpg", $string); if must use regex: $string = "privateimg-0123456789.jpg"; echo preg_replace("/\.(jpe?g|png|gif)$/si", "[whateveryouwant].$1", $string); this jpg, jpeg, png , gif, long last part. /foo/bar.gif/thisisweird wont match

ruby - Test local version of gem in Rails project -

my rails site uses gem not good. every time need new end having spend time adding features gem adding code actual rails project. don't mind, , have gemfile set point github fork of gem (i tried submitting prs, maintainer seems have stepped down). the problem haven't found sane way of testing new things add gem. it'd nice test within rails c , ways can think of doing a) changing ~/.rvm/gems/.../foo.rb , doesn't seem right or b) bumping version, pushing github, , running bundle up , in addition being time-consuming disaster since don't know sure whether commits make right or not. i'd happy standard irb . various permutations of require lib/foo within gem's directory don't work. so what's best practice here? if using gem , working on @ same time, best way use bundler , provide local path: gem 'my_bad_gem', path: '../my_bad_gem/' this gem under given (relative in case) path. option use local git repositories (see h

Leak when run subprocess in python -

when run leak. not sure happening. guess pipe not close or might else happening. in advance guys! def deactivatemetadatadevice(input_dmd_lun_wwn): #print('pvremove /dev/mapper/' + input_dmd_lun_wwn) status_cmd = false ps = subprocess.popen('/sbin/pvremove /dev/mapper/' + input_dmd_lun_wwn, shell=true, stdout=subprocess.pipe, stderr=subprocess.stdout) line in iter(ps.stdout.readline, ''): print line if re.search('wiped', line): status_cmd = true else: # cleaning metadata , removing lvm if ok return true status_cmd = false raise warning('\t\t pv /dev/mapper/'+ input_dmd_lun_wwn +' belongs volume group') return status_cmd getting issue when run code above. file descriptor 4 (pipe:[323948]) leaked on pvremove invocation. parent pid 15380: python the problem return before reading of data in pipe , don't issue wait return code , remo

jquery - removeClass - doesn't work -

this question exact duplicate of: removeattr scroll-sel , add atriv 1 answer i remove sel-scroll <ul class="selection-list sel-scroll sel-items js-items-unchecked" id="yui_3_11_1_1377278254438_3699"> but dont work $('.sel-scroll').removeclass('sel-scroll'); any ideas? way beginner in jquery, try explain clearly. this data contained in checkbox, type facebook. how not work? here jsfiddle works fine. $('.sel-scroll').removeclass('sel-scroll');

Export R object table to excel -

i searching way export table-like r objects excel/csv. example gains table, in r saved object. usual write.table function doesn't allow me convert object csv. although object table...: gains(actual, predicted, groups=10,optimal=false,percents=false)->gains_test2 > dput(head(gains_test2)) structure(list(depth = c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100), obs = c(146l, 147l, 147l, 147l, 147l, 146l, 147l, 147l, 147l, 147l), cume.obs = c(146l, 293l, 440l, 587l, 734l, 880l, 1027l, 1174l, 1321l, 1468l), mean.resp = c(0.0116469582940705, 0.0125322442801302, 0.0142252481339337, 0.0106531565074638, 0.0130847548479835, 0.0106034244135535, 0.00455378455081303, 0.0061834241946857, 0.00989105136990672, 0.00841145735618072), cume.mean.resp = c(0.0116469582940705, 0.012091112014039, 0.0128041074904584, 0.0122654536667783, 0.012429537145848, 0.0121265684425355, 0.0110426354025324, 0.0104341992461836, 0.010373758112336, 0.0101772606932932), cume.pct.of.total = c(0.113817

(Java) Copy files trough sockets -

this question has answer here: java sending , receiving file (byte[]) on sockets 5 answers today i'm having troubles files in java. the issue is: i'm trying copy file (not text, kind) 1 side of socket another. read file bufferedreader (byte byte) , write them on file fileoutputstream. it works fine, when open file is not same te original , writting bytes on text file or that. a piece of code: in = new bufferedinputstream(s.getinputstream()); byte b[] = new byte[max_length]; file f = new file(name); fileoutputstream fos = new fileoutputstream(name); for(int = 0; < segments; i++){ in.read(b,i*max_length,max_length); fos.write(b); } where s oppened socket (working fine), name name of file , segments number of segments sent trough socket (segments of max_length). thanks help.

Wordpress CURL login not working -

i had curl script wordpress blog started failing. error message cookies must enabled login. below code logging in. $post_str = 'log=username&pwd=password&redirect_to=https://sub.wordspress.com/wp-admin/&testcookie=1&wp-submit=log%20in'; $cookie = tempnam ("/tmp", "curlcookie"); $url = "https://domain.com/wp-login.php"; $ch = curl_init(); curl_setopt ($ch, curlopt_url, $url); curl_setopt ($ch, curlopt_ssl_verifypeer, false); curl_setopt ($ch, curlopt_useragent, "mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.8.1.6) gecko/20070725 firefox/2.0.0.6"); curl_setopt ($ch, curlopt_timeout, 60); curl_setopt ($ch, curlopt_cookiejar, $cookie); curl_setopt ($ch, curlopt_referer, 'https://sub.wordpress.com/wp-admin/'); curl_setopt ($ch, curlopt_post, 1); curl_setopt ($ch, curlopt_postfields, $post_str); curl_setopt($ch, curlopt_cookiesession, true); curl_exec ($ch); curl_close($ch); cookie file: # netscape http

debugging - output a value in Haskell, with a default in case its type is not an instance of Show -

this question has answer here: implementation of “show” function 1 answer i tried debug arrows , hard. end sticking trace here , there, wants show instance argument, limits uses. there way show if instance of show, , use kind of default output value if it's not? promise use debugging ;-) how people debug arrows anyway... your best bet compose trace arrow: strace x = trace (show x) x :: (num c, show c, arrow cat) => cat c c = arr (+1) <<< arr strace -- > 1 -- 1 -- 2

asp.net mvc - Assigning an icon instead of text for ActionLink -

i trying replace link text in here class contains icon: @html.actionlink("edit", "editsatellitemeeting", "bylaws", new { id = meeting.blclubsatellitemeetingid, bylawsid = model.bylawsid }, new { @class = "js-opendialog", data_dialog_id = "addsatellitemeetingdialog", data_dialog_title = "edit satellite meeting" }) i understand common solution use @url.action . but when try parser error. this breaks <a href="@url.action("editsatellitemeeting", "bylaws", new { id = meeting.blclubsatellitemeetingid, bylawsid = model.bylawsid }, new { @class = "js-opendialog icon edit", data_dialog_id = "addsatellitemeetingdialog",

primefaces - JSF Sorting a datatable column throwing error -

i building primefaces data tables dynamically , datatable code inside composite interface. inside of loop call composite using primefaces columns tag. when add sortby="#{tblvar[column.name]}" columns tag , sort following error sortby="#{tblvar[column.name]}": property 'documentstatuscode' not found on type org.kheaa.verify.data.verificationreviewerpf the part of error states property documentstatuscode not found on type same on errors, type org.kheaa.verify.data.verificationreviewerpf changes depending on data table trying sort column on. the documentstatuscode property of list item last data table created. verificationreviewerpf list item of data table trying sort on. even though error occurs evertime sort column columns still seem sort correctly. how prevent error occuring <p:datatable id="datatable" value="#{cc.attrs.datatablelist}" var="tblvar" paginator="true" rows="10" pagina

linux - How to eliminate xterm flickering on a slow machine? -

when scrolling back, xterm window flickers while updating contents. same occurs if program produces output continuously written terminal. i searched man pages , google, found nothing dobule-buffering in xterm. there way enable such feature? how prevent text flickering? (i sure of don't have problem, work on old integrated video card , every lightweight program works rather fine, except xterm, annoys me bit...) it possible compile xterm source, --enable-double-buffer option passed ./configure script. simple make && make install (but, @hek2mgl noticed, feature enabled default in systems)

sql server - Moving Stored Procedures from SSMS into TFS 2012 -

i needing move of stored procedures tfs 2012. wondering best/fastest way accomplish is. using sql server 2012. our suggestion use sql server data tools (ssdt) , create database schema change management project in visual studio can check-in team foundation server. has quite few benefits being able "compile" schema , has tools can used in generating automatic change scripts target servers (whether empty, test, or production servers). http://msdn.microsoft.com/en-us/data/tools.aspx

Visual C++ read entire file -

for days have been trying read entire png string, can upload server via winsock2, appears stop reading file after few characters or sort of line break, there particular reason , way of solving it. i have tried many many solutions , starting drive me insane. current code using follows std::ifstream in ("some.png", ios::in|ios::binary|ios::ate ); std::string contents; if (in) { in.seekg(0, in.end); contents.resize(in.tellg()); in.seekg(0, in.beg); in.read(&contents[0], contents.size()); in.close(); length = contents.size(); } i have no idea problem be, relatively new c++, have trolled through google days no working solution. please help update code posting server wsadata wsa; if (wsastartup(makeword(2, 2), &wsa) != 0) return; socket fd = socket(af_inet, sock_stream, ipproto_tcp); if (fd < 0) throw; sockaddr_in service; service.sin_fami

c# - Windows Forms don't work -

i want set code, if there no file opened (i use tabs also), it'll display message. here's if code: if (getrichtextbox().text = null) { messagebox.show("you must open document first!", "failure", messageboxbuttons.okcancel); } and getrichtextbox() function: private richtextbox getrichtextbox() { richtextbox rtb = null; tabpage tp = tabcontrol1.selectedtab; if (tp != null) { rtb = tp.controls[0] richtextbox; } return rtb; } see here how assign null in if statement: if (getrichtextbox().text = null) { you need check equality: if (getrichtextbox().text == null) { the other problem if function returns null, trying check text property fail. better way it: richtextbox rtbtext = getrichtextbox(); if (rtbtext == null) {

plot - R - heatmap.2 log scale -

is there way use log scale heatmap.2 or have log data beforehand before plot? currently, have 50 x 50 matrix big numbers , heatmap showing little depth. what's problem taking logs beforehand? it's simple as... m<- matrix( sample( c(10,100,1000) , 16 , repl = true ) , 4 , 4 ) # [,1] [,2] [,3] [,4] #[1,] 10 10 100 100 #[2,] 100 10 100 1000 #[3,] 100 1000 100 100 #[4,] 100 10 10 1000 log10(m) # [,1] [,2] [,3] [,4] #[1,] 1 1 2 2 #[2,] 2 1 2 3 #[3,] 2 3 2 2 #[4,] 2 1 1 3 or indeed require( gplots ); heatmap.2( log10(m) ) .

android - Cannot change name to the App -

i've made application , androidmanifest.xml has these attributes: <application android:allowbackup="true" android:icon="@drawable/flower" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="com.manish.tabdemo.tabhostactivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name="com.manish.tabdemo.homeactivity"/> <activity android:name="com.manish.tabdemo.aboutactivity"/> <activity android:name="com.manish.tabdemo.contactactivity"/> </ap

java - Using a DrawerLayout along with a ListView -

Image
i'm trying write android app listview of few different items , drawerlayout can drag left side of screen. here's mean.... this main screen looks like: and here's drawer menu thing looks like: the problem i'm having when open side drawer menu thing , tap option doesn't work , menu closes. i'm able interact main listview page. here's code looks like: string[] homearray = { "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test" }; private listview homelistview; private arrayadapter arrayadapter; private drawerlayout mdrawerlayout; private listview mdrawerlist; private actionbardrawertoggle mdrawertoggle; private charsequence mdrawertitle; private charsequence mtitle; private string[] mdrawertitles; @override protected void oncreate(b

Is it possible to upload videos on specific channel through youtube API? -

is possible upload videos on specific channel through youtube api? i able upload videos on main account. have created channels using business names. but, not find way upload videos on channels far using api. on main account, profile using human name. need use business name , channels have been created using business names under main youtube account. uploaded video manually too. but, need upload videos using api on business channels. can here? if authorized account, can upload account too. if using google+ manage accounts, you can read here. (this suggested way manage multiple channels 1 login name.) if content owner managing these channels, can use content id api.

javascript - Firefox 23 and IE10 no longer playing nice with my XMLHttpRequest, I have CORS in php -

i have bit of java script grabbing id off website , passing php script on seperate domain: javascript on: https://myspot.com and going to http://theotherwebsite.edu this more or less working, had work previous cross site solution seems not honored on firefox 23 , ie10. the previous solution using this: var isie10 = false; //this beacuse stupid ie10 not work window.xdomainrequest /*@cc_on if (/^10/.test(@_jscript_version)) { isie10 = true; } @*/ console.log(isie10); var isie8 = window.xdomainrequest ? true : false; var invocation=createcrossdomainrequest(); function createcrossdomainrequest(url, handler) { var request; if ((isie8) && (!isie10)) //tried hack own isie10 fix didnt work { request = new window.xdomainrequest(); } else { request = new xmlhttprequest(); } return request; } function callotherdomain() { if (invocation)

scala - Uploading play application to maven repository -

i trying upload play 2.1.3 application our internal maven repository. zip file generated play dist uploaded repo. i tried following steps mentioned in this google group thread but method dependson not seem exist on taskkey anymore!. no luck; publish continues publish jar file. how can make sure the artifact published publish task zip file generated dist ? i ended using sbt-aether-deploy sbt plugin deploy play application nexus repository.

nsdate - Alarm Clock for iOS -

i tried re-write following tutorial under xcode 4.6.3 - http://vimeo.com/29824336 but have problem @ around 24:00 code not bringing alarm: -(void) schedulelocalnotificationwithdate:(nsdate *)firedate { uilocalnotification *notification = [[uilocalnotification alloc] init]; notification.firedate = firedate; notification.alertbody = @"time wake up!"; notification.soundname = @"snsd-oh.caf"; nslog(@"ring ring ring!"); [[uiapplication sharedapplication] schedulelocalnotification: notification]; } - (ibaction) alarmsetbuttontapped:(id)sender { nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; dateformatter.timezone = [nstimezone defaulttimezone]; dateformatter.timestyle = nsdateformattershortstyle; dateformatter.datestyle = nsdateformattershortstyle; nsstring *datetimestring = [dateformatter stringfromdate: datetimepicker.date]; nslog(@"alarm set button tapped: %@", datetim

ios - Cocos2d - move a sprite from point A to point B in a sine wave motion -

what best way this? see cceasesineinout action doesn't used this. i need move 1 side of screen other. sprite should move in sine-wave pattern across screen. i have complete control on ccnode motion. use ccaction s basic things. while case sounds simple enough possibly ccaction s, show how move ccnode according function on time. can change scale, color, opacity, rotation, , anchor point same technique. @interface somelayer : cclayer { ccnode *nodetomove; float t; // time elapsed } @end @implementation somelayer // assumes nodetomove has been created somewhere else -(void)startaction { t = 0; // updatenodeproperties: gets called @ framerate // exact time between calls passed selector [self schedule:@selector(updatenodeproperties:)]; } -(void)updatenodeproperties:(cctime)dt { t += dt; // option 1: update properties "differentially" cgpoint velocity = ccp( vx(t), vy(t) ); // have provide vx(t), , vy(t) nodetom

javascript - $.load() links do not work -

i'm loading page page. has variables in page url. reason, when load onto page, loads fine, links don't work. when load itself, links work. links jquery .click() function .load() function called in it. here's first load function. 1 works fine: $(".menuday").click(function () { $("body").append('<div id="scheduleinfo"></div>'); $("#scheduleinfo").load('utilities/appointmentscheduling.php?year=' + year + '&month=' + month + '&day=' + day); }); here's second load function. 1 works when page opened directly, not when opened through implementation of jquery's .load() listed above: $("table.hourlyschedule tr").click(function () { $("body").append('<div class="addappointment"></div>'); $("div.addappointment").load('addappointment.php?year=' + year +'&month=' kk+ month + '&am

What happens on the memory when Windows Phone application sent to background? -

how memory managed if lot's of application opened. for example if user keeps opening apps , hits windows button turn home screen, how windows phone manages memory? is there limitation on this? usually when app gets dismissed remain in memory no longer cpu time , therefore saves power. can removed memory e.g. tombstoned. here article on states within windows phone. process of how work state , getting described in msdn article . hth

iphone - UIFont Woes (some custom fonts loading, but other's are not) -

i'm having issue getting custom fonts load. followed advice in traditional, 400+ upvoted answer question, , worked 1 project perfectly. however, in different project working on have run issues loading uifont. these issues similar issues found in post adding multiple fonts uiappfonts overrides each other . solution there there issues p-list parsing out names xml leading overwriting. have attempted test hypothesis of issue: i listed fonts in p-list under uiappfonts (which turns "fonts provided application") item 0 - merriweather-regular.ttf item 1 - opensans-regular.ttf item 2 - opensans-bold.ttf the last of (opensans-bold) 1 loaded. have since tried moving items around no effect. have deleted opensans-bold.ttf p-list , project , tried running it. not "overwriting each other." of files copied bundle copy (another common error) , still, file registered opensans-bold in of views. i've deleted , added in... done traditional "weird xcode

c# - How to unit test ASP.Net MVC controller that has private methods in the action? -

i having hard time wrapping head around unit testing pattern when trying test asp.net mvc controller/action. with following code, trying write test showperson() method: public class personcontroller : controller { private idataaccessblock _dab; public personcontroller() : this(new dataaccessblock()) { } public personcontroller(idataaccessblock dab) { _dab = dab; } public actionresult showperson(personrequestviewmodel personrequest) { var person = getpersonviewmodel(personrequest); return view("person", person); } private personviewmodel getpersonviewmodel(personrequestviewmodel personrequest) { var personservice = new commondomainservice.personservice(_dab); var dt = personservice.getpersoninfo(personrequest.id); var person = new personviewmodel(); if (dt.rows.count == 1) { person.firstname = dt.rows[0]r["firstname"]);

ios - If an app works on the iPad 2 is it necessary to test it on the iPad mini? -

it may seem want test app on devices apple offers: ipad 2, ipad mini, , ipad 4. expensive or difficult obtain 3 devices , keep them around testing. the ipad 2 , mini both have 512mb ddr2, use 1ghz dual core a9, dual-core powervr sgx543mp2 , have same screen resolution. seems same hardware together. is there difference between these 2 devices cause problem app, other obvious physically smaller screen size? honestly depends on app is. said, screen size different, may have small effect on usability of app. other that, don't know. sorry.

c++ - How to use RTTI to determine the behavior of code -

i have piece of code use rtti case selector #include <iostream> #include <vector> #include <typeinfo> #include <complex> #include <algorithm> using namespace std; typedef complex<int> data; typedef std::vector< data > list; template <typename t> void zeros(t &v) { if (typeid(typename t::value_type)==typeid(complex<int>)) std::fill(v.begin(), v.end(), complex<int>(0, 0)); else std::fill(v.begin(), v.end(), static_cast<typename t::value_type>(0)); } int main(int argc, char *argv[]) { list a; zeros(a); return 0; } in above code, use typename t::value_type determine data type of list, if there complex fill list complex zero. otherwise, make 0 of corresponding type. in above code, if set data int, compile , run without problem. if set other type, fail compile. wonder if there way make above code work different type of data (for float, double, long, int, complex, complex , complex). p.s. reason

converting from float to Int in php -

this question has answer here: explain php output 1 answer i trying understand converting float int in php ,and came across following code: echo (int) ( (0.1+0.7) * 10 ); // echoes 7! my question why echo 7 instead of 8? logic behind it? here: $var = (int) $othervar; i guess: $var = int($othervar); would work too. not! gettype() tell type, get_class() tell class of object, both return strings, get_class() returns current class if no argument or null provided, if provide non-object get_class() it's sort of error. these functions example of how bad php, gettype() , get_class() , fun fact, because have play "guess has underscore" have is_a() (function, expects $var , "typename") , instanceof (operator). instead is: $var = intval($othervar); and there's floatval , whole lot have val after them! more php s

http - Golang: how to follow location with cookie -

in case response http request redirection (http code 302) cookie, how can instruct go client follow new location cookie has been received? in curl, can achieved setting client with: cookiefile = "" autoreferer = 1 followlocation = 1 how can in go? with go 1.1 can use net/http/cookiejar that. here working example: package main import ( "golang.org/x/net/publicsuffix" "io/ioutil" "log" "net/http" "net/http/cookiejar" ) func main() { options := cookiejar.options{ publicsuffixlist: publicsuffix.list, } jar, err := cookiejar.new(&options) if err != nil { log.fatal(err) } client := http.client{jar: jar} resp, err := client.get("http://dubbelboer.com/302cookie.php") if err != nil { log.fatal(err) } data, err := ioutil.readall(resp.body) resp.body.close() if err != nil { log.fatal(err) }

Unable to find files in hadoop streaming -

i have similar issue hadoop streaming - unable find file error . none of solutions presented there working. my command line is: hadoop jar /mnt/shared/hadoop-streaming-1.0.3.jar -input /user/cloudera/mz_paf/batch_sk=1234 \ -output /user/cloudera/mz_paf/out \ -file /mnt/shared/java/paf-rules.properties -file /mnt/shared/java/pafvalid.py \ -mapper "pafvalid.py paf-rules.properties 10" this results in java.io.ioexception: cannot run program "pafvalid.py": java.io.ioexception: error=2, no such file or directory @ java.lang.processbuilder.start(processbuilder.java:460) @ org.apache.hadoop.streaming.pipemapred.configure(pipemapred.java:214) @ org.apache.hadoop.streaming.pipemapper.configure(pipemapper.java:66) i have tried several other approaches mentioned in other sof issue including using hdfs locations input files: still same error of file not found. have tried having files in local directory avoid path issues. still no dice. i

SQL - Delete Cascade is used with? -

i'm learning sql , i'm stuck on 1 of review questions , can't find answer in text book. when 'delete cascade' what 'used' with? a. used primary key constraint b. used unique constraint c. used referential constraint d. used type constraint i want primary key because going identify correct tuple when cascades? right/wrong, don't know 1 right. thanks. it used referential constraint. more referential constraint

asp.net - How can I implement a local testing database for my Azure Website? -

i have website i'm developing uses sql azure database. want able test website using database locally hosted on debugging machine designer can work on style , content without having deal overhead of firing azure emulator , communicating external service in areas no-connectivity. i imagine possible extract .sql scripts create database , execute them every test run, seems tedious. i'm not sure best way configure these deployment details in order switch between development, , published configurations. i'm new web-developer cutting teeth on rather large project. using asp.net mvc4 , have mssql 2012 installed it's worth. you can export sql azure database .bacpac format , import sql server database. create tables , fill data. don't need on every test run, once , have proper database debug needs. switching between debug , release (or can rename if want, e.g. local , production) configurations , using different web.config (or config transformations) wa

ruby on rails - Error in running RSpec. 2.13.1 -

i have written spec file update function of 1 controller. using ruby-1.9.3 p194 , rails 3.2.13 , rspec 2.13.1 , data mapper version ~> 1.2.0' . calling update function in spec follows: put :update, :id=>@xyz.id, :xyz=> {key1:val1, key2:val2} in update function of xyz controller have accessed id follows: def update params[:xyz][:id] = params[:id] #this line working fine , params[:id] not nil params = params[:xyz] id = params[:id] end problem while running same file without change twice @ time, giving 2 different errors. once giving following error: /home/joy/.rvm/gems/ruby-1.9.3-p194@packagename/gems/dm-core-1.2.0/lib/dm- core/collection.rb:1302: in resource undefined method 'saved?' nil:nilclass (nomethoderror) .... next time, while running, giving following error: nomethoderror: undefined_method 'id' "57":string" # ./app/controllers/xyz_controller.rb : in line number 3 of update set

Regex: Find four tabs, but then select the first { prior to the tabs -

i'm pretty close need rubular: http://rubular.com/r/tazrj1h1z7 but, rather selecting whole block of lines indented 4 tabs, want match { appears before block. basically, allow me search codebase find how many occurences of 4-tab blocks have, rather how many lines of 4-tab code. /\t{4}.+/ .progressbar{ .progressbarrow { .progressbarcontainer { .progress { filter: none; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; border: #b9b9b9 1px solid; height:40px; } } } } you can reverse question: find first { followed line 4 (or more) leading tabs. this regex trick: \{\s*\n\t{4,} if whatever reason want match { itself, can either put in group: (\{)\s*\n\t{4,} or use look-ahead make whole match { : \{(?=\s*\n\t{4,})

asp.net - User Of local Databases to temporary store data For main Database in Case of Internet non Availability -

i have project of nation wide transport company, need build ticketing system. web based asp application using sql server 2008 r2 database. main database b managed @ server. in case internet not available, application work local system database. when internet available local db update changes main server db , update server database. how can this? usually approach record transaction statements update local db, , replay them main db.

C# window application checkboxlist selection mode one not working -

i have window application. now, @ run time adding 1 page & checkboxlist inside of page. for code is: form inputbox = new form(); inputbox.formborderstyle = system.windows.forms.formborderstyle.fixeddialog; inputbox.clientsize = size; inputbox.text = "doc selection"; inputbox.startposition = formstartposition.centerscreen; inputbox.controlbox = false; system.windows.forms.checkedlistbox doctypechklist = new checkedlistbox(); doctypechklist.location = new system.drawing.point(15, 10); doctypechklist.font = new system.drawing.font("microsoft sans serif", 12f, system.drawing.fontstyle.regular, system.drawing.graphicsunit.point, ((byte)(0))); doctypechklist.items.add("b"); doctypechklist.items.add("p"); doctypechklist.items.add("other"); d

iphone - Progressively scrolling child scrollView -

Image
i have 2 scrollviews, smaller scrollview needs scroll little bit slower (and stop on next "page) larger scrollview. basically, scrolling larger scrollview scrolls smaller scrollview, @ slower pace larger scrollview. (confusing know). so scrollview1 (the larger) , scrollview2, smaller: swipe scrollview1, scrollview2 scrolling slower. both having paging enabled , contentsizes have been set based on scrollview2's content. i having trouble calculating offset between 2 scroll perfectly. - (void)scrollviewdidscroll:(uiscrollview *)scrollview { if ( scrollview == scrollview1 ) { cgfloat xoffset = (scrollview2.contentsize.width * scrollview1.contentsize.width); // issue [scrollview2 scrollrecttovisible:cgrectmake(xoffset, 0, scrollview2.frame.size.width, scrollview2.frame.size.height) animated:yes]; } } try replacing 2 lines with: float xoffset = scrollview1.contentoffset.x * (scrollview2.frame.size.width / scrollview1.frame.size.wid