Skip to content

Instantly share code, notes, and snippets.

View holysugar's full-sized avatar

HORII Keima holysugar

  • Aiming, Inc
  • Tokyo
View GitHub Profile
@holysugar
holysugar / Vagrantfile
Created February 28, 2014 05:32
Docker Registry を立てる Vagrantfile のサンプル
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos65-x86_64-20131205"
config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.1/centos65-x86_64-20131205.box"
#config.vm.network :public_network, ip: "192.168.1.99", bridge: "en0: Ethernet"
@holysugar
holysugar / build.observr
Last active August 29, 2015 13:57
Dockerfile 等の変更を検知して自動ビルド→テスト(serverspec); notify は趣味で書き換え
# vim: ft=ruby
# Run me with:
# ovservr build.observr
# ovservr については https://github.com/kevinburke/observr
require 'terminal-notifier-guard'
def notify(message, succeeded = true)
type = succeeded ? "success" : "failed"
system("terminal-notifier-#{type} -message '#{message}' -title 'Docker'")
@holysugar
holysugar / org.jenkins-ci.node.plist
Created May 13, 2014 07:29
jenkins ノード永続化 with launchd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.jenkins-ci.node.plist</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/java</string>
<string>-Dfile.encoding=UTF-8</string>
@holysugar
holysugar / temporary_table_class.rb
Last active August 29, 2015 14:02
テンポラリテーブル使うコードたたき台みたいな
require 'active_record'
def temporary_table_class(name, sql = nil, primary_key: nil, &block)
name = name.to_s.tableize
if block
ActiveRecord::Schema.define do
create_table(name, :temporary => true, &block)
end
elsif sql
@holysugar
holysugar / benchmark_struct.rb
Created July 23, 2014 04:31
benchmark structs. Struct が速いのは当たり前なので ostruct と hashie の比較がメイン
#!/usr/bin/env ruby
require 'benchmark'
require 'ostruct'
require 'hashie'
n = 1000000
O = Struct.new(:foo, :bar, :baz)
puts "Benchmark: Initialize"
@holysugar
holysugar / ngircd.patch
Created October 16, 2014 09:56
ngircd patch for POODLE
--- conn-ssl.c.orig 2014-10-16 09:37:47.303936573 +0000
+++ conn-ssl.c 2014-10-16 09:38:31.513421919 +0000
@@ -296,7 +296,7 @@
return false;
}
- newctx = SSL_CTX_new(SSLv23_method());
+ newctx = SSL_CTX_new(TLSv1_method());
if (!newctx) {
LogOpenSSLError("Failed to create SSL context", NULL);
@holysugar
holysugar / two-kanji-noun.rb
Created November 13, 2014 04:57
2文字の漢字リスト生成(メモ)
File.open("x.txt",'w'){|f| f.puts File.read("SKK-JISYO.L", external_encoding: Encoding::EUC_JP).encode(Encoding::UTF_8).split(/\n+/).map{|x| x.scan(%r!/(\p{Han}{2})(?=[;/])!).flatten.first if x !~ /[a-z]/ }.compact.flatten.sort.uniq }
@holysugar
holysugar / sslnotafter.sh
Created December 9, 2014 05:30
SSL証明書の期限を表示する
#!/bin/sh
HOST=$1
if [ -z "$HOST" ]; then
echo "$0 host [port]"
exit 1
fi
PORT=${2:-443}
openssl s_client -tls1 -connect $HOST:$PORT 2>&1 < /dev/null | openssl x509 -enddate | awk -F '=' '/^notAfter/{ print $2 }'
@holysugar
holysugar / daime.rb
Created February 18, 2015 06:39
x代目xx
require 'gimei'
def daime(max=99)
[*(2..max)].sample.to_s.tr('0123456789','〇一二三四五六七八九') + "代目"
end
def name
"#{daime}#{Gimei.first.kanji}"
end
@holysugar
holysugar / activesupport_testcase_inherits_test_unit_testcase.rb
Last active August 29, 2015 14:16
test-unit を rails 4.2 で使う
# Rails で test-unit を使う. 参考:
# * https://github.com/test-unit/test-unit-activesupport
# * https://github.com/rails/rails/blob/master/activesupport/lib/active_support/test_case.rb
#
require 'minitest'
def Minitest.autorun; end # remove Minitest at_exit process
require 'active_support/test_case'
require 'active_support/testing/tagged_logging'
require 'active_support/testing/assertions'