Skip to content

Instantly share code, notes, and snippets.

View znz's full-sized avatar

Kazuhiro NISHIYAMA znz

View GitHub Profile
@znz
znz / nslcd.conf
Last active December 16, 2015 05:08
/etc/nslcd.conf の設定例
# nslcd configuration file. See nslcd.conf(5)
# for details.
# The user and group nslcd should run as.
uid nslcd
gid nslcd
# The location at which the LDAP server(s) should be reachable.
uri ldaps://ldap1.example.jp:636/
uri ldaps://ldap2.example.jp:636/
@znz
znz / ex.rb
Last active December 14, 2015 16:48
gsub_file with UTF-8 regexp causes Encoding::CompatibilityError. related issue is https://github.com/wycats/thor/issues/191
# -*- coding: utf-8 -*-
create_file "config/locales/foo.yml", <<-'YAML'
ja:
foo: "foo"
YAML
gsub_file "config/locales/foo.yml", /"foo"/, '"bar"'
create_file "config/locales/hoge.yml", <<-'YAML'
ja:
hoge: "ほげ"
YAML
@znz
znz / README.md
Created February 23, 2013 13:30
あとで書く

使い方

  1. http://doc.ruby-lang.org/ja/1.9.3/class/Array.html の冒頭に追加
  <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
  <script src="pre-to-mruby.js"></script>
  <script src="http://qiezi.me/projects/mruby-web-irb/mruby.js"></script>
@znz
znz / poltergeist-on-confirm.diff
Created February 20, 2013 06:29
poltergeist gem (+ phantomjs 1.8.1) の onConfirm 対応に挑戦しているけど onAlert と同じように書いているのに onConfirm が呼ばれなくて困っている。
diff --git a/lib/capybara/poltergeist/browser.rb b/lib/capybara/poltergeist/browser.rb
index c4100c2..97d790f 100644
--- a/lib/capybara/poltergeist/browser.rb
+++ b/lib/capybara/poltergeist/browser.rb
@@ -170,6 +170,18 @@ module Capybara::Poltergeist
command 'remove_cookie', name
end
+ def js_alert_messages
+ command 'js_alert_messages'
@znz
znz / autogrow.js.coffee
Created February 15, 2013 05:17
jQuery Mobile を参考にして作った textarea 自動拡大
do ($ = jQuery) ->
jQuery.fn.autogrow = (options) ->
settings = $.extend {
extraLineHeight: 15
timeoutBuffer: 100
}, options
self = this
timerId = self.removeData('timerId')
if timerId
clearTimeout timerId
@znz
znz / .vimrc
Created February 14, 2013 07:34
/usr/share/vim/vim73/syntax/ruby.vim の include とか extend とかの色付けを参考にして prepend にも色付けする設定をしてみた。
au BufNewFileBufRead *.rb syn keyword rubyInclude prepend
au BufNewFileBufRead *.rb syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(prepend\)\>"
@znz
znz / date_time_selector.rb
Last active May 31, 2018 13:44
DateTimeSelector の選択肢のテキストの生成部分をもっと汎用的にしてほしい
# -*- coding: utf-8 -*-
# config/initializers/date_time_selector.rb
# based on actionpack-3.2.11/lib/action_view/helpers/date_helper.rb
require "action_view/helpers/date_helper"
class ActionView::Helpers::DateTimeSelector
undef select_day
def select_day
if @options[:use_hidden] || @options[:discard_day]
build_hidden(:day, day || 1)
else
@znz
znz / bootstrap-nav-icon.html
Last active December 12, 2015 10:39
i nsbp だと Chrome でアイコンの後の文字がずれる
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>test</title>
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap.no-icons.min.css" rel="stylesheet">
<link href="https://netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/js/bootstrap.min.js"></script>
</head>
# -*- coding: utf-8 -*-
# alias_method_chain problem demo
# checked with rails 3.2.11
#
# usage:
# rails new /tmp/amc-problem-demo --skip-bundle --skip-active-record --skip-test-unit -m amc-problem-demo.rb
# cd /tmp/amc-problem-demo
# bundle install
# bundle exec rails server
# open http://localhost:3000/
@znz
znz / rmagick.org
Created December 17, 2012 04:01
homebrew の imagemagick 6.8.0-10 と rmagick 2.13.1 の組み合わせでインストール出来ない
Installing rmagick (2.13.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/kazu/.rbenv/versions/1.9.3-p327/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes