Skip to content

Instantly share code, notes, and snippets.

View pasela's full-sized avatar

Yuki pasela

  • Japan
View GitHub Profile
@pasela
pasela / ohai_bench.rb
Created January 25, 2013 09:58
[ruby] Ohai plugins benchmark script
#!/usr/bin/env ruby
# encoding: utf-8
# Ohai Plugin Benchmark
# =====================
#
# Usage: ohai_bench.rb [option] [loop_count]
#
# Options:
# -d PLUGIN_DIR Ohai plugin path
@pasela
pasela / accessing_current_class_constants.rb
Created December 5, 2012 08:35
[ruby] Accessing current class constants
class Foo
CONST = 'foo'
def put_const
puts [
self.class.name, # (1)
CONST, # (2)
self.class::CONST # (3)
].join(' ')
end
@pasela
pasela / ext_logger.rb
Created November 26, 2012 03:00
[ruby] Logger: Use filepath if progname was omitted.
# encoding: utf-8
require 'pathname'
# Set filename if progname was omitted.
class Logger
alias_method :org_add, :add
def add(severity, message = nil, progname = nil, &block)
if message.nil? && !block_given?
message = progname
@pasela
pasela / error_handling_example.sh
Created November 21, 2012 07:35
[bash]error handling and error report example
#!/bin/bash
#
# error handling and error report example
#
set -e
# logfile
LOGFILE=`mktemp`
@pasela
pasela / gist:3685515
Created September 9, 2012 16:37
CentOSでRubyをビルドするときに必要っぽいもの
sudo yum install \
zlib-devel \
openssl-devel \
readline-devel \
iconv-devel \
libffi-devel
@pasela
pasela / svn2git.md
Created August 31, 2012 10:14
SubversionのリポジトリからGitのbareリポジトリへの移行

SubversionのリポジトリからGitのbareリポジトリへの移行

手順

git init --bare --shared=true foo.git
cd foo.git
git --bare svn init -s file:///path/to/svn/repo
git --bare svn fetch
@pasela
pasela / README.md
Created August 22, 2012 06:18
mintty: A soft pastel color theme(xoria256) for mintty

A soft pastel color theme for mintty

This is ported version of color theme xoria256.

screenshot

Settings

Merge mintty-color-xoria256-rc into your .minttyrc

@pasela
pasela / README.md
Created August 21, 2012 07:03
mintty: A pastel color theme for mintty

A pastel color theme for mintty

screenshot

Settings

Merge mintty-color-pastel-rc into your .minttyrc

or

@pasela
pasela / export-mintty-color.rb
Created August 21, 2012 06:17
Convert .minttyrc color settings to escape sequences.
# encoding: utf-8
# Convert .minttyrc color settings to escape sequences.
#
# USAGE:
# ruby export-mintty-color.rb [minttyrc_file]
#
# minttyrc_file target rc file(default is ~/.minttyrc)
COLOR_SETTINGS = {
@pasela
pasela / screen-4.1.0-cygwin-sock-permission.patch
Created August 20, 2012 05:40
GNU screen: A patch to avoid /tmp/uscreens permission check on Cygwin
diff --git a/src/screen.c b/src/screen.c
index 6e19732..3a8ca3e 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1102,8 +1102,10 @@ char **av;
n = (eff_uid == 0 && (real_uid || (st.st_mode & 0775) != 0775)) ? 0755 :
(eff_gid == (int)st.st_gid && eff_gid != real_gid) ? 0775 :
0777;
+#if !defined(__CYGWIN__)
if (((int)st.st_mode & 0777) != n)