Skip to content

Instantly share code, notes, and snippets.

View prepare-commit-msg
#!/usr/bin/ruby
# -*- mode: Ruby -*-
# usage: ruby-commit-hook <file>
changelog = nil
# find out ChangeLog file
diff = `git diff --stat HEAD`
diff.scan(/^ (ChangeLog) +\|/) { |ary|
View gtags-git-update.rb
#!/usr/bin/ruby
# usage : gtags-git-update commit-id
commit = ARGV.shift
git_show = `git show --stat #{commit}`
# match like this " include/linux/memblock.h |"
git_show.scan(/^ (.*\.[ch]) +\|/) { |ary|
path = ary[0]
View ruby-setup.sh
#!/bin/zsh
# see https://github.com/shyouhei/ruby/wiki/committerhowto
# see http://shyouhei.tumblr.com/post/997747981/ruby-svn-git-gateway
# see http://blogs.atlassian.com/2013/12/git-svn-tips-and-tricks/
./yum-install-if-not-exist.sh git subversion git-svn screen
./install-gtags.sh
./install-gnulib.sh
View rpmpatch.
#!/usr/bin/ruby
# usage: rpmpatch specfile [--localname name] files...
# example: rpmpatch kernel.spec --localname .mytest ../SOURCES/00*
require "optparse"
localname = nil
View output
start: 0 0
uid: 0 0
uid: 0 0
ret: 1000 1000
uid: 1000 1000
uid: 1000 1000
uid: 1000 1000
uid: 1000 1000
uid: 1000 1000
uid: 1000 1000
View hello_motif.c
#include <Xm/XmAll.h>
void main(int argc, char *argv[])
{
Widget toplevel, main_w, button;
XtAppContext app;
XtSetLanguageProc(NULL, NULL, NULL);
toplevel = XtVaAppInitialize(&app, "main", NULL, 0,
View flymake-conf.el
;; flymake
(require 'flymake)
(require 'flymake-cursor)
;; for C
(add-hook 'c-mode-hook
'(lambda ()
(flymake-mode t)))
;; Use <topdir>/build/Makefile if exist (for ruby)
View output
% gcc readstat.c -g -Wall; ./a.out
cpu[0].iowait : 544257 -> 544256 : 429496729500.000000 0.000000
cpu[2].iowait : 123875 -> 123874 : 429496729500.000000 0.000000
cpu[0].iowait : 544268 -> 544267 : 429496729500.000000 0.000000
cpu[2].iowait : 123882 -> 123881 : 429496729500.000000 0.000000
cpu[0].iowait : 544275 -> 544274 : 429496729500.000000 0.000000
cpu[2].iowait : 123884 -> 123882 : 429496729400.000000 0.000000
cpu[0].iowait : 544281 -> 544279 : 429496729400.000000 0.000000
cpu[2].iowait : 123885 -> 123883 : 429496729400.000000 0.000000
cpu[0].iowait : 544288 -> 544287 : 429496729500.000000 0.000000
View gist:1f0581f8e24f155e1ab2
# Running tests:
[ 3315/13696] TestConst#test_redefinition = 10.04 s
1) Error:
TestConst#test_redefinition:
Timeout::Error: execution of assert_no_memory_leak expired
/home/kosaki/ruby/git/test/ruby/test_const.rb:64:in `test_redefinition'
[ 4015/13696] TestException#test_machine_stackoverflow_by_define_method
2) Failure:
View mail-test.rb
require 'mail'
Mail.defaults do
options = { :address => "smtp.gmail.com",
:port => 587,
:user_name => 'kosaki.motohiro',
:password => 'パスワード',
:authentication => 'plain',
:enable_starttls_auto => true }