Skip to content

Instantly share code, notes, and snippets.

@winebarrel
winebarrel / gist:9013842
Last active August 29, 2015 13:56
コネクションプーリング無効
$ for i in 1st 2nd 3rd; do echo "### $i ###"; siege -c 16 -t 1m -b -q http://dagon/employee_count; echo '---'; sleep 3; done
### 1st ###
Lifting the server siege... done.
Transactions: 5451 hits
Availability: 100.00 %
Elapsed time: 59.31 secs
Data transferred: 0.08 MB
Response time: 0.17 secs
@winebarrel
winebarrel / gist:9013850
Last active August 29, 2015 13:56
コネクションプーリング有効
$ for i in 1st 2nd 3rd; do echo "### $i ###"; siege -c 16 -t 1m -b -q http://dagon/employee_count; echo '---'; sleep 3; done
### 1st ###
Lifting the server siege... done.
Transactions: 5436 hits
Availability: 100.00 %
Elapsed time: 59.02 secs
Data transferred: 0.08 MB
Response time: 0.17 secs
An h1 header
============
Paragraphs are separated by a blank line.
2nd paragraph. *Italic*, **bold**, `monospace`. Itemized lists
look like:
* this one
* that one
@winebarrel
winebarrel / event_handler.rb
Last active August 29, 2015 13:57
Kumogata+Serf- event_handler.rb
#!/usr/bin/env ruby
require 'fileutils'
require 'tempfile'
require 'socket'
HOSTS_PATH = '/etc/hosts'
EVENTS = %w(member-join member-leave member-failed)
EXCLUDES = %w(127.0.0.1)
def open_hosts
@winebarrel
winebarrel / template.rb
Created March 9, 2014 17:29
Kumogata+Serf - template.rb
hosts = [:cthulhu, :hastur, :nyar]
Parameters do
SerfURL do
Type "String"
Default "https://dl.bintray.com/mitchellh/serf/0.4.5_linux_amd64.zip"
end
EventHandlerURL do
Type "String"
@winebarrel
winebarrel / template.rb
Created March 10, 2014 15:55
Kumogata: Post command
Resources do
MyInstance do
Type "AWS::EC2::Instance"
Properties do
ImageId "ami-0d13700c"
InstanceType "t1.micro"
KeyName "XXX"
NetworkInterfaces [

Follow these steps to install graphite on OS X Mavericks.

Prerequisites

  • Homebrew
  • Python 2.7
  • Git

Install dependencies

Install Cairo and friends

@winebarrel
winebarrel / serverless-gyazo.rb
Last active August 29, 2015 14:24
Replace "Gyazo/script" to follow script:
#!/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
@winebarrel
winebarrel / test.rb
Last active December 23, 2015 07:09
Postfixログパースベンチマーク
#!/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 / price.rb
Last active December 24, 2015 03:57
Rubyとjqでap-northeast-1のLinux/OnDemandの料金を出すやつ
#!/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)