Skip to content

Instantly share code, notes, and snippets.

@tony612
tony612 / ecto_deadlock1
Last active April 21, 2016 14:13
ecto deadlock
....
1) test get latest timestamp of user for a channel (Exchat.UserReadMessageRepoTest)
test/models/user_read_message_repo_test.exs:6
** (Postgrex.Error) ERROR (deadlock_detected): deadlock detected
Process 45728 waits for ShareLock on transaction 7900; blocked by process 45727.
Process 45727 waits for ShareLock on transaction 7898; blocked by process 45728.
stacktrace:
(ecto) lib/ecto/adapters/sql.ex:405: Ecto.Adapters.SQL.struct/6
@tony612
tony612 / tmux-cheatsheet.markdown
Created February 17, 2016 05:43 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@tony612
tony612 / install_elixir.sh
Last active May 30, 2016 14:21
install precompiled elixir(not including Erlang)
#!/bin/sh
# Usage: install_elixir.sh 1.2.0-rc.1
wget https://github.com/elixir-lang/elixir/releases/download/v$1/Precompiled.zip -O ~/repo/pre-elixir/Precompiled.zip
rm -r ~/repo/pre-elixir/Precompiled
unzip -o ~/repo/pre-elixir/Precompiled.zip -d ~/repo/pre-elixir/Precompiled
# When installing precompiled elixir at the first time
# export PATH=$HOME/repo/pre-elixir/Precompiled/bin:$PATH
@tony612
tony612 / date_util.erl
Last active August 29, 2015 14:20 — forked from zaphar/date_util.erl
-module(date_util).
-compile(export_all).
epoch() ->
now_to_seconds(now())
.
epoch_hires() ->
now_to_seconds_hires(now())
.
@tony612
tony612 / bongo.sh
Last active August 29, 2015 14:07 — forked from francoisTemasys/bongo.sh
LOADING=false
usage()
{
cat << EOF
usage: $0 [options] <DBNAME>
OPTIONS:
-h Show this help.
-l Load instead of export
var collectionNames = db.getCollectionNames();
collectionNames.forEach(function(n) { print(n + ": " + db[n].count()); });
@tony612
tony612 / keybase.md
Created September 23, 2014 01:44
keybase.md

Keybase proof

I hereby claim:

  • I am tony612 on github.
  • I am tony612 (https://keybase.io/tony612) on keybase.
  • I have a public key whose fingerprint is 7E9A B91D DB30 F06C EA44 6739 B8A1 4A54 10D2 351C

To claim this, I am signing this object:

@tony612
tony612 / routes.rake
Last active August 29, 2015 14:06 — forked from oivoodoo/routes.rake
namespace :grape do
desc 'Print compiled grape routes'
task :routes => :environment do
API.routes.each do |route|
puts route
end
end
end
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@tony612
tony612 / label_required.rb
Last active August 29, 2015 14:05
A nice way to add asterisk* to "required" field in frontend used with https://github.com/amatsuda/html5_validators
# config/initializers/label_required.rb
module ActionView
module Helpers
# For rails 4
if ActionPack::VERSION::STRING >= '4'
module Tags
class Label
def render_with_required(&block)