Skip to content

Instantly share code, notes, and snippets.

View thefron's full-sized avatar
📕

Hoseong Liam Hwang thefron

📕
View GitHub Profile
@thefron
thefron / _README.md
Created August 22, 2016 06:05 — forked from schickling/_README.md
Script to import and export docker-machine configurations to sync between hosts/collaborators

docker-machine import/export

Script to import and export docker-machine configurations to sync between hosts/collaborators

Export (on host A)

$ docker-machine ls
NAME       ACTIVE   DRIVER         STATE     URL                            SWARM   DOCKER    ERRORS
dev        -        digitalocean   Running   tcp://example.com:2376                 v1.10.1
@thefron
thefron / .zshrc
Created January 23, 2014 05:42 — forked from Veraticus/.zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Example aliases
birthyears_users = {}
User.unscoped.registered.select([:id, :birthday]).find_each do |user|
if user.birthday
birthyears_users[user.birthday.year] ||= []
birthyears_users[user.birthday.year] << user.id
else
birthyears_users[0] ||= []
birthyears_users[0] << user.id
end
dates_matchings = {}
Matching.unscoped.select([:id, :created_at]).find_each do |matching|
dates_matchings[matching.created_at.to_date.to_s] ||= 0
dates_matchings[matching.created_at.to_date.to_s] += 1
end; nil
dates_matchings.sort.each do |date, matchings_count|
puts "#{date}\t#{matchings_count}"
end; nil
dates_messages = {}
Message.where(message_type: 'MESSAGE').select([:message_type, :created_at, :id]).find_in_batches(batch_size: 10000) do |messages|
messages.each do |message|
dates_messages[message.created_at.to_date.to_s] ||= 0
dates_messages[message.created_at.to_date.to_s] += 1
end
end; nil
dates_messages.each do |date, messages_count|
revelations_by_dates = {}
Revelation.select([:id, :created_at]).find_in_batches(batch_size: 10000) do |revelations|
revelations.each do |revelation|
revelations_by_dates[revelation.created_at.to_date.to_s] ||= 0
revelations_by_dates[revelation.created_at.to_date.to_s] += 1
end
end; nil
revelations_by_dates.sort.each do |date, revelations_count|