Skip to content

Instantly share code, notes, and snippets.

@STRd6
STRd6 / replicant_generator.coffee
Created November 16, 2013 16:24
Replicant Generator
# Return a function
# that when called returns a string,
# that when evaluated executes the code and returns a function
# .. that when called returns a string,
# .. that when evaluated executes the code and returns a function
# .. ..
replicantGenerator = (code) ->
quine = ->
"""
var code = #{JSON.stringify(code)};
@STRd6
STRd6 / package.json
Created November 29, 2013 16:56
Best way to compile to JS for CoffeeScript NPM packages. `prepublish` should actually be `script/prepublish` but gist doesn't allow for directories :\
...
"devDependencies": {
"coffee-script": "~1.6.3"
},
"files": [
"dist"
],
"scripts": {
"prepublish": "prepublish"
},
@STRd6
STRd6 / rename.js
Created December 5, 2013 21:09
Rename function in JS
var f, rename, renamedFunction;
rename = function(fn, name) {
return Function("fn", "return (function " + name + "(){\n return fn.apply(this, arguments)\n});")(fn);
};
f = function() {};
renamedFunction = rename(f, "a_new_name");
@STRd6
STRd6 / images.json
Created December 6, 2013 04:01
Experimental storing of game data in gists.
{
"new_game": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAC80lEQVRYR8VXz0tUURQ+QqHRohGGaCQiKzAIxH4wIbkpkqCNUCC1adEiUohw0x/RJtpYtHDRphASWiREW0MUTRGCgkqJMBdGs5EEk2m+w3yPM/e9+35NMHczM++ec893v3O+c960SYtXW4vjiwVQBZhjR88FmL6tLYR+cxN22I9bCTYaOwBQM65euVqWyuaGFIqH9Ny5lSXp6Srpb/sc37Foxz0+x97n9Z8hbJUfO1I4vFc+zMwGsRsAnC8fCQ5GcCwAsItgEMDuWTC0JwjYWUCRAGpO1ZvD19SXh7vB5ua/p6IdtyS4KCa8DDAFpBeU8oC6U+qaPTPQ7wWRCgACI2dYScXmQ4UiRFrdVMSmgLSD7maCExRAICV2eQGMjI5qtdvb0zErC5Qz/ZASLjBbex6WIVXA21vUeQE0KKjORKwMcXsY3Ok/Lau/98vX7e1cqSADxzs6pLtzS88q9h4M2A0xQBmiBp6Mj/9XALgBglPi3hRAhlgAMHhyQG/PdtxMCsACAZhe4q+BF5NTOgMul3aVunefZlLr3xrijHvldhmbfK8XOnGpV95Oz1PW0QBYAzjo4f0+Pe/B4+VcAB4NXxC5eEDGRqYDAGjxkSlADUAq9U1l4O7QXw389PWezM3I+uMCZAAAvH2AWoWBTQGVkIcGpPHZ7JKwNXtrwGWAMkT+7TtCFhAoXNw8kwx9fSAuMFotZ739hA8UwIUiRKetsxBfhK4M3X6exAQHmQXhSDGbDG0vTwqOfdYRZcgaMOO9EQBqAMOIjciVoZ3vaQCgl1gZWgBeGfKNiI0I6HdKW/JycV/o1SwJBG564+yfoI8gpb+Ku/o7FgBnASq/71RFlj8W1AmTku99ScGxj46HhTOm3nxRGTI4PiOHEWkCA64MOSfSBCcAV4ZggI2uZhOuAduI3HF8+9b1tLHVbuL5K
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}
@STRd6
STRd6 / nginx.conf.erb
Created January 28, 2014 22:39
Static Heroku nginx buildpack conf
worker_processes 1;
error_log stderr;
pid nginx.pid;
daemon off;
events {
worker_connections 768;
}
http {
@STRd6
STRd6 / gasoline.md
Created February 1, 2014 20:16
Chainsaw Parables

Gasoline

A man drove to the country seeking to understand the power of gasoline. He asked the chemist, "what is the power of gasoline?"

The chemist told him, "pick up this machete and clear an acre of land."

The man wondered what clearing land with a machete had to do with gasoline but did so anyway. Every day for thirty days he ate breakfast and cleared trees with the machete. At the end of thirty days he again asked the chemist "what is the power of gasoline?"

The chemist told him, "pick up this chainsaw and clear an acre of land."

@STRd6
STRd6 / hello.js
Created February 6, 2014 18:29
Testing eval-ing gists.
alert("hello");
#! /usr/bin/env coffee
Heyo
console.log "wat"

Symbol#to_proc is CoffeeScript

A = (name) ->
  (x) ->
    x[name]
items.map A("size")