Skip to content

Instantly share code, notes, and snippets.

View GarrettS's full-sized avatar

Garrett Smith GarrettS

View GitHub Profile
@GarrettS
GarrettS / ndaa-flyer
Created January 9, 2012 22:40
NDAA Flyer
[FRONT]
NDAA - Indefinite Detention with no trial.
[/FRONT]
[BACK]
NDAA of 2012
Indefinite Detention with no trial. On Dec 2011, Congress and President Obama passed NDAA 2012. NDAA goes against most of the bill of rights, habeas corpus, and posse comitatus.
Taxpayer Cost: $622 billion
@GarrettS
GarrettS / usurp-tco.js
Created January 29, 2012 18:58
UsurpTCO
function tcoToLinkTitleURL(ev) {
var target = ev.target;
if(/^(http(?:s?):)?\/\/t.co\//.test(target.href) && /^(http(?:s?):)?\/\//.test(target.title)) {
target.href = target.title;
}
}
if(location.hostname == "twitter.com") {
document.addEventListener("mousedown", tcoToLinkTitleURL, true);
}
@GarrettS
GarrettS / usurp-tco.js
Created January 29, 2012 18:58
UsurpTCO
javascript: void(function(){document.addEventListener("mousedown", tcoToLinkTitleURL, true); function tcoToLinkTitleURL(ev) { var target = ev.target; if(/^http(?:s?):\/\/t.co\//.test(target.href)) target.href=target.title; } }());
@GarrettS
GarrettS / tco no
Created June 21, 2012 23:46
tco no
document.addEventListener("mouseover", function(e) {
var t=e.target, u;
if(!t.href) t = t.parentNode;
if(t.href) {
if(t.host=="t.co"){
u=t.getAttribute("data-expanded-url");
if(!u && t.search) {
u=(u=t.search.match(/\burl=(.+)?&/))&&unescape(u[1]);
} else if(!u && t.title.indexOf("http") == 0) {
u = t.title;
@GarrettS
GarrettS / bind
Last active December 26, 2015 10:49
Function.prototype.bind example.
var couple = { m : "Garrett", f : "Tomomi" };
var marriage = function() { console.log(this.f + " is married to " + this.m); };
var status = marriage.bind(couple);
status();
"Tomomi is married to Garrett";
@GarrettS
GarrettS / Prototype Inheritance
Created August 23, 2014 04:01
Prototype Inheritance - extends.
function Car(make) {
this.make = make;
}
Car.prototype.drive = function() {
console.log('driving ' + this.make);
};
@GarrettS
GarrettS / gist:1fb0709bb03e8d5bae25
Created September 4, 2014 00:02
Selectors: findAncestor
function matchesSelector(el, selectorText, ctx) {
var all = (ctx||el.ownerDocument).querySelectorAll(selectorText);
return indexOf(all, el) != -1;
}
function findAncestor(el, selectorText, container) {
if(el == null || el === container)
return null;
var parent = el.parentNode;
@GarrettS
GarrettS / Variable Speed for YouTube
Last active August 27, 2015 17:56
Bookmarklet Variable Speed for YouTube
javascript:var gSpeedControl = (function(v,i,n,t){ n.insertBefore(i, n.firstChild);i.type="range";i.min=.3;setTimeout(function(){i.max=i.value=1;i.oninput();},1); i.step=.05;t=i.nextSibling;i.oninput=function(){t.data=(100*(v.playbackRate=i.value)|0)+"%"};return i})(document.querySelector("video"), document.createElement("input"), document.getElementById("watch-header"))
@GarrettS
GarrettS / YouTube Speed & Pitch
Last active October 17, 2017 06:11
Updated for standalone Video Player and also Framed Tweet Media (Edit Tweet ID)
(
function(v,n) {
var doc = this.contentDocument || document;
if(!v) v = doc.querySelector("video");
if(!v) return;
var fbButtonsDiv = doc.getElementById("fbPhotoPageButtons");
var artistworksDiv = doc.getElementById("playlist0");
@GarrettS
GarrettS / index.html
Last active April 10, 2019 16:18
Max Range Sum — JP Morgan Chase Interview Question // source https://jsbin.com/cikekev
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="JP Morgan Chase Intervew Question">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JP Morgan Chase Intervew Question</title>
</head>
<body>