Skip to content

Instantly share code, notes, and snippets.

View koko1000ban's full-sized avatar
🏠
Working from home

たびと koko1000ban

🏠
Working from home
View GitHub Profile
@koko1000ban
koko1000ban / auto.watchr
Created May 21, 2012 06:08
configuration example in watchr for c++, cmake
#-*- coding: utf-8 -*-
#-*- mode: ruby-mode;-*-
$out_dir = 'build'
def run_test
system("cd #{$out_dir}; make all && ./a.out -vmodule='hoge=0,foo=2' -logtostderr=1")
end
watch('CMakeLists.txt'){|md|
run_test
@koko1000ban
koko1000ban / gist:3186222
Created July 27, 2012 04:46
log解析 rubyさん
ruby -e "puts STDIN.map{|line| line.split(/ /)}.select{|log| log[-1].to_f > 5.0 }.map{|log| log.join(' ')}" < access.log
#色付き
ruby -e "puts STDIN.map{|line| line.chomp.split(/ /)}.select{|log| log[-1].to_f > 5.0 }.map{|log| log[-1]=\"\e[31m\"+log[-1]+\"\e[0m\"; log.join(' ')}" < access.log
@koko1000ban
koko1000ban / router.php
Created August 3, 2012 15:06
router.php
<?php
// htaccessのかわり
$real_file = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'];
if (file_exists($real_file)) {
return false;
}
if (!preg_match('/^\/(?:index\.php|images|robots\.txt)/', $_SERVER['REQUEST_URI'])) {
@koko1000ban
koko1000ban / xtrabackup_runner.sh
Created September 28, 2012 14:36
run innobackupex for slave script
#!/bin/sh
BACKUP_DIR="${HOME}/backup"
TMPFILE="/tmp/backup_xtra.tmp"
MY_CONF="/etc/my.cnf"
XTRABACKUP="/usr/bin/innobackupex"
USER="root"
PASSWORD="--password=ぱすわーど"
LOCKFILE=`basename $0`.lock
ON_SLAVE='--slave-info --safe-slave-backup'
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'cool.io'
class Handler < Coolio::Socket
def initialize(io, on_message)
super(io)
if io.is_a?(TCPSocket)
opt = [1, @timeout.to_i].pack('I!I!') # { int l_onoff; int l_linger; }
@koko1000ban
koko1000ban / mem_vs_redis.rb
Created December 11, 2012 08:55
benchmark memcached vs redis
# -*- coding: utf-8 -*-
require 'benchmark'
require "securerandom"
namespace :dev do
desc "benchmark mem vs redis"
task :benchmark => :environment do
dev_server = '172.19.60.176'
n = 10000
@koko1000ban
koko1000ban / repl_pry.json
Created March 6, 2013 04:41
launch pry in sublime with SublimeRepl
{
"keys": ["ctrl+="],
"command": "repl_open",
"args" : {
"type":"subprocess",
"external_id":"ruby",
"encoding":"utf8",
"soft_quit":"\nexit\n",
"cwd":"$file_path",
"cmd_postfix":"\n",
#!/bin/sh
# enable debug mode
if [ "$DEBUG" = "yes" ]; then
set -x
fi
usage() {
echo "usage: git merge-master <release_version>"
echo
@koko1000ban
koko1000ban / setup_docker_containers.sh
Created August 23, 2013 02:14
docker lunch on private
#!/bin/bash
CONTAINERS=(app mysql redis memcached)
for container in ${CONTAINERS[@]}; do
container_id=$(sudo docker run -d -dns 172.17.42.1 tabito/centos_base)
echo "$(sudo docker inspect ${container_id} | grep IPAddress | cut -d '"' -f 4) ${container}.local" | sudo tee -a /etc/hosts
done
@koko1000ban
koko1000ban / newrelic-sysmond
Created January 9, 2014 05:11
newrelic_nrsysmond
#!/bin/sh
#
# newrelic-sysmond <summary>
#
# chkconfig: 2345 80 20
# description: Starts and stops the New Relic Server Monitor Daemon.
# processname: nrsysmond
# config: /etc/newrelic/nrsysmond.cfg
LANG=C