⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remove any bad refs | |
git remote prune origin | |
# pipe into bash and auto-delete any branches that have been merged into master! | |
git log master --pretty=format:'%d' | grep '^ (origin' | tr -d ' ()' | sed 's/origin\//git push origin :/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assuming your partial is named 'list_row' and your model is 'Todo' | |
class Sync.TodoListRow extends Sync.View | |
maxRows: 10 | |
afterInsert: -> | |
$rows = @$el.siblings("tr") | |
$rows.first().remove() if $rows.length > @maxRows | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ERedis do | |
@name :eredis_connection | |
def start do | |
{:ok, pid} = :eredis.start_link | |
:global.register_name(@name, pid) | |
end | |
def connection do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommentsController < ApplicationController | |
def create | |
CommentCreator.new(current_user, params[:comment], self).create | |
end | |
private | |
def create_successful(comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defrecord User, email: nil | |
defmodule Access.User do | |
def access(record, attr), do: apply(elem(record, 0), attr, [record]) | |
end | |
user = User.new(email: "[email protected]") | |
iex> user[:email] | |
"[email protected]" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vim_ins_mode="[INS]" | |
vim_cmd_mode="[CMD]" | |
vim_mode=$vim_ins_mode | |
function zle-keymap-select { | |
vim_mode="${${KEYMAP/vicmd/${vim_cmd_mode}}/(main|viins)/${vim_ins_mode}}" | |
zle reset-prompt | |
} | |
zle -N zle-keymap-select |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This worked on 0.10 | |
defmodule Records do | |
defmacro __using__(_) do | |
quote do | |
defrecord A, name: "chris" | |
defrecord B, id: nil, nested: A.new | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Example do | |
defmacro __using__(_options) do | |
quote do | |
Module.register_attribute __MODULE__, :attr, accumulate: true, persist: false | |
import unquote(__MODULE__) | |
end | |
end | |
defmacro append(attr) do |
OlderNewer