Skip to content

Instantly share code, notes, and snippets.

@aibou
aibou / gist:7078875
Created October 21, 2013 05:00
Rubyのラムダ式まわり。func_with_blockあたりがクサい
def func_without_args
yield if block_given?
end
def func_with_block &block
yield block
end
def func_with_proc p
p.call
Earthquake.init do
output do |item|
next unless item["_stream"]
if item["text"] =~ /@aibou/i
notify "#{item["user"]["screen_name"]}: #{item["text"]}"
end
end
end
@aibou
aibou / gist:5ab6d006ac602e28008f
Last active August 29, 2015 14:01
install atom on ubuntu
sudo apt-get install git nodejs npm libgnome-keyring-dev
sudo npm config set python /usr/bin/python2 -g
# if there is /usr/bin/nodejs and is not /usr/bin/node , run this:
cd /usr/bin && sudo ln -s nodejs node && cd ~/
git clone https://github.com/atom/atom
cd atom/
script/build
sudo script/grunt install
@aibou
aibou / hab.go
Created July 16, 2014 02:28
ひっとあんどぶろーてきな
package main
import (
"fmt"
)
func countHit(a string, b string) (hits int) {
for i := 0; i < 10; i++ {
if a[i] == b[i] {
hits ++
@aibou
aibou / hello.go
Created September 9, 2014 08:56
こういう書き方って一般的なのかどうか知りたいです
package main
import (
"fmt"
"errors"
)
func hoge() (string, error) {
return "hello", errors.New("hello err")
}
@aibou
aibou / 0_hello.yaml
Last active August 29, 2015 14:15
こういうの欲しい
hello:
method: GET
patterns:
- request:
params:
name: "Tom"
response:
body: "Hello, Tom!"
- request:
params:
@aibou
aibou / functions.sh
Created March 11, 2015 10:20
/etc/init.d/functions の中身(CodeHubで読む用)
# -*-Shell-script-*-
#
# functions This file contains functions to be used by most or all
# shell scripts in the /etc/init.d directory.
#
TEXTDOMAIN=initscripts
# Make sure umask is sane
umask 022
@aibou
aibou / grafana-image-handler.json
Created April 27, 2015 08:06
sensu + grafana で、hipchatにグラフ画像投下するやつ
{
"handlers": {
"hipchat": {
"type": "pipe",
"command": "/etc/sensu/handlers/hipchat.rb"
},
"grafana-image": {
"type": "pipe",
"command": "/etc/sensu/handlers/grafana-image.rb"
}
@aibou
aibou / ntpd_spec.rb
Created June 30, 2015 07:25
なにか(for amazon linux)
require 'spec_helper'
describe package('ntp') do
it { should be_installed.with_version('4.2.6p5-30.24.amzn1') }
end
# describe service('ntpd') do
# it { should be_enabled }
# it { should be_running }
# end
@aibou
aibou / create_vpc.tf
Created December 11, 2015 02:12
terraformでVPC作るやつ
resource "aws_vpc" "loadtest" {
cidr_block = "10.200.0.0/16"
enable_dns_support = true
enable_dns_hostnames = true
tags {
Name = "load-test"
}
}
resource "aws_subnet" "public-loadtest-a" {