Search Results

Search found 14236 results on 570 pages for 'times square'.

Page 31/570 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • Conditionally Summing the same Column multiple times in a single select statement?

    - by btollett
    I have a single table that shows employee deployments, for various types of deployment, in a given location for each month: ID | Location_ID | Date | NumEmployees | DeploymentType_ID As an example, a few records might be: 1 | L1 | 12/2010 | 7 | 1 (=Permanent) 2 | L1 | 12/2010 | 2 | 2 (=Temp) 3 | L1 | 12/2010 | 1 | 3 (=Support) 4 | L1 | 01/2011 | 4 | 1 5 | L1 | 01/2011 | 2 | 2 6 | L1 | 01/2011 | 1 | 3 7 | L2 | 12/2010 | 6 | 1 8 | L2 | 01/2011 | 6 | 1 9 | L2 | 12/2010 | 3 | 2 What I need to do is sum the various types of people by date, such that the results look something like this: Date | Total Perm | Total Temp | Total Supp 12/2010 | 13 | 5 | 1 01/2011 | 10 | 2 | 1 Currently, I've created a separate query for each deployment type that looks like this: SELECT Date, SUM(NumEmployees) AS "Total Permanent" FROM tblDeployment WHERE DeploymentType_ID=1 GROUP BY Date; We'll call that query qSumPermDeployments. Then, I'm using a couple of joins to combine the queries: SELECT qSumPermDeployments.Date, qSumPermDeployments.["Total Permanent"] AS "Permanent" qSumTempDeployments.["Total Temp"] AS "Temp" qSumSupportDeployments.["Total Support"] AS Support FROM (qSumPermDeployments LEFT JOIN qSumTempDeployments ON qSumPermDeployments.Date = qSumTempDeployments.Date) LEFT JOIN qSumSupportDeployments ON qSumPermDeployments.Date = qSumSupportDeployments.Date; Note that I'm currently constructing that final query under the assumption that a location will only have temp or support employees if they also have permanent employees. Thus, I can create the joins using the permanent employee results as the base table. Given all of the data I currently have, that assumption holds up, but ideally I'd like to move away from that assumption. So finally, my question. Is there a way to simplify this down to a single query or is it best to separate it out into multiple queries - if for no other reason that readability.

    Read the article

  • How would I add code that would update an online "counter" so I know how many times an iPhone app is

    - by Luis Tovar
    So I have searched for this but not finding anything about it and if I missed it sorry about that. What I am trying to do is see how to go about adding some code to my iphone app that will connect to a php script (if connection available) and update a counter so that I can let my clients know that their app is constantly being used? Also, would apple allow that? Or would my app be denied for doing such a thing? Any help would be great! Thanks in advance.

    Read the article

  • I need to speed this code at least 2 times!

    - by Dominating
    include include include include using namespace std; inline void PrintMapName(multimap pN, string s) { pair::iterator, multimap::iterator ii; multimap::iterator it; ii = pN.equal_range(s); multimap tmp; for(it = ii.first; it != ii.second; ++it) { tmp.insert(pair(it-second,1)); } multimap::iterator i; bool flag = false; for(i = tmp.begin(); i != tmp.end(); i++) { if(flag) { cout<<" "; } cout<first; if(flag) { cout<<" "; } flag = true; } cout< int main() { multimap phoneNums; multimap numPhones; int N; cinN; int tests; string tmp, tmp1,tmp2; while(N 0) { cintests; while(tests 0) { cintmp; if(tmp == "add") { cintmp1tmp2; phoneNums.insert(pair(tmp1,tmp2)); numPhones.insert(pair(tmp2,tmp1)); } else { if(tmp == "delnum") { cintmp1; multimap::iterator it; multimap::iterator tmpr; for(it = phoneNums.begin(); it != phoneNums.end();it++) { tmpr = it; if(it-second == tmp1) { phoneNums.erase(it,tmpr); } } numPhones.erase(tmp1); } else { if(tmp == "delname") { cintmp1; phoneNums.erase(tmp1); multimap::iterator it; multimap::iterator tmpr; for(it = numPhones.begin(); it != numPhones.end();it++) { tmpr = it; if(it-second == tmp1) { numPhones.erase(it,tmpr); } } } else { if(tmp =="queryname") { cintmp1; PrintMapName(phoneNums, tmp1); } else//querynum { cintmp1; PrintMapName(numPhones, tmp1); } } } } tests--; } N--; } return 0; }

    Read the article

  • as3 custom functions

    - by pixeltocode
    hi, i'm new to AS3. how do i go about executing a custom function n number of times and then executing another function n number of times repeatedly? eg. function firstOne():void { } function secondOne():void { } i need firstOne() executed say 3 times and then secondOne() 3 times and then firstOne 3 times again and so on. thanks

    Read the article

  • Output from OouraFFT correct sometimes but completely false other times. Why ?

    - by Yan
    Hi I am using Ooura FFT to compute the FFT of the accelerometer data in windows of 1024 samples. The code works fine, but then for some reason it produces very strange outputs, i.e. continuous spectrum with amplitudes of the order of 10^200. Here is the code: OouraFFT *myFFT=[[OouraFFT alloc] initForSignalsOfLength:1024 NumWindows:10]; // had to allocate it UIAcceleration *tempAccel = nil; double *input=(double *)malloc(1024 * sizeof(double)); double *frequency=(double *)malloc(1024*sizeof(double)); if (input) { //NSLog(@"%d",[array count]); for (int u=0; u<[array count]; u++) { tempAccel = (UIAcceleration *)[array objectAtIndex:u]; input[u]=tempAccel.z; //NSLog(@"%g",input[u]); } } myFFT.inputData=input; // specifies input data to myFFT [myFFT calculateWelchPeriodogramWithNewSignalSegment]; // calculates FFT for (int i=0;i<myFFT.dataLength;i++) // loop to copy output of myFFT, length of spectrumData is half of input data, so copy twice { if (i<myFFT.numFrequencies) { frequency[i]=myFFT.spectrumData[i]; // } else { frequency[i]=myFFT.spectrumData[myFFT.dataLength-i]; // copy twice } } for (int i=0;i<[array count];i++) { TransformedAcceleration *NewAcceleration=[[TransformedAcceleration alloc]init]; tempAccel=(UIAcceleration*)[array objectAtIndex:i]; NewAcceleration.timestamp=tempAccel.timestamp; NewAcceleration.x=tempAccel.x; NewAcceleration.y=tempAccel.z; NewAcceleration.z=frequency[i]; [newcurrentarray addObject:NewAcceleration]; // this does not work //[self replaceAcceleration:NewAcceleration]; //[NewAcceleration release]; [NewAcceleration release]; } TransformedAcceleration *a=nil;//[[TransformedAcceleration alloc]init]; // object containing fft of x,y,z accelerations for(int i=0; i<[newcurrentarray count]; i++) { a=(TransformedAcceleration *)[newcurrentarray objectAtIndex:i]; //NSLog(@"%d,%@",i,[a printAcceleration]); fprintf(fp,[[a printAcceleration] UTF8String]); //this is going wrong somewhow } fclose(fp); [array release]; [myFFT release]; //[array removeAllObjects]; [newcurrentarray release]; free(input); free(frequency);

    Read the article

  • How does the NY Times iPhone app do this?

    - by ArgMan
    Alright, I have an RSS feed that gets arranged in a UITableView and then the user selects a story and it loads in a UIWebView. However, I'd like to stop using the UIWebView and just use a UITextView or UILabel. This png is what I am trying to do (just display the various text aspects of a news story): http://img411.imageshack.us/img411/2449/screenshot20100315at120.png Let me start off by saying that I have tried to use the usualNSString *myText = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.textContent"]; and assign it to a UILabel, but it doesn't work the way that I am implementing it (in webViewDidFinishLoad--is that not correct?) and I get a blank textView and normal webView. If I overlay a UITextView on top of a UIWebView on its own (that is, a webView that just loads one page), the code posted above works fine to display the text I require, but the problem arises when the RSS feed is added into the mix. Ideas and/or help, guys? I've been stuck wondering why this doesn't work as it should for a few days now. If you have a better, more efficient way of doing it then placing the code in webViewDidFinishLoad, please let me know! Does it go in my didSelectRowAtIndexPath? I'm lost here, guys. Thank you very much in advance!

    Read the article

  • Communicate multiple times with a process without breaking the pipe?

    - by Manux
    Hello, it's not the first time I'm having this problem and its really bugging me. Whenever I open a pipe using the Python subprocess module, I can only communicate with it once, as the documentation specifies: Read data from stdout and stderr, until end-of-file is reached proc = sub.Popen("psql -h darwin -d main_db".split(),stdin=sub.PIPE,stdout=sub.PIPE) print proc.communicate("select a,b,result from experiment_1412;\n")[0] print proc.communicate("select theta,zeta,result from experiment_2099\n")[0] The problem here is that the second time, Python isn't happy. Indeed, he decided to close the file after the first communicate: Traceback (most recent call last): File "a.py", line 30, in <module> print proc.communicate("select theta,zeta,result from experiment_2099\n")[0] File "/usr/lib64/python2.5/subprocess.py", line 667, in communicate return self._communicate(input) File "/usr/lib64/python2.5/subprocess.py", line 1124, in _communicate self.stdin.flush() ValueError: I/O operation on closed file So... multiple communications aren't allowed? I hope not ;) Please enlighten me.

    Read the article

  • wpf progress bar slows 10x times serial port communications... how could be possible that?

    - by D_Guidi
    I know that this could look a dumb question, but here's my problem. I have a worker dialog that "hides" a backgroundworker, so in a worker thread I do my job, I report the progress in a standard way and then I show the results in my WPF program. The dialog contains a simply animated gif and a standard wpf progress bar, and when a progress is notified I set Value property. All lokks as usual and works well for any kind of job, like web service calls, db queries, background elaboration and so on. For my job we use also many "couplers", card readers that reads data from smart card, that are managed with native C code that access to serial port (so, I don't use .NET SerialPort object). I have some nunit tests and I read a sample card in 10 seconds, but using my actual program, under the backgroundworker and showing my worker dialog, I need 1.30 minutes to do the SAME job. I struggled into problem for days until I decide to remove the worker dialog, and without dialog I obtain the same performances of the tests! So I investigated, and It's not the dialog, not the animated gif, but the wpf progress bar! Simply the fact that a progress bar is shown (so, no animation, no Value set called, nothing of nothing) slows serialport communicatitons. Looks incredible? I've tested this behavior and it's exactly what happens.

    Read the article

  • Is the C++ compiler optimizer allowed to break my destructor ability to be called multiple times?

    - by sharptooth
    We once had an interview with a very experienced C++ developer who couldn't answer the following question: is it necessary to call the base class destructor from the derived class destructor in C++? Obviously the answer is no, C++ will call the base class destructor automagically anyway. But what if we attempt to do the call? As I see it the result will depend on whether the base class destructor can be called twice without invoking erroneous behavior. For example in this case: class BaseSafe { public: ~BaseSafe() { } private: int data; }; class DerivedSafe { public: ~DerivedSafe() { BaseSafe::~BaseSafe(); } }; everything will be fine - the BaseSafe destructor can be called twice safely and the program will run allright. But in this case: class BaseUnsafe { public: BaseUnsafe() { buffer = new char[100]; } ~BaseUnsafe () { delete[] buffer; } private: char* buffer; }; class DerivedUnsafe { public: ~DerivedUnsafe () { BaseUnsafe::~BaseUnsafe(); } }; the explicic call will run fine, but then the implicit (automagic) call to the destructor will trigger double-delete and undefined behavior. Looks like it is easy to avoid the UB in the second case. Just set buffer to null pointer after delete[]. But will this help? I mean the destructor is expected to only be run once on a fully constructed object, so the optimizer could decide that setting buffer to null pointer makes no sense and eliminate that code exposing the program to double-delete. Is the compiler allowed to do that?

    Read the article

  • How to make code run a certain amount of times before returning something?

    - by user3564967
    I made a trivia game and I have to make a method (SuccessOrFail) that will return whether the user beat the trivia or not. namespace D4 { /// <summary> /// Displays the trivia and returns whether the user succeeded or not, number of questions asked, and a free piece of trivia. /// </summary> public partial class TriviaForm : Form { private Trivia trivia; private Question question; private Random rand = new Random(); private HashSet<int> pickedQuestion = new HashSet<int>(); private string usersAnswer; private int numCorrectAnswers; private int numIncorrectAnswers; public TriviaForm() { InitializeComponent(); this.trivia = new Trivia(); QuestionRandomizer(); QuestionOutputter(); } /// <summary> /// This method will return true if succeeded or false if not. /// </summary> /// <returns>Whether the user got the trivia right or not</returns> public bool SuccessOrFail(bool wumpus) { bool successOrFail = false; int maxQuestions = 3; if (wumpus == true) maxQuestions = 5; int numNeededCorrect = maxQuestions / 2 + 1; if (this.usersAnswer == question.CorrectAnswer.ToString()) numCorrectAnswers++; else numIncorrectAnswers++; if (numCorrectAnswers + numIncorrectAnswers == maxQuestions) { if (numCorrectAnswers == numNeededCorrect) successOrFail = true; else successOrFail = false; numCorrectAnswers = 0; numIncorrectAnswers = 0; return successOrFail; } else return false; } /// <summary> /// This method will output a free answer to the player. /// </summary> public string FreeTrivia() { return question.Freetrivia; } // This method tells the player whether they were correct or not. private void CorrectOrNot() { if (this.usersAnswer == question.CorrectAnswer.ToString()) MessageBox.Show("Correct"); else MessageBox.Show("Incorrect"); } // Displays the questions and answers on the form. private void QuestionOutputter() { this.txtQuestion.Text = question.QuestionText; this.txtBox0.Text = question.Answers[0]; this.txtBox1.Text = question.Answers[1]; this.txtBox2.Text = question.Answers[2]; this.txtBox3.Text = question.Answers[3]; } // Clears the TextBoxes and displays a new random question. private void btnNext_Click(object sender, EventArgs e) { this.usersAnswer = txtAnswer.Text; CorrectOrNot(); this.txtQuestion.Clear(); this.txtBox0.Clear(); this.txtBox1.Clear(); this.txtBox2.Clear(); this.txtBox3.Clear(); this.txtAnswer.Clear(); this.txtAnswer.Focus(); QuestionRandomizer(); QuestionOutputter(); this.txtsuc.Text = SuccessOrFail(false).ToString(); } // Choose a random number and assign the corresponding data to question, refreshes the list if all questions used. private void QuestionRandomizer() { if (pickedQuestion.Count < trivia.AllQuestions.Count) { int random; do { random = rand.Next(trivia.AllQuestions.Count); } while (pickedQuestion.Contains(random)); pickedQuestion.Add(random); this.question = trivia.AllQuestions.ToArray()[random]; if (pickedQuestion.Count == trivia.AllQuestions.ToArray().Length) pickedQuestion.Clear(); } } } } My question is how to make it so that the code asks the user 3 or 5 questions and then returns whether the user won or not? I was wondering if somehow I could make a public void that would just make the form pop up and ask the user 3 to 5 questions and then once it asks the maximum number of questions, to close and then have a method that returns true if the user won, or false if they didn't. But I literally have no idea how to do that. Edit: So I know a for loop can make code run more than once. But the problem I'm having is, is that I don't know how to make it so that the trivia game asks 3 to 5 questions BEFORE returning something.

    Read the article

  • What's the best/easiest way to compare two times in Objective-C?

    - by Andy
    I've got a string representation of a time, like "11:13 AM." This was produced using an NSDateFormatter and the stringFromDate: method. I'd like to compare this time to the current time, but when I use the dateFromString: method to turn the string back into a date, a year, month and day are added - which I don't want. I just need to know if right now is < or the time stored in the string. What's going to be the best way to handle that? Thanks in advance for your help.

    Read the article

  • is there a limit on the number of times navigator.geolocation.getCurrentPostion can be called ?

    - by Raja
    Hi all, This is may not be a true programming question but deals with geolocation Api, hence hoping StackOverflow is the right place for this. I'm calling the navigator.geolocation.getCurrentPosition at every 3 seconds interval. After 10-15 tries the responses stop. So i'm wondering is there a limit on the number of calls being made, Or is it because i'm testing it with a desktop and hence instead of giving back the same response each time the API is waiting for a change of location. Anyone has any experiences to share ? Thanks

    Read the article

  • I've registered my oath about 5 times now, but... (twitteR package R)

    - by user2985989
    I'm attempting to mine twitter data in R, and am having trouble getting started. I created a twitter account, an app in twitter developers, changed the settings to read, write, and access, created my access token, and followed instructions to the letter in registering it: My code: > library(twitteR) > download.file(url="http://curl.haxx.se/ca/cacert.pem", + destfile="cacert.pem") > requestURL <- "https://api.twitter.com/oauth/request_token" > accessURL <- "https://api.twitter.com/oauth/access_token" > authURL <- "https://api.twitter.com/oauth/authorize" > consumerKey <-"my key" #took this part out for privacy's sake > consumerSecret <- "my secret" #this too > twitCred <- OAuthFactory$new(consumerKey=consumerKey, consumerSecret = consumerSecret, requestURL = requestURL, accessURL = accessURL, authURL = authURL) > twitCred$handshake(cainfo="cacert.pem") To enable the connection, please direct your web browser to: https://api.twitter.com/oauth/authorize?oauth_token=zxgHXJkYAB3wQ2IVAeyJjeyid7WK6EGPfouGmlx1c When complete, record the PIN given to you and provide it here: 0010819 > registerTwitterOAuth(twitCred) [1] TRUE > save(list="twitCred", file="twitteR_credentials") And yet, this: > s <- searchTwitter('#United', cainfo="cacert.pem") [1] "Unauthorized" Error in twInterfaceObj$doAPICall(cmd, params, "GET", ...) : Error: Unauthorized I'm about to have a temper tantrum. I'd be extremely grateful if someone could explain to me what is going wrong, or, better yet, how to fix it. Thank you.

    Read the article

  • Scalably processing large amount of comlpicated database data in PHP, many times a day.

    - by Eph
    I'm soon to be working on a project that poses a problem for me. It's going to require, at regular intervals throughout the day, processing tens of thousands of records, potentially over a million. Processing is going to involve several (potentially complicated) formulas and the generation of several random factors, writing some new data to a separate table, and updating the original records with some results. This needs to occur for all records, ideally, every three hours. Each new user to the site will be adding between 50 and 500 records that need to be processed in such a fashion, so the number will not be steady. The code hasn't been written, yet, as I'm still in the design process, mostly because of this issue. I know I'm going to need to use cron jobs, but I'm concerned that processing records of this size may cause the site to freeze up, perform slowly, or just piss off my hosting company every three hours. I'd like to know if anyone has any experience or tips on similar subjects? I've never worked at this magnitude before, and for all I know, this will be trivial to the server and not pose much of an issue. As long as ALL records are processed before the next three hour period occurs, I don't care if they aren't processed simultaneously (though, ideally, all records belonging to a specific user should be processed in the same batch), so I've been wondering if I should process in batches every 5 minutes, 15 minutes, hour, whatever works, and how best to approach this (and make it scalable in a way that is fair to all users)?

    Read the article

  • Alert is showing two times. how to restrict?

    - by Dev
    function test(myObject, flag) { if ( (flag) || ((event.keyCode == 59) || (event.which == 59)) || ((event.keyCode == 44) || (event.which == 44))) {alert(myObject.value);} } function closeWin() {self.close();} --foaram name='test' --textaarea name='textareaName' cols='44' rows='3' onChange='test(this, true);' --onKeyPress='test(this);' onBlur='test(this, true);' ---inpaut type='text' name='textName' --inpaut type='button' name='buttonName' onclick='closeWin();' value='Cancel' --/foarm I have a problem: when input value(e.g: test;) into textareaName field, the test function is always run more one time. Please show me the way can run this only one time.

    Read the article

  • AWK: how to reuse a result NR-times without removing END?

    - by HH
    How can I get all differences, not just one? I want to use the calculated result for each item in the third column. The dilemma is that if I remove END I can print $3 but cannot have ave. If I leave END I have ave but not all differences. awk '{sum+=$3} END {ave=sum/NR} END {print $3-ave}' coriolis_data -0.00964 // I want to see the rest differences, how? coriolis_data .105 0.005 0.9766 0.0001 0.595 0.005 .095 0.005 0.9963 0.0001 0.595 0.005 .115 0.005 0.9687 0.0001 0.595 0.005 .105 0.005 0.9693 0.0001 0.595 0.005 .095 0.005 0.9798 0.0001 0.595 0.005 .105 0.005 0.9798 0.0001 0.595 0.005 .095 0.005 0.9711 0.0001 0.595 0.005 .110 0.005 0.9640 0.0001 0.595 0.005 .105 0.005 0.9704 0.0001 0.595 0.005 .090 0.005 0.9644 0.0001 0.595 0.005

    Read the article

  • Been asked a dozen times, but no luck from what I've read. Prevent Anchor Jumping on page load

    - by jasenmp
    I'm currently working with WP theme that can be found here: sanjay.dmediastudios.com I'm currently using 'smooth scroll' on my page, I'm attempting to have the page smoothly scroll to the requested section when coming from an external link (for instance coming from the blog page takes you to sanjay.dmediastudios.com/#portfolio) from there I want the page to start at the top and THEN scroll to the portfolio section. What's happening is it briefly displays the 'portfolio section' (anchor jump) and THEN resets to the top and scrolls down. It's driving me nuts :(. Here is the code I'm using: Click function for smooth scroll: $(function() { $('.menu li a').click(function() { if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); if (target.length) { $root.animate({ scrollTop: target.offset().top - 75 }, 800, 'swing'); return false; } } }); //end of click function }); The page load function: $(window).on("load", function() { if (location.hash) { // do the test straight away window.scrollTo(0, 0); // execute it straight away setTimeout(function() { window.scrollTo(0, 0); // run it a bit later also for browser compatibility }, 1); } var urlHash = window.location.href.split("#")[1]; if (urlHash && $('#' + urlHash).length) $('html,body').animate({ scrollTop: $('#' + urlHash).offset().top - 75 }, 800, 'swing'); }); Any help would be MUCH appreciated.

    Read the article

  • My Android game runs out of memory when it is closed and opened and couple times.

    - by sirconnorstack
    I have an Android game that has an activity for the menu, and then another activity for the game that creates a SurfaceView and Thread to deal with canvas drawing and game logic. When you exit the game and start it up again too much or if you open and close the keyboard (thus restarting the activity), the game runs out of memory, usually when loading a bitmap: java.lang.OutOfMemoryError: bitmap size exceeds VM budget How can I keep all my images in memory without loading them again when the game changes state, or how can I release them from memory and let them reload when the game is restarted?

    Read the article

  • Is it possible to set different select2 parameters at different times?

    - by ReiMasuro
    From playing around I can see that this code $("#Selected3").select2({ minimumInputLength: 3 }); $("#Selected3").select2({ placeholder: "Show a placeholder" }); will show me the placeholder but remove the minimumInputLength parameters value. Does anyone know a way please that this example could be modified so that the placeholder will be added without losing the minimum..Length value. Any answers will need to allow for the possibility of the statements being in separate files, i.e. one on the page and another in a referenced .js file. I am aware that this would be much easier if I set all the parameters at once, e.g. $("#Selected3").select2({ minimumInputLength: 3, placeholder: "Show a placeholder" }); but I am working within a framework which won't currently allow that. EDIT: For anyone who is willing to give this a shot but doesn't know select2 the library comes from here Select2 on GitHub

    Read the article

  • Can i use a parameter multiple times in the qame query?

    - by djerry
    Hey guys, i was wondering, can a parameter be used more then once in the same query, like this : MySqlParameter oPar0 = new MySqlParameter("e164", MySqlDbType.String); oPar0.Value = user.E164; string sSQL0 = "Delete from callmone.call where (caller=?e164 or called=?e164);"; clsDatabase.ExecuteSQL(sSQL0, oPar0); Is this possible or should i write 2 parameters?

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >