Skip to content

Instantly share code, notes, and snippets.

View alanpeabody's full-sized avatar

Alan Peabody alanpeabody

View GitHub Profile
@alanpeabody
alanpeabody / plug_authentication.ex
Last active August 29, 2015 14:20
Plug 101 - Part 2
defmodule Authenticate do
import Plug.Conn
def call(conn, _opts) do
case get_req_header(conn, "authorization") do
["Bearer " <> token] -> authenticate(conn, token)
_ -> reject(conn, "Bearer token missing")
end
end
@alanpeabody
alanpeabody / elixir_workshop_ideas.md
Last active August 29, 2015 14:21
Elixir Workshop Ideas

Brown Bag Beers Elixir Workshop

Goal: Get some hands on time playing with Elixir and OTP.

Things to try (pick one!)

0. Generating a new supervised app with mix.

Covers:

  • mix
@alanpeabody
alanpeabody / ja_serializer.ex
Created June 14, 2015 19:20
JSON API serializers - w/o routing
defmodule JaSerializer do
end
@alanpeabody
alanpeabody / 0_README.md
Last active August 29, 2015 14:23
Relax DSL RFC

Relax DSL expansion.

Serialization has been moved to the JaSerializer library with the intent of improving the routing/resource DSL to provide more out of the box functionality.

Goals

  • Super easy to create simple jsonapi.org compliant RESTful APIs.
  • Standard Ecto models need little to no "wiring" to get working.
  • Improved DSL for working with non Ecto models (eg: Mnesia, ETS, Riak, etc)
  • Complete ability to override anything as needed.
@alanpeabody
alanpeabody / a_discussion.md
Last active August 29, 2015 14:26
JaSerializer Serialization Milestones

JaSerializer Roadmap

The initial release of JaSerializer successfully accomplishes it's mission; it serializes data to jsonapi.org format.

Roadmap:

  • Solidify/determine future of the DSL.
  • Better Ecto integration.
  • A Phoenix view integration.
@alanpeabody
alanpeabody / foosball.clj
Created January 12, 2012 18:32
foosball.clj
(defn modfive [number]
(= 0 (mod number 5)))
(defn modthree [number]
(= 0 (mod number 3)))
(defn foosball [number]
(if (modthree number)
(if (modfive number) "foosball" "foos")
(if (modfive number) "ball" number)))
@alanpeabody
alanpeabody / chef.clj
Created October 9, 2012 22:34
chef attributes explained via clojure
(let [env-attributes {:rabbit {:host "blah"}}
role-attributes {:rabbit {:host "blah2"}}
node-attributes {:rabbit {:host "blah3"}}]
(merge env-attributes role-attributes node-attributes))
@alanpeabody
alanpeabody / railst
Created October 16, 2012 23:50
HackVT Rails Template
#!/bin/sh
# Use: Generate rails app from template in rvm gemset named after app.
# wget https://raw.github.com/gist/3902844/railst
# chmod +x railst
# ./railst appname
rvm use 1.9.3
rvm gemset create $1
rvm gemset use $1

(Breakfast) Tacos

This is really a two meal recipe, with my favorite the second meal - breakfast!

You can prepare the meat either on the gril or in a crock pot. If you prepare on the grill buy better steak.

Ingredients

  • Sweet Onion - Diced fine
  • Steak.
@alanpeabody
alanpeabody / stack.ex
Created February 17, 2013 04:26
Elixir stack trace - cowboy
=INFO REPORT==== 16-Feb-2013::23:23:18 ===
application: pascal
exited: {bad_return,
{{'Elixir-Pascal',start,[normal,[]]},
{'EXIT',
{undef,
[{cowboy_router,compile,
[[{'_',[{<<"/">>,'Elixir-Pascal-Handler',[]}]}]],
[]},
{'Elixir-Pascal',start,2,