Skip to content

Instantly share code, notes, and snippets.

View thefron's full-sized avatar
📕

Hoseong Liam Hwang thefron

📕
View GitHub Profile
require 'net/http'
require 'uri'
require 'json'
def put_metric(name, value, unit='Count')
metric_name = "ApiSidekiq#{name.split('_').collect(&:capitalize).join}"
`/usr/local/bin/aws cloudwatch put-metric-data --metric-name #{metric_name} --namespace Sidekiq --value #{value} --unit #{unit}`
end
uri = URI.parse("#{ENV['SIDEKIQ_WEB_HOST']}/stats")
@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 / build.md
Last active October 19, 2017 09:22
android build

Build Howto

Install Ubuntu 14.04.3 LTS

You know how.

$ sudo apt-get update
$ sudo apt-get install build-essential module-assistant
@thefron
thefron / gist:9343238
Created March 4, 2014 09:38
Install puppet open source version with latest version
1. `$ sudo rpm -ivh https://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-7.noarch.rpm`
2. Edit priority of puppetlabs repository
```
[puppetlabs-products]
name=Puppet Labs Products El 6 - $basearch
baseurl=http://yum.puppetlabs.com/el/6/products/$basearch
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs
enabled=1
@thefron
thefron / deploy.rb
Created February 9, 2014 20:41
Node.js deploy /w Capistrano 3
# config/deploy.rb
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'my_app'
set :repo_url, 'git@github.com:USER/my_app.git'
# Default deploy_to directory is /var/www/my_app
set :deploy_to, '/var/node/my_app'
@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|