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
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"

begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'activerecord', '4.2.4'
@kidlab
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="http://en.wikipedia.org/wiki/Lsof">lsof</a>
----
show open files
lsof -nPp <pid>
<a href="http://linux.die.net/man/1/strace">strace</a>
------
@kidlab
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
kidlab / README.md
Created November 6, 2016 18:45 — forked from joakimk/README.md
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
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
kidlab / GIF-Screencast-OSX.md
Created May 12, 2017 03:42 — forked from dergachev/GIF-Screencast-OSX.md
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

Instructions

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

@kidlab
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
kidlab / manual_preloading.rb
Created May 2, 2018 16:43 — forked from sobstel/manual_preloading.rb
Rails manual association preloading
# taken from https://mrbrdo.wordpress.com/2013/09/25/manually-preloading-associations-in-rails-using-custom-scopessql/
# collection association e.g. has_many
owners = People.all
association_name = :photos
owners.each do |owner|
records = Array(whatever_you_want)
@kidlab
kidlab / System Design.md
Created December 2, 2018 19:01 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?