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
// This coder is a dangerous madman who NEVER tests his function output | |
function encryptEmailAddress($emailAddress, $secretKey){ | |
$emailAddress = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, pack('H*', $secretKey), str_repeat(chr(16-(strlen($emailAddress)%16)), (16-(strlen($emailAddress)%16))), MCRYPT_MODE_CBC, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); | |
return strtr(base64_encode($emailAddress), '+/', '-_'); | |
} |
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
/* | |
* fizzbuzz() object | |
* I play the fizzbuzz game (http://en.wikipedia.org/wiki/Fizz_buzz) | |
* | |
* properties: | |
* start - integer (optional, defaults to 1) | |
* finish - integer (optional, defaults to 100) | |
* modFizz - integer (optional, defaults to 3) | |
* modBuzz - integer (optional, defaults to 5) | |
* txtFixx - string (optional, defaults to "fizz") |
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
QUnit.test( "check individual results", function(assert){ | |
for (x = fizzbuzz.start; x <= fizzbuzz.finish; x++) { | |
assert.ok( | |
(results[x] == x) || | |
(results[x] == 'fizz') || | |
(results[x] == 'buzz') || | |
(results[x] == 'fizzbuzz') , "We expect results[x] is equal to x, 'fizz', 'buzz', or 'fizzbuzz.'"); | |
} | |
}); |
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
// before | |
phrase = phrase.replace(/[^a-zA-Z]/g, ""); | |
// after | |
phrase = phrase.match(/[a-zA-Z]/g); | |
phrase = phrase.toString(); | |
phrase = phrase.replace(/[,]/g, ""); |
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
var start, stop, duration; | |
start = new Date(); | |
// the function or method you want to test | |
fizzbuzz.play(); | |
stop = new Date(); | |
duration = stop.getTime() - start.getTime(); | |
console.log( duration + " milliseconds"); |
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
function scytale(d, msg) { | |
var ciphertext = "", baton = []; | |
// wrap blank parchment around baton | |
for (x = 0; x < d; x += 1) { | |
baton[x] = ""; | |
} | |
// write message on wrapped parchment |
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
/** | |
* howManyXinYthruZ.js - solves those annoying "How Many X's Are There In Y Through Z?" puzzles | |
* @type {object} | |
* @namespace | |
*/ | |
var puzzle = { | |
/** | |
* Our variables/properties. No need to assign values, our function does that for us. |
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
<cfscript> | |
/* Sources: | |
http://www.paperthin.com/commonspot/help/api_help/content/invokeviacf.html | |
http://www.paperthin.com/commonspot/help/api_help/content/components/subsite.html | |
*/ | |
subSiteComponent = Server.CommonSpot.api.getObject('Subsite'); | |
aboutUsSubsites = subSiteComponent.getChildSubsites('/about/'); |
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
<!--- | |
credit to Oscar A. Revalo and Simon Bingham | |
see http://www.oscararevalo.com/blog/index.cfm/2008/1/26/CFImage-and-PJPEG-Images for details | |
---> | |
<cffunction name="fixProgressiveJPEG" access="public" returntype="void"> | |
<cfargument name="source" type="string" required="true" /> | |
<cfargument name="filename" type="string" required="true" /> | |
<cfset var oImage="" /> |
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
/** | |
* ChineseZodiac.js - JavaScript object, find Chinese Zodiac animal based on birthyear provided | |
* @type {Object} | |
* @namespace | |
*/ | |
var ChineseZodiac = { | |
/** | |
* animals, array of all 12 animals in the Chinese Zodiac |
OlderNewer