Search Results

Search found 29841 results on 1194 pages for 'random number generator'.

Page 59/1194 | < Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >

  • Need to find number of new unique ID numbers in a MySQL table

    - by Nicholas
    I have an iPhone app out there that "calls home" to my server every time a user uses it. On my server, I create a row in a MySQL table each time with the unique ID (similar to a serial number) aka UDID for the device, IP address, and other data. Table ClientLog columns: Time, UDID, etc, etc. What I'd like to know is the number of new devices (new unique UDIDs) on a given date. I.e. how many UDIDs were added to the table on a given date that don't appear before that date? Put plainly, this is the number of new users I gained that day. This is close, I think, but I'm not 100% there and not sure it's what I want... SELECT distinct UDID FROM ClientLog a WHERE NOT EXISTS ( SELECT * FROM ClientLog b WHERE a.UDID = b.UDID AND b.Time <= '2010-04-05 00:00:00' ) I think the number of rows returned is the new unique users after the given date, but I'm not sure. And I want to add to the statement to limit it to a date range (specify an upper bound as well).

    Read the article

  • Organizing a random list of objects in Python.

    - by Saebin
    So I have a list that I want to convert to a list that contains a list for each group of objects. ie ['objA.attr1', 'objC', 'objA.attr55', 'objB.attr4'] would return [['objA.attr1', 'objA.attr55'], ['objC'], ['objB.attr4']] currently this is what I use: givenList = ['a.attr1', 'b', 'a.attr55', 'c.attr4'] trgList = [] objNames = [] for val in givenList: obj = val.split('.')[0] if obj in objNames: id = objNames.index(obj) trgList[id].append(val) else: objNames.append(obj) trgList.append([val]) #print trgList It seems to run a decent speed when the original list has around 100,000 ids... but I am curious if there is a better way to do this. Order of the objects or attributes does not matter. Any ideas?

    Read the article

  • How to change source order of <div> in less steps/automatically?

    - by metal-gear-solid
    How can i do this task automate. i need to change source order of div, which has same id in above 100 pages. i created example This is default condition <div class="identification"> <div class="number">Number 1</div> </div> <div class="identification"> <div class="number">Number 2</div> </div> <div class="identification"> <div class="number">Number 3</div> </div> <div class="identification"> <div class="number">Number 4</div> </div> <div class="identification"> <div class="number">Number 5</div> </div> <div class="identification"> <div class="number">Number 6</div> </div> I need lik this <div class="identification"> <div class="number">Number 1</div> </div> <div class="identification"> <div class="number">Number 3</div> </div> <div class="identification"> <div class="number">Number 2</div> </div> <div class="identification"> <div class="number">Number 6</div> </div> <div class="identification"> <div class="number">Number 4</div> </div> <div class="identification"> <div class="number">Number 5</div> </div> Is the manual editing only option? I use dreamweaver.

    Read the article

  • Negative number representation across multiple architechture

    - by Donotalo
    I'm working with OKI 431 micro controller. It can communicate with PC with appropriate software installed. An EEPROM is connected in the I2C bus of the micro which works as permanent memory. The PC software can read from and write to this EEPROM. Consider two numbers, B and C, each is two byte integer. B is known to both the PC software and the micro and is a constant. C will be a number so close to B such that B-C will fit in a signed 8 bit integer. After some testing, appropriate value for C will be determined by PC and will be stored into the EEPROM of the micro for later use. Now the micro can store C in two ways: The micro can store whole two byte representing C The micro can store B-C as one byte signed integer, and can later derive C from B and B-C I think that two's complement representation of negative number is now universally accepted by hardware manufacturers. Still I personally don't like negative numbers to be stored in a storage medium which will be accessed by two different architectures because negative number can be represented in different ways. For you information, 431 also uses two's complement. Should I get rid of the headache that negative number can be represented in different ways and accept the one byte solution as my other team member suggested? Or should I stick to the decision of the two byte solution because I don't need to deal with negative numbers? Which one would you prefer and why?

    Read the article

  • Random access view in boost::multi_array

    - by linai
    Here is a boost example: typedef boost::multi_array<double, 1> array_type; typedef array_type::index index; array_type A(boost::extents[100]); for(index i = 0; i != A.size(); ++i) { A[i] = (double)i; } // creating view array_type::index_gen indices; typedef boost::multi_array_types::index_range range; array_type::array_view<1>::type myview = A[ indices[range(0,50)] ]; What this code does is creating a subarray or view mapping onto the original array. This view is continuous and covers from 0th to 50th elements of an original array. What if I need to explicitly define elements I'd like to see in the view? How can I create a view with indices like [1, 5, 35, 23] ? Any ideas?

    Read the article

  • Just a random basic OO javascript qn

    - by Reno Yeo
    I am coding an external Javascript slideshow file, which i want to load and display on my HTML/CSS webpage. How do i go about doing that? I understand that i need to load the .js file in the header of the HTML, but what do i call inside the body's DIV that will make the javascript file understand that i want it to load at that area? I'm extremely confused with working with Javascript here. If anyone has any helpful links to implementing a complete slideshow on a webpage it would be appreciated as well.

    Read the article

  • In SQL can I return a tables with a varying number of columns

    - by Matt
    I have a somewhat more complicated scenario, but I think it should be possible. I have a large SPROC whose result is a set of characteristics for a set of persons. So the Table would look something like this: Property | Client1 Client 2 Client3 ----------------------------------------------------------- Sex | M F M Age | 67 56 67 Income | Low Mid Low It's built using cursors, iterating over different datasets. The problem I am facing is that there is a varying number of Clients and Properties, so an equally valid result over different input sets might be: Property | Client1 Client 2 ------------------------------------------- Sex | M F Age | 67 56 Weight | 122 122 The different number of properties is easy, those are just extra rows. My problem is that I need to declare a temporary table with a varying number of columns. There could be 2 clients or 100. Every client in guaranteed to have every property ultimately listed. What SQL structure would statisfy this and how can I declare it and insert things into it? I can't just flip the columns and rows either because there is a variable number of each.

    Read the article

  • OpenMP: Get total number of running threads

    - by Konrad Rudolph
    I need to know the total number of threads that my application has spawned via OpenMP. Unfortunately, the omp_get_num_threads() function does not work here since it only yields the number of threads in the current team. However, my code runs recursively (divide and conquer, basically) and I want to spawn new threads as long as there are still idle processors, but no more. Is there a way to get around the limitations of omp_get_num_threads and get the total number of running threads? If more detail is required, consider the following pseudo-code that models my workflow quite closely: function divide_and_conquer(Job job, int total_num_threads): if job.is_leaf(): # Recurrence base case. job.process() return left, right = job.divide() current_num_threads = omp_get_num_threads() if current_num_threads < total_num_threads: # (1) #pragma omp parallel num_threads(2) #pragma omp section divide_and_conquer(left, total_num_threads) #pragma omp section divide_and_conquer(right, total_num_threads) else: divide_and_conquer(left, total_num_threads) divide_and_conquer(right, total_num_threads) job = merge(left, right) If I call this code with a total_num_threads value of 4, the conditional annotated with (1) will always evaluate to true (because each thread team will contain at most two threads) and thus the code will always spawn two new threads, no matter how many threads are already running at a higher level. I am searching for a platform-independent way of determining the total number of threads that are currently running in my application.

    Read the article

  • SVG text parameter changing on conversion to image uri : random dy on tspan element

    - by Kitex
    Sorry that I could not compile jsfiddle because it's jsf application hosted locally and code is dependent on data from jsf application. Although I have arrange part of it and part if it as snippet here. Now Everything's correct in Firefox. Suddenly when I open it in chrome something happened. The text on raphael paper suddenly gets scattered in the paper. It's not where it's meant to be. This happens when I convert svg to image and again generate svg. Everything works fine in Firefox. There is chagne id dy of tspan dy=3.09499999 dy=432.0949999999999 Why is there this change in dy although x and y are same? SVG Correct: The fiddle is here. SVG Incorrect: The fiddle is here. function printMap(){ var svg = $('#map').html().replace(/>\s+/g, ">").replace(/\s+</g, "<"); // strips off all spaces between tags canvg('cvs', svg, { ignoreMouse: true, ignoreAnimation: true }); var canvas = document.getElementById('cvs'); var img = canvas.toDataURL("image/png"); $("#resImg").attr("src",img); $("#resImg").css("display",'block'); //$("resImg").css("display",'none'); $("#map").css("display",'none'); // location.href = img; } Before: Text are above the object: After: Texts are scattered:

    Read the article

  • StreamWriter appends random data

    - by void
    Hi I'm seeing odd behaviour using the StreamWriter class writing extra data to a file using this code: public void WriteToCSV(string filename) { StreamWriter streamWriter = null; try { streamWriter = new StreamWriter(filename); Log.Info("Writing CSV report header information ... "); streamWriter.WriteLine("\"{0}\",\"{1}\",\"{2}\",\"{3}\"", ((int)CSVRecordType.Header).ToString("D2", CultureInfo.CurrentCulture), m_InputFilename, m_LoadStartDate, m_LoadEndDate); int recordCount = 0; if (SummarySection) { Log.Info("Writing CSV report summary section ... "); foreach (KeyValuePair<KeyValuePair<LoadStatus, string>, CategoryResult> categoryResult in m_DataLoadResult.DataLoadResults) { streamWriter.WriteLine("\"{0}\",\"{1}\",\"{2}\",\"{3}\"", ((int)CSVRecordType.Summary).ToString("D2", CultureInfo.CurrentCulture), categoryResult.Value.StatusString, categoryResult.Value.Count.ToString(CultureInfo.CurrentCulture), categoryResult.Value.Category); recordCount++; } } Log.Info("Writing CSV report cases section ... "); foreach (KeyValuePair<KeyValuePair<LoadStatus, string>, CategoryResult> categoryResult in m_DataLoadResult.DataLoadResults) { foreach (CaseLoadResult result in categoryResult.Value.CaseLoadResults) { if ((LoadStatus.Success == result.Status && SuccessCases) || (LoadStatus.Warnings == result.Status && WarningCases) || (LoadStatus.Failure == result.Status && FailureCases) || (LoadStatus.NotProcessed == result.Status && NotProcessedCases)) { streamWriter.Write("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\"", ((int)CSVRecordType.Result).ToString("D2", CultureInfo.CurrentCulture), result.Status, result.UniqueId, result.Category, result.ClassicReference); if (RawResponse) { streamWriter.Write(",\"{0}\"", result.ResponseXml); } streamWriter.WriteLine(); recordCount++; } } } streamWriter.WriteLine("\"{0}\",\"{1}\"", ((int)CSVRecordType.Count).ToString("D2", CultureInfo.CurrentCulture), recordCount); Log.Info("CSV report written to '{0}'", fileName); } catch (IOException execption) { string errorMessage = string.Format(CultureInfo.CurrentCulture, "Unable to write XML report to '{0}'", fileName); Log.Error(errorMessage); Log.Error(exception.Message); throw new MyException(errorMessage, exception); } finally { if (null != streamWriter) { streamWriter.Close(); } } } The file produced contains a set of records on each line 0 to N, for example: [Record Zero] [Record One] ... [Record N] However the file produced either contains nulls or incomplete records from further up the file appended to the end. For example: [Record Zero] [Record One] ... [Record N] [Lots of nulls] or [Record Zero] [Record One] ... [Record N] [Half complete records] This also happens in separate pieces of code that also use the StreamWriter class. Furthermore, the files produced all have sizes that are multiples of 1024. I've been unable to reproduce this behaviour on any other machine and have tried recreating the environment. Previous versions of the application didn't exhibite this behaviour despite having the same code for the methods in question. EDIT: Added extra code.

    Read the article

  • PHP - Find a string in file then show it's line number

    - by xZero
    I have an application which needs to open the file, then find string in it, and print a line number where is string found. For example, file example.txt contains few hashes: APLF2J51 1a79a4d60de6718e8e5b326e338ae533 EEQJE2YX 66b375b08fc869632935c9e6a9c7f8da O87IGF8R c458fb5edb84c54f4dc42804622aa0c5 APLF2J51 B7TSW1ZE 1e9eea56686511e9052e6578b56ae018 EEQJE2YX affb23b07576b88d1e9fea50719fb3b7 So, I want to PHP search for "1e9eea56686511e9052e6578b56ae018" and print out its line number, in this case 4. Please note that there are will not be multiple hashes in file. I found a few codes over Internet, but none seem to work. I tried this one: <?PHP $string = "1e9eea56686511e9052e6578b56ae018"; $data = file_get_contents("example.txt"); $data = explode("\n", $data); for ($line = 0; $line < count($data); $line++) { if (strpos($data[$line], $string) >= 0) { die("String $string found at line number: $line"); } } ?> It just says that string is found at line 0.... Which is not correct.... Final application is much more complex than that... After it founds line number, it should replace string which something else, and save changes to file, then goes further processing.... Thanks in advance :)

    Read the article

  • SQL dealing with rubbish in a phone number field

    - by DoctaJonez
    Hello stackers! I've got a wonderfully fun little SQL problem to solve today and thought I'd ask the community to see what solutions you come up with. We've got a really cool email to text service that we use, you just need to send an email to [email protected] and it will send a text message to the desired phone number. For example to send a text to 0790 0006006, you need to send an email to [email protected], pretty neat huh? The problem is with the phone numbers in our database. Most of the phone numbers are fine, but some of them have "rubbish" mixed in with the phone number. Take these wonderful examples of the rubbish you need to deal with (I've anonymised the phone numbers by placing zeroes in): 07800 000647(mobile) 07500 000189 USE 1ST SEE NOTES 07900 000415 HO ONLY try 1st 0770 0000694 then home 07500 000465 Cannot Requirements The solution needs to be in SQL (for MS SQL server). So the challenge is as follows, we need to get the phone number without spaces, and without any of the rubbish seen in the samples. For example: This: try 1st 0770 0000694 then home Should become this: 07700000694 Anything without a phone number in it (e.g. "SEE NOTES") should be null.

    Read the article

  • Error : Number of Rows In Section in UITableView in iPhone SDK

    - by Meghan
    I am getting this error while I am trying to load the data into my table view. Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (73) must be equal to the number of rows contained in that section before the update (71), plus or minus the number of rows inserted or deleted from that section (3 inserted, 0 deleted). What could be wrong? Thanks EDIT : I am initializing the array on ViewWillAppear and adding new objects to the same array on Tableview's didSelectRowAtIndexPath method Here is the code On viewWillAppear : cellTextArray = [[NSMutableArray alloc] init]; [cellTextArray addObjectsFromArray:newPosts]; Here is the code which modifies the array on didSelectRowAtIndexPath : [cellTextArray addObjectsFromArray:newPosts]; NSMutableArray *insertIndexPaths = [NSMutableArray array]; for (NSUInteger item = count; item < count + newCount; item++) { [insertIndexPaths addObject:[NSIndexPath indexPathForRow:item inSection:0]]; } [self.table beginUpdates]; [self.table insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade]; [self.table endUpdates]; [self.table scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionNone animated:YES]; NSIndexPath *selected = [self.table indexPathForSelectedRow]; if (selected) { [self.table deselectRowAtIndexPath:selected animated:YES]; } Here newPosts is an array which has the values that are added to cellTextArray on didSelectRowAtIndexPath method and viewWillAppear method.

    Read the article

  • Random selection in jQuery

    - by danit
    Im using the following function to hide a series of forms on a page: $('.ask').toggle(function() { $(this).text('-').next('.addtitle').slideDown('fast'); }, function() { $(this).text('+').next('.addtitle').slideUp('fast'); }); There can be anything from 0 to 5 forms on the page all with the class .ask What I want to be able to do is to select one form NOT to hide, so the jQuery needs to hide all put one of the forms on the page randomly. How can I achieve this?

    Read the article

  • NUnit Test Case Code Generator Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information

    - by user1732969
    im trying to load an assembly nunit created in Monodevelop Im using the software NUnit Test Case Code Generator for create unit testing http://www.codeproject.com/Articles/28461/NUnit-Test-Case-Code-Generator After compiling the project in MonoDevelop, loading file .dll of the proyect in Nunit Test case generator the following error appears: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Can you help me?

    Read the article

  • unique random id

    - by Piyush
    I am generating unique id for my small application but I am facing some variable scope problem. my code- function create_id() { global $myusername; $part1 = substr($myusername, 0, -4); $part2 = rand (99,99999); $part3 = date("s"); return $part1.$part2.$part3; } $id; $count=0; while($count == 1) { $id; $id=create_id(); $sqlcheck = "Select * FROM ruser WHERE userId='$id';"; $count =mysql_query($sqlcheck,$link)or die(mysql_error()); } echo $id; I dont know which variable I have to declare as global

    Read the article

  • PC boot: dl register and drive number

    - by kikou
    I read somewhere in the internet that, before jumping to 0x7c00, the BIOS loads into %dl the "drive number" of the booted device. But what is this "drive number"? Each device attached to the computer is assigned a number by the BIOS? If so, how can I know which number is a given device assigned to? Reading GRUB's source code I found when %dl has bits 0x80 and 0x70 set, it overwrites the whole register with 0x80. Why is that? Here is the code: jmp 3f /* grub-setup may overwrite this jump */ testb $0x80, %dl jz 2f 3: /* Ignore %dl different from 0-0x0f and 0x80-0x8f. */ testb $0x70, %dl jz 1f 2: movb $0x80, %dl 1: By the way. Is there any detailed resource on the boot process of PC's in the web? Specially about what the BIOS does before giving the control to the bootloader and also the standard codes used to communicate with it (like that "drive numer"). I was hoping to write my own bootloader and everything I found is a bit too vague, not technical enough to the point of informing of the exact state of the computer when my bootloader starts to run.

    Read the article

  • Random RAM usage amounts

    - by DTown
    I was hoping someone could explain why my application when loaded uses varying amounts of RAM. I'm speaking about a compiled version that uses the exe directly. It's a pretty basic applications and there are no conditional branches in the startup of the application. Yet every time I start it up the RAM amount varies from 6MB-16MB. I know it's on the small end of usage anyways but I'm curious of why this happens.

    Read the article

  • R: Given a set of random numbers drawn from a continuous univariate distribution, find the distribut

    - by knorv
    Given a set of real numbers drawn from a unknown continuous univariate distribution (let's say is is one of beta, Cauchy, chi-square, exponential, F, gamma, Laplace, log-normal, normal, Pareto, Student's t, uniform and Weibull).. x <- c(15.771062,14.741310,9.081269,11.276436,11.534672,17.980860,13.550017,13.853336,11.262280,11.049087,14.752701,4.481159,11.680758,11.451909,10.001488,11.106817,7.999088,10.591574,8.141551,12.401899,11.215275,13.358770,8.388508,11.875838,3.137448,8.675275,17.381322,12.362328,10.987731,7.600881,14.360674,5.443649,16.024247,11.247233,9.549301,9.709091,13.642511,10.892652,11.760685,11.717966,11.373979,10.543105,10.230631,9.918293,10.565087,8.891209,10.021141,9.152660,10.384917,8.739189,5.554605,8.575793,12.016232,10.862214,4.938752,14.046626,5.279255,11.907347,8.621476,7.933702,10.799049,8.567466,9.914821,7.483575,11.098477,8.033768,10.954300,8.031797,14.288100,9.813787,5.883826,7.829455,9.462013,9.176897,10.153627,4.922607,6.818439,9.480758,8.166601,12.017158,13.279630,14.464876,13.319124,12.331335,3.194438,9.866487,11.337083,8.958164,8.241395,4.289313,5.508243,4.737891,7.577698,9.626720,16.558392,10.309173,11.740863,8.761573,7.099866,10.032640) .. is there some easy way in R to programmatically and automatically find the most likely distribution and the estimated distribution parameters?

    Read the article

  • Random begining index iterator for HashSet

    - by funktku
    I use HashSet for add(); remove(); clear(); iterator(); methods. So far everything worked like a charm. However, now I need to fulfill a different requirement. I'd like to be able to start iterating from a certain index. For example, I'd like the following two programs to have same output. Program 1 Iterator it=map.iterator(); for(int i=0;i<100;i++) { it.next(); } while (it.hasNext()) { doSomethingWith(it.next()); } Program 2 Iterator it=map.iterator(100); while (it.hasNext()) { doSomethingWith(it.next()); } The reason I don't want to use the Program 1 is that it creates un-neccesary overhead. From my researchs, I couldn't not find a practical way of creating an iterator with begining index. So, my question is, what would be a good way to achieve my goal while minimizing the overheads? Thank you.

    Read the article

  • Getting the current item number or index when using will_paginate in rails app

    - by Rich
    I have a rails app that stores movies watched, books read, etc. The index page for each type lists paged collections of all its items, using will_paginate to bring back 50 items per page. When I output the items I want to display a number to indicate what item in the total collection it is. The numbering should be reversed as the collection is displayed with most recent first. This might not relate to will_paginate but rather some other method of calculation. I will be using the same ordering in multiple types so it will need to be reusable. As an example, say I have 51 movies. The first item of the first page should display: Fight Club - Watched: 30th Dec 2010 Whilst the last item on the page should display: The Matrix - Watched: 3rd Jan 2010 The paged collection is available as an instance variable e.g. @movies, and @movies.count will display the number of items in the paged collection. So if we're on page 1, movies.count == 50, whilst on page 2 @movies.count == 1. Using Movie.count would give 51. If the page number and page size can be accessed the number could be calculated so how can they be returned? Though I'm hopeful there is something that already exists to handle this calculation!

    Read the article

  • Random Loss of precision in Python ReadLine()

    - by jackyouldon
    Hi all, We have a process which takes a very large csv (1.6GB) and breaks it down into pieces (in this case 3). This runs nightly and normally doesn't give us any problems. When it ran last night, however, the first of the output files had lost precision on the numeric fields in the data. The active ingredient in the script are the lines: while lineCounter <= chunk: oOutFile.write(oInFile.readline()) lineCounter = lineCounter + 1 and the normal output might be something like StringField1; StringField2; StringField3; StringField4; 1000000; StringField5; 0.000054454 etc. On this one occasion and in this one output file the numeric fields were all output with 6 zeros at the end i.e. StringField1; StringField2; StringField3; StringField4; 1000000.000000; StringField5; 0.000000 We are using Python v2.6 (and don't want to upgrade unless we really have to) but we can't afford to lose this data. Does anyone have any idea why this might have happened? If the readline is doing some kind of implicit conversion is there a way to do a binary read, because we really just want this data to pass through untouched? It is very wierd to us that this only affected one of the output files generated by the same script, and when it was rerun the output was as expected. thanks Jack

    Read the article

  • 'Random' Orderby in webservice using LINQ To Entities

    - by MrDean
    Morning all Now I know there is a reason to this odering but my tiny little brain can't get my head around it. I am using a webservice to pull through data to a webp[age and have the following that is so far pulling data through from UUF1: public string[] GetBuyer(string Memberkey) { try { WebService.EntitiesConnection buyer = new WebService.EntitiesConnection(); return buyer.tblProducts .Where(p => p.MemberId == Memberkey) .OrderBy(p => p.UnitUserfield1) .Select(p => p.UnitUserfield1) .Distinct() .ToArray(); } catch (Exception) { return null; } } This works fine and pulls the data through but in a strange order. Where I would expect results of A B C D E F, it appears to be returning A C E B D F. Could someone point out the error in my ways please?

    Read the article

< Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >