Skip to content

Instantly share code, notes, and snippets.

View phillipalexander's full-sized avatar

Phillip Alexander phillipalexander

  • Galvanize
  • San Francisco
View GitHub Profile

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

@phillipalexander
phillipalexander / GitBanish.sh
Created August 31, 2013 20:22
Banish a file or directory (and any record of it ever existing) from your git repository
#!/bin/sh
#####################################################################
# Program: git banish
#####################################################################
# Version: 1.0.0
# Date: 2013-08-31 13:08:23
# Author: Phillip Alexander (github.com/phillipalexander)
#
# Notes: See the excelent github article on this topic for more info
# https://help.github.com/articles/remove-sensitive-data
@phillipalexander
phillipalexander / JavaScript.sublime-build
Created August 28, 2013 03:53
Sublime Text 3 JavaScript Build System
{
"cmd": ["node", "$file"]
, "selector": "source.js"
, "path": "/usr/local/bin"
, "working_dir": "$project_path"
, "variants":
[
{
"name": "Run",
"cmd": ["js2coffee", "$file"],
#depends on underscore
_.isConstructor = (thing) ->
if thing.name && thing.name[0].toUpperCase() == thing.name[0]
true
else
false
class Instrumentor
constructor: (namespace) ->
@phillipalexander
phillipalexander / ObjectCreationN8Nstyle.js
Created August 15, 2013 04:43
ObjectCreationN8Nstyle.js
var Stack = function() {
return Object.create(Stack.prototype, {
_storage: { value: [], writable: false, configurable: false }
});
};
Stack.prototype = Object.create(null);
Stack.prototype.add = function(element) {
// ...
copy = function(str, mimetype) {
document.oncopy = function(event) {
event.clipboardData.setData(mimetype, str);
event.preventDefault();
};
document.execCommand("Copy", false, null);
}
#!/bin/bash
for FILE in `find . -name "*.js" -type f -o -path './node_modules' -prune -o -path './components' -prune`
do
if [ -e $FILE ] ; then
COFFEE=${FILE//.js/.coffee}
echo "converting ${FILE} to ${COFFEE}"
js2coffee "$FILE" > "$COFFEE"
else
/**
* Annoying.js - How to be an asshole to your users
*
* DO NOT EVER, EVER USE THIS.
*
* Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com)
* Visit https://gist.github.com/767982 for more information and changelogs.
* Visit http://kilianvalkhof.com/2011/javascript/annoying-js-how-to-be-an-asshole/ for the introduction and weblog
* Check out https://gist.github.com/942745 if you want to annoy developer instead of visitors
*
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh
@phillipalexander
phillipalexander / InjectLib.coffee
Created August 8, 2013 19:39
inject a JS library into the current webpage
injectLib = do ->
scriptSrc = prompt('Source to inject')
head = document.getElementsByTagName('head')
body = document.getElementsByTagName('body')
target = if head? then head else body
scriptEl = document.createElement('script')
scriptEl.src = scriptSrc
target[0].appendChild(scriptEl)
console.log("injected: #{scriptSrc}")