Skip to content

Instantly share code, notes, and snippets.

@kirs
kirs / promote.sh
Created October 3, 2016 21:54 — forked from mislav/promote.sh
Publish a git branch and open a tmux split that reports the outcome of CI
#!/bin/bash
# Pushes the current branch to origin and opens a tiny tmux split to track
# the CI status. Upon completion, speaks the status aloud using `say`.
set -e
if [ "$1" != "--wait" ]; then
git push -u origin HEAD
tmux split-window -dv -l 2 "'$0' --wait"
else
ref="$(git rev-parse -q HEAD)"
@kirs
kirs / crypt.md
Last active November 22, 2016 21:26

Legacy Database

User.first.name # => "Renan"

After put encrypted_coder.rb and crypt.rb

User.first.name # => OpenSSL::Cipher::CipherError: bad decrypt
@kirs
kirs / gist:2a0025466944def92b3be3e0d04266cd
Created April 9, 2017 15:20 — forked from tonyc/gist:1384523
Using strace and lsof

Using strace and lsof to debug blocked processes

You can use strace on a specific pid to figure out what a specific process is doing, e.g.:

strace -fp <pid>

You might see something like:

select(9, [3 5 8], [], [], {0, 999999}) = 0 (Timeout)

@kirs
kirs / gdb_ruby_backtrace.py
Created September 3, 2017 16:22 — forked from csfrancis/gdb_ruby_backtrace.py
Dump an MRI call stack from gdb
# Updated for Ruby 2.3
string_t = None
def get_rstring(addr):
s = addr.cast(string_t.pointer())
if s['basic']['flags'] & (1 << 13):
return s['as']['heap']['ptr'].string()
else:
return s['as']['ary'].string()
@kirs
kirs / deploy.rb
Created July 5, 2012 12:38 — forked from mikhailov/0. nginx_setup.sh
Nginx+Unicorn (production-ready setup)
# Capistrano configuration
#
# require 'new_relic/recipes' - Newrelic notification about deployment
# require 'capistrano/ext/multistage' - We use 2 deployment environment: staging and production.
# set :deploy_via, :remote_cache - fetch only latest changes during deployment
# set :normalize_asset_timestamps - no need to touch (date modification) every assets
# "deploy:web:disable" - traditional maintenance page (during DB migrations deployment)
# task :restart - Unicorn with preload_app should be reloaded by USR2+QUIT signals, not HUP
@kirs
kirs / notes
Created June 24, 2019 15:16 — forked from justincormack/notes
criu setup Ubuntu 18.04
apt update
apt upgrade
apt install build-essential
apt install pkg-config
apt install libnet-dev python-yaml libaio-dev
apt install libprotobuf-dev libprotobuf-c0-dev protobuf-c-compiler protobuf-compiler python-protobuf libnl-3-dev libcap-dev python-future
# criu install
curl -O -sSL http://download.openvz.org/criu/criu-3.10.tar.bz2
tar xjf criu-3.10.tar.bz2
@kirs
kirs / queuing.rb
Created April 20, 2020 15:00 — forked from sirupsen/queuing.rb
Queuing theory exercise
class Node
attr_accessor :edges, :jobs, :id
def initialize(id, arrivals_per_tick)
@id = id
@jobs = 0.0
@tick = 0
@edges = []
@arrivals_per_tick = arrivals_per_tick
end