Skip to content

Instantly share code, notes, and snippets.

View charlesetc's full-sized avatar
🪁
Flying kites in NYC

Charles Chamberlain charlesetc

🪁
Flying kites in NYC
View GitHub Profile
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@Ceasar
Ceasar / parse.hs
Created December 1, 2012 22:17
A basic parser written in Haskell. Written as a learning exercise.
import Data.List
-- Evaluate a postfix expression
evalPostfix :: (Num a, Read a) => String -> a
evalPostfix = head . foldl comb [] . words
where
comb (x:y:ys) "*" = (x * y) : ys
comb (x:y:ys) "+" = (x + y) : ys
comb (x:y:ys) "-" = (y - x) : ys
@irrationalistic
irrationalistic / keymap.cson
Last active August 23, 2016 08:24
Vim + Colemak on Atom
# Override Vim Bindings for Colemak
'.editor.vim-mode:not(.command-mode)':
'cmd-k': 'vim-mode:activate-command-mode'
'cmd-shift-k': 'vim-mode:activate-command-mode'
'cmd-h': 'core:move-left'
'cmd-i': 'core:move-right'
'cmd-e': 'core:move-up'
'cmd-n': 'core:move-down'
@daemonfire300
daemonfire300 / email.exs
Created October 13, 2016 12:07
Simple shot at implementing an email validator for use with `Ecto.Changeset`
defmodule YourApp.Validators.Email do
use Ecto.Changeset
@mail_regex ~r/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/
# ensure that the email looks valid
def validate_email(changeset, field) do
changeset
|> validate_format(field, @mail_regex)
end
end