Skip to content

Instantly share code, notes, and snippets.

View pguillory's full-sized avatar

Preston Guillory pguillory

  • Pinterest
  • San Francisco
View GitHub Profile
@pguillory
pguillory / game.ex
Last active February 25, 2016 07:29
defmodule Game do
# Client
def start do
spawn &Game.play/0
end
def move(pid, request) do
send(pid, {:request, self, request})
receive do
@pguillory
pguillory / output.txt
Last active June 14, 2016 16:51
Built-in macros expanding to invalid code
case(:condition) do
x when x in [false, nil] ->
nil
_ ->
:ok
end
case(:condition) do
x when Enum.member?([false, nil], x) ->
nil
_ ->
@pguillory
pguillory / text.md
Last active March 19, 2017 23:39
Internet Explorer quirk: HTML entities in URLs

Try going into your browser console and typing:

window.location = 'http://causes.com/?a=true&not_a=false'

Now look at your address bar. What you see depends on which browser you're using.

Chrome, Firefox: http://www.causes.com/?a=true&not_a=false

@pguillory
pguillory / gist:729616
Created December 5, 2010 23:51
Hooking into Node.js stdout
var util = require('util')
function hook_stdout(callback) {
var old_write = process.stdout.write
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
write.apply(process.stdout, arguments)
callback(string, encoding, fd)
}
I.
THE LIFE AND DEATH OF SCYLD.
{The famous race of Spear-Danes.}
Lo! the Spear-Danes' glory through splendid achievements
The folk-kings' former fame we have heard of,
How princes displayed then their prowess-in-battle.