Skip to content

Instantly share code, notes, and snippets.

@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 / 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)"
require "bundler/setup"
require 'active_record'
require 'sqlite3'
require 'minitest/autorun'
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Schema.define do
create_table :gift_cards, force: true do |t|
t.references :checkout
end
@kirs
kirs / repro.rb
Created September 28, 2016 20:38
require "bundler/setup"
require 'active_record'
require 'sqlite3'
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Schema.define do
create_table :gift_cards, force: true do |t|
t.references :checkout, null: false
t.string :code
end
@kirs
kirs / svg.html
Created September 23, 2016 14:13
<html>
<head>
<style>
body {
background-image: url("data:image/xvg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%20id%3D%22Layer_1%22%20x%3D%220px%22%20y%3D%220px%22%20width%3D%2224px%22%20height%3D%2215.572px%22%20viewBox%3D%220%200%2024%2015.572%22%20enable-background%3D%22new%200%200%2024%2015.572%22%20xml%3Aspace%3D%22preserve%22%3E%3Cg%3E%3Cpath%20fill%3D%22%23E5E5E5%22%20d%3D%22M23.999%2C0H10.028v12.166h6.346c0.498-1.091%2C1.597-1.853%2C2.873-1.853s2.375%2C0.762%2C2.873%2C1.853H24L23.999%2C0%20%20%20%20%20%20%20L23.999%2C0z%22%2F%3E%3Cpath%20fill%3D%22%23E5E5E5%22%20d%3D%22M5.942%2C10.313c1.047%2C0%2C1.974%2C0.514%2C2.549%2C1.301V3.438H3.192L0%2C6.964v5.201h3.07%20%20%20%20%20%20%20C3.568%2C11.074%2C4.666%2C10.313%2C5.942%2C10.313z%20M1.961%2C7.294l1.782-2.115h2.831v3.79H1.961C1.961%2C8.969%2C1.961%2C7.294%2C1.961%2C7.294z%22%2F%3E%3Ccircle%20fill%3D%22%23E5E5E5%22%
# runs on Rails 5 master / 831f1b67b741ee7a8af070ab18975ecdde4a9a69
require 'bundler/setup'
require 'active_record'
ActiveRecord::Base.establish_connection(adapter: 'mysql2', database: 'after_commit_test')
ActiveRecord::Schema.define do
%w(shops api_permissions api_clients).each do |table|
if table_exists?(table)
drop_table(table)
end
var stripAnsi = require('strip-ansi');
var RequestShortener = require('webpack/lib/RequestShortener');
var requestShortener = new RequestShortener(process.cwd());
function formatError(e) {
var showErrorDetails = true;
var text = '';
if (typeof e === 'string') {
e = {
message: e,
class Bottles
def song
verses(99, 0)
end
def verses(starting, ending)
(ending..starting)
.to_a
.reverse
.map(&method(:verse))
@kirs
kirs / unicorn_killer.rb
Last active August 6, 2016 16:50
Debug stuck unicorn threads
after_fork do |server, worker|
Signal.trap('USR2') do
pid = Process.pid
puts "[#{pid}] Received USR2 at #{Time.now}. Dumping threads:"
Thread.list.each do |t|
trace = t.backtrace.join("\n[#{pid}] ")
puts "[#{pid}] #{trace}"
puts "[#{pid}] ---"
end
puts "[#{pid}] -------------------"