Skip to content

Instantly share code, notes, and snippets.

@winebarrel
winebarrel / db.r6g-test.md
Last active Apr 7, 2021
https://github.com/winebarrel/qlap を使ったdb.r6g.largeとdb.r5.largeの性能比較
View db.r6g-test.md
@winebarrel
winebarrel / tiny_mysql.rb
Last active Jan 20, 2017
https://goo.gl/HPNOeb sha1: 3149baf94ad92fc4254e4864d5b4faa53dc191b0
View tiny_mysql.rb
require 'open3'
class TinyMysql
attr_reader :mysql_command
attr_reader :defaults_extra_file
attr_reader :host
attr_reader :port
attr_reader :username
attr_reader :database
@winebarrel
winebarrel / wrap.rb
Created Feb 7, 2016
Usage: wrap.rb any.txt 30
View wrap.rb
#!/usr/bin/env ruby
trap('PIPE', 'EXIT')
filnum = ARGV[0]
col = Integer(ARGV[1])
File.read(filnum).lines.each do |line|
state = 0
print line.split(//).slice_before {|ch|
@winebarrel
winebarrel / pg_show_grants.sql
Last active Aug 5, 2020
show grants for PostgreSQL
View pg_show_grants.sql
select
pg_user.usename,
t1.nspname,
t1.relname,
relacl.privilege_type,
relacl.is_grantable
from (
select
pg_namespace.nspname,
pg_class.relname,
@winebarrel
winebarrel / price.rb
Last active Dec 24, 2015
Rubyとjqでap-northeast-1のLinux/OnDemandの料金を出すやつ
View price.rb
#!/usr/bin/env ruby
require 'json'
require 'jq/extend'
#require 'pp'
trap(:PIPE, :EXIT)
# wget https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json -O AmazonEC2.json
json = File.read('AmazonEC2.json')
jq = JQ(json)
@winebarrel
winebarrel / test.rb
Last active Dec 23, 2015
Postfixログパースベンチマーク
View test.rb
#!/usr/bin/env ruby
require 'benchmark'
require 'postfix_status_line'
it = 5
n = 500000
status_lines = "Feb 27 09:02:37 MyHOSTNAME postfix/smtp[26490]: D53A72713E5: to=<myemail@bellsouth.net>, relay=gateway-f1.isp.att.net[204.127.217.16]:25, delay=0.57, delays=0.11/0.03/0.23/0.19, dsn=2.0.0, status=sent (250 ok ; id=20120227140036M0700qer4ne)"
r = /^(?<time>[^ ]* [^ ]* [^ ]*) (?<host>[^ ]+) (?<ident>[a-zA-Z0-9_\/\.\-]*)(?:\[(?<pid>[0-9]+)\])?[^\:]*\: (?<key>[^:]+): ?((to|from)=(<(?<address>[^>]+)>)?)?,( ?(orig_to=<(?<orig_to>[^>]+)>),)? ?(relay=(?<relay>[^ ]+)), ?(delay=(?<delay>[^ ]+)), ?(delays=(?<delays>[^ ]+)), ?(dsn=(?<dsn>[^ ]+)), ?(status=(?<status>[^,]+))/
@winebarrel
winebarrel / serverless-gyazo.rb
Last active Aug 29, 2015
Replace "Gyazo/script" to follow script:
View serverless-gyazo.rb
#!/usr/bin/env ruby
require 'securerandom'
require 'tmpdir'
S3_BACKET = 'my-bucket'
S3_PATH = 'path'
ENDPOINT = 'my-bucket.s3-website-ap-northeast-1.amazonaws.com'
Dir.mktmpdir do |dir|
now = Time.now.utc
View graphite.md

Follow these steps to install graphite on OS X Mavericks.

Prerequisites

  • Homebrew
  • Python 2.7
  • Git

Install dependencies

Install Cairo and friends

View drone-template.rb
Parameters do
ImageId do
Type "String"
# http://cloud-images.ubuntu.com/precise/current/
# ap-northeast-1; 64-bit; ebs
Default "ami-1f334f1e"
end
InstanceType do
Type "String"
@winebarrel
winebarrel / template.rb
Created Mar 10, 2014
Kumogata: Post command
View template.rb
Resources do
MyInstance do
Type "AWS::EC2::Instance"
Properties do
ImageId "ami-0d13700c"
InstanceType "t1.micro"
KeyName "XXX"
NetworkInterfaces [