Dienstag, 14. April 2009

Sortieralgorithmen

Schicke kleine Seite um Sortieralgorithmen auf verschiedenen Datenmengen zu vergleichen: http://www.sorting-algorithms.com/

Like it? Share it! Flattr this

Freitag, 3. April 2009

Automatically create and insert random profil in web form

A useful Firefox plug-in to fill out form you use often is Autofill Forms.
This powerful tool can easily be modified to create random profiles you maybe need to get a free trial account without losing your privacy.

Install the add-on, open the extended preferences and activate dynamic tags. Then you can use Javascript to insert what you want into the form. Some simple example to create random strings with 8 chars length:

function a(size) {
var s = '';
for (i=1;i < size;i++){
s += String.fromCharCode(Math.floor(Math.random()*25)+97); };
return s;
};
a(8)


If you now add a domain of a provider for instant mail accounts:

function a(size) {
var a = new Array();
a[0]="mailinator2.com"; a[1]="sogetthis.com"; a[2]="mailin8r.com"; a[3]="mailinator.net"; a[4]="spamherelots.com"; a[5]="thisisnotmyrealemail.com";
return "@"+a[Math.floor(Math.random()*a.length)];
};
a(8)


You can define an email field by putting both tags together as value.

The tags are case sensitive so you can also define upper case strings for name:

function a(size) {
var s = String.fromCharCode(Math.floor(Math.random()*25)+65);
for (i=1;i < size;i++){
s += String.fromCharCode(Math.floor(Math.random()*25)+97);
};
return s;
};
a(8)


Of course those names don't look very authentic, but you can extend this:

function r(i){
return String.fromCharCode(Math.floor(Math.random()*25)+i);
};
function voc(){
var v = new Array('a','e','i','o','u');
return v[Math.floor(Math.random()*v.length)];
};
function a(size){
var s = r(65);
for (i=1;i
< size;i+=2){
s += voc()+r(97) };
return s;
};
a(Math.floor(Math.random()*4)+5)


This returns a string where every second letter is a vocal, which looks more readable. Also the first letter is upper case and the length is random. e.g.: Tolepoh, Oeuex, Bukerog
Works find as a last name. Of course a name list would come in handy here a large list would probable not fit in the field. Maybe you can use Ajax technique to load a name from a web page.

Like it? Share it! Flattr this