Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryota Arai ryotarai

View GitHub Profile
View kube-resource-stat.rb
#!/usr/bin/env ruby
require 'json'
require 'terminal-table'
def cpu_to_milli(cpu)
if cpu =~ /\A(\d+)m\z/
return $1.to_i
end
return cpu.to_i * 1000
end
View aws-console-color.user.js
// ==UserScript==
// @name AWS Console Header Color
// @namespace http://ryotarai.info/
// @version 0.1
// @description Change color of header
// @author Ryota Arai
// @match https://*.console.aws.amazon.com/*
// @grant none
// ==/UserScript==
View print-docker-run-from-container.rb
#!/usr/bin/env ruby
require 'json'
require 'shellwords'
cid = ARGV[0]
JSON.parse(`docker inspect #{cid}`).each do |c|
config = c['Config']
args = %w!docker run -it!
config['Env'].each do |e|
View temper-hidapi.rb
require 'ffi'
vendor_id = 3141
product_id = 29697
module HidApi
extend FFI::Library
ffi_lib 'hidapi'
attach_function :hid_open, [:int, :int, :int], :pointer
@ryotarai
ryotarai / larger-sg-selector.user.js
Last active Aug 14, 2019
Larger Security Group selector (AWS RDS and Elasticache / tested with Tampermonkey)
View larger-sg-selector.user.js
// ==UserScript==
// @name Larger SG Selector
// @namespace http://ryotarai.info/
// @version 0.1
// @description Why is it too small?
// @author Ryota Arai
// @match https://*.console.aws.amazon.com/*
// @grant none
// ==/UserScript==
View ltsv2tsv.rb
data = []
columns = []
ARGF.each_line do |line|
data << Hash[line.split("\t").map do |kv|
k, v = kv.split(':', 2)
columns << k unless columns.include?(k)
[k, v]
end]
@ryotarai
ryotarai / patch.rb
Created Sep 1, 2014
Use better_errors in production env
View patch.rb
# Gemfile
gem 'better_errors'
gem 'binding_of_caller'
# config/application.rb
module BetterErrors
class Railtie < Rails::Railtie
def use_better_errors?
return true if ENV['BETTER_ERRORS']
!Rails.env.production? and app.config.consider_all_requests_local
View get-aws-status-rss.rb
require 'open-uri'
region = ARGV.first
unless region
puts "usage: ruby get-aws-status-rss.rb ap-northeast-1"
end
source = open("http://status.aws.amazon.com/") {|f| f.read }
source.scan(/'(\w+-#{region})'/) do |match|
@ryotarai
ryotarai / gist:7743407
Last active Dec 29, 2015
Monitoring Casual Talk in Kyoto の スライド
View gist:7743407