Skip to content

Instantly share code, notes, and snippets.

Avatar

Alan Peabody alanpeabody

  • Burlington, Vermont
View GitHub Profile
View 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 Oct 9, 2012
chef attributes explained via clojure
View chef.clj
(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 Oct 16, 2012
HackVT Rails Template
View railst
#!/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
@alanpeabody
alanpeabody / stack.ex
Created Feb 17, 2013
Elixir stack trace - cowboy
View stack.ex
=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,
@alanpeabody
alanpeabody / dynamo diff
Last active Dec 14, 2015
Dynamo validate path
View dynamo diff
diff --git a/lib/mix/tasks/dynamo.ex b/lib/mix/tasks/dynamo.ex [22/1920]
index b5a268d..8f41e37 100644
--- a/lib/mix/tasks/dynamo.ex
+++ b/lib/mix/tasks/dynamo.ex
@@ -40,9 +40,9 @@ defmodule Mix.Tasks.Dynamo do
[] ->
raise Mix.Error, message: "expected PATH to be given, please use `mix dynamo PATH`"
[path|_] ->
+ path = validate_path(path)
name = opts[:app] || Path.basename(Path.expand(path))
@alanpeabody
alanpeabody / elixir.md
Last active Dec 20, 2015
Code Camp 2013 Proposal
View elixir.md

An Elixir for the Web's Future

The web has evolved; has your tech stack?

The evolution of the web has been fueled by hacks, workarounds, and abuses. This evolution has spawned many tools and techniques along the way. This talk will reflect on the web's history and what it means for the web's future. Armed with this knowledge we will examine the functional programming language Elixir and how its philosophy so perfectly fits the future of the web. The technical part of the talk will examine the architecture and code of an example JavaScript (Backbone?) application using websockets for real time communication and collaboration with an Elixir backend.

Notes:

  • Discuss history and future of web:
@alanpeabody
alanpeabody / timer.rb
Last active Dec 22, 2015
Time how long something take in ruby.
View timer.rb
def time
start = Time.now
yield
stop = Time.now
stop - start
end
# Usage:
time { method_to_test }
View ls
Project@0.0.1 /project_path/
├─┬ browserify@3.19.1
│ ├── assert@1.1.0
│ ├─┬ browser-pack@2.0.1
│ │ ├─┬ combine-source-map@0.3.0
│ │ │ ├── convert-source-map@0.3.3
│ │ │ ├── inline-source-map@0.3.0
│ │ │ └─┬ source-map@0.1.31
│ │ │ └── amdefine@0.1.0
@alanpeabody
alanpeabody / .projections.json
Last active Aug 29, 2015
Ember App Kit & vim-projectile
View .projections.json
{
"app/models/*.js": {
"command": "model",
"template": [ "export default DS.Model.extend({", "});" ]
},
"app/router.js": { "command": "router"},
"app/routes/*.js": {
"command": "route",
"template": [ "export default Ember.Route.extend({", "});" ],
"alternate": "app/controllers/%s.js"
@alanpeabody
alanpeabody / silly_long_elixir_function_pattern_match.ex
Created Dec 3, 2014
silly_long_elixir_function_pattern_match.ex
View silly_long_elixir_function_pattern_match.ex
defmodule Post do
def create(%{title: t, body: b, author_id: a} = atts) when is_binary(t) and is_binary(b) and is_binary(a) do
{:ok, Dict.merge(atts, :id, 1234)}
end
def create(_atts) do
{:error, %{error: "Invalid attributes"}}
end
end