Skip to content

Instantly share code, notes, and snippets.

View thash's full-sized avatar
🌵
⭐️ ⭐️ ⭐️ ⭐️ ⭐️

Takuya Hashimoto thash

🌵
⭐️ ⭐️ ⭐️ ⭐️ ⭐️
View GitHub Profile
@thash
thash / memo.md
Created November 13, 2011 19:13
Rails3.1でOmniauth+MongoDB(Mongoid)なアプリを作成するまでの手順
% rails new myapp2 --skip-bundle --skip-test-unit -O

% vim Gemfile
    # https://gist.github.com/1360121
% bunle install --path vendor/bundle
    # bundle will create new directory
% git init
% vim .gitignore
    # ignore vendor/, log/ ...

% git a .

@thash
thash / clean-rails.sh
Created November 15, 2011 07:41
local gemをきれいに保ちながらRailsプロジェクトをnewする方法
# Usage: sh clean-rails.sh my_proj
mkdir $1
cd $1
cat <<__EOF__ > Gemfile
source 'http://rubygems.org'
gem 'rails'
__EOF__
bundle install --path vendor/bundle
#!/bin/sh
### check run as root
if [ "`whoami`" != "root" ]; then
echo "ERROR: should run as root"
exit 1
fi
### install yums
yum -y install gcc make zlib-devel wget
# -*- coding: utf-8 -*-
require 'yaml'
require 'pp'
settings_yaml = File.expand_path(File.dirname(__FILE__))+"/config/settings.yml"
settings = YAML::load(File.open(settings_yaml))
#p settings.class #=> Hash
p settings.keys

1. Launch!

Rails3では、関連コマンドをまとめるためにscript/serverがrails serverに変わっている。

1.1 bin/rails

実際のrailsコマンドはbin/railsにある。内容はこんな感じ。

#!/usr/bin/env ruby
@thash
thash / file0.vim
Created December 8, 2011 09:36
vimでhoge.rbというファイルを新しく作ったとき、ファイルの頭にshebang行を自動的に挿入する。 ref: http://qiita.com/items/1325
augroup SetShebang
autocmd! SetShebang
autocmd BufNewFile *.rb 0put =\"# -*- encoding: UTF-8 -*-\"|$
augroup END
@thash
thash / file0.html
Created January 8, 2012 21:18
CSSでfloatをかけた2カラムレイアウトを縦に並べたいのだが、ズレる。 ref: http://qiita.com/items/1610
<body>
<div id="content">
<div id="left_content">
<div class="box">
left
</div>
</div>
<div id="right_content">
<div class="box">
right-1
# 参考: http://stackoverflow.com/questions/8087610/ruby-debug-with-ruby-1-9-3
# Ruby1.9.3-p0でruby-debug19を使いたい。
=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
/Users/hash/work/Rails/giblos/vendor/bundle/ruby/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:212: [BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
@thash
thash / file0.rb
Created January 10, 2012 00:24
Rails3.1.3 + Ruby1.9.3-p0でruby-debug19が動かない件 ref: http://qiita.com/items/1625
gem 'ruby-debug19'
gem 'ruby-debug-base19x', '0.11.30.pre4'
@thash
thash / Home2Lang.scala
Created February 10, 2012 08:45 — forked from yuroyoro/Home2Lang.scala
プログラミング言語「ほむほむ」
import java.io.File
import scala.io.Source
import scala.util.matching.Regex
import scala.util.parsing.combinator._
import scala.util.parsing.input.{Position, NoPosition}
sealed abstract class Insn extends ( CED => CED ){
val pos:Position
}
case class App( m:Int, n:Int, pos:Position ) extends Insn{