Skip to content

Instantly share code, notes, and snippets.

View getify's full-sized avatar
💭
Just coding

Kyle Simpson getify

💭
Just coding
View GitHub Profile
@getify
getify / bar.js
Created August 26, 2011 19:27
how to use LABjs to load nested resources serially, with callbacks
// look ma, I have no dependencies, no need for any wrappers!
alert("bar.js is loaded!");
<!DOCTYPE html>
<html>
<head>
<title>WebSocket test</title>
</head>
<body>
<script src="http://localhost:8080/socket.io/socket.io.js"></script>
<script>
var server = 'smtp.example.com',
port = 587,
// Here is a proposal for minimalist JavaScript classes, humbly offered.
// There are (at least) two different directions in which classes can be steered.
// If we go for a wholly new semantics and implementation, then fancier classical
// inheritance can be supported with parallel prototype chains for true inheritance
// of properties at both the class and instance level.
// If however, we keep current JavaScript prototype semantics, and add a form that
// can desugar to ES3, things must necessarily stay simpler. This is the direction
// I'm assuming here.
@getify
getify / index.html
Created November 23, 2011 18:17
showing how i use $LAB in my pages -- aka, best-practice recommendation
<!DOCTYPE html>
<html>
<head>...</head>
<body>
...
<script src="load.js"></script>
</body>
</html>
@nathansmith
nathansmith / file_input_example.css
Created December 9, 2011 14:56
Markup to Hide a File Input
.fake_file_input {
background: url(../images/fake_file_input.png) no-repeat;
cursor: pointer;
width: 150px;
height: 30px;
overflow: hidden;
position: relative;
display: inline-block;
*display: inline;
*zoom: 1;
@mondaychen
mondaychen / gist:1598350
Created January 12, 2012 03:17 — forked from getify/gist:670840
using LABjs to load from a CDN, with simple error detection (& timeout), and a local load fallback
function loadOrFallback(scripts,idx) {
var successfully_loaded = false;
function testAndFallback() {
clearTimeout(fallback_timeout);
if (successfully_loaded) return; // already loaded successfully, so just bail
try {
scripts.tester();
successfully_loaded = true; // won't execute if the previous "test" fails
scripts.success();
// console.log("success: " + scripts.src[idx]);
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@gasman
gasman / pnginator.rb
Created April 30, 2012 18:08
pnginator: pack Javascript into a self-extracting PNG
#!/usr/bin/env ruby -w
# pnginator.rb: pack a .js file into a PNG image with an HTML payload;
# when saved with an .html extension and opened in a browser, the HTML extracts and executes
# the javascript.
# Usage: ruby pnginator.rb input.js output.png.html
# By Gasman <http://matt.west.co.tt/>
# from an original idea by Daeken: http://daeken.com/superpacking-js-demos
@polotek
polotek / .gitignore
Last active October 5, 2015 13:57
A little wrapper around localStorage that supports compound keys and non-string values
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
@cowboy
cowboy / object-forin-forown.js
Created June 5, 2012 17:34
JavaScript: Object#forIn and Object#forOwn
/*
* Object#forIn, Object#forOwn
*
* Copyright (c) 2012 "Cowboy" Ben Alman
* Licensed under the MIT license.
* http://benalman.com/about/license/
*/
Object.defineProperties(Object.prototype, {
forIn: {