Created
September 7, 2011 13:04
-
-
Save vancura/1200503 to your computer and use it in GitHub Desktop.
DMNC Generator (AS2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// org.vancura.util.DmncGenerator | |
// | |
// Created by Václav Vančura on 2007-08-19. | |
// Copyleft (cc) 2007 Václav Vančura (www.Vaclav.Vancura.org). All rights reserved. | |
// | |
import com.gnarlysurf.LoremIpsum; | |
import org.vancura.util.MathExtra; | |
class org.vancura.util.DmncGenerator { | |
public static var CLASSID:String = 'org.vancura.util.DmncGenerator'; | |
// --------------------------------------------- PUBLIC METHODS --------------------------------------------- | |
public static function init() { | |
LoremIpsum.vocabulary = | |
'a,a,a,a,a,a,a,i,i,i,i,i,i,to,to,to,to,' + | |
'je prekérka,ta rozkošnůstka,na browsdadlo,u poče,ten moňák,do baziše,vyjemnit,vymazlit,' + | |
'poblijón,málomoc,nejvíc,skoro,lábuž,řácky,bez fiží,bižu,ten bachor,máš pazdrát,vořešprut,vošťůrák,je hejtypocem,je podržtaška,' + | |
'čupr supr,trupr,mega,můj ty janku na stojánku,kryndypindy,kakraholte,jémináčku,potěškoště,dám si šlofík,čunín,hele,hele,tohle,' + | |
'tamto,toto,šlejška,šlaušek,má živůtek,na negližé,ta halenka,nemá škapulíř,ale,protože,rozhodně,málo,tam,kožnatý,božínku,' + | |
'techtle mechtle,čupr,pirošuk,mičuda,máš čůčo,s klky,bohovský,žok,župánek,cicmat a,cucflek,do cancáku,jářku,s šošolí,' + | |
'to je šlamastyka,s koblehou,s kramflekem,s pidižvíkem,s mušličkou,se šňupákem,tři škopky,žíněnka,je sralbotka,má chlebánek,' + | |
'má šprušli,má žbrlinu,jak štoudev,forychtung,jádřinec,dělá šoufky a,bižule,je fotromat' + | |
'to,a,je,tak,já,ale,že,co,si,jsem,no,už,tam,jak,mi,ty,mám,jo,ne,ten,sem,teď,asi,ti,jako,bude,ještě,i,jen,ok,nebo,taky,hele,' + | |
'něco,bych,me,moc,fakt,nevím,tu,když,toho,ho,pak,nic,máš,pro,nějak,není,až,mne,má,jj,rofl,lol,takže,budu,tím,tom,jsi,nemám,aha,' + | |
'hehe,ani,bylo,jí,super,kde,jestli,tě,byl,dobrý,mít,jsou,musím,ta,dík,mu,měl,zase,jasně,dneska,dost,tohle,třeba,kdy,on,možná,' + | |
'teda,plz,rád,jsme,nějaký,hm,tady,ať,aby,furt,snad,jinak,vůbec,věci,proč,prostě,dobře,úplně,čuz,docela,jdu,než,zatím,někde,večer,' + | |
'budeš,čau,dal,spíš,online,víc,tomu,nějakej,lidi,myslím,tebe,udělat,vím,právě,být,chtěl,můžu,čas,stejně,někdy,den,víš,chci,aspoň,' + | |
'kolik,jde,nemáš,btw,přes,sorry,zítra,práce,test,bejt,protože,my,chceš,všechno,nemůžu,jeden,jojo,hodně,dám,dát,včera,kdo,běž,dej,' + | |
'trošku,hlavně,' + | |
'!,!,!,!,!,?,?,?,?,?,.,.,.,.,.,.,.,.,.,.,:,:,;'; | |
} | |
// --------------------------------------------- GETTERS & SETTERS --------------------------------------------- | |
public static function get randomParagraph():String { | |
return( LoremIpsum.generate( MathExtra.randomBetween( 11, 15 ) ) ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*################################################################## | |
Lorem Ipsum Generator | |
by L. Drolet © 2004 | |
Use at your own risk! | |
USAGE: | |
#import loremIpsum | |
var LI:LoremIpsum = new LoremIpsum(); | |
var sampleString:String = LI.generate(2); //Displays 2 paragraphs (random number of sentences and words) | |
var sampleString:String = LI.generate(10); //Displays 10 paragraphs (random number of sentences and words) | |
var sampleString:String = LI.generate(19); //Displays 19 words | |
var sampleString:String = LI.generate(200); //Displays 200 words | |
Notes: | |
generate(x) | |
x > 10 generates words to the value of x. | |
x < 11 generates paragraphs to the value of x. Sentence count is random in addition to word count. | |
####################################################################*/ | |
class com.gnarlysurf.LoremIpsum { | |
public static var vocabulary:String = "lorem,ipsum,dolor,sit,amet,consectetuer,adipiscing,elit,sed,diam,nonummy,nibh,euismod,tincidunt,ut,laoreet,dolore,magna,aliquam,erat,volutpat,ut,wisi,enim,ad,minim,veniam,quis,nostrud,exerci,tation,ullamcorper,suscipit,lobortis,nisl,ut,aliquip,ex,ea,commodo,consequat,duis,autem,vel,eum,iriure,dolor,in,hendrerit,in,vulputate,velit,esse,molestie,consequat,vel,illum,dolore,eu,feugiat,nulla,facilisis,at,vero,eros,et,accumsan,et,iusto,odio,dignissim,qui,blandit,praesent,luptatum,zzril,delenit,augue,duis,dolore,te,feugait,nulla,facilisi,ut,wisi,enim,ad,minim,veniam,quis,nostrud,exerci,tation,ullamcorper,suscipit,lobortis,nisl,ut,aliquip,ex,ea,commodo,consequat,duis,autem,vel,eum,iriure,dolor,in,hendrerit,in,vulputate,velit,esse,molestie,consequat,vel,illum,dolore,eu,feugiat,nulla,facilisis,at,vero,eros,et,accumsan,et,iusto,odio,dignissim,qui,blandit,praesent,luptatum,zzril,delenit,augue,duis,dolore,te,feugait,nulla,facilisi"; | |
public static function generate(x:Number):String{ | |
var res:String = ""; | |
if(x>10){ | |
res += getWords(x) ; | |
} else { | |
for(var i=0; i<x; i++){ | |
//--Get a random number of sentences-- | |
var s:Number = Math.round( Math.random()*5 ) + 2; | |
for(var z=0; z<s; z++){ | |
//--Get a random number of words-- | |
var w:Number = Math.round( Math.random()*16 ) + 7; | |
res += getWords(w); | |
} | |
//--Add a proceding Line Break except for the last line. Can replace with <p></p> if html enabled | |
res += (i<(x-1)) ? "\r" : ""; | |
} | |
} | |
return res ; | |
} | |
private static function getWords(n):String{ | |
var arrLatin:Array = vocabulary.split(","); | |
var arrLen:Number = arrLatin.length; | |
var res:String = ""; | |
for(var i=0; i<n; i++){ | |
//--Get a random word-- | |
var word:String = arrLatin[ Math.round( Math.random()*arrLen ) ]; | |
//--Capitalize word if at the beginning of the sentence-- | |
if(i==0){ word = word.substr(0,1).toUpperCase() + word.substr(1, word.length-1); } | |
res += word ; | |
if( i<(n-2) ){ | |
//--Randomly add in a comma-- | |
if( Math.round( Math.random()*14 ) == 11){ res += ","; } | |
} | |
//--Add a proceding blank space or period with 2 blank spaces-- | |
res += ( i<(n-1) ) ? " " : ". " ; | |
} | |
return res ; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// org.vancura.util.MathExtra | |
// | |
// Created by Václav Vančura on 2007-08-19. | |
// Copyleft (cc) 2007 Václav Vančura (www.Vaclav.Vancura.org). All rights reserved. | |
// | |
class org.vancura.util.MathExtra { | |
public static var CLASSID:String = 'org.vancura.util.MathExtra'; | |
// --------------------------------------------- PUBLIC METHODS --------------------------------------------- | |
public static function randomBetween( a:Number, b:Number ):Number { | |
return( a + Math.floor( Math.random() * ( b - a + 1 ) ) ); | |
} | |
public static function randomDistribution( max:Number, iterations:Number ):Number { | |
if( iterations == undefined ) iterations = 5; | |
var x:Number = 0; | |
for( var a:Number = 0; a < iterations; a++ ) x += Math.random() * max * 2; | |
return( x / iterations - max ); | |
} | |
// --------------------------------------------- PRIVATE METHODS --------------------------------------------- | |
public static function get flipCoin():Boolean { | |
return( !Math.round( Math.random() ) ); | |
} | |
public static function get quickGUID():Number { | |
return( MathExtra.randomBetween( 1000000, 9999999 ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment