Skip to content

Instantly share code, notes, and snippets.

View mbyczkowski's full-sized avatar

Mat Byczkowski mbyczkowski

View GitHub Profile
# Assuming you already have Go installed
# Works with any released version of Go (including beta builds)
# Prior to Go 1.11 `go get<GO_VERSION>` was used.
go get
# Assuming that $GOBIN is added to your $PATH
go1.11 download
mbyczkowski /
Last active August 20, 2018 11:00
Dnsmasq config for OS X
#!/usr/bin/env bash
# Resolve dev domains locally and passthrough other DNS requests
set -e
dnsmasq_installed=`brew list | grep dnsmasq`
if [ -n "$dnsmasq_installed"]; then
echo "Installing Dnsmasq..."
brew install dnsmasq
mbyczkowski / decrypt_rails_session.lua
Created March 10, 2017 07:25
session cookie decrypter for Rails 4.2+ (in OpenResty Lua)
local aes = require("resty.aes")
local str = require("resty.string")
local sha1 = require("bgcrypto.sha1")
local cjson = require("cjson")
function verify_and_decrypt_session_cookie(cookie, secret_key_base)
local rounds = 1000
local secret_length = 32
local sign_secret_length = 64
local cookie = ngx.unescape_uri(cookie)
mbyczkowski / with_active_support.rb
Last active September 28, 2023 03:56 — forked from tonytonyjan/rails_42_with_active_support.rb
session cookie decrypter for Rails 4.2+
require 'cgi'
require 'json'
require 'active_support'
def verify_and_decrypt_session_cookie(cookie, secret_key_base)
cookie = CGI::unescape(cookie)
salt = 'encrypted cookie'
signed_salt = 'signed encrypted cookie'
key_generator =, iterations: 1000)
secret = key_generator.generate_key(salt)[0, ActiveSupport::MessageEncryptor.key_len]
# create a new dir for each version of Go
git clone $HOME/go1.8
cd $HOME/go1.8
git checkout release-branch.go1.8
# assuming you installed go binary with homebrew
export GOROOT_BOOTSTRAP=/usr/local/opt/go/libexec

Keybase proof

I hereby claim:

  • I am mbyczkowski on github.
  • I am matb ( on keybase.
  • I have a public key whose fingerprint is 1B88 DB20 5BFB 3A69 FFBA 16C1 CBAE 8AE6 119D 01E4

To claim this, I am signing this object:

mbyczkowski / .codeclimate.yml
Created July 4, 2015 23:15
CodeClimate set-up for Node.js and Ruby project
# CodeClimate supports multiple-language set-up on per-file basis
JavaScript: true
Ruby: true
mbyczkowski / .travis.yml
Created July 4, 2015 22:18
Travis CI config file for Node.js and Ruby in one repo
# As of writing this (7/4/2015) Travis CI only supports one language per project
# However, every box comes with Node.js and Ruby pre-installed.
# On top of it, you can install custom programs/libraries in the the `before_script` or 'before_install`
# stages.
# The easiest approach is to go with Node.js box and install approprtiate Ruby version
# or vice-versa
language: node_js
# pick your version of Node.js
- 0.12.2
mbyczkowski /
Last active August 29, 2015 14:02
Keep your git clean!
#!/usr/bin/env ruby
STDOUT.write("---+ Pruning origin... ")
`git remote prune origin`
STDOUT.write("---+ Collecting a list of merged branches to delete... ")
branch_output = `git branch -a --merged remotes/origin/master | grep -v master`
list_of_branches_to_delete = branch_output.split("\n")
# make sure we don't delete special branches, e.g. deploy branch