Skip to content

Instantly share code, notes, and snippets.

View icodeforlove's full-sized avatar
:octocat:
Indefinitely In Bangkok

Chad icodeforlove

:octocat:
Indefinitely In Bangkok
View GitHub Profile
var userActivity = [
1.2,
2,
0,
74,
6,
3,
0
];
import flash.display.Loader;
import flash.display.LoaderInfo;
/*
* pull a var from the embed and return it, if there is no param matching the name
* return a default value
*/
function getEmbedParam(name:String, defaultValue:String):String
{
var parameters:Object = LoaderInfo(stage.loaderInfo).parameters;
@icodeforlove
icodeforlove / gist:868532
Created March 13, 2011 23:05
querySelectorAll for anything less than IE8
// IE7 support for querySelectorAll in 226 bytes... It's a little slow but better than a 20kb solution when you need something cross platform and lightweight.
(function(d){d=document,a=d.styleSheets[0]||d.createStyleSheet();d.querySelectorAll=function(e){a.addRule(e,'f:b');for(var l=d.all,b=0,c=[],f=l.length;b<f;b++)l[b].currentStyle.f&&c.push(l[b]);a.removeRule(0);return c}})()
@icodeforlove
icodeforlove / gist:952564
Created May 2, 2011 23:26
node.js basic http.get request
var http = require('http');
http.get(
{
host: 'chadscira.com',
port: 80,
path: '/'
},
function(response) {
var data = '';
@icodeforlove
icodeforlove / each_with_classes.js
Created December 4, 2011 05:43 — forked from burin/each_with_index.coffee
each_with_classes handlebars helper, adds {{item_*}} properties accessible from within the block
/**
* adds an a bunch of item prefixed logic to the object
*
* {{#each_with_classes records prefix="record"}}
* <li class="record_{{item_index}}{{item_position}} {{item_alt}}">{{item_index}}</li>
* {{/each_with_classes}}
*
* results in the following html
*
* <li class="record_0 record_first">0</li>
@icodeforlove
icodeforlove / JSONP.js
Created December 4, 2011 23:17
simple JSONP support
/**
* simple JSONP support
*
* JSONP.get('https://api.github.com/gists/1431613', function (data) { console.log(data); });
* JSONP.get('https://api.github.com/gists/1431613', {}, function (data) { console.log(data); });
*
* gist: https://gist.github.com/gists/1431613
*/
var JSONP = (function (document) {
var requests = 0,
@icodeforlove
icodeforlove / embed.html
Created December 5, 2011 00:21
Working with flash params
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript">
var flashvars = {
name: 'bob'
};
var params = {
menu: 'false',
allowscriptaccess: 'always',
wmode: 'window'
/**
* Copyright (c) Mozilla Foundation http://www.mozilla.org/
* This code is available under the terms of the MIT License
*/
if (!('bind' in Function.prototype)) {
Function.prototype.bind = function(){
var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift();
return function(){ return fn.apply(object, args.concat(Array.prototype.slice.call(arguments))); };
};
}
@icodeforlove
icodeforlove / latest-iphone-sdk-hack.sh
Created March 19, 2012 03:52
enable support for the latest SDK in Snow Leopard without having to upgrade to Lion (blog post: http://chadscira.com/post/4f66b44dbc2f008577000001/iOS-SDK-5-1-on-Snow-Leopard)
# copy the iPhone SDK
sudo cp -R /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
# copy the iPhone Simulator SDK
sudo cp -R /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/
# copy the Device Support folder (replace 9B176 with the latest version that comes with XCode)
sudo cp -R /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/5.1\ \(9B176\) /Developer/Platforms/iPhoneOS.platform/DeviceSupport/
# remove and update the Latest symlink (replace 9B176 with the latest version that comes with XCode)
@icodeforlove
icodeforlove / hack.sh
Created March 31, 2012 18:09 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#