Skip to content

Instantly share code, notes, and snippets.

package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
pic := make([][]uint8, dy)
for y := range pic {
pic[y] = make([]uint8, dx)
for x := range pic[y] {
pic[y][x] = uint8(x^y)
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := 1.0
for {
# coding: utf-8
class KaraokeMachine
NOTES = %w(C C# D D# E F F# G G# A A# B)
def initialize(melody)
@melody = parse(melody)
end
def transpose(amount)
@kei-s
kei-s / elb_status.rb
Created November 18, 2013 04:11
ELB watch
require 'aws-sdk'
logger = Logger.new('elb_status.log')
ACCESS_KEY = 'foo'
SECRET_ACCESS_KEY = 'bar'
LB = 'baz'
health = AWS::ELB.new(access_key_id: ACCESS_KEY, secret_access_key: SECRET_ACCESS_KEY, elb_endpoint: 'elasticloadbalancing.ap-northeast-1.amazonaws.com').load_balancers[LB].instances.health
@kei-s
kei-s / beer_document.rb
Created August 6, 2013 06:16
ビアドキュメント #駄洒落クラブ
puts <<🍺
\u{1F37A}
🍺
@kei-s
kei-s / face_detect.rb
Created June 10, 2013 06:07
OpenCV Face Detect sample.
require 'bundler/setup'
require 'opencv'
include OpenCV
if ARGV.length < 2
puts "Usage: ruby #{__FILE__} source dest"
exit
end
@kei-s
kei-s / deploy.rb
Created January 10, 2013 10:11
capistrano の server 一覧
@roles.each do |name, role|
role.servers.each do |server|
logger.info server.to_s, name
end
end
@kei-s
kei-s / productction.rb
Created November 14, 2012 10:54
Catch DB connection error by exception_notification
# Catch DB connection error by exception_notification(https://github.com/smartinez87/exception_notification)
Sample::Application.configure do
#...
config.middleware.insert_before ActiveRecord::ConnectionAdapters::ConnectionManagement, ExceptionNotifier,
# settings for exception_notification
end
end
@kei-s
kei-s / gist:3809475
Created October 1, 2012 04:29
Mountain Lion, homebrew, imagemagick, update

Mountain Lion, homebrew, imagemagick, update

convert -v が通るようになれば imagemagick アップデート完了なのでステップ毎にチェック。

imagemagick に関係しないものもあるかも。

  1. brew doctor で warning なくなるまで対応

    brew install autoconf fontconfig freetype libpng p11-kit とか

@kei-s
kei-s / satsubatsu.txt
Created June 8, 2012 08:02
殺伐としたTLにJavaScriptが
use strict;
class Foo
public static void main(String[] @args)
bar :: Foo -> String
def bar(self):
@args.inject(result, (function(elem) do
my $str = htmlspecialchars(elem)
result += $str