This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem "fastimage", "~>1.2.13" | |
module ApplicationHelper | |
include ActionView::Helpers::AssetTagHelper | |
# 画像サイズ見て自動でwidth/height属性つけるimage_tag | |
def image_tag_with_auto_size(source, options) | |
if options[:size] || options[:width] || options[:height] | |
image_tag_without_auto_size(source, options) | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/environments/development.rb | |
# ActiveRecord 3.2.8 / mysql2 0.3.11 | |
Application.configure do | |
config.after_initialize do | |
class ActiveRecord::ConnectionAdapters::Mysql2Adapter | |
def execute_with_warning_is_error(sql, *rest) | |
result = execute_without_warning_is_error(sql, *rest) | |
warnings = execute_without_warning_is_error('show warnings', :skip_logging).to_a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Application.configure do | |
config.after_initialize do | |
# Partialの情報をHTMLに埋める | |
# For ActionPack 3.2.8 | |
class ActionView::PartialRenderer | |
def render_with_partial_annotation(*args) | |
setup(*args) | |
path = @path | |
content = "".html_safe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# まだテーブル構造がちゃんと決まってないので、データをコード内にベタ書きしてある。 | |
# 将来的にはActiveRecord化してDBに保存したい。 | |
class NewModel | |
def self.find(id) | |
INSTANCES[id] || (raise "not found") | |
end | |
INSTANCES = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding:utf-8 -*- | |
raise <<EOS | |
MOVED: https://github.com/todesking/svn-cherry-pick | |
EOS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
def hsv_to_rgb(h, s, v) | |
h_i = (h*6).to_i | |
f = h*6 - h_i | |
p = v * (1 - s) | |
q = v * (1 - f*s) | |
t = v * (1 - (1 - f) * s) | |
r, g, b = v, t, p if h_i==0 | |
r, g, b = q, v, p if h_i==1 | |
r, g, b = p, v, t if h_i==2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\\t => \\2/' | sort | |
a = add | |
a-i = add -i | |
a-p = add -p | |
co = checkout | |
b = branch | |
k = !gitk --all --max-count=200 & | |
s = status -sb | |
ci = commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum A { | |
Hoge(CONST); // Cannot reference a field before it is defined | |
private static int CONST = 1; | |
private A(int x) { | |
} | |
} | |
public enum B { // Syntax error on token "{", ; expected after this token | |
private static int CONST = 1; | |
Hoge(CONST); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 自分で定義したDateRange型から、where条件を生成したい */ | |
-- before | |
select * from table | |
where | |
update_time between /*range.getStart()*/'2011-01-01' and /*range.getEnd()*/'2011-12-31' | |
-- after | |
select * from table | |
where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function __show_errorcode() { | |
ERR=$? | |
if [ $ERR != 0 ]; then | |
echo -en "\033[31m\$?=$ERR" | |
fi | |
} | |
function __show_jobs() { | |
JOBS=$(jobs|sed 's/ \+/\t/g'|cut -f1,3|tr \\t :|tr \\n ','|sed 's/,$//'|sed 's/,/, /g') | |
if [ "$JOBS" != "" ]; then |