Skip to content

Instantly share code, notes, and snippets.

View jswhisperer's full-sized avatar
💭
zzz

Gregory The JSWhisperer jswhisperer

💭
zzz
View GitHub Profile
@jswhisperer
jswhisperer / datetime
Created July 25, 2013 08:55
date and time formats
#Format meaning:
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
@jswhisperer
jswhisperer / GeolocationAPI
Created August 25, 2013 19:54
Basic Geolocation API namespaced
var Geo = {};
Geo.positionOptions = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 30000
}
Geo.error = function(positionError) {
var code = positionError.code,
@jswhisperer
jswhisperer / reverseastring
Created August 27, 2013 07:22
Reverse a string in javascript
var aString = "sometext";
reversed = [].slice.call(aString).reverse().join("");
//outputs "txetemos"
@jswhisperer
jswhisperer / localfont
Created September 18, 2013 12:15
Working Draft, Load Fonts from Localhost JQuery
ladumauifont = "data:;base64,AAEAAAANAIAAAwBQRkZUTWZFhywAABSYAAAAHEdERUYASgAGAAAUeAAAACBPUy8yT93diAAAAVgAAABWY21hcDxQKrgAAAIkAAABgmdhc3D//wADAAAUcAAAAAhnbHlm6m2p7QAAA+QAAA5QaGVhZP3fWLsAAADcAAAANmhoZWEEGf/9AAABFAAAACRobXR4NGIDdwAAAbAAAAB0bG9jYSoWLhIAAAOoAAAAPG1heHAAagCzAAABOAAAACBuYW1llh/W/wAAEjQAAAGPcG9zdAYWPZsAABPEAAAArAABAAAAAQAA/DFm718PPPUACwIAAAAAAM5eC/0AAAAAzl4L/f/9/98CBwHlAAAACAACAAAAAAAAAAEAAAHl/98ALgIA//3+AAIHAAEAAAAAAAAAAAAAAAAAAAAdAAEAAAAdALAACwAAAAAAAgAAAAEAAQAAAEAAAAAAAAAAAQH9AZAABQAIAUwBZgAAAEcBTAFmAAAA9QAZAIQAAAIABQMAAAAAAAAAAAABEAAAAAAAAAAAAAAAUGZFZABAACHxZwHg/+AALgHlACGAAAABAAAAAAAAAgAAAAAAAAAAqgAAAAAAAAIAAAACAAAFAgAAAAIAAAACAADcAgAA3AIAADUCAP/+AgAAAAIAALECAACAAgAAAAIAAAACAAAAAgAAAgIAAAICAAANAgAAMAIAAAMCAP//AgAAAAIAAAICAAAFAgAABQG2AAcAAAADAAAAAwAAABwAAQAAAAAAfAADAAEAAAAcAAQAYAAAAAwACAACAAQAAAAw4AfwAPFn//8AAAAAACHgAPAA8Wf//wAAAAAgBBADDrUAAQAAAAoAAAAAAAAAAAANAAwADgAPABAAEQASABMAFAAVABYAFwAYABkAGgAbAAABBgAAAQAAAAAAAAABAgAAAAIAAAAAAAAAAAAAAAAAAAABAAAADQwODxAREhMUFRYXGBkaGwAAAAAAAAAAAAAAAAAAAAAAAAA
@jswhisperer
jswhisperer / prettygitlog
Created October 2, 2013 17:21
Git Log Pretty Formatting
git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
@jswhisperer
jswhisperer / module-pattern.js
Created October 5, 2013 12:39
JS Module Pattern
var batman = (function () {
var identity = "Bruce Wayne";
return {
fightCrime: function () {
console.log("Cleaning up Gotham.");
},
goCivilian: function () {
console.log("Attend social events as " + identity);
@jswhisperer
jswhisperer / NPM install without sudo
Created October 14, 2013 09:53
NPM install without sudo
sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules
var person = {
firstName :"Penelope",
lastName :"Barrymore",
showFullName:function () {
// The "context"
console.log (this.firstName + " " + this.lastName);
}
}
// The "context", when invoking showFullName, is the person object, when we invoke the showFullName () method on the person object.
@jswhisperer
jswhisperer / insertAdjacentHTML javascript.js
Created October 21, 2013 08:05
insertAdjacentHTML javascript
var box2 = document.getElementById("box2");
box2.insertAdjacentHTML('beforebegin', '<div><p>This gets inserted.</p></div>');
//beforebegin
//The HTML would be placed immediately before the element, as a sibling.
//afterbegin
//The HTML would be placed inside the element, before its first child.
//beforeend
//The HTML would be placed inside the element, after its last child.
//afterend
@jswhisperer
jswhisperer / getBoundingClientRect() js.js
Created October 21, 2013 08:09
getBoundingClientRect() js
var box = document.getElementById('box'),
x, y, w;
x = box.getBoundingClientRect().left;
y = box.getBoundingClientRect().top;
w = box.getBoundingClientRect().width; //|| box.offsetWidth;
h = box.getBoundingClientRect().height; // || box.offsetHeight;
console.log(x, y, w, h);