Weighted random selection





ranking Sort Sort   |   date Sort Sort   |   member Sort Sort
Syndication

8
Date Submitted Wed. Oct. 11th, 2006 5:28 PM
Revision 1
Helper jeremec
Tags console | rails | reload | Ruby
Comments 1 comments
When doing a lot of testing in script/console, you often have to reload to pickup changes in DB schema, models and libs. The process of quitting the console and restarting it can become incredibly tedious amidst bugtracking.

note: I don't believe this reloads items in the libs dir
1
Date Submitted Wed. Oct. 11th, 2006 3:08 PM
Revision 1
Helper jeremec
Tags activerecord | find | override | rails | Ruby
Comments 0 comments
From time to time you may have reasons to override the default find method that ActiveRecord provides. In this example, we'll store a side-copy of the record attributes so that we have some basis for discovering changes to the data.

note: this will not override dynamic finders such as find_by_id
19
Date Submitted Mon. Oct. 9th, 2006 10:39 PM
Revision 1
Helper inxilpro
Tags "Random Generation" | Generator | Password | PHP | Random
Comments 2 comments
This function creates relatively secure random passwords. It's by no means ideal, but it should work in most non-critical situations. The nice thing is the generator attempts to create passwords that people can pronounce and chooses letters that won't be mistaken for others (such as the numeral "1", an upper-case "i" and a lower-case "L"). To keep the code short much of this functionality is very rudimentary, but it's better than nothing.
-12
Date Submitted Mon. Oct. 9th, 2006 7:29 AM
Revision 1
Helper BrandonReese
Tags MD5 | Password | PHP | Random
Comments 5 comments
This is a quick and easy method to generate a somewhat random password. This simply generates the MD5 hash for the integer returned by the time() function and then truncates it to the specific length.
11
Date Submitted Mon. Oct. 9th, 2006 4:57 AM
Revision 1
Helper serpentskiss
Tags Password | Random
Comments 1 comments
Creates a random string, usefull for passwords etc.

Use: $password = makeRandomPassword($Length);

If $Length is not specified (ie $password = makeRandomPassword();) then it will default to 8 characters
13
Date Submitted Mon. Oct. 2nd, 2006 1:05 PM
Revision 1
Beginner drench
Tags Array | JavaScript | List | Random | shuffle
Comments 3 comments
It works with Array types. The example is a simple list of numbers, but the array could contain anything; lists of strings, functions, DOM nodes, whatever. Unfortunately, a lot of things that seem like arrays in the DOM aren't really, so you can't shuffle the images on a page with just document.images.shuffle() all by itself.
2
Date Submitted Wed. Aug. 9th, 2006 5:49 AM
Revision 1
Beginner plinge
Tags Ruby | signals | slots
Comments 0 comments
Well, ruby is actually so flexible that there is no real need to implement the goode olde signals & slots metaphor. But it serves nicely as demonstration of ruby properties, so here we go.
6
Date Submitted Sun. Jul. 23rd, 2006 5:39 PM
Revision 1
Helper rugi
Tags Array | Java | Random
Comments 0 comments
Method for get n random number's
5
Date Submitted Fri. Jul. 21st, 2006 4:00 AM
Revision 1
Helper lavaramano
Tags colors | Random
Comments 3 comments
A very simple script to generate random hexa colors.
just modify line 36 to generate more/less colors.
13
Date Submitted Tue. Jul. 11th, 2006 10:34 PM
Revision 1
Coder mattrmiller
Tags Generator | Number | PHP | Random | String
Comments 2 comments
Generate a random number or string in PHP.