Skip to content

Instantly share code, notes, and snippets.

@KitaitiMakoto
KitaitiMakoto / chapter-02.hs
Created November 3, 2011 19:25
Excersises of Pragramming in Haskell
-- 3.
n = a `div` length xs
where
a = 10
xs = [1,2,3,4,5]
-- 4.
last1 xs = xs!!(length xs - 1)
last2 xs = head (reverse xs)
last3 xs = head (drop (length xs - 1) xs)
@KitaitiMakoto
KitaitiMakoto / file0.txt
Created February 26, 2012 13:33
PHP-CSS-ParserのDeclarationBlockは__toString()が使える ref: http://qiita.com/items/2837
<?php
require(dirname(__FILE__) . '/../CSSParser.php');
$cssFile = 'epub/OEBPS/stylesheet.css';
$parser = new CSSParser(file_get_contents($cssFile));
$css = $parser->parse();
foreach ($css->getAllDeclarationBlocks() as $db) {
echo $db, PHP_EOL;
echo '---------------------------------------------', PHP_EOL;
@KitaitiMakoto
KitaitiMakoto / file0.txt
Created March 1, 2012 17:41
SCSSをCSSにして送るだけのサーバー ref: http://qiita.com/items/2923
require 'sass/plugin/rack'
use Sass::Plugin::Rack
run Rack::File.new('./public/')
@KitaitiMakoto
KitaitiMakoto / file0.txt
Created March 12, 2012 11:46
正規表現の中で名前付きグループの後方参照 ref: http://qiita.com/items/3144
# 文字列からクォートのペアを取り除く
re = /(?<quote>['"])(?<body>[^'"]*)\k<quote>/
puts "These are 'quotes'".gsub(re, '\k<body>')
@KitaitiMakoto
KitaitiMakoto / file0.txt
Created March 14, 2012 16:55
SCSS拡張のCompassで、background: url(...);の後ろにパラメーターを付ける ref: http://qiita.com/items/3180
compass watch --sass-dir=sass --css-dir=css --images-dir=images
@KitaitiMakoto
KitaitiMakoto / Rakefile
Created March 16, 2012 16:37
開発用ディレクトリーとチェック用ディレクトリーをすばやく切り替える方法は? ref: http://qiita.com/items/484b7242322c5f4f6e94
desc 'チェック用リポジトリーのブランチを切り替えます'
task :checkrepo, [:branch] do |t, args|
if args[:branch].nil? || args[:branch].empty?
$stderr.puts 'ブランチ名を指定してください'
$stderr.puts '使い方:rake checkrepo[branchname]'
exit!
end
Dir.chdir '../check' do
unless system("git checkout #{args[:branch]}")
@KitaitiMakoto
KitaitiMakoto / file0.txt
Created March 18, 2012 08:49
Rabbitでリンクを含むMarkdownでエラー ref: http://qiita.com/items/c892146aff09afe0a204
リンクを含んでいるとエラー?
============================
Cucumber
========
参考書
* [『Build Awesome Command-Line Applications in Ruby』][1]
* [『はじめる! Cucumber』][2]
@KitaitiMakoto
KitaitiMakoto / file0.rb
Created April 26, 2012 19:21
ファイルから読み込む時に自動的にBOMを削除する ref: http://qiita.com/items/2e2d425e439d4b16a279
content = open(file, 'r:BOM|UTF-8') {|f| f.read}
@KitaitiMakoto
KitaitiMakoto / file0.rb
Created May 28, 2012 09:50
RSSライブラリーでREXMLを使う時とNokogiriを使う時のベンチマーク ref: http://qiita.com/items/ab872c13d2cf40fc572a
require 'benchmark'
require 'open-uri'
require 'rss'
require 'rss/nokogiri'
uri = 'http://ja.wikipedia.org/w/index.php?title=%E7%89%B9%E5%88%A5:%E6%9C%80%E8%BF%91%E3%81%AE%E6%9B%B4%E6%96%B0&feed=atom'
xml = open(uri) {|f| f.read}
Benchmark.bmbm do |x|
x.report 'REXML from URI' do
@KitaitiMakoto
KitaitiMakoto / RunningHiki.markdown
Created May 28, 2012 19:20
Running Hiki on Sqale

RunningHiki

Sqale に Hiki をインストールする方法を説明します。

Hikiとは

[Hiki][hiki] とは、軽量でシンプルな Wiki エンジンです。はじめからついてくるプラグインに加え、簡単な Ruby スクリプトを書くことで自分のプラグインを作成することもできます。また、[tDiary][tdiary] の豊富なテーマを流用することができます(後述します)。

以下、Sqale に Hikiを インストールして動かす方法を説明していきます。 「[公開鍵の設定][pubkey]」から、鍵を登録しておいてください。