Skip to content

Instantly share code, notes, and snippets.

View gist:316400191d50278c3fed
set-option -g default-command "reattach-to-user-namespace -l zsh"
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
View gist:b662bd26f68fa10b6651
defmodule MyApp.Password do
@moduledoc """
Handles password authentication, encryption, and decryption
"""
@doc """
Encrypte the password String
"""
def encrypt(raw_password) do
@chrismccord
chrismccord / phoenix-0.15-upgrade.md
Last active Aug 29, 2015
Phoenix upgrade instructions 0.14.x to 0.15.0
View phoenix-0.15-upgrade.md

Sockets and Channels

A new socket behaviour has been introduced to handle socket authentication in a single place, wire up default channel assigns, and disconnect a user's multiplex connection as needed.

First things first, create a UserSocket module in web/channels/user_socket.ex and move all your channel routes from web/route.ex to the user socket: (replace MyApp with your application module)

0.14.x - web/router.ex:

defmodule MyApp.Router do
   ...
@chrismccord
chrismccord / upgrade.md
Last active Aug 29, 2015
Phoenix 0.15.x to 0.16.0 upgrade instructions
View upgrade.md

Phoenix dep

Update your phoenix dep:

def deps do
 [...,
  {:phoenix, "~> 0.16"},
  ...]
end
@chrismccord
chrismccord / gist:ee5ae90b949a9768b871
Last active Aug 29, 2015
Phoenix 0.16.x to 0.17.0 upgrade instructions
View gist:ee5ae90b949a9768b871

Deps

Bump your :phoenix and :phoenix_live_reload deps in mix.exs:

def deps do
  [...
   {:phoenix, "~> 0.17"},
   {:phoenix_live_reload, "~> 1.0"},
  ...]
@chrismccord
chrismccord / gist:1507045
Created Dec 21, 2011 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts
View gist:1507045

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
View document_channel.ex
broadcast! socket, "insert_img", %{
url: url,
start: params["start"],
end: params["end"]
}
View catch_all_action.ex
defmodule MyApp.Web do
def controller do
quote do
use Phoenix.Controller
use MyApp.CatchAllController
...
end
end
end
@chrismccord
chrismccord / gist:3801696
Created Sep 28, 2012
Rake Task to kill postgres test and development database connections
View gist:3801696
  desc "Kill test and development postgres database connections"
  task :pg_terminate => :environment do

    dbs = []
    dbs << ActiveRecord::Base.configurations["development"]["database"]
    dbs << ActiveRecord::Base.configurations["test"]["database"]
    db_names = "#{dbs.map{|name| "'#{name}'"}.join(", ")}"

    terminated = false
@chrismccord
chrismccord / phoenix showdown rackspace onmetal io.md
Created Nov 17, 2015 — forked from omnibs/phoenix showdown rackspace onmetal io.md
Phoenix Showdown Comparative Benchmarks @ Rackspace
View phoenix showdown rackspace onmetal io.md

Comparative Benchmark Numbers @ Rackspace

I've taken the benchmarks from Matthew Rothenberg's phoenix-showdown, updated Phoenix to 0.13.1 and ran the tests on the most powerful machines available at Rackspace.

Results

Framework Throughput (req/s) Latency (ms) Consistency (σ ms)