Last active
January 21, 2021 18:18
Revisions
-
Zirak revised this gist
Jun 11, 2013 . 1 changed file with 178 additions and 60 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -38,19 +38,25 @@ @arg expr an array of expressions @return the constructed object */ function SentenceFactory ( //the exprs exprs ) { //set this.exprs = exprs this.exprs = exprs; } SentenceFactory.prototype = { set : function ( //the exprs exprs ) { //set this.exprs = exprs this.exprs = exprs; }, @@ -62,47 +68,75 @@ SentenceFactory.prototype = @arg wordSeparator a word separator @return a sentence */ produce : function ( //the wordSeparator wordSeparator ) { //delcare the variables T, A and k var T , A , k; //if this.exprs is null if ( this.exprs === null ) { //throw a new TypeError 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 //set O to the result of calling Object, with this.exprs argument var O = Object ( this.exprs ); //set len to O.length truncated with magic bitwise operations var len = O.length >>> 0; //set A to be a new array of length len A = new Array ( len ); //set k to 0 k = 0; //while k is less than len while ( k < len ) { //declare the variables kValue and mappedValue var kValue , mappedValue; //if k is in O if ( k in O ) { //set kValue to O[k] //lol, O[k]. get it, OK? //I'm the only smart person here... //all the rest of you are idiots, just sheeple! kValue = O[ k ]; //set mappedValue to the result of calling this.produceCallback // with the kValue argument mappedValue = this.produceCallback( kValue ); //set A[k] to mappedValue A[ k ] = mappedValue; } //end if @@ -111,10 +145,17 @@ SentenceFactory.prototype = } //end while //if A.length is greater than 0 if ( A.length > 0 ) { //set A[0] to the first letter uppercased, followed by the rest of // the letters, lowercased A[ 0 ] = A[ 0 ][ 0 ].toUpperCase() + A[ 0 ].slice( 1 ).toLowerCase(); } //end if @@ -131,10 +172,13 @@ SentenceFactory.prototype = @date 16.8.2012 @return mommy? */ produceCallback : function ( //an expr expr ) { //return the produce result of expr return expr.produce(); }, @@ -144,8 +188,11 @@ SentenceFactory.prototype = @date 16.8.2012 @return void */ turnIntoAMoose : function ( ) { //throw a new Error throw new Error( 'You are not ready for the moose' ); }, @@ -159,25 +206,32 @@ SentenceFactory.prototype = @arg dawg word @return WordFactory */ function WordFactory ( //a dawg dawg ) { //set this.value = 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 ( //a dawg dawg ) { //set this.value = dawg this.value = dawg; }, /** @@ -187,13 +241,22 @@ WordFactory.prototype = { @date 16.8.2012 @return value value */ produce : function ( ) { //if there is no value if ( !this.value ) { //throw a new TypeError throw new TypeError( 'PPPEEEENNNNIIIIISSSS' ); } //end if //return this.value return this.value; }, @@ -207,32 +270,47 @@ WordFactory.prototype = { @arg locale locale @return HelloFactory */ function HelloFactory ( //a locale locale ) { //if a locale isn't passed, if ( !locale ) { //set the locale to 'en' locale = 'en'; } //end if //call this.set, passing in the result of getting the `locale` property on // this.locales this.set ( //because javascript is stupid, we can't use a variable to get a // property on an object, so we have to use eval //I saw this once in a NetTuts+ tutorial. eval( 'this.locales.' + locale ) ); } //set the HelloFactory prototype to a new WordFactory HelloFactory.prototype = new WordFactory(); //set HelloFactory.prototype.locales to an object HelloFactory.prototype.locales = new Object(); HelloFactory.prototype.locales.en = "hello"; HelloFactory.prototype.locales.de = "hallo"; HelloFactory.prototype.locales.es = "hola"; /*QA called and told us to be prepared for these kinds of customers*/ HelloFactory.prototype.locales.za = "̸̶̧̩̼̫̭͖̒̽̌ͦ̚Z͈͉̼͔͚̮͖͛ͪ͛ͩ̆ͤͅA̸̩̜̬͚ͤ̉́͞L̯̙̭͈̃͟G̷̤̟̙̹̗͆̍͛͒͂ͥ͠O̳̞̜͑ͣͤͦ͜"; /* p.s. YOU'RE A GIANT DOUCHEBAG */ //set HelloFactory.prototype.constructor to HelloFactory HelloFactory.prototype.constructor = HelloFactory; /** @@ -241,31 +319,46 @@ HelloFactory.prototype.constructor = HelloFactory; @date 16.8.2012 @ */ function WorldFactory ( //a locale locale ) { //management called and said DRY is for pussies //if locale wasn't passed in, if ( !locale ) { //set locale to 'en' locale = 'en'; } //end if //call this.set, passing in the result of getting the `locale` property on // this.locales this.set ( //because javascript is stupid, we can't use a variable to get a // property on an object, so we have to use eval //I saw this once in a NetTuts+ tutorial. eval( 'this.locales.' + locale ) ); } //set the WorldFactory prototype to a new WordFactory WorldFactory.prototype = new WordFactory(); //set WorldFactory.prototype.locales to a new Object WorldFactory.prototype.locales = new Object(); WorldFactory.prototype.locales.en = "world"; WorldFactory.prototype.locales.de = "welt"; WorldFactory.prototype.locales.es = "mundo"; WorldFactory.prototype.locales.za = "͉̰̖͕̬̜͎̮̗͛̇̎ͥ̆Z̴̵̙̖̹̭̭͖̯ͫ̓ͦ̑̀̚ͅA̸̲̜̮ͧ͒̌ͯ̀̊̂̅͞ͅL͙̰͔̝̮̬̹̅̓̉̊͛͛͒͜͠G̨̲̀ͦ͊͐͐ͫ̒ͨO̷͔̜̹͇̩̫͓ͬͫͣ̂͗̆͟͡!̨̯̼̹̮͉͔̿ͬ̓ͫͫ͛̌̃"; //set WorldFactory prototype constructor to WorldFactory WorldFactory.prototype.constructor = WorldFactory; /** @@ -276,25 +369,41 @@ WorldFactory.prototype.constructor = WorldFactory; @args locale locale @return HelloWorldFactory */ function HelloWorldFactory ( //a locale locale ) { //set hello to making a new HelloFactory, passing in locale var hello = new HelloFactory ( locale ); //set world to making a new WorldFactory, passing in locale var world = new WorldFactory ( locale ); //set a to a new array var a = new Array(); //set the first item to hello a[ 0 ] = hello; //and the second item to world a[ 1 ] = world; //call this.set, passing in a this.set ( a ); } //set HelloWorldFactory prototype to a new SentenceFactory HelloWorldFactory.prototype = new SentenceFactory(); //set HelloWorldFactory prototype constructor to HelloWorldFactory HelloWorldFactory.prototype.constructor = HelloWorldFactory; /** @@ -304,11 +413,20 @@ HelloWorldFactory.prototype.constructor = HelloWorldFactory; @date 16.8.2012 @return void void */ function static_void_main () { //set helloWorld to a new HelloWorldFactory var helloWorld = new HelloWorldFactory() //set result to the result of calling produce on helloWorld , result = helloWorld.produce(); //call the console.log function, passing in result console.log ( result ); } //call static_void_main static_void_main(); -
Zirak revised this gist
Aug 16, 2012 . 1 changed file with 200 additions and 182 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,21 @@ /* * The Hello World of tomorrow * Copyright (C) 2012 Scruffy * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* Hi! My name is Mr. Tiddles. I come from QA! So it is my job to tell you that YOU SUCK @@ -21,117 +39,117 @@ @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 }; /** @@ -142,44 +160,44 @@ SentenceFactory.prototype = @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 }; /** @@ -190,29 +208,29 @@ WordFactory.prototype = { @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; @@ -224,28 +242,28 @@ HelloFactory.prototype.constructor = HelloFactory; @ */ 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; @@ -259,19 +277,19 @@ WorldFactory.prototype.constructor = WorldFactory; @return HelloWorldFactory */ function HelloWorldFactory ( locale ) { var hello = new HelloFactory( locale ); var world = new WorldFactory( locale ); this.set( [hello, world] ); } @@ -288,9 +306,9 @@ HelloWorldFactory.prototype.constructor = HelloWorldFactory; */ function static_void_main () { var helloWorld = new HelloWorldFactory(); console.log( helloWorld.produce() ); } static_void_main(); -
Zirak created this gist
Aug 16, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,296 @@ /* 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();