Skip to content

Instantly share code, notes, and snippets.

View THEtheChad's full-sized avatar

Chad Elliott THEtheChad

View GitHub Profile
@THEtheChad
THEtheChad / byReference.js
Last active December 31, 2017 03:43
Best overall shuffling algorithm (browser tests only)[https://jsperf.com/array-shuffle-comparator/9] #toolbox
// **WARNING**
// in place (by reference) reordering
// http://stackoverflow.com/a/2450976/1037948
function knuthfisheryates2(arr) {
var temp, j, i = arr.length;
while (--i) {
j = ~~(Math.random() * (i + 1));
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
/**
* "reinitilizes" bootstrap on the jQuery
* object passed in
*
* @param {object} jQuery
* @param {string} url to retrieve the bootstrap source
*/
function bindBootstrap($target, source){
if(!source){
;(function(exports) {
// export the class if we are in a Node-like system.
if (typeof module === 'object' && module.exports === exports)
exports = module.exports = SemVer;
// The debug function is excluded entirely from the minified version.
// Note: this is the semver.org version of the spec that it implements
// Not necessarily the package version of this code.
@THEtheChad
THEtheChad / parse-query.js
Last active December 21, 2016 22:45
Correctly Parse Query String
function parseQuery(q) {
var dec = window.decodeURIComponent;
var hash = {};
//if `q` is `null` or `undefined`, there are no keys
if (q == null) {
return hash;
}
[
{
"_id": 1234,
"picture": "http://www.eonline.com/resize/200/200//eol_images/Entire_Site/201095/300.superman.lc.100510.jpg",
"name": "Superman",
"secret_identity": "Clark Kent",
"superpower": "Being Super",
"likes": 4,
"sidekick": null
},
<table border="0" cellspacing="0" cellpadding="0" width="470" style="width:470px">
<tbody>
<tr valign="top">
<td style="border-right:1px solid #0072b1;padding-right:10px;width:10px">
<img src="https://s3-us-west-2.amazonaws.com/thethechad.misc/thethechad/THEtheChad_Portrait_75x75.jpg" alt="What a handsome mug!" title="What a handsome mug!" style="border-radius:50%;width:74px;min-height:74px;max-width:120px" class="CToWUd"><span class="HOEnZb"><font color="#888888"> </font></span>
</td>
<td style="font:14px Arial;color:#646464;padding-left:10px">
<div>
<b>Chad Elliott</b><br>
</div>
@THEtheChad
THEtheChad / curry.js
Last active August 29, 2015 14:06 — forked from amatiasq/curry.js
/**
* @param {Function} fn Function to curry.
* @param {Number} lenght The arguments required to invoke the function. Optional. By default is fn.length
* @returns {Function} The currified function.
*/
function curry(fn, length) {
length = length || fn.length;
return function currified() {
// Optimization friendly arguments
// naic acts as our placeholder for
// the library we intend to load
naic = [];
// we use the push method on our placeholder
// to build a queue of actions
naic.push(['method1', 'param1', 'param2']);
naic.push(['method2', 'param3', 'param4']);
<?php
// Licence: Do Whatever The Fuck You Want! http://www.wtfpl.net/about/
// Author: Your bro!
$fbAuth = array("facebook_id" => "123456789", "facebook_token" => "<Use charles proxy to do man-in-middle SSL sniffing and extract fb token>");
// Do the magic.
$tinderToken = tinderCall("auth", "token", $fbAuth); // Authenticate
@THEtheChad
THEtheChad / stop.js
Created August 7, 2014 18:09
Not sure what to do? "Stop!" can help you!
function stop(){
var idx = Math.floor(Math.random() * 3);
alert(stop.MAP[idx]);
}
stop.MAP = [
'You should collaborate and listen.',
'It\'s Hammertime!',
'In the name of love.'
];