Skip to content

Instantly share code, notes, and snippets.

@Zirak
Last active January 21, 2021 18:18
Show Gist options
  • Save Zirak/3373067 to your computer and use it in GitHub Desktop.
Save Zirak/3373067 to your computer and use it in GitHub Desktop.
The Hello World of the future
/*
Hi! My name is Mr. Tiddles. I come from QA!
So it is my job to tell you that YOU SUCK
WHY ARE THERE NO UNIT TESTS?
WHY IS YOUR AGILE DRAWING BOARD BLANK!?
BLANK I TELL YOU!
YOU UNGRATEFUL PIECE OF MOTHERFUCKING TURDWAT
I GIVE AWAY MY LIFE TO GIVE YOU AGILE CARDS, AND THIS IS HOW YOU REPAY ME?
FUCK YOU
I DON'T WANT YOUR LAPDANCES
<3,
Mr. Tiddles
*/
/**
@author Scruffy (I'm the janitor)
@description The enterprise solution to your SentenceFactory needs!
@date 16.8.2012
@arg expr an array of expressions
@return the constructed object
*/
function SentenceFactory (
exprs
)
{
this.exprs = exprs;
}
SentenceFactory.prototype =
{
set : function (
exprs
)
{
this.exprs = exprs;
},
/**
@author Scruffy (Life goes on, but I believe we'll forever carry the pain
on the inside)
@description The enterprise solution to your SentenceFactory.prototype.produce needs!
@date 16.8.2012
@arg wordSeparator a word separator
@return a sentence
*/
produce : function (
wordSeparator
)
{
var T, A, k;
if (
this.exprs === null
)
{
throw new TypeError(
"YOU DICK Y U NO PROVIDE EXPRESSIONS AM I TOO FAT NOW FOR " +
"YOU AS WELL!?!?"
/*added per QA request*/
);
}
//end if
var O = Object(
this.exprs
);
var len = O.length >>> 0;
A = new Array(
len
);
k = 0;
while (
k < len
)
{
var kValue, mappedValue;
if (
k in O
)
{
kValue = O[ k ];
mappedValue = this.produceCallback( kValue );
A[ k ] = mappedValue;
}
//end if
k++; //increase k by 1
}
//end while
if ( A.length > 0 )
{
A[ 0 ] =
A[ 0 ][ 0 ].toUpperCase() +
A[ 0 ].slice( 1 ).toLowerCase();
}
//end if
//TODO: consider localization ramifications of amputation by a nation's
// cancellation with violation of the right of pagination all for
// liberation of vegetation accomodation
return A.join( " " );
},
/**
@author Scruffy (The candle that burns twice as bright turns half as long)
@description A produceCallback solution to your SentenceFactory.prototype.produceCallback needs!
@date 16.8.2012
@return mommy?
*/
produceCallback : function (
expr
)
{
return expr.produce();
},
/**
@author Scruffy (It's a mirror into Scruffy's soul)
@description The enterprise solution to all your turnIntoAMoose needs!
@date 16.8.2012
@return void
*/
turnIntoAMoose : function ()
{
throw new Error( 'You are not ready for the moose' );
},
constructor : SentenceFactory
};
/**
@author Scruffy (Don't thank me. Thank the ladder.)
@description The enterprise solution to all your WordFactory needs!
@date 16.8.2012
@arg dawg word
@return WordFactory
*/
function WordFactory (
dawg
)
{
this.value = dawg;
}
WordFactory.prototype = {
/**
@author Scruffy (Scruffy's work here is done.)
@description The enterprise solution to all your set needs!
@date 16.8.2012
@arg dawg word
@return WordFactory
*/
set : function (
dawg
)
{
this.value = dawg;
},
/**
@author Scruffy (I took a regular board, and made it into a divin' board.
Mhrm.
@description The enterprise solution to all your produce needs!
@date 16.8.2012
@return value value
*/
produce : function ()
{
if ( !this.value )
{
throw new TypeError( 'PPPEEEENNNNIIIIISSSS' );
}
//end if
return this.value;
},
constructor : WordFactory
};
/**
@author Scruffy (I'm on break *eats potato chip*)
@description The enterprise solution to all your HelloFactory needs!
@date 16.8.2012
@arg locale locale
@return HelloFactory
*/
function HelloFactory (
locale
)
{
if ( !locale )
{
locale = 'en';
}
//end if
this.set(
this.locales[ locale ]
);
}
HelloFactory.prototype = new WordFactory();
HelloFactory.prototype.locales = {
en : "hello",
de : "hallo",
es : "hola",
/*QA called and told us to be prepared for these kinds of customers*/
za : "̸̶̧̩̼̫̭͖̒̽̌ͦ̚Z͈͉̼͔͚̮͖͛ͪ͛ͩ̆ͤͅA̸̩̜̬͚ͤ̉́͞L̯̙̭͈̃͟G̷̤̟̙̹̗͆̍͛͒͂ͥ͠O̳̞̜͑ͣͤͦ͜"
/* p.s. YOU'RE A GIANT DOUCHEBAG */
};
HelloFactory.prototype.constructor = HelloFactory;
/**
@author Scruffy (Life and death are a seamless continuum)
@description The enterprise solution to your WorldFactory needs!
@date 16.8.2012
@
*/
function WorldFactory (
locale
)
{
//management called and said DRY is for pussies
if ( !locale )
{
locale = 'en';
}
//end if
this.set(
this.locales[ locale ]
);
}
WorldFactory.prototype = new WordFactory();
WorldFactory.prototype.locales = {
en : "world",
de : "welt",
es : "mundo",
za : "͉̰̖͕̬̜͎̮̗͛̇̎ͥ̆Z̴̵̙̖̹̭̭͖̯ͫ̓ͦ̑̀̚ͅA̸̲̜̮ͧ͒̌ͯ̀̊̂̅͞ͅL͙̰͔̝̮̬̹̅̓̉̊͛͛͒͜͠G̨̲̀ͦ͊͐͐ͫ̒ͨO̷͔̜̹͇̩̫͓ͬͫͣ̂͗̆͟͡!̨̯̼̹̮͉͔̿ͬ̓ͫͫ͛̌̃"
};
WorldFactory.prototype.constructor = WorldFactory;
/**
@author Scruffy (What fevered dream is this that bids to tear this company
in twain!?
@description The enterprise solution to all your HelloWorldFactory needs!
@date 16.8.2012
@args locale locale
@return HelloWorldFactory
*/
function HelloWorldFactory (
locale
)
{
var hello = new HelloFactory(
locale
);
var world = new WorldFactory(
locale
);
this.set(
[hello, world]
);
}
HelloWorldFactory.prototype = new SentenceFactory();
HelloWorldFactory.prototype.constructor = HelloWorldFactory;
/**
@author Scruffy (My job. Toilets 'n boilers, boilers 'n toilets. Plus that
one boilin' toilet. Fire me if'n you dare.)
@description The enterprise solution to all your static_void_main needs!
@date 16.8.2012
@return void void
*/
function static_void_main ()
{
var helloWorld = new HelloWorldFactory( 'za' );
document.write( helloWorld.produce() );
}
static_void_main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment