Skip to content

Instantly share code, notes, and snippets.

View niku's full-sized avatar
💭
🍖

KITAMURA Daisuke niku

💭
🍖
View GitHub Profile
/usr/local/Library/Formula% cd
cd
/Users/niku% cd /usr/local
cd /usr/local
/usr/local% git diff
git diff
diff --git a/Library/Formula/poppler.rb b/Library/Formula/poppler.rb
index 79f8e4f..8aa211c 100644
--- a/Library/Formula/poppler.rb
+++ b/Library/Formula/poppler.rb
/usr/local% git diff
git diff
diff --git a/Library/Formula/poppler.rb b/Library/Formula/poppler.rb
index 79f8e4f..70088b6 100644
--- a/Library/Formula/poppler.rb
+++ b/Library/Formula/poppler.rb
@@ -31,6 +31,9 @@ class Poppler < Formula
args = ["--disable-dependency-tracking", "--prefix=#{prefix}"]
args << "--disable-poppler-qt4" unless ARGV.include? "--with-qt4"
args << "--enable-xpdf-headers" if ARGV.include? "--enable-xpdf-headers"
# -*- coding: utf-8 -*-
class Foo
a=1 # インスタンス変数じゃない!
define_method(:bar, lambda{ a+=1 })
end
f = Foo.new
f.bar # => 2
f.bar # => 3
f.bar # => 4
@niku
niku / config.ru
Created October 10, 2011 11:42
rackupfile include non ascii char
# -*- coding: utf-8 -*-
require 'rack'
require 'rack/lobster'
NON_ASCII_VALUE = '日本語'
run Rack::Lobster.new
@niku
niku / create_gem.rb
Created November 6, 2011 13:59
my create gem script
#!/usr/bin/env ruby
def gem_name
ARGV[0].chomp("/")
end
def constant_name
constant_name = gem_name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
constant_name
@niku
niku / codevs_check.rb
Created December 1, 2011 15:11
check ruby version for codevs
File.open('result.txt', 'w') do |f|
f << RUBY_DESCRIPTION
while line = STDIN.gets
f << line
STDOUT.print '0'
STDOUT.flush
end
end
@niku
niku / 365.rb
Created March 1, 2012 06:20
1から365の数字の組み合わせで、合計が 1000 になるもののうち,組み合わせた要素の数が最大のものを求める
# -*- coding: utf-8 -*-
result = (1..365).take_while { |i|
# 枝刈り
# (1..i)の合計(組み合わせの最小値)が1000を超えないものを対象にする
(1..i).reduce(:+) < 1000
}.map { |i|
(1..365).to_a.combination(i)
}.map { |e|
# スレッドに分けて高速化
Thread.new(e) { |g|
@niku
niku / anything-git-project.el
Created March 6, 2012 01:19 — forked from yaotti/anything-git-project.el
List up all files under the control of git and do something (open/view/delete/etc) with them
(defun anything-c-sources-git-project-for (pwd)
(loop for elt in
'(("Modified files (%s)" . "--modified")
("Untracked files (%s)" . "--others --exclude-standard")
("All controlled files in this project (%s)" . ""))
collect
`((name . ,(format (car elt) pwd))
(init . (lambda ()
(unless (and ,(string= (cdr elt) "") ;update candidate buffer every time except for that of all project files
(anything-candidate-buffer))
@niku
niku / mount-ram.sh
Created April 29, 2012 16:55 — forked from koshigoe/mount-ram.sh
Like tmpfs in Mac OSX
#!/bin/sh
# This program has two feature.
#
# 1. Create a disk image on RAM.
# 2. Mount that disk image.
#
# Usage:
# $0 <dir> <size> <volume>
#
def plus5div2 ary
plus5 = ->(input){ input + 5 }
div2 = ->(input){ input / 2 }
ary.map(&plus5).map(&div2)
end
plus5div2 [2, 4, 5, 3] # => [3, 4, 5, 4]