Skip to content

Instantly share code, notes, and snippets.

View aackerman's full-sized avatar
💻
Working

Aaron Ackerman aackerman

💻
Working
View GitHub Profile
@aackerman
aackerman / lebowski.coffee
Created February 19, 2015 19:44
lebowski.coffee
# Description:
# Get a random quote from The Big Lebowski.
#
# Dependencies:
# "htmlparser": "1.7.6"
# "soupselect": "0.2.0"
# "underscore": "1.3.3"
# "underscore.string": "2.3.0"
_ = require("underscore")
@aackerman
aackerman / index.html
Last active August 29, 2015 14:15
Validate Class properties based on React.PropTypes
<script src="main.js"></script>
@aackerman
aackerman / webpack.config.js
Created February 13, 2015 02:52
Alias react to react/addons
module.exports = {
entry: './main.js',
output: {
filename: 'build.js'
},
resolve: {
alias: {
react: 'react/addons'
}
}
@aackerman
aackerman / rename.js
Last active August 29, 2015 14:12
Rename object keys
function rename(obj, keymap) {
var ret = {};
for (var key in obj) {
if (key in keymap) {
ret[keymap[key]] = obj[key];
} else {
ret[key] = obj[key];
}
}
return ret;
@aackerman
aackerman / isNaN.js
Last active August 29, 2015 14:12
Global isNaN
isNaN({}); // true
isNaN('str'); // true
isNaN(NaN); // true
isNaN('1'); // false
isNaN('NaN'); // true
isNaN([]); // false
isNaN({} + {}); // true
NaN != NaN; // true
@aackerman
aackerman / add.js
Last active August 29, 2015 14:10
ES6 modules with webpack and 6to5
export default function add(...args){
return args.reduce( (a,b) => a + b, 0 )
}
@aackerman
aackerman / output.txt
Last active August 29, 2015 14:10
react/issues/2569
❯ node test.js
MyMixin.componentWillMount
MyComponentWithMyMixin.componentWillMount
<div data-reactid=".1mp0vtdeha8" data-react-checksum="1376071101"><span data-reactid=".1mp0vtdeha8.0">Hello </span><span data-reactid=".1mp0vtdeha8.1">World</span></div>
@aackerman
aackerman / gist:c7569aaada406aa38ab0
Created November 14, 2014 13:58
Detect Global Variables
(function(){
var differences = {},
exceptions,
globals = {},
ignoreList = (prompt('Ignore filter (comma sep)?', '') || '').split(','),
i = ignoreList.length,
iframe = document.createElement('iframe');
while (i--) {
globals[ignoreList[i]] = 1
}
@aackerman
aackerman / hello.go
Created May 9, 2014 16:30
hello http
package main
import (
"net/http"
"fmt"
"log"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request){
@aackerman
aackerman / escape.rb
Last active September 5, 2017 02:09
Escaping a Lucene query in Ruby
RE_ESCAPE_LUCENE = /
( [-+!\(\)\{\}\[\]^"~*?:\\\/] # A special character
| && # Boolean &&
| \|\| # Boolean ||
)
/x
"123-456-7890".gsub(RE_ESCAPE_LUCENE) { |m| "\\#{m}" }