Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
int main(void)
{
printf("Hello gist.el\n");
return 0;
}
obj = Object.new
module Hoge
def one
"one"
end
def two
"two"
end
end
require 'activerecord'
ActiveRecord::Base # autoload all modules
class MyClass
def save; end
def save!; end
def new_record?; true; end
include ActiveRecord::Validations
@maehrm
maehrm / p226modules.rb
Created February 27, 2011 13:15
メタプログラミングRubyのp226
require 'active_record'
ActiveRecord::Base # autoload all modules
class MyClass
def save; end
def save!; end
def new_record?; true; end
def deprecated_callback_method(symbol); end
include ActiveRecord::Validations
@maehrm
maehrm / gist:960807
Created May 7, 2011 20:22
rw3sat.rb
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
def random_walk_3_sat(f, n, rr) # W1: R を rr に変更
ff = f.split("and").map(&:strip)
r = 1
while r <= rr
x = Array.new(n) { [true, false].sample } # W4: a を x に変更
k = 1
while k <= 3*n
@maehrm
maehrm / gist:961031
Created May 8, 2011 01:56 — forked from antimon2/gist:960956
rw3sat.rb
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
def random_walk_3_sat(f, n, rr) # W1: R を rr に変更
ff = f.split(/\s*and\s*/)
rr.times do
x = Array.new(n) { [true, false].sample } # W4: a を x に変更
(3*n).times do
return "充足可能である" if ff.all? { |c| eval(c) } # W7,8,9
c = ff.find { |cc| !eval(cc) } # W10
@maehrm
maehrm / gist:961036
Created May 8, 2011 02:01
rw3sat.rb
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
def random_walk_3_sat(f, n, rr) # W1: R を rr に変更
ff = f.split(/\s*and\s*/)
r = 1
while r <= rr
x = Array.new(n) { [true, false].sample } # W4: a を x に変更
k = 1
while k <= 3*n
@maehrm
maehrm / fibo.rb
Created May 10, 2011 12:47
fiberを使ってフィボナッチ数列
def fib
a, b = 0, 1
Fiber.new do
loop do
Fiber.yield b
a, b = b, a + b
end
end
end
@maehrm
maehrm / .emacs23.el
Created May 12, 2011 08:33
twittering-modeの設定
;; Twitter
(add-to-list 'load-path "~/.emacs.d/twittering-mode")
(require 'twittering-mode)
(setq twittering-username "maehrm")
(add-hook 'twittering-mode-hook
(lambda ()
(twittering-icon-mode t)
(twittering-scroll-mode t)
(set-face-bold-p 'twittering-username-face t)))
(setq twittering-account-authorization 'authorized)
@maehrm
maehrm / error.txt
Created May 29, 2011 02:23
twittering-mode時のエラー
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
+(39098 50130 nil 25674 59556 2)
sha1-block([25674 12904 27991 31028 17772 25154 25410 29552 30261 30310 20293 12907 25932 22117 18533 31041 21146 60094 15486 63247 21432 63059 21562 24543 15218 62738 37713 20710 5894 37964 15430 46668 33717 43467 38326 42015 29342 20717 60962 56383 63222 50234 39868 11399 15305 53923 64172 61667 25772 26245 ...] [21831 22322 22901 22903 28791 12393 17007 14710 12646 29811 9831 22118 26933 27724 28746 22866 41520 5368 44142 14992 40875 37498 29607 6136 20119 35477 59784 40027 6275 40408 31500 34211 47651 49123 49116 7461 38617 20237 46643 7214 42082 15933 42483 29065 38615 58635 3370 24947 35116 9122 ...])
sha1-binary("dJUG2hW2mWYuy4YwElpwbB0icBBosp9vv51fvftsOE&g2kVfeLi5VelLHepJyAYRIgbQcCH95uM5mAfMxTuMM")
sha1-string-internal("dJUG2hW2mWYuy4YwElpwbB0icBBosp9vv51fvftsOE&g2kVfeLi5VelLHepJyAYRIgbQcCH95uM5mAfMxTuMM" t)
sha1-string("dJUG2hW2mWYuy4YwElpwbB0icBBosp9vv51fvftsOE&g2kVfeLi5VelLHepJyAYRI