Skip to content

Instantly share code, notes, and snippets.

#!/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
// ==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==
#!/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|
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 August 14, 2019 19:12
Larger Security Group selector (AWS RDS and Elasticache / tested with Tampermonkey)
// ==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==
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 September 1, 2014 14:11
Use better_errors in production env
# 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
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 December 29, 2015 23:29
Monitoring Casual Talk in Kyoto の スライド
@ryotarai
ryotarai / Google Chrome.zip
Last active December 27, 2015 16:29
Google Chrome without SPDY