Skip to content

Instantly share code, notes, and snippets.

View shugo's full-sized avatar

Shugo Maeda shugo

  • NaCl
  • Matsue, Shimane, Japan
View GitHub Profile
@shugo
shugo / xchat-disable-ctrl-m.diff
Created February 17, 2012 06:49
disabling XChat's shortcut key Ctrl-m
--- src/fe-gtk/menu.c.orig 2012-02-17 15:45:48.845535697 +0900
+++ src/fe-gtk/menu.c 2012-02-17 15:40:04.000000000 +0900
@@ -1646,7 +1646,7 @@
{N_("Raw Log..."), menu_rawlog, 0, M_MENUITEM, 0, 0, 1}, /* 62 */
{N_("URL Grabber..."), url_opengui, 0, M_MENUITEM, 0, 0, 1},
{0, 0, 0, M_SEP, 0, 0, 0},
- {N_("Reset Marker Line"), menu_resetmarker, 0, M_MENUITEM, 0, 0, 1, GDK_m},
+ {N_("Reset Marker Line"), menu_resetmarker, 0, M_MENUITEM, 0, 0, 1, 0},
{N_("C_lear Text"), menu_flushbuffer, GTK_STOCK_CLEAR, M_MENUSTOCK, 0, 0, 1, GDK_l},
#define SEARCH_OFFSET 67
@shugo
shugo / for_loop_scope_fix_3.diff
Created February 25, 2012 11:18
@n0kada このパッチあてるとbootstraptest/test_eval.rbの[ruby-core:25714]のテストから返って来ないのですが、何でかわかります?
diff --git a/parse.y b/parse.y
index 82eb3d4..c66f229 100644
--- a/parse.y
+++ b/parse.y
@@ -698,7 +698,7 @@ static void token_info_pop(struct parser_params*, const char *token);
%type <node> command_asgn mrhs superclass block_call block_command
%type <node> f_block_optarg f_block_opt
%type <node> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs
-%type <node> assoc_list assocs assoc undef_list backref string_dvar for_var
+%type <node> assoc_list assocs assoc undef_list backref string_dvar
@shugo
shugo / red_black.rb
Created March 7, 2012 14:36
red-black tree implementation by pattern-match
# ported from http://www.cs.kent.ac.uk/people/staff/smk/redblack/Untyped.hs
require "pattern-match"
module RedBlack
class Tree
include PatternMatch::Extractable
include Enumerable
def insert(key, value)
@shugo
shugo / red_black_error.rb
Created March 9, 2012 02:32
error in pattern-match
# ported from http://www.cs.kent.ac.uk/people/staff/smk/redblack/Untyped.hs
require "pattern-match"
module RedBlack
class Tree
include PatternMatch::Extractable
include Enumerable
def insert(key, value)
@shugo
shugo / prime.scm
Created March 14, 2012 08:38
Schemeではtakeもlazyだった
(use util.stream)
(use srfi-42)
(define (primes)
(stream-filter (lambda (k)
(not (any?-ec (: j 3 (sqrt k) 2) (zero? (modulo k j)))))
(stream-cons 2 (stream-iota -1 3 2))))
(print (stream-take (primes) 20))
(print (stream->list (stream-take (primes) 20)))
@shugo
shugo / syslog
Created March 28, 2012 01:58
@oftly いやマジですよ
raichu:~$ sudo grep Dazed /var/log/syslog.0
Mar 27 09:21:52 raichu kernel: Uhhuh. NMI received. Dazed and confused, but trying to continue
Rehearsal ---------------------------------------------------------
Hash aset 0.140000 0.010000 0.150000 ( 0.146636)
Hash aref 0.070000 0.000000 0.070000 ( 0.064835)
Hash delete 0.110000 0.000000 0.110000 ( 0.111818)
AVLTree aset 4.310000 0.010000 4.320000 ( 4.319618)
AVLTree aref 1.090000 0.000000 1.090000 ( 1.092948)
AVLTree delete 4.970000 0.000000 4.970000 ( 4.968573)
RedBlackTree aset 5.570000 0.000000 5.570000 ( 5.568030)
RedBlackTree aref 1.100000 0.000000 1.100000 ( 1.093582)
RedBlackTree delete 3.360000 0.000000 3.360000 ( 3.363166)
Rehearsal ---------------------------------------------------------
Hash aset 0.320000 0.000000 0.320000 ( 0.320000)
Hash aref 0.192000 0.000000 0.192000 ( 0.192000)
Hash delete 0.091000 0.000000 0.091000 ( 0.091000)
AVLTree aset 2.724000 0.000000 2.724000 ( 2.723000)
AVLTree aref 0.787000 0.000000 0.787000 ( 0.786000)
AVLTree delete 2.323000 0.000000 2.323000 ( 2.323000)
RedBlackTree aset 3.615000 0.000000 3.615000 ( 3.615000)
RedBlackTree aref 0.581000 0.000000 0.581000 ( 0.582000)
RedBlackTree delete 2.087000 0.000000 2.087000 ( 2.088000)
@shugo
shugo / fib.rb
Created April 11, 2012 14:35
Rubyでもzip_withでfibが書けた
require "immutable/stream"
include Immutable
fibs = Stream.cons{1}.tail {
Stream.cons{1}.tail {
fibs.zip_with(fibs.tail, &:+)
}
}
p fibs.take(10).to_list
@shugo
shugo / mruby_segv.rb
Created April 20, 2012 02:48
#mruby をSEGVさせることに成功した
module X
end
X.new