Skip to content

Instantly share code, notes, and snippets.

var RandomNumbers =(function(w){
return {
//l = low
//h = high
GetInt: function (l, h) {
return l + w.Math.floor(Math.random() * (h - l));
},
GetFloat: function (l, h) {
return l + w.Math.random() * (h - l);
}
@WorthyD
WorthyD / 0_reuse_code.js
Created June 2, 2014 02:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
//Should fix any console log issues.
if (!window.console) {
console = {
log: function () { },
time : function () { },
timeEnd : function () { }
}
};
var Cookies = (function (d, w) {
return {
Set: function (cookieName, cookieValue, daysExperation) {
var expires = '',
xpDate = new Date();
if (daysExperation) {
xpDate.setTime(xpDate.getTime() + (daysExperation * 24 * 60 * 60 * 1000));
expires = '; expires=' + xpDate.toUTCString();
}
d.cookie = cookieName + '=' + cookieValue + expires + '; path=/';
@WorthyD
WorthyD / QueryString.js
Last active August 29, 2015 14:01
JavaScript Get Query String
var QueryString =(function(w){
return {
GetVariable: function (variable) {
var query = '',
vars = [],
i = 0,
pair = '';
if (!window.location || !window.location.search) {
//No query string to search.