Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kidlab's full-sized avatar

Man Vuong kidlab

  • Toptal (@toptal)
  • Ho Chi Minh City, Vietnam
View GitHub Profile
kidlab / gist:4c40fababb3944385f55
Last active August 29, 2015 14:28 — forked from masonforest/gist:4048732
Installing a Gem on Heroku from a Private GitHub Repo

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

  1. Get an OAuth Token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note"

require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
gemfile(true) do
source ''
gem 'activerecord', '4.2.4'
kidlab / Debugging Ruby Notes.html
Created December 6, 2015 03:50 — forked from wallace/Debugging Ruby Notes.html
My notes from Aman Gupta's Debugging Ruby webinar by Engine Yard
<a href="">lsof</a>
show open files
lsof -nPp <pid>
<a href="">strace</a>
kidlab / another_example.rb
Last active April 18, 2017 07:07 — forked from shawndrost/application.rb
Single file Rails application
# Activate the gem you are reporting the issue against.
gem 'activerecord'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
kidlab /
Created November 6, 2016 18:45 — forked from joakimk/
CircleCI elixir build example

This runs a build for a small elixir (phoenix) project in about 40 seconds by caching as much of the compiled files as possible.

We've been using this for months in multiple projects without any issues. Please ping be if there is any issues with this script and I'll update it.

It should be generic enough to work on any elixir app using mix.

If you have a elixir_buildpack.config, then enable that section in the build script to keep versions in sync!

2016-08-09: Updated to newer Erlang and Elixir and fixed curl command.

kidlab / Rakefile.rb
Created April 18, 2017 07:11 — forked from drogus/Rakefile.rb
This is the example contents of the Rakefile, which you would use to run active record tasks without using Rails. It assumes using the same directories as rails uses: `db/migrate`, `config/database.yml`.
require 'bundler/setup'
require 'active_record'
include ActiveRecord::Tasks
db_dir = File.expand_path('../db', __FILE__)
config_dir = File.expand_path('../config', __FILE__)
DatabaseTasks.env = ENV['ENV'] || 'development'
kidlab /
Created May 12, 2017 03:42 — forked from dergachev/
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF


To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

kidlab / .rvmrc
Created November 3, 2017 03:14 — forked from eirc/.rvmrc
Ruby-based Benchmark of MessagePack vs. JSON vs. Yajl vs. Protobuffers vs. MultiJson vs. Marshal vs. YAML vs. BSON
rvm --create ree@benchmarks
kidlab /
Last active November 3, 2017 04:21
Ruby memory conscious


There are several gems that help with determining where a program allocates memory. The two that I most often use are allocation_tracer and memory_profiler.

Both tools can measure a whole program or they can be turned on and off to only measure certain parts of a program. Either method allows you to determine hotspots in your program and then act on the information. For example, while developing kramdown several years ago I found that the HTML converter class allocated huge amounts of throw-away strings. By changing this hotspot to a better alternative kramdown got faster and used less memory.

To get you started on using these two gems, here are two files that are intended to get pre-loaded using the -r switch of the ruby binary (i.e. ruby -I. -ralloc_tracer myscript.rb).


kidlab / manual_preloading.rb
Created May 2, 2018 16:43 — forked from sobstel/manual_preloading.rb
Rails manual association preloading
# taken from
# collection association e.g. has_many
owners = People.all
association_name = :photos
owners.each do |owner|
records = Array(whatever_you_want)