Weighted random selection
13
Generate a random number or string in PHP.
5
A very simple script to generate random hexa colors.
just modify line 36 to generate more/less colors.
just modify line 36 to generate more/less colors.
6
Method for get n random number's
2
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.
13
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.
11
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
Use: $password = makeRandomPassword($Length);
If $Length is not specified (ie $password = makeRandomPassword();) then it will default to 8 characters
-12
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.
19
inxilpro
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.
1
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
note: this will not override dynamic finders such as find_by_id
8
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
note: I don't believe this reloads items in the libs dir









