Search Results

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

Page 122/1194 | < Previous Page | 118 119 120 121 122 123 124 125 126 127 128 129  | Next Page >

  • Most secure way to generate a random session ID for a cookie?

    - by ensnare
    I'm writing my own sessions controller that issues a unique id to a user once logged in, and then verifies and authenticates that unique id at every page load. What is the most secure way to generate such an id? Should the unique id be completely random? Is there any downside to including the user id as part of the unique id?

    Read the article

  • Can't get port based virtual hosts working in Apache2.2 CentOS 5.2, Plesk 8.6

    - by soopadoubled
    I have installed Google Sitemap Generator on my CentOS server, which is running plesk 8.6. Google Sitemap Generator adds an include to an external conf in my httpd.conf as follows: Listen 8181 NameVirtualHost *:8181 <VirtualHost *:8181> DocumentRoot "/usr/local/google-sitemap-generator/admin-console" ScriptAlias /cgi-bin/ "/usr/local/google-sitemap-generator/admin-console/cgi-bin/" <Directory "/usr/local/google-sitemap-generator/admin-console"> Allow from all Options ExecCGI DirectoryIndex index.html </Directory> </VirtualHost> LoadModule google_sitemap_generator_module /usr/local/google-sitemap-generator/lib/mod_sitemap.so After installation I should be able to navigate to myserverip:8181 and access the GSG console. Unfortunately my browser throws up "Safari can’t open the page “http://myserverip:8181/” because the server where this page is located isn’t responding." I've checked the port with netstat and nmap, and it's open and listening. I've added a rule to allow traffic on 8181 in iptables, but no joy. Is there anything obvious I could be missing? Any ideas would be greatly appreciated. Cheers, Ian

    Read the article

  • Error installing new rails version. Failed to build gem native extension.

    - by davidcmolina
    I am trying to build my first ruby on rails app using the following guide (http://ruby.railstutorial.org/chapters/a-demo-app#code-demo_gemfile_sqlite_version_redux) and have run into a few obstacles. The first, receiving errors when upgrading to the latest rails version 3.2.8. bash-3.2$ gem install rails Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension. /Users/davidmolina/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb creating Makefile make compiling generator.c make: /usr/bin/gcc-4.2: No such file or directory make: *** [generator.o] Error 1 Gem files will remain installed in /Users/davidmolina/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5 for inspection. Results logged to /Users/davidmolina/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/ext/json/ext/generator/gem_make.out Even when trying to install from rails app: $ gem install rails Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension. /Users/davidmolina/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb creating Makefile make compiling generator.c make: /usr/bin/gcc-4.2: No such file or directory make: *** [generator.o] Error 1 Gem files will remain installed in /Users/davidmolina/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5 for inspection. Results logged to /Users/davidmolina/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/ext/json/ext/generator/gem_make.out When trying to Bundle Install: $ bundle install Could not locate Gemfile Background details: Mac OS X Version 10.8.2 Ruby 1.9.3 Rails 2.3.4 I'm wondering if there is a direct one-liner or gem that is missing?

    Read the article

  • how to use random bits to simulate a fair 26-sided die?

    - by Michael Levin
    How do I use a random number generator that gives bits (0 or 1) to simulate a fair 26-sided die? I want to use a bitstream to pick letters of the English alphabet such that the odds of any one letter coming up is the same as the odds of any other letter (I know real words aren't like that and have specific frequency distributions for each letter but it doesn't matter here). What's the best way to use binary 0/1 decisions to pick letters fairly from the set A-Z? I can think of a few ways to map bits onto letters but it's not obvious to me that they won't be biased. Is there a known good way?

    Read the article

  • How to use correctly the comments in C/++

    - by Lucio
    I'm learning to program in C and in my stage, the best form to use correctly the comments is writing good comments from the beginning. As the comments are not just for that one understands better the code but others too, I want to know the views of all of you to reach a consensus. So what I want is that the most experienced users edit the following code as you please. (If it's unnecessary, delete it; If it's wrong, correct it; If needed, add more) Thus there'll be multiple answers with different syntax and the responses with the most votes will be taken as referring when commenting. The code to copy, paste and edit to your pleasure is: (And I remark again, just import the comments, not the code) /* This programs find 1 number in 1 file. The file is binary type and has integers in series. The number is integer type and it's entered from the keyboard. When finished the program, a poster will show the results: Saying if the number is in the file or not. */ #include <stdio.h> //FUNCTION 1 //Open file 'path' and closes it. void openf(char path[]) { int num; //Read from Keyboard a Number and it save it into 'num' var printf("Ready for read number.\n\nNumber --> "); fflush(stdin); scanf("%d",&num); //Open file 'path' in READ mode FILE *fvar; fvar=fopen(path,"rb"); //IF error happens when open file, exit of function if (fvar==NULL) { printf("ERROR while open file %s in read mode.",path); exit(1); } /*Verify the result of 'funct' function IF TRUE, 'num' it's in the file*/ if (funct(path,fvar,num)) printf("The number %d it is in the file %s.",num,path); else printf("The number %d it is not in the file %s.",num,path); fclose(fvar); } /*FUNCTION 2 It is a recursive function. Reads number by number until the file is empty or the number is found. Parameters received: 'path' -> Directory file 'fvar' -> Pointer file 'num' -> Number to compare */ int funct(char path[],FILE *fvar,int num) { int compare; //FALSE condition when the pointer reaches the end if (fread(&compare,sizeof(int),1,fvar)>0) /*TRUE condition when the number readed is iqual that 'num' ELSE will go to the function itself*/ if (compare!=num) funct(path,fvar,num); else return 1; else return 0; } int main(int argc, char **argv) { char path[30]="file.bin"; //Direction of the file to process openf(path); //Function with algorithm return 0; }

    Read the article

  • Beginnerquestion: How to count amount of each number drawn in a Lottery and output it in a list?

    - by elementz
    I am writing this little Lottery application. Now the plan is, to count how often each number has been drawn during each iteration of the Lottery, and store this somewhere. My guess is that I would need to use a HashMap, that has 6 keys and increments the value by one everytime the respective keys number is drawn. But how would I accomplish this? My code so far: public void numberCreator() { // creating and initializing a Random generator Random rand = new Random(); // A HashMap to store the numbers picked. HashMap hashMap = new HashMap(); // A TreeMap to sort the numbers picked. TreeMap treeMap = new TreeMap(); // creating an ArrayList which will store the pool of availbale Numbers List<Integer>numPool = new ArrayList<Integer>(); for (int i=1; i<50; i++){ // add the available Numbers to the pool numPool.add(i); hashMap.put(nums[i], 0); } // array to store the lotto numbers int [] nums = new int [6]; for (int i =0; i < nums.length; i++){ int numPoolIndex = rand.nextInt(numPool.size()); nums[i] = numPool.get(numPoolIndex); // check how often a number has been called and store the new amount in the Map int counter = hashMap.get numPool.remove(numPoolIndex); } System.out.println(Arrays.toString(nums)); } Maybe someone can tell me if I have the right idea, or even how I would implement the map properly?

    Read the article

  • What could cause a Labwindows/CVI C program to hate the number 2573?

    - by Adam Bard
    Using Windows So I'm reading from a binary file a list of unsigned int data values. The file contains a number of datasets listed sequentially. Here's the function to read a single dataset from a char* pointing to the start of it: function read_dataset(char* stream, t_dataset *dataset){ //...some init, including setting dataset->size; for(i=0;i<dataset->size;i++){ dataset->samples[i] = *((unsigned int *) stream); stream += sizeof(unsigned int); } //... } Where read_dataset in such a context as this: //... char buff[10000]; t_dataset* dataset = malloc( sizeof( *dataset) ); unsigned long offset = 0; for(i=0;i<number_of_datasets; i++){ fseek(fd_in, offset, SEEK_SET); if( (n = fread(buff, sizeof(char), sizeof(*dataset), fd_in)) != sizeof(*dataset) ){ break; } read_dataset(buff, *dataset); // Do something with dataset here. It's screwed up before this, I checked. offset += profileSize; } //... Everything goes swimmingly until my loop reads the number 2573. All of a sudden it starts spitting out random and huge numbers. For example, what should be ... 1831 2229 2406 2637 2609 2573 2523 2247 ... becomes ... 1831 2229 2406 2637 2609 0xDB00000A 0xC7000009 0xB2000008 ... If you think those hex numbers look suspicious, you're right. Turns out the hex values for the values that were changed are really familiar: 2573 -> 0xA0D 2523 -> 0x9DB 2247 -> 0x8C7 So apparently this number 2573 causes my stream pointer to gain a byte. This remains until the next dataset is loaded and parsed, and god forbid it contain a number 2573. I have checked a number of spots where this happens, and each one I've checked began on 2573. I admit I'm not so talented in the world of C. What could cause this is completely and entirely opaque to me.

    Read the article

  • Your server administrator has limited the number of items you can open simultaneously.

    - by Kez
    I receive the following sync error in Outlook 2007 SP2: Your server administrator has limited the number of items you can open simultaneously. Try closing messages you have opened or removing attachments and images from unsent messages you are composing. It is stopping me updating another user's calendar, which is open within my Outlook. Change are simply not syncing, either way. Is there a fix for this, e.g. increasing the number of permitted connections on the Exchange Server? We are using Exchange Server 2007 on a domain.

    Read the article

  • What does the number after 7-zip's -m switch mean?

    - by AndreKR
    7-zip has a command line switch to set the compression method, -m followed by a number, e.g. -m0=LZMA. What does the number (0 in the example) mean? Different numbers produce slightly different compression results and performance: time 7z -m0=LZMA -mx=9 -ms=on -mmt=off real 0m2.292s user 0m2.190s sys 0m0.080s time 7z -m1=LZMA -mx=9 -ms=on -mmt=off real 0m2.405s user 0m3.240s sys 0m0.070s time 7z -m0=LZMA -mx=9 -ms=on -mmt=on real 0m1.038s user 0m1.920s sys 0m0.150s time 7z -m1=LZMA -mx=9 -ms=on -mmt=on real 0m1.187s user 0m2.800s sys 0m0.130s

    Read the article

  • passing value of index number to different php file.

    - by tooepic
    hi, i am a php beginner and have a question for you please. i have a text file with list of first and last names like this: john,smith sam,lewis david,davidson mike,anderson in my sort.php file, it sorts that name list by first name in ascending order with index number, which will display like this: 1. david,davidson 2. john,smith 3. mike,anderson 4. sam,lewis also, in that sort.php file, there's a form for input type=text where you can type index number and a button to delete that index number entered in that text field: <form action="deletename.php" method="post"> <table> <tr valign="top"> <td>Delete: <input type="text" size="2" name="indexnumber" /> </td> <td> <div align="left"> <input type="submit" name="delete" value="Delete" /> </div> </td> </tr> </table> </form> now the question...is there anything i can do in that form to send the value of that index number i entered in the text field? in other word...if i enter 3, what can i do to that form to send the value "mike,anderson" to deletename.php? thanks in advance.

    Read the article

  • What is the maximum number of virtualhosts Apache can handle?

    - by FractalizeR
    Hello. What is the maximum number of VirtualHosts Apache can handle on a single machine (I don't mean anything related to load, let's suppose it's irrelevant for the question). And we take only Apache without any proxifying things like nginx. I am asking because on one forum one guy reported that his Apache works unstable with the number of sites more than 400 on a single machine. If you have a config, that handles more than 400, please tell me here. Thanks.

    Read the article

  • Windows Server 2008 Scheduled Tasks not running - 0x80041323 - Reduce Number of tasks running in the specified context?

    - by Mayb2Moro
    I am getting the following problem on a number of windows 2008 servers. 0x80041323 Task Scheduler failed to start task \Reporting" in TaskEngine "S-1-5-18:NT AUTHORITY\System:Service:" for user "NT AUTHORITY\System". User Action: Reduce the number of tasks running in the specified user context. I've done lots of research around the web but have been unable to come up with a working answer. I have found some information suggesting increasing a value in the registry key "TasksInMemoryQueue" which I have done, but even setting this as high as 500 has not helped. I have rebooted the server after setting this value. The server does run a high volume of Scheduled tasks, there could be 150 or so running at any one time, but certainly not 500. The scheduled tasks are all running under the system user. Does anyone have any ideas?

    Read the article

  • How to increase the number of items in the "recent" folder in Windows 7?

    - by netvope
    Windows 7 keeps a list of recently used files in C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Recent. Based on my observation, it keeps 10 items for each file extension. So when you So open 11 .txt files in a row, the 2nd to the 11th items will stay in that Recent folder, but the first one will be gone. My question is: How to keep an unlimited number of items in that Recent folder? Note: Increasing the per-application recent items (e.g. as in http://www.mydigitallife.info/2009/05/21/change-increase-or-decrease-number-of-recent-or-frequent-items-displayed-in-windows-7-taskbar-jump-list/ ) has no effect on the per-user Recent item folder that I'm concerning.

    Read the article

  • How does a client find the port number of a server?

    - by Jonathan
    Hello all, I am currently learning about basic networking in java. I have been playing around with the server and client relationship between two of my computers. However, I cannot figure out how distributed programs (say, a videogame), can not only find the 'host' computer, but also the port number on which the server is running in order to create a Socket between the two computers. The only way I really see to create a Socket is with an already known IP Address, and with a known port number. How do you search a LAN network for another computer (host) searching for clients? How do you determine what port the server is located on without 'pinging' all available ports for a response (which, I understand, is bad form... Something about 'server attack'...)? In such a situation as a video game, there can be any number of computers on the same network, and any number of them might be attempting to host, or otherwise running the application. Any other important information, or perhaps reference to a more detailed tutorial than the one I am using, regarding making connections on so very little information on the client side would be appreciated. Many thanks, Jonathan

    Read the article

  • Is there a limit for the number of files in a directory on an SD card?

    - by jamesh
    I have a project written for Android devices. It generates a large number of files, each day. These are all text files and images. The app uses a database to reference these files. The app is supposed to clear up these files after a little use (perhaps after a few days), but this process may or may not be working. This is not the subject of this question. Due to a historic accident, the organization of the files are somewhat naive: everything is in the same directory; a .hidden directory which contains a zero byte .nomedia file to prevent the MediaScanner indexing it. Today, I am seeing an error reported: java.io.IOException: Cannot create: /sdcard/.hidden/file-4200.html at java.io.File.createNewFile(File.java:1263) Regarding the sdcard, I see it has plenty of storage left, but counting $ cd /Volumes/NO_NAME/.hidden $ ls | wc -w 9058 Deleting a number of files seems to have allowed the file creation for today to proceed. Regrettably, I did not try touching a new file to try and reproduce the error on a commandline; I also deleted several hundred files rather than a handful. However, my question is: are there hard limits on filesize or number of files in a directory? am I even on the right track here? Nota Bene: The SD card is as-is - i.e. I haven't formatted it, so I would guess it would be a FAT-* format. The FAT-32 format has hard limits of filesize of 2GB (well above the filesizes I am dealing with) and a limit of number of files in the root directory. I am definitely not writing files in the root directory.

    Read the article

  • (Oracle) How get total number of results when using a pagination query?

    - by BestPractices
    I am using Oracle 10g and the following paradigm to get a page of 15 results as a time (so that when the user is looking at page 2 of a search result, they see records 16-30). select * from ( select rownum rnum, a.* from (my_query) a where rownum <= 30 ) where rnum > 15; Right now I'm having to run a separate SQL statement to do a "select count" on "my_query" in order to get the total number of results for my_query (so that I can show it to the user and use it to figure out total number of pages, etc). Is there any way to get the total number of results without doing this via a second query, i.e. by getting it from above query? I've tried adding "max(rownum)", but it doesn't seem to work (I get an error [ORA-01747] that seems to indicate it doesnt like me having the keyword rownum in the group by). My rationale for wanting to get this from the original query rather than doing it in a separate SQL statement is that "my_query" is an expensive query so I'd rather not run it twice (once to get the count, and once to get the page of data) if I dont have to; but whatever solution I can come up with to get the number of results from within a single query (and at the same time get the page of data I need) should not add much if any additional overhead, if possible. Please advise. Here is exactly what I'm trying to do for which I receive an ORA-01747 error because I believe it doesnt like me having ROWNUM in the group by. Note, If there is another solution that doesnt use max(ROWNUM), but something else, that is perfectly fine too. This solution was my first thought as to what might work. SELECT * FROM (SELECT r.*, ROWNUM RNUM, max(ROWNUM) FROM (SELECT t0.ABC_SEQ_ID AS c0, t0.FIRST_NAME, t0.LAST_NAME, t1.SCORE FROM ABC t0, XYZ t1 WHERE (t0.XYZ_ID = 751) AND t0.XYZ_ID = t1.XYZ_ID ORDER BY t0.RANK ASC) r WHERE ROWNUM <= 30 GROUP BY r.*, ROWNUM) WHERE RNUM > 15

    Read the article

  • How can I lookup data about a book from its barcode number?

    - by Joel Spolsky
    I'm building the world's simplest library application. All I want to be able to do is scan in a book's UPC (barcode) using a typical scanner (which just types the numbers of the barcode into a field) and then use it to look up data about the book... at a minimum, title, author, year published, and either the Dewey Decimal or Library of Congress catalog number. The goal is to print out a tiny sticker ("spine label") with the card catalog number that I can stick on the spine of the book, and then I can sort the books by card catalog number on the shelves in our company library. That way books on similar subjects will tend to be near each other, for example, if you know you're looking for a book about accounting, all you have to do is find SOME book about accounting and you'll see the other half dozen that we have right next to it which makes it convenient to browse the library. There seem to be lots of web APIs to do this, including Amazon and the Library of Congress. But those are all extremely confusing to me. What I really just want is a single higher level function that takes a UPC barcode number and returns some basic data about the book.

    Read the article

< Previous Page | 118 119 120 121 122 123 124 125 126 127 128 129  | Next Page >