Skip to content

Instantly share code, notes, and snippets.

View phillipalexander's full-sized avatar

Phillip Alexander phillipalexander

  • Galvanize
  • San Francisco
View GitHub Profile
copy = function(str, mimetype) {
document.oncopy = function(event) {
event.clipboardData.setData(mimetype, str);
event.preventDefault();
};
document.execCommand("Copy", false, null);
}
@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) {
// ...
#depends on underscore
_.isConstructor = (thing) ->
if thing.name && thing.name[0].toUpperCase() == thing.name[0]
true
else
false
class Instrumentor
constructor: (namespace) ->
@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"],
@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

Gist Clients

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

Editor Support

@phillipalexander
phillipalexander / TidyRefs.py
Created October 5, 2013 00:02
Tidy Markdown Refs
#!/usr/bin/python
import sys
import re
'''Read a Markdown file via standard input and tidy its
reference links. The reference links will be numbered in
the order they appear in the text and placed at the bottom
of the file.'''
@phillipalexander
phillipalexander / uri.js
Created October 16, 2013 18:52 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@phillipalexander
phillipalexander / filterFilesinCWD.js
Created January 27, 2014 17:30
filter files in cwd to js files
var util = require('util');
var path = require('path');
var fs = require('fs');
var allFiles = fs.readdirSync(process.cwd())
var jsFiles = [];
for (var i = 0; i < allFiles.length ; i++) {
var selectedFile = allFiles[i];
if (selectedFile.substr(selectedFile.length - 3) === '.js') {
@phillipalexander
phillipalexander / SourceCodeSearchEngines.md
Last active July 8, 2025 18:27
Source Code Search Engines You Can Use For Programming Projects

Source Code Search Engines

NOTE: This list is almost entirely copy/pasted from THIS awesome article. I've made my own personal edits (adding some additional content) which is why I keep it here.

Every day meanpath crawls over 200 million websites capturing the visible text, HTML source code, CSS and Javascript. This information is used by many companies to monitor the growth of web facing technology.