Posts

Showing posts from May, 2012

mysql - How to optimize data aggregation in day of week, time of day for a period of one month back -

Image
here situation: i have saas application simple rss feed reader. think people know - users subscribing rss feeds , reading items them. nothing new. 1 feed can have many subscribers. i've implemented statistics users, don't think i've chosen right approach, because things getting slower hour number of users , feeds grows. here's i'm doing now: at every hour total number of articles each feed: select count(*) articles feed_id=? get previous value calculate delta (this getting little slow): select value feeds_stats feed_id=? , name='total_articles' order date desc limit 1 insert new value , delta: insert feeds_stats (date,feed_id,name,value,delta) values ('".date("y-m-d h:i:s",$global_timestamp)."','".$feed_id','total_articles','".$value."','".($value-$old_value)."') for every user feeds , each feed number of articles has read: select count(*) users_artic

excel - Copy values to new sheet after the last sheet and delete column b if empty -

i want copy values (not formulas) of last sheet of workbook run macro on (i won't know names of sheets or quantity of sheets) , delete b column if it's blank , name new wirksheet "games". have , it's not working =(. give me help? sub arrumartabela() activesheet.copy cells.copy application.cutcopymode = false activesheet.name = "games" range("a1").pastespecial paste:=xlpastevalues application.screenupdating = false activesheet.name = "games" dim cl range each cl in range("$b$2:$b" & range("$b$65536").end(xlup).row) if cl = "" cl.entirecolumn.delete next cl range("c1").select selection.entirecolumn.insert , copyorigin:=xlformatfromleftorabove application.screenupdating = true end sub will modification need? sub arrumartabela() activesheet.copy 'this create new workbook , new sheet current activesheet

ios - Long name in UIButton shortens -

i have uibutton has title longer width of button itself. while in uitextfield see first part of string (which 1 want show) , 3 dots, on uibutton see first part, towards center 3 dots , third part. there way fix issue without cutting string? if button size can't change titlelabel size can, can either change font in of button in interface builder or in code or allow label adjust font with: button.titlelabel.adjustsfontsizetofitwidth = yes; if button size can change, adjust rather font size: cgrect frame; frame.origin = self.button.frame.origin; frame.size = [self.button.titlelabel.text sizewithfont:self.button.titlelabel.font]; self.button.frame = frame; alternatively, if want line break @ end of string instead of middle, similar how uitextfield appears, set linebreakmode nslinebreakbytruncatingtail

java - Texture Mapping is reversed! Java3D -

i use eyes me see why texture map reversed on object. prints backwards -- if seeing in mirror. had suspected maybe reversing indices help, changed mapped without reversing reversal. public class mobiusbanner extends applet { public static void main(string[] args) { new mainframe(new mobiusbanner(), 800, 600); } @override public void init() { graphicsconfiguration gc = simpleuniverse.getpreferredconfiguration(); canvas3d canvas = new canvas3d(gc); this.setlayout(new borderlayout()); this.add(canvas, borderlayout.center); simpleuniverse su = new simpleuniverse(canvas); su.getviewingplatform().setnominalviewingtransform(); branchgroup bg = createscenegraph(); bg.compile(); su.addbranchgraph(bg); } private branchgroup createscenegraph() { branchgroup root = new branchgroup(); shape3d sh

android - TIMEZONE_CHANGED intent being received every few seconds -

i use broadcastreceiver timezone_changed action reset alarms using alarmmanager make sure alarm runs @ set time, not few hours earlier or later, depending on time zone change. however in latest log sent user, saw information intent timezone_changed action being received every few seconds user complaining app being glitchy. here's broadcastreceiver's onreceive code @override public void onreceive(context context, intent intent) { utils.log("ontimechange"); string action = intent.getaction(); if (action.equals(intent.action_time_changed)) { utils.log("timechange"); } else if (action.equals(intent.action_timezone_changed)) { utils.log("timezonechanged"); } broadcastsmanager.updatebroadcastsfromalarms(context, alarmsdbadapter.getinstance(context)); } the manifest's intent filter: <intent-filter> <action android:name="android.intent.action.timezone_changed" /&g

node.js - Why page not redirecting in AngularJS+Express -

i making demo site angular express seed brian ford (thanks lot), after edit post not redirecting listing url. edit operation doing fine not redirecting listing page after hit submit button . in chrome showing pending in status never ends... codes bellow: angular controller function editpostctrl($scope, $http, $location, $routeparams) { $scope.form = {}; $http.get('/api/posts/details/' + $routeparams.id). success(function(data) { $scope.form = data.post; }); $scope.editpost = function () { $http.post('/api/posts/edit/' + $routeparams.id, $scope.form). success(function(data) { $location.path('/posts'); }); }; }; express app app.post('/api/posts/edit/:id',api.adminlogincheck,api.editpost); api.js exports.editpost = function (req, res,next) { console.log("editpost"); var id = req.params.id; req.body.slug = req.body.title.split(&#

objective c - Remove leftBarButtonItem Background -

Image
how remove leftbarbuttonitem blue background? tried style:uibarbuttonitemstyleplain had no result. code: self.navigationitem.leftbarbuttonitem = [[uibarbuttonitem alloc] initwithimage:[uiimage imagenamed:@"icon_home"] style:uibarbuttonitemstyleplain target:self.navigationcontroller action:@selector(openmenu) ]; uibutton *tempbutton = [uibutton buttonwithtype:uibuttontypecustom]; [tempbutton setframe:cgrectmake(2, 1, 34, 34)]; // home button image width , height. [tempbutton addtarget:self action:@selector(btnbackclicked:) forcontrolevents:uicontroleventtouchupinside]; [tempbutton setimage:[uiimage imagenamed:@"icon_home.png"] forstate:uicontrolstatenormal]; [tempbutton setimage:[uiimage imagenamed:@"icon_home_h.png"] forstate:uicontrolstatehighlighted]; [self.navigationitem setleftbarbuttonitem:[[uibarbuttonitem alloc] initwithcustomview:tempbutton]];

java - Decimal format class problems -

i have string , im trying format decimal format there , every 3 numbers using decimal format class im having troble. here code public string getnum() { //turn string mynum formatted number there's , after every 3 digits decimalformat formnum = new decimalformat(mynum "000,000"); //set formnum string don't know method use step return formnum ; } mynum text document , number 6486 in instance in others using same code gets way 301122. method want turn these numbers things such 6,486 or 301,112 constructor statement ide telling in ")"is expected i'm not sure how change decimal format string once format number. you missed comma there after mynum. also, should be decimalformat formnum = new decimalformat("000,000"); return formnum.format(mynum);

testing - Frank setup for iOS not working -

i trying setup frank-cucumber ios, using this tutorial , stuck @ frank setup. navigate ios app, sudo gem install frank-cucumber , works fine. enter frank setup , gives me this: in activate: can't activate i18n (= 0.6.1, runtime) ["activesupport-3.2.13", "xcodeproj-0.5.5", "frank-cucumber-1.1.9.pre1"], activated i18n-0.6.4 ["frank-cucumber-1.1.9.pre1"] (gem::loaderror) should i18n ? thank you!

html - PHP $_POST doesn't take accents -

this question solved, check answer see solution i'm trying add db text accented letters through html form submits post php page, problem accented letters converted unreadable characters. i have form: <form action="page.php" method="post"> <input type="textarea" id="text1" name="text1" /> <input type="submit" value="send" /> </form> and then, in page.php: echo $_post['text1']; the problem if input àèìòù in textarea , submit form, output: à èìòù my next step convert accented letters html entities htmlentities($_post['text1'] need $_post give me correct letters. note: in page head have <meta http-equiv = "content-type" content = "text/html; charset=utf-8" /> how can fix this? edit i tried with <form action="page.php" method="post" accept-charset="utf-8"> <input

c - Stat errors in pthread (S_ISDIR not working) -

i attempting write program finds size of directory tree size of subdirectories within creating thread each new subdirectory , using thread find size of subdirectory. it's pretty simple program, it's hard debug. having ton of issues s_isdir not working intended (regular files passing if statement , program trying change dir regular files). below code have problem. have each parent directory wait subdirectories finish, don't want each subdirectory wait next one. #define namesize 256 #define num_threads 100 #define max_path_length 500 int totalsum = 0; pthread_mutex_t sum_mutex ; pthread_mutex_t thread_mutex ; void *findsize(void *p) { int levelsum = 0, numberthreads = 0, = 0; dir *dir ; struct dirent *entry ; struct stat entry_stat ; char cwd[2049] ; char threads[num_threads] ; char paths[num_threads][max_path_length]; char *path = (char*)p ; // change directory passed in if(chdir (p) == -1) { perror("chdi

java - What does this warning mean when running a vaadin web app in IntelliJ IDEA - no startup urls -

i able run vaadin app , development mode task starts, , warning displayed: [warn] no startup urls supplied , no plausible ones found -- use -startupurl i can not find information warning , means. intellij idea not launching selected web browser, , suspect warning reason why, don't know how follow above directions, because don't know telling me this, , in idea project might add -startupurl parameter. my problem although development mode task starts when run project, cannot seem locate url ( http://localhost:8000 or whatever) app loadable from. the full output when run app is: /system/library/java/javavirtualmachines/1.6.0.jdk/contents/home/bin/java -xmx256m -didea.launcher.port=7535 "-didea.launcher.bin.path=/applications/intellij idea 12.app/bin" .... [warn] no startup urls supplied , no plausible ones found -- use -startupurl dev mode initialized

ios - Detect which button was clicked in a grouped UITableView -

i have grouped uitableview (this 1 has 4 sections) , several rows each. have programatically created 2 buttons in each of cells. this how creating uitableviewcell . in code, trying detect indexpath.row , indexpath.section of button pressed , pass method. how able ? -(uitableviewcell*)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{ static nsstring *cellid = @"cell"; uitableviewcell *cell ;//= [tableview dequeuereusablecellwithidentifier:nil]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellid]; } nsstring *doctitle = [currentdocument objectforkey:@"displayname"]; uiview *cellview = [[uiview alloc] initwithframe:cgrectmake(cell.contentview.frame.origin.x+5, cell.contentview.frame.origin.y, cell.contentview.frame.size.width, cell.contentview.frame.size.height)]; uilabel *celltitle = [[uilabel alloc] initwithframe:cgrectmake(cellview.frame.origin.x

css - 2 columns - clicking thumbnail image in one reveals text in other -

i'm trying create page clicking on thumbnail image in left column reveals text in right column. there number of thumbnails each have own text appears in same place in right column when clicked. i'm wondering if there css or jquery projects out there kind of thing? thanks i think wanting, made jsfiddle it. html: <div id="wrapper"> <div id="left"> <p><a href="javascript:void()" class="one">thumbnail #1</a> </p> <p><a href="javascript:void()" class="two">thumbnail #2</a> </p> <p><a href="javascript:void()" class="three">thumbnail #3</a> </p> </div> <div id="right"> <!-- each div here contain text show on right --> <div id="textone" class="text" style="display:block;"> <h1>one</h1>

c++ - Why message loop doesn't block the GUI in windows app but does in Qt? -

i'm working on program using qt, , of code based on windows samples. problem i'm having, , don't quite understand how same code block qt gui while work totally fine in windows app. here's example. have program gets data camera, processing on it, displays on screen. in windows sample there's this: // create event these self-explanatory parameters // event signals when next frame ready process handle frameevent = createevent(nullptr, true, false, nullptr) // run while loop magically doesn't block handle hevents[1]; while (wm_quit != msg.message) { hevents[0] = frameevent; dword dwevent = msgwaitformultipleobjects(1, hevents, false, infinite, qs_allinput); // if have our event run processing if (wait_object_0 == dwevent) { update(); } // else handle input or whatever } the update function looks this: if (wait_object_0 = waitforsingleobject(frameevent, 0) { gettheframe(); processtheframe(); drawtheframe(); } if try implemen

c++ - How to determine if my program is 'on the company domain' -

i'm trying determine if service connected company domain or not. i tried bool bresult = logonuser(m_username, m_domainstr, m_password, logon32_logon_network, logon32_provider_default, &userhandle); but returns true if credentials good. i'm guessing windows checking cached credentials , determining good. i suppose use ping, firewall stop too. is there nice, clean way determine if computer on 'corporate network' (e.g. can connect ad). check availability of dcs sysvol share. i query dns list of dcs, loop through dcs until can access share. if can, i'm online. if can't, i'm offline. if on company lan, dcs unavailable, might offline...

android - Vertical Screen Split Transitions (Animation) -

Image
the animation should following: vertically split screen 2 parts. upper part moving upward. lower part moving down. finally, reverse way . (closing screen) the idea simple: save activity bitmap split bitmap 2 parts animate bitmaps outwards (up , down) in order bitmap of activity: view root = curractivity.getwindow().getdecorview().findviewbyid(android.r.id.content); root.setdrawingcacheenabled(true); bitmap bmp = root.getdrawingcache(); in order split bitmap: int splitycoord = (splitycoord != -1 ? splitycoord : bmp.getheight() / 2); if (splitycoord > bmp.getheight()) throw new illegalargumentexception("split y coordinate [" + splitycoord + "] exceeds activity's height [" + bmp.getheight() + "]"); bitmap mbmp1 = bitmap.createbitmap(bmp, 0, 0, bmp.getwidth(), splitycoord); bitmap mbmp2 = bitmap.createbitmap(bmp, 0, splitycoord, bmp.getwidth(), bmp.getheight() - splitycoord); private static int[] mloc1; pr

java - Making a Button restart the activity -

ok know may seem simple, mean thought was. want restartactivity method restart activity. first thing did create button , had line of code in xml such. android:onclick="restartactivity" then class contains restartactivity method such public void restartactivity() { intent intent= new intent(this, mainactivity.class); startactivity(intent); } when try ends happening stopped working dialog box. question why not working. made sure made restart button in right layout, checked make sure needed references made. , android manifest correct. wasn't until added 2 lines started crashing. should mention target api 8 , 1 of answers suggested api 11 or higher. eclipse "kindly" let me knew. activity class provides method: public void recreate () since: api level 11 cause activity recreated new instance. results in same flow when activity created due configuration change -- current instance go through lifecycle ondestroy() , new instance create

javascript - Create a transparent HTML cursor -

is possible create transparent html cursor on web page? i'm using div cursor, , want make div 50% transparent: http://jsfiddle.net/mcgmp/16/ <div id="cursor"><font size="6">i want cursor 50% transparent!</font></div> maybe help: #cursor { opacity:0.4; filter:alpha(opacity=40); /* ie8 , earlier */ } here's working demo .

android - Google Static Maps Api? -

i using google maps api v1 , draw map canvas , save , im using google maps api v2 because got debug key before march 13th , weekend ready sign , couldnt because didnt know going discontinued, so, questions have are: 1: static maps api correct way doing in google maps api v1 draw mapview canvas , compress bitmap. 2: if 25000 free requests pertain me developer or each individual user of app making? thank time.... my guess confused google maps api v2 (also depracated) google maps android api v2. the new api here: https://developers.google.com/maps/documentation/android/ the android api v2 has no such limits.

.net - How to add child object in parent object in EF -

work on ef4. i know ef objectcontext can 3 properties involved in parent-child association, 2 navigation properties ( parent.children , child.parent ) , foreign key property ( child.parentid ). need on parent.childer navigation. private list<t2> fillchildcontrolonsave<t1, t2>(bommastercontroller objcontroller, list<t2> entitydetail, t1 objentity) t1 : plnbommaster t2 : plnbomdetail { #region myregion #endregion foreach (t2 c in entitydetail) { if (c.action == xerp.entity.actionmode.add) { objentity.plnbomdetails.add(c); } if (c.action == xerp.entity.actionmode. update) { objentity.plnbomdetails.add(c); } } } want replace objentity.plnbomdetails.add(c); generic objentity.###<t2>.add(c); . me writa generic syntax above add , update condition . if have question please ask, type of suggestion acceptable.thanks in advanced.

Error 53 when updating Active Directory password with Ruby -

i'm having bit of trouble trying add password active directory accounts created ruby script. ssl connection established with: ldap = ldap::sslconn.new(ldap_host, ssl_port) plain text passwords run through function return base 64 utf-16le string. def convert_to_unicode pwd unicode_pwd = pwd.encode("utf-16le") return base64.encode64(unicode_pwd) end adding entries ad aren't issue password put in returns error 53: unwilling perform. passwords being passed in meet ad requirements , don't have problems when done through bash script. example running following through convert_to_unicode should return quoted new_password1 ad set. '"new_password1"' wondering if has useful can point me towards might missing. have tried run encoding utf-16le? def microsoft_encode_password pwd ret = "" pwd = "\"" + pwd + "\"" pwd.length.times{|i| ret+= "#{pwd[i..i]}\000" }

java - Exception while Deploying ear on glassfish server of amazon cloud -

Image
we working on java technology , have created enterprise application in java. created instances on amazon aws. have following hosts our web enterpeise application on amazon server amazon= ec2-54-235-50-8.compute-1.amazonaws.com mysql= mysqld@ec2-23-23-65-23.compute-1.amazonaws.com we have created jdbc connection pool on glassfish follows when ping jdbc connetction pool giving following exception "class name wrong or class path not set com.mysql.jdbc.mysqldatasource". try this: cd ./glassfish3/glassfish/domain/domainl/lib wget http://mysql.llarian.net/downloads/connector-j/mysql-connector-java-5.1.18.zip unzip mysql-connector-java-5.1.18.zip mv ./glassfish3/glassfish/domain/domainl/lib/mysql-connector-java-5.1.18/mysql-connector-java-5.1.18-bin.jar ./glassfish3/glassfish/domain/domainl/lib by u mysql-coonector-java.jar file in lib folder.

Purpose of goto in java -

this question has answer here: is there goto statement in java? 24 answers i know goto keyword in java. also, wiki , can excerpt that, "it not used , has no function". i wonder, why goto declared keyword if has no use , not used anywhere? did ever used goto in java program? there other keywords goto declared in java programming had metaphorically no use. where use goto in our daily programming or when? here bit of summary goto statements usage: they used jump out of block of statements in language, jmp instruction work @ assembly level. goto's strictly prohibited make program difficult trace excessive jumps in code makes slow. imagine loop having goto inside it. not @ good. java reserved keyword may involves native code inside jvm(that's bit of c/c++) code, may avoid ambiguity. java provides break implementation of goto usa

iphone - All items are not displayed properly while using UICollectionView grid view -

i developing app in xcode4.2 , ios6 i using uicollectionview display item in grid view. want display items in 3x3 format have 15 items items should displayed in following way page 1 item1 item2 item3 item4 item5 item6 item7 item8 item9 page 2 item10 item11 item12 item13 item14 item15 here page 1 should displayed default while page 2 on screen swiping these displayed in following way page 1 item1 item4 item7 item2 item5 item8 item3 item6 item9 page 2 item7 item10 item13 item8 item11 item14 item9 item12 item15 it seems uicollectionview arranges items vertically not horizontally. can please resolve problem i implemented selecting direction horizontal , arranged item left right dynamically. default items arranged top bottom, changed item according index number items looks arranging left right , works perfectly.

Display Chrome extension popup at middle of page -

i new writing chrome extensions , wondering how can following. how can make popup(when clicks on extension icon) display @ center of webpage instead of displaying popup @ top right corner ? use chrome.browseraction.onclicked.addlistener(), fires "when browser action icon clicked." inject popup manually dom of supplied tab, using chrome.tabs.executescript(). also consider adding context-menu item , might make more sense user depending on extension does.

c# - How to use the both JavaScript validation and asp.net validation for a control -

i use button click asp.net validation group , client side validation (javascript). give first preference javascript validation if returns true means directly go serverside button click event not check asp.net validations. <asp:imagebutton id="img_btn_register" runat="server" imageurl="~/images/register1.png" **onclientclick="return validat_form()"** onclick="img_btn_register_click1" **validationgroup="qa"** /> based on question understand that- need field validations should occur first , script should execute. you can call page_clientvalidate () in client script explicitly execute validations , if successful client script should executed. here small demo on same: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript" language="javascript"> funct

osx - Generating ctags for libc in mac -

i'm trying use tags of libc library on mac (mountain lion) through vim. i've generated tags *.c files in /usr/include ( ctags -r /usr/include/*.h ). i've set tags include generated tags file ( set tags+=tags ). but, if try go tag on function fseek() "no tags found". how can solve this? edit: i've tried doing ctags /usr/lib/libc.dylib , , results in error saying file not sorted. :( use line generate usable tags file: ctags -r --c++-kinds=+p --fields=+ias --extra=+q /usr/include once it's done, :tag fseek should work, <c-]> on fseek call. be sure read :h tags , :h ctags carefully.

Switch statement within while loop in C -

there several postings concerning switch statements within while loops, except fact none of them done in c, @ least i've seen. c++ can create boolean expressions, i'm aware of, not in c. have while loop contains switch control. however, when write break statements within switch, goes beginning of loop , makes program run forever. ignore functions use, work sure. need clarification on handling of nesting. thanks! here main.c: while(1) { printf("0) exit\n1) list tasks\n2) add task\n"); printf("3)delete task\n4) add task file\n"); printf("what do?\n"); fgets(buf1, 50, stdin); p = atoi(buf1); switch(p) { case 0: break; case 1: printtasklist(ptasklist); break; case 2: printf("enter

iphone - how to find the permutations and combinations of any integer value? -

i want permutations , combinations in objective c.i have found both problem in code don't understand occurring. want print value in textfield prints last value entered. used code given below. me please.. typedef enum{power,exponent,ncr,npr} calcoperation; nsstring *storage; calcoperation operation; -(ibaction)combination{ operation = npr; storage = label.text; textfield.text=@""; label.text = @""; } -(int) factorial:(int)n{ int d = n; int temp = 1; for(int b = 2; b <= d; b++){ temp = temp*b; } //nslog(@"the factorials = %i",temp); return temp; } -(ibaction)equalbutton{ float tempo = [storage floatvalue]; float b = [label.text floatvalue]; nsstring *val = [[nsstring alloc]initwithformat:@"%f" , b]; switch(operation) { case ncr: textfield.text = [[nsstring alloc]initwithformat:@"%f",[self factorial:tempo] / ([self factorial:[val floatvalu

call javascript function in php and pass php variables? -

say have 3 variables, id, name, number, on php script, $name, $number, $id on php, create button print "<td><form><input type='button' name='edit' id='edit' onclick=ed($name, $number, $id) value='edit' /></td>"; i want 3 variables sent javascript. the function call seems work fine if use onclick=ed(this.id) and modify function header, , passes string "edit" that's not quite useful. function header in javascript is function ed(name, number, id) { //stuff here } for whatever it's worth using code gets me error on html, unexpected } on line2 of html document. edit:i should clarify said code gives me errors didn't "well use this!" when expected not work. using this: <input type='button' id='$id' onclick=ed(this.id) value='edit' /> allows me send value in $id javascript function because saved in id field. along lines i'm hoping

c - Why do I get a different value of "a". To get the same value what needs to be done? -

this question has answer here: why isn't size of array parameter same within main? 13 answers #include<stdio.h> void func(int x[]); main() { int a[]={1,2,3,4}; printf("size of %d \n",sizeof(a)); // value i'm getting func(a); } void func(int a[]) { printf("size of %d",sizeof(a)); // value changing } both times, value of 'a' not printing same. same value maintaining code, more code need added or changes required? i don't want change signature of function. without changing signature, code needed added inside func(int a[]) ?. an array function argument decays pointer, meaning argument func of type int* . can therefore calculate sizeof(int*) inside func . if want pass array size, can either pass separate argument func(a, sizeof(a)/sizeof(a[0])); .... void func(int* a, int num_elems); o

behavior - Java - Strange behaviour on PrintStream with custom OutputStream -

i trying write program redirects system.out jtextarea (it doesn't have jtextarea), when call system.out.println("test!") output text area so: \n st! \n the code outputstream: package gui; import java.awt.*; import java.io.*; import javax.swing.text.*; public class logoutputstream extends outputstream { public void write(final int b) throws ioexception { eventqueue.invokelater(new runnable() { public void run() { write0(b); } }); } public void write(final byte[] b, final int off, final int len) { eventqueue.invokelater(new runnable() { public void run() { write0(b, off, len); } }); } public void write(final byte[] b) { eventqueue.invokelater(new runnable() { public void run() { write0(b); } }); }

android - Phone light Turn On when incoming call come -

i got incoming call , working well. when screen turn off , incoming call come. screen light not on . using code in oncreate():- getwindow().addflags( windowmanager.layoutparams.flag_allow_lock_while_screen_on | windowmanager.layoutparams.flag_show_when_locked ); powermanager pm = (powermanager) getsystemservice(context.power_service); wl = pm.newwakelock(powermanager.screen_bright_wake_lock, "my tag"); wl.acquire(); also when screen light on , incoming call come connection server successful. when screen light off , incoming call come(by service run in background registration server) registration failed . please android expert me! use following in oncreate getwindow().addflags(windowmanager.layoutparams.flag_dismiss_keyguard); getwindow().addflags(windowmanager.layoutparams.flag_show_when_locked); getwindow().addflags(windowmanager.layoutparams.flag_turn_screen_on); getwindow().addflags(window

Add elements to a vector in R with while loop -

suppose vector follow: fruit = c("apple", "orange") i sample 1 fruit @ time , store chosen fruit in vector. chosen=sample(fruit, size = 1, replace = true) suppose want continue sampling until total number of oranges 2 more of apples, i'm having trouble combining samples single vector. i = 1 keepgoing = true while(keepgoing){ i=sample(fruit, size = 1, replace = true) i+1=sample(fruit, size = 1, replace = true) fruitlist=rbind(i, i+1) if(sum(fruitlist=="orange")-sum(fruitlist=="apple")==2){ keepgoing = false} = +2 } since sample units independent (probability of later units not depend on probability of earlier units, being 0.5 in case), can use strategy. instead of growing sample, can draw large(r) sample first, , cut off @ point our desired condition satisfied: makesample <- function(n=20) { fruit <- c("apple", "orange") full.sample <- sample(x = fruit, size = n, rep

javascript - Php Mysql Ajax Infinite Scrolling -

i using code bellow make infinite scrolling got 2 "errors". 1. when reaches last record displays next 4 records again 2. when comes end , display records didn't message "no more records" in php file got this: <script type="text/javascript"> $(document).ready(function(){ $(window).scroll(function() { if ( document.documentelement.clientheight + $(document).scrolltop() >= document.body.offsetheight ) { $("#myloaderias").fadein("fast"); $.ajax({ //start of ajax call url: "loadmore.php?lastcomment=" + $(".imgholder:last").attr("id"), cache: false, success: function(html){ $("#myloaderias").fadeout("fast"); if(html){ //if(html) $("#masterdivholder").append(html); //append results in div holds images $("#nmc").hide(); } else {

Add values show into single column in sql server -

in table, have experience field like experience 5years0months 2years0months here want convert seconds add years , months single column. experience - [some value] so create 1 query following, select top(10)'insert candidates(experience)values('+ cast(substring(cast(o.experience varchar(50)), 0, patindex('%years%', o.experience)) * 31536000 varchar(50)) +','+cast(substring(cast(o.experience varchar(50)), patindex('%years%', o.experience) + 5 ,patindex('%months%', o.experience) - patindex('%years%', o.experience) - 5) * 2678400 varchar(50))+')' candidatedetails o from above code have result like, experience insert candidates(experience)values(157680000,0) insert candidates(experience)values(31536000,26784000) expected result insert candidates(experience)values(157680000) insert candidates(experience)values(58320000)//add(31536000+26784000) how in query? me anyo

r - Find pattern containing string not preceeded by other string -

i use grepl function in r find if string contains something, on condition not preceeded else. so example wanted find string includes pattern 'xx' , long not preceeded 'yy' . so: '123xx45' world return true '123yy4xx5' return true 'yy' not preceding 'xx' however '123yyxx45' return false . please let me know if unclear or better example. how grepl('(?<!yy)xx', c('123yy4xx5','123xx45','123yyxx45'), perl=true) ?

ruby on rails - Neo4j admin neo4j.rb -

i use "neo4j-admin" , "neo4j.rb" following links. https://github.com/andreasronge/neo4j https://github.com/andreasronge/neo4j-admin after install neo4j-admin gem, cannot start rails server , neo4j-admin gem doesn't work. got error. loaderror: load error: jruby-openssl -- java.lang.verifyerror: class org.bouncycastle.asn1.asn1primitive overrides final method equals.(ljava/lang/object) this our gemfile , use jruby-1.7.4 gem 'neo4j', '>= 2.2.3' gem 'neo4j-community', '1.9' gem 'neo4j-advanced', '1.9' gem 'neo4j-enterprise', '1.9' gem 'neo4jrb-paperclip', :require => 'neo4jrb_paperclip' gem 'aws-s3',:require => 'aws/s3' gem 'neo4j-admin' i appreciated help.

c# - Can't retrieve InputOutput SqlParameter anymore -

i have strange behavior in web application started happening week. when worked before cannot retrieve inputoutput parameters sql server anymore. syntax in procedures same, need retrieve identity values tables continue process. sqlparameter paramid = new sqlparameter("@id", objmyvalueid); paramid.direction = parameterdirection.inputoutput; after executing sp executenonquery null values (or value set in inputoutput parameter). paramid.value --> (always null) it's collection remains still , can't modified. there setting in sql server or configuration parameter connection string affect behavior? happens in every stored procedure execute , worked before. well, came conclusion (finally) our fault , error clear. after tracking commits in svn found of team included new feature core of database interaction assembly. avoid repeating code in data layer of parameters inferred .net type. keeps simple , separates layer of engine (sql server, oracle, mysql, e

jquery - .toggle not working in Safari -

for reason doesn't work in safari , functions less on ipad, guesses? =( $(".dropdown .sub").click(function () { $("#menu .holder").toggle(); }); after looking @ web page provided appears toggle selector has many children. this: <div id="menu" class="dropdown"> <ul> <li class="level1"> <a class="sub" href="#"><strong>tv &amp; video</strong></a> <div class="holder">holder</div> </li> <li class="level1"> <a class="sub" href="#"><strong>tv &amp; video</strong></a> <div class="holder">holder</div> </li> </ul> </div> this not work: $(".dropdown .sub").click(function () { $("#menu .holder").toggle(); });

asp.net mvc - Why are the nested objects in my parent object null when posting to my MVC 4 Controller? -

let's have complex model contains custom class: public class car { public car() {} public engine engine { get; set } // nested object public int fuelremaining {get; set;} public int vehiclestatus {get; set;} } and mvc 4 controller looks this: [httppost] public partialviewresult showvehicledetails(car currentvehicle) { return partialview(currentvehicle); } if pass instance of class controller using ajax post, , try return view, partial view, or peek object, of values of engine null , else fine. here in example of json see showing in form data of request header post: {"engine":{"enginevin":258736,"enginekm":160015,"enginedesc":"ecotech v8"},"fuelremaining":90,"vehiclestatus":1} note: values fuelremaining , , vehiclestatus showing fine in controller , in resulting view. can explain me why case, , how best work around this? i did come across this bl

android - Why the data start scrolling horizontally when data is coming from server? -

i working on jquery , jquery mobile .i facing 1 simple complicated issue .i have 1 div in append server data. in div insert style (width example 40%).when inserted static data working fine in other word data come in new line when width complete. when data coming server start scrolling horizontally. take example if have data static. data this hi demo no come next morning but when data come server show thsi hi demo(see upto here , can scroll data) no come next morning facing problem in android . here code. <div id="test" style="width:40%"></div> $('#test').append(result) i getting result server this console.log("result"+result); 08-15 21:32:20.898: i/web console(5635): result&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{mrr}&nbsp;distanced&nbsp;himself&nbsp;in&nbsp;may&nbsp;of&nbsp;2010&nbsp;following&nbsp;the&

ios - Accessing iPhone's Contact List via mobile browser -

is there way access iphone's contact list via browser safari? i researched phonegap permission, think it's not possible via phonegap. yes, possible ( at least possible in ios 4.2.1 , 4.3 ), have quite bit of hacker achieve ;)

Java Maven Project appears in another project as directory not a jar -

so, created spring maven project, dao project, works great. code in correct place, unit tests run, , can mvn clean install. can see in target directory there build jar, , in looks fine. can confirm when check local .m2/repository, latest jar built in there. here small segment of pom.xml: <modelversion>4.0.0</modelversion> <groupid>com.tom.myproject</groupid> <artifactid>myproject-dao</artifactid> <version>0.0.1-snapshot</version> <packaging>jar</packaging> <name>my project dao</name> now, creating new spring maven web-project ui, , pom.xml starts out like: <modelversion>4.0.0</modelversion> <version>0.0.1-snapshot</version> <groupid>com.tom.myproject</groupid> <artifactid>myproject-ws</artifactid> <name>my web project</name> <packaging>war</packaging> also in pom.xml file, 1 of first dependencies have is: <!-- dao proj

r - How to aggregate (using "by") a data.table with customized column name without ":="? -

i know can this <- dt[,sum(x), by=y] also can this dt[,z:=sum(x), by=y] # modify dt however don't why cannot this: <- dt[,z=sum(x), by=y] how should perform "summarize" customized column names? is option? <- copy(dt) a[,z:=sum(x), by=y] you're looking list() in j argument: a <- dt[,list(z=sum(x)), by=y]

python - specifying targets for a custom scon builder -

hey i've written custom builder should work differently .c files .structdoc file. here's sconstruct file env = environment() prepare_structdoc = builder(action='python prep_structdoc.py < $source > $target', suffix='.structdoc', src_suffix='.c') prepare_postc = builder(action='python preprocess_mods.py < $source > $target', suffix='.postc', src_suffix='.structdoc') env['builders']['structdocbuilder'] = prepare_structdoc env['builders']['postcbuilder'] = prepare_postc sconscript('mods/sconscript', exports='env') these builders work on 1 source , produce 1 target, run loop in sconscript on *.c files this import("env") fname in glob("*.c"): struct_doc= env.structdocbuilder(source=fname) post_c = env.postcbuilder(source=struct_doc) this trick. however, use these builders 1 file if mention . i.e. inside mods/ specify scons -u abc.c .

phantomjs - Run CasperJS as an included Javascript in a web page and execute casperJS commands interactively -

can casperjs (with phantomjs) run directly in browser , not via command line ? i run interactive test browser take inputs user , proceed accordingly. run casperjs normal javascript function executed in browser , able produce output of each command user, such user can decide wants next. the short answer is: no, not you've described it. casperjs runs on, , depends on, phantomjs, is browser - can't run in user's browser. if want offer interactive casperjs session through webpage, you'd need run casper/phantom on server, , proxy input/ouput through server. operation requires fetching other webpages , scraping or interacting them require server-side mechanism, because same origin policy makes quite difficult implement using client-side javascript (though browser extension might able it).

Remote XDebug with Aptana and Zend Framework -

okay, i'm killing myself on this. i've been trying every single tutorial can , still not luck. aptana "waiting xdebug session". i have xdebug setup on remote server on port 9000. xdebug.remote_enable=on xdebug.remote_host="localhost" xdebug.remote_port=9000 xdebug.remote_handler="dbgp" xdebug.remote_mode="jit" this seems correct , phpinfo makes correct. went aptana set , of tutorials involve localhost in way. maybe severely overlooking component of xdebug (can debug local?). there no way have application run locally because running nontraditional stack items don't want install this. i have setup aptana php interpreter: http://grab.by/pomm have setup aptana remote server using base url , local file document root have chrome xdebug helper turned on using key eclipse_dbgp aptana still waiting xdebug session. please help! here relevant part of (working) php.ini: zend_extension=/usr/local/zend/lib/php_extensions/x