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 generateRandomHexCode(length) { | |
var charSet = "0123456789ABCDEF"; | |
var result = ""; | |
for (var i = 0; i < length; i++) { | |
result += charSet.charAt(Math.floor(Math.random()*charSet.length)); | |
} | |
return result; | |
} |
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 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 bd(binaryString) { | |
return parseInt(binaryString, 2); | |
} | |
function db(num) { | |
return num.toString(2); | |
} | |
function rl(binaryString,l) { | |
var zeros = ""; | |
for (var i = 0; i < l - binaryString.length; i++) { | |
zeros += "0"; |
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 generatePlace(type) { | |
var name = ""; | |
var l = "bcdfghjklmnprstvwxyz"; | |
var v = "aeiou"; | |
var a = ["an","on","al","aph","ah"]; | |
var b = ["or","an","ro","ain","am"]; | |
var c = ["ia","sha","ea","ae","on","ue","a","as","in","na","o","di"]; | |
var d = ["ph","th","sh"]; | |
var sequences = [ |
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
// Crud Permissions | |
function CRUDPermissions () { | |
var self = this; | |
self.CREATE = 8, | |
self.READ = 4, | |
self.UPDATE = 2, | |
self.DELETE = 1, |
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
// "Class" for calculating CRC8 checksums... | |
function CRC8(polynomial) { // constructor takes an optional polynomial type from CRC8.POLY | |
if (polynomial == null) polynomial = CRC8.POLY.CRC8_CCITT | |
this.table = CRC8.generateTable(polynomial); | |
} | |
// Returns the 8-bit checksum given an array of byte-sized numbers | |
CRC8.prototype.checksum = function(byte_array) { | |
var c = 0 |
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
<?php | |
//TODO: implement recursion | |
$rootPath = "\\source\\"; | |
$distPath = "\\public\\"; | |
$componentsPath = "\\components\\"; | |
function insertComponents($targetFilePath, $componentsPath) { | |
$components = array(); | |
$componentFiles = scandir(__DIR__ . $componentsPath); |
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
<?php | |
//start with $ end with ) | |
preg_match_all('/\$.+?(?=\))/', '<p>$test(hello)</p> <p>$test(testing)</p>', $matches, PREG_UNMATCHED_AS_NULL); | |
print_r($matches); | |
/* | |
Array | |
( | |
[0] => Array | |
( | |
[0] => $test(hello |
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 getNoun (str) { | |
var indexOfNoun = RiTa.getPosTags(str,true).indexOf("n"); | |
if (indexOfNoun != -1) { | |
return RiTa.tokenize(str)[indexOfNoun]; | |
} else { | |
return false; | |
} | |
} |
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
// Observable | |
function Observable(val) { | |
var listeners = new Set(); | |
var value; | |
function observable(val) { | |
if (val !== undefined) { | |
value = val; | |
observable.update(val); | |
} |