Skip to content

Instantly share code, notes, and snippets.

🤙

pete gamache gamache

Block or report user

Report or block gamache

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gamache
gamache / safe_task.ex
Created Mar 24, 2016
SafeTask proof of concept: make a Task's raises, throws, and exits happen locally
View safe_task.ex
defmodule SafeTask do
def async(func) do
safe_func = fn ->
try do
{:ok, func.()}
rescue
e -> {:error, e}
catch
:exit, x -> {:exit, x}
t -> {:throw, t}
@gamache
gamache / language-and-locale-codes.json
Created Mar 14, 2016
Language (`xx`) and locale identifier (`xx-yy`) codes, in JSON format
View language-and-locale-codes.json
[
{"desc": "Abkhaz", "code": "ab"},
{"desc": "Afar", "code": "aa"},
{"desc": "Afrikaans", "code": "af"},
{"desc": "Akan", "code": "ak"},
{"desc": "Albanian", "code": "sq"},
{"desc": "Amharic", "code": "am"},
{"desc": "Arabic", "code": "ar"},
{"desc": "Aragonese", "code": "an"},
{"desc": "Armenian", "code": "hy"},
@gamache
gamache / conntest_example.ex
Last active Jan 27, 2016
Phoenix.ConnTest appears not to pass request body to controller
View conntest_example.ex
# router.ex
defmodule Myapp.Router do
use Myapp.Web, :router
pipeline :api do
plug :accepts, ["json"]
end
scope "/", Myapp do
pipe_through :api
@gamache
gamache / validating.md
Last active Jan 16, 2018
Validating Data in Elixir with ExJsonSchema
View validating.md

priv/schema.json

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Events API Schema",

  "definitions": {

    "event_collection": {
View ExUnit runs tests in separate processes
# test/myapp_test.exs
defmodule MyAppTest do
use ExUnit.Case
test "the truth" do
IO.inspect self
assert 1 + 1 == 2
end
test "the whole truth" do
View gist:65232738d68d398784d2
### Keybase proof
I hereby claim:
* I am gamache on github.
* I am gamache (https://keybase.io/gamache) on keybase.
* I have a public key ASApD3qhoE9_IY1NmZwNBQgR9Rs1_DrrYoSw7eQkd1F3Wgo
To claim this, I am signing this object:
View gist:ecac725483aced9789b5
### Keybase proof
I hereby claim:
* I am gamache on github.
* I am gamache (https://keybase.io/gamache) on keybase.
* I have a public key whose fingerprint is 1E3A D3A7 A62D 5CEE 5EFE C0AB 1C59 EDEE 13C6 C4F9
To claim this, I am signing this object:
@gamache
gamache / gist:190c1efc7184b856a2b1
Created Jun 4, 2014
fixing Homebrew on OS X Yosemite
View gist:190c1efc7184b856a2b1

This worked for me.

  1. Change the first line of /usr/local/Library/brew.rb to: #!/usr/bin/env ruby.
  2. cd $(brew --repository)
  3. git commit -am 'use env ruby'.
  4. OLD_REF = $(git log | head -1 | sed 's/commit //')
  5. git reset --hard HEAD^
  6. git checkout $OLD_REF
  7. brew update
@gamache
gamache / gist:6962760
Last active Dec 25, 2015
Running method-cache-test on MRI Ruby 2.1.0dev.
View gist:6962760
$ ruby --version
ruby 2.1.0dev (2013-10-13 trunk 43273) [x86_64-darwin13.0.0]
$ ruby method-cache-test.rb
user system total real
defined methods, not busting cache:
0.310000 0.010000 0.320000 ( 0.311989)
method_missing dispatch, not busting cache:
@gamache
gamache / gist:6962596
Last active Dec 25, 2015
Running method-cache-test.rb on Ruby 2.0.0-p195.
View gist:6962596
$ ruby --version
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]
$ ruby method-cache-test.rb
user system total real
defined methods, not busting cache:
0.270000 0.000000 0.270000 ( 0.273828)
method_missing dispatch, not busting cache:
You can’t perform that action at this time.