Skip to content

Instantly share code, notes, and snippets.

@fukajun
fukajun / gist:4379121
Last active December 10, 2015 04:08
トピックブランチでやりましたよ
git reset --hard 自分がコミットを追加する前のコミットのhash
git merge ORIG_HEAD --no-ff -m "Merge branch '適当なトピックブランチ名'"

Railsの変更点

2013-01-22

  • イレギュラーな単数形に対応するための変更 activesupport/lib/active_support/inflector/inflections.rb

2013-01-21

@fukajun
fukajun / gist:5142075
Last active December 14, 2015 20:09
和暦の日付選択
 module ApplicationHelper
   
   def date_select_ja(object_name, method, options = {}, html_options = {})
     t = date_select(object_name, method, options, html_options)
     t.gsub(/>([12]\d\d\d)</) do |m|
       year = m.match(/>(\d\d\d\d)</)[1].to_i
       wareki = case year
       when 0..1911 # 明治
         "明治#{year - 1867}"
@fukajun
fukajun / gist:5226593
Created March 23, 2013 05:33
Install rsense
cd $HOME
mkdir -p lib/
wget http://cx4a.org/pub/rsense/rsense-0.3.zip
unzip rsense-0.3.zip
@fukajun
fukajun / pre-commit
Last active December 15, 2015 08:29
git commit の時にRubyの古いスタイルのハッシュをチェックするフック
#!/bin/sh
echo "========Check old type hash statement========="
git diff --cached | grep ":[^ ]* *=> *:[^ ]*"
result=$?
ret=0
if [ $result -eq 0 ]; then
echo "!!!!!!!!Include old type hash statement!!!!!!!"
ret=1
fi
@fukajun
fukajun / gist:5242750
Last active December 15, 2015 09:59
色見本
- 16.times do |r|
- 16.times do |g|
- 16.times do |b|
- if (r + 1) % 4 == 0 && (g + 1) % 4 == 0 && (b + 1) % 4 == 0
%span{:style => "background-color:##{'%01x'%r + '%01x'%g + '%01x'%b}"}
hoge
- k = 0
- (0..15).each do |r|
@fukajun
fukajun / gist:5637228
Created May 23, 2013 16:05
AXLSXで入力規則を使用するためのサンプル
ws.add_data_validation("C12", { :type => :list, :formula1 => 'A1:A2', :showDropDown => true})
require 'mandrill'
m = Mandrill::API.new
message = {
:subject=> "Hello from the Mandrill API",
:from_name=> "Your name",
:text=>"Hi message, how are you?",
:to=>[
{
:email=> "fukajun.shark@gmail.com",
:name=> "fukajun Test user"
@fukajun
fukajun / status.sql
Last active December 29, 2015 09:49
MYSQL
-- 接続ホスト接続数 接続時間
select left(host, 20) host_prefix, command, count(*), max(time)/3600 from INFORMATION_SCHEMA.PROCESSLIST group by host_prefix, command order by host_prefix;
crumb :oya do |oya|
link "Oya", oya_path(oya)
end
crumb :kodomo do |kodomo|
link "Kodomo", kodomo_path(kodomo)
parent :oya, kodomo.oya
end
crumb :mago do |mago|