Skip to content

Instantly share code, notes, and snippets.

View znz's full-sized avatar

Kazuhiro NISHIYAMA znz

View GitHub Profile
@znz
znz / Gemfile
Last active August 29, 2015 13:57
Ruby/Rails勉強会@関西 60th #rubykansai のプレゼン用に作成した正規表現(ごく一部)の動作をステップ表示するアプリ
source "https://rubygems.org"
ruby "2.1.1"
gem "sinatra"
@znz
znz / rspec-boolean.txt
Created June 13, 2014 04:27
rspec で be(false) と eq(false) の違い
% cat spec/falsey_spec.rb
describe do
it do
expect(true).to be(false)
end
it do
expect(true).to eq(false)
end
end
% bundle exec rspec -v
# -*- coding: utf-8 -*-
# env_ltsv_each.rb
# https://gist.github.com/znz/849166c048a2117c341d
# copyright (c) 2014 Kazuhiro NISHIYAMA
# This software is released under the MIT License.
# http://opensource.org/licenses/MIT
require 'ostruct'
def env_ltsv_each(prefix, start: 0, encoding: Encoding::UTF_8, scrub: false)
block_given? or return enum_for(__method__)
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
$str = "abcd"
data = %w[
0 14 5 14
32 0 38 12
46 28 0 7
33 18 44 0
]
data = data.map(&:to_i)
@znz
znz / ruby-enterprise-1.8.6-20080810 installer failed on lenny(testing)
Created October 1, 2008 06:05
ruby-enterprise-1.8.6-20080810 installer failed on lenny(testing)
Welcome to the Ruby Enterprise Edition installer
This installer will help you install Ruby Enterprise Edition 1.8.6-20080810.
Don't worry, none of your system files will be touched if you don't want them
to, so there is no risk that things will screw up.
You can expect this from the installation process:
1. Ruby Enterprise Edition will be compiled and optimized for speed for this
system.
2. Ruby on Rails will be installed for Ruby Enterprise Edition.
http://groups.google.com/group/redmine-users-ja/browse_thread/thread/6ca8cfb88541e254/40dcd8d66de85a31?#40dcd8d66de85a31
の文字化け対応パッチが改行とかの問題でそのままだと当てられない。
diff -r 23aa8d1c4bcf -r d7daa8217d67 app/controllers/hoge_controller.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/controllers/hoge_controller.rb Wed Nov 05 20:09:58 2008 +0900
@@ -0,0 +1,10 @@
+class HogeController < ApplicationController
+ session :off
+
+ def index
+ end
+
@znz
znz / check_regexp_n.rb
Created January 29, 2009 18:35
ripperで正規表現のnオプションの使用箇所を探す
#!/usr/bin/ruby
require 'ripper/filter'
class CheckRegexpN < Ripper::Filter
def on_regexp_end(token, data)
if /n/ =~ token
puts "#{data}:#{lineno}:#{token}"
end
data
@znz
znz / gist:104842
Created May 1, 2009 03:12
rcodetoolsの設定例
(setq load-path
(cons "~/.emacs.d/site-lisp/elisp" load-path))
(require 'auto-complete)
(setq-default ac-sources '(ac-source-abbrev ac-source-words-in-buffer))
(global-auto-complete-mode t)
(setq ac-auto-start 3)
(add-hook
'emacs-lisp-mode-hook
(lambda ()
(setq ac-sources '(ac-source-words-in-buffer ac-source-symbols))))
@znz
znz / configure.log
Created May 12, 2009 12:20
OpenSolarisでruby-1.9.1-p129
checking build system type... i386-pc-solaris2.11
checking host system type... i386-pc-solaris2.11
checking target system type... i386-pc-solaris2.11
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes