Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
subtleGradient / git-cherry-punch-ext4.sh
Created January 24, 2012 22:42
Convert a Git repo into a new Subversion repo using brute force commit copying
#!/usr/bin/env bash -l
die () {
echo "[ERROR] $@" 1>&2
exit 1
}
GIT_SRC="$HOME/Projects/Sencha/SDK"
GIT_ROOT="$GIT_SRC-copy"
SVN_REPO="$HOME/Projects/Sencha/sdk-svn-repo"
if [[ ! -d "$SVN_REPO" ]]; then
@subtleGradient
subtleGradient / prim.js
Created September 29, 2011 20:38
Minimal Object Pattern
exports.constructor = function(){}
exports.constructor.prototype = exports
exports.create = function(){
return this.constructor.apply(Object.create(this), arguments)
}
exports.property = 'foo'
@subtleGradient
subtleGradient / loadAsyncScript.js
Created August 23, 2011 01:55
Safe loadAsyncScript implementation
function loadAsyncScript(URL) {
var script = document.createElement('script'),
firstScript = document.getElementsByTagName('script')[0];
script.async = 1;
script.src = URL;
firstScript.parentNode.insertBefore(script, firstScript);
}
loadAsyncScript('ext.js');
@subtleGradient
subtleGradient / sortByFoo.js
Created August 3, 2011 02:21
Write the body of the sortByFoo function below
/*
* Write the body of the sortByFoo function below.
* Executing the code must display no warnings in your browser's console.
* i.e. all the assertions must pass
*/
function sortByFoo(array){
// TODO: Write code here. Use Array.sort.
return array;
}
@subtleGradient
subtleGradient / instance config pattern.js
Created July 29, 2011 20:55 — forked from nktpro/gist:1114601
instance config pattern
Ext.define('Ext.SomeThing', {
config: {
foo: {
height: 123,
baz: {
something: 'zzz'
}
},
bar: {
@subtleGradient
subtleGradient / appify
Created July 19, 2011 17:16 — forked from mathiasbynens/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" ]; then cat <<EOF
appify v3.0.0 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh
@subtleGradient
subtleGradient / Object.getPrototypeOf.js
Created June 28, 2011 22:22 — forked from xavierm02/Object.getPrototypeOf.js
Polyfill for Object.getPrototypeOf
if (typeof Object.getPrototypeOf != "function")(function(){
Object.getPrototypeOf =
(typeof "".__proto__ == "object")
? function(object){
return getPrototypeValue(object, '__proto__');
}
: function(object){
return getPrototypeValue(object, 'constructor').prototype;
require({
paths: {
'CoreTest': '../core/Specs/2.0',
'Core': '../core/Source',
'DOM': '../core/Source/DOM',
'More': '../more/Source',
'ART': '../art/Source',
'Slick': '../Slick/Source'
},
ready: function(){
(function Earth(){
var FootBall = new Game('the one you play with your feet with all the running and stuff');
var Canada
(function USA(soccer){
var FootBall = new Game('the one you play with your hands with all the padding and stuff');
Canada = this;
}(FootBall));
@subtleGradient
subtleGradient / Safer Module.example.js
Created June 21, 2011 18:06
Simple JavaScript Module Pattern
function MyClass(){
if (this instanceof MyClass){
this.init.apply(this, arguments);
} else {
MyClass.from(arguments[0])
}
}
MyClass.from = function(object){
// convert object into a MyClass or something