Skip to content

Instantly share code, notes, and snippets.

@sugamasao
sugamasao / gist:753177
Created December 23, 2010 16:05
こんな感じのエラーになります><
% cat create.php
<?php
include('rhaco3.php');
$dbc = new \org\rhaco\store\db\Dbc(
'{"type":"org.rhaco.store.db.module.Sqlite","dbname":"board"}'
);
$dbc->query('create table board('
.'id integer primary key autoincrement'
.',name text,comment text,created_at text)'
);
@sugamasao
sugamasao / gist:753196
Created December 23, 2010 16:20
php -v
PHP 5.3.2 (cli) (built: Oct 13 2010 13:09:53)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with XCache v1.3.0, Copyright (c) 2005-2009, by mOo
@sugamasao
sugamasao / define.php
Created April 13, 2011 09:05
これぐらいできるよ
% cat unko.php
<?php
define('HOGE', 'hogehoge');
echo HOGE
?>
% php unko.php
hogehoge
@sugamasao
sugamasao / gist:992696
Created May 26, 2011 07:14
watchrでrstファイルを監視
# gem install watchr でインストールできるよ
# watchr hogehoge.rb で実行するよ
require 'watchr'
target_file = 'hogehoge.rst'
watch(target_file) do |md|
system("date;rst2html.py #{md[0]} #{File.basename(md[0], '.rst')}.html")
end
@sugamasao
sugamasao / gist:1158633
Created August 20, 2011 03:59
整数値を16進数のコロン区切りに
:035 > 100000.to_s(16).reverse.scan(/.{1,4}/).join(':').reverse
=> "1:86a0"
:036 > 102400.to_s(16).reverse.scan(/.{1,4}/).join(':').reverse
=> "1:9000"
:037 > 102400.to_s(16)
=> "19000"
@sugamasao
sugamasao / gist:1278649
Created October 11, 2011 16:47
座標変換のつもり
def x_rotate(x, y, r)
(x * Math.cos(r/180.0 * Math::PI)) - (y * Math.sin(r/180.0 * Math::PI))
end
def y_rotate(x, y, r)
(x * Math.sin(r/180.0 * Math::PI)) + (y * Math.cos(r/180.0 * Math::PI))
end
def rotate(x, y, r);
{:x => x_rotate(x, y, r), :y => y_rotate(x, y, r)}
@sugamasao
sugamasao / gist:1289822
Created October 15, 2011 16:46
ReVIEWのh1とかのタグの a タグをどうにかする
# lib/review/htmlbuilder.rb
def headline(level, label, caption)
prefix, anchor = headline_prefix(level)
puts '' if level > 1
a_id = anchor.nil? ? "" : "h#{anchor}"
if caption.empty?
# ここの出力が何が正しいのかよくわかんないんだよなー
unless label.nil?
puts %Q[<a id="#{a_id}" >#{a_id}</a>] unless a_id.empty?
@sugamasao
sugamasao / gist:1306865
Created October 23, 2011 04:09
rubyのtrunkをSnow Leopard(10.6.8)でビルドした結果
0. %uname -a
Darwin gram.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
1. %svn co http://svn.ruby-lang.org/repos/ruby/trunk/ ruby_src_20111023
リビジョン: 33510
2. %autoconf
3. %./configure --prefix=$HOME/rubies/ruby_20111023
4. %make
CC = gcc
LD = ld
LDSHARED = gcc -dynamic -bundle
@sugamasao
sugamasao / gist:1307620
Created October 23, 2011 17:35
rubyのtrunkをSnow Leopard(10.6.8)でビルドした結果(test-all)
= 結果 =
9791 tests, 2208074 assertions, 26 failures, 72 errors, 46 skips
= 環境 =
% uname -a
Darwin gram.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
== 以下ログ ==
%svn co http://svn.ruby-lang.org/repos/ruby/trunk/ ruby_src_20111024/
(略)
@sugamasao
sugamasao / gist:1321263
Created October 28, 2011 00:09
スノレパ rev33528
定期的に実行
Updating http://svn.ruby-lang.org/repos/ruby/trunk
U ChangeLog
U version.h
U test/ruby/test_path.rb
U file.c
At revision 33528
[workspace] $ /bin/sh -xe /var/folders/zz/zzzivhrRnAmviuee+++++E++++2/-Tmp-/hudson3121286858741482101.sh
+ ORG_HOME=/var/root
+ HOME=/Users/Shared/Jenkins/Home