Skip to content

Instantly share code, notes, and snippets.

View kentbrew's full-sized avatar

Kent Brewster kentbrew

View GitHub Profile
@kentbrew
kentbrew / guessmynumber.html
Created February 3, 2011 15:11
In response to Adam Dachis' Lifehacker article, at http://lifehac.kr/ekdUVW
<!doctype html>
<html>
<head>
<title>Guess My Number</title>
</head>
<body>
<h3 id="t"></h3>
<ul id="o"></ul>
<input id="g" />
<button id="b">Guess</button>
@kentbrew
kentbrew / safeScriptInsertion.js
Created February 26, 2011 17:30
Safe Script Tag Insertion
// When a script appends new SCRIPT tags to the HEAD or BODY, it can
// run into serious trouble. If it was originally included in the HEAD, the
// HEAD might not have fully rendered when it fires, and the BODY isn't there yet.
// And if it's in the BODY, older browsers may blow chunks if it tries to append
// SCRIPT tags to the HEAD.
//
// What seems to work: be HEAD/BODY agnostic. Look for the first SCRIPT tag on the
// page and insert before it.
var runScript = function(url) {
@kentbrew
kentbrew / saferDocumentWrite.js
Created March 29, 2011 20:59
Hey, experts? Have I just fixed document.write?
We couldn’t find that file to show.
@kentbrew
kentbrew / behavior.js
Created April 15, 2011 04:35
Placeholders for Everyone
(function (w, d, a) {
var $ = w[a.k] = {};
$.a = a;
$.w = w;
$.d = d;
$.f = (function () {
return {
getEl: function (v) {
// helper: which is the target of this event?
var el;
@kentbrew
kentbrew / Twitter Favorites widget
Created September 28, 2011 21:26
Get your last few Twitter favorites.
// twitter favorites
(function (w, d, a) {
var $ = w[a.el] = {};
$.w = w;
$.d = d;
$.a = a;
$.f = (function () {
return {
listen : function (el, ev, fn) {
@kentbrew
kentbrew / IOS5contacts.txt
Created October 13, 2011 20:15
Recovering Contacts after IOS5 Loses Them
I upgraded to IOS5 last night and turned everything (iCloud, Find My iPhone) on. First thing I noticed this morning was that my contacts were all gone.
If you turned on iCloud and your contacts are missing, try this:
Settings -> iCloud -> Contacts OFF
Keep previously synced iCloud contacts on your phone
(phone will tell you it's turning off iCloud contacts)
Turn Contacts BACK ON
Merge your contacts with iCloud
(phone will tell you it's turning on iCloud contacts)
@kentbrew
kentbrew / chainingFunctionsWithEval.html
Created November 23, 2011 18:39
Chaining JavaScript Functions with Eval
<!doctype html>
<html>
<head><title>Chaining JavaScript Functions with Eval</title></head>
<body>
<p>I was feeling deeply frustrated with my lack of ability to figure out how to do this the Right Way, so here it is in the Wrongest Way Possible.</p>
<script>
var a = function(s) {
@kentbrew
kentbrew / go_sopa_yourself.js
Created January 18, 2012 00:10
Go SOPA Yourself
(function (w, d, a) {
var $ = w[a.k] = {
"a": a, "w": w, "d": d,
"s": {},
"v": {'el': []},
"f": ( function () {
return {
listen : function (el, ev, fn) {
if(typeof $.w.addEventListener !== 'undefined') {
el.addEventListener(ev, fn, false);
@kentbrew
kentbrew / t.js
Created March 4, 2012 05:48
A tiny bookmark hack.
(function(d){alert(d.title);}(document));
@kentbrew
kentbrew / pinterest_embed.html
Created April 2, 2012 23:00
testing Pinterest embed from https
<html>
<head>
<title>Testing</title>
<body>
woo yay
</body>
</html>