Skip to content

Instantly share code, notes, and snippets.

View rummelonp's full-sized avatar
🐈‍⬛
ニャーン

Kazuya Takeshima rummelonp

🐈‍⬛
ニャーン
View GitHub Profile
@rummelonp
rummelonp / oniisama.rcp
Created August 25, 2014 10:07
oniisama.el の el-get の rcp
(:name oniisama
:type github
:pkgname "yu-i9/oniisama")
@rummelonp
rummelonp / beautiful-controller-spec.sh
Created August 22, 2014 10:57
rails generate controller で生成される controller 取り敢えず skip にして action ごとの method も合わせるやつ
#!/usr/bin/env bash
echo "$@" | xargs gsed -i "
s/describe \"\(.*\) \(.*\)\"/skip '\1 \"\2\"'/g;
s/it \"returns http success\" do/it do/g;
s/GET \"create\"/POST \"create\"/;
s/get :create/post :create/;
s/GET \"update\"/PATCH \"update\"/;
s/get :update/patch :update/;
s/GET \"destroy\"/DELETE \"destroy\"/;
@rummelonp
rummelonp / application.html.erb
Last active August 29, 2015 14:05
雑なディスパッチャ
<!DOCTYPE html>
<html>
<head>
<%= javascript_include_tag "application" %>
</head>
<body data-route="<%= controller_name %>#<%= action_name %>">
</body>
</html>
@rummelonp
rummelonp / git-stats
Last active August 29, 2015 14:05
git で今週の総追加行数/総削除行数を出すサブコマンド改 http://mitukiii.hatenablog.com/entry/2014/08/14/221805
#!/usr/bin/env bash
stats() {
local desc="$1"
local from="$2"
local to="${3:-$from}"
local since="$(date -v${from} +'%Y-%m-%d') 00:00:00"
local until="$(date -v${to} +'%Y-%m-%d') 23:59:59"
echo $desc
@rummelonp
rummelonp / git-ignore-template
Last active August 29, 2015 14:05
gitignore 生成するやつ
#!/usr/bin/env bash
curl "http://www.gitignore.io/api/$(IFS=,; echo "$*")"
@rummelonp
rummelonp / typed_coffee_script.rb
Created August 20, 2014 18:02
Rails でめっちゃ雑に TypedCoffeeScript 使う
require 'open3'
module TypedCoffeeScript
class Error < StandardError
end
class NotInstalled < Error
end
class Template < Tilt::Template
@rummelonp
rummelonp / Vagrantfile.rb
Created August 18, 2014 11:05
DigitalOcean 用 Vagrantfile 雛形
VAGRANTFILE_API_VERSION = '2'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.hostname = '<Your Hostname>'
config.vm.provider :digital_ocean do |provider, config|
config.vm.box = 'digital_ocean'
config.vm.box_url = 'https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box'
config.ssh.private_key_path = '<Your SSH Private Key Path>'
@rummelonp
rummelonp / negitoro.rb
Created August 15, 2014 18:44
雑な MeCab の Ruby バインディング
class Negitoro
extend FFI::Library
ffi_lib 'mecab'
attach_function :mecab_new2, [:string], :pointer
attach_function :mecab_sparse_tostr, [:pointer, :string], :string
attach_function :mecab_destroy, [:pointer], :void
def self.clean_proc(tagger)
Proc.new { mecab_destroy tagger }
@rummelonp
rummelonp / git-stats
Last active August 29, 2015 14:05
git で今週の総追加行数/総削除行数を出すサブコマンド http://mitukiii.hatenablog.com/entry/2014/08/14/221805
#!/usr/bin/env ruby
require 'date'
def stats(desc, from, to = from)
command = "git log" <<
" --oneline" <<
" --shortstat" <<
" --no-merges" <<
" --since='#{from.strftime('%Y-%m-%d')} 00:00:00'" <<
@rummelonp
rummelonp / nyan.md
Created August 12, 2014 13:18
A has_many B, B belongs_to C の A fields_for B で C を一覧に出しつつ checkbox で操作して作成したり削除したりしたいみたいなやつ
class Staff
  has_many :staff_holidays
  accepts_nested_attributes_for :staff_holidays, allow_destroy: true
end
class StaffHoliday
  has_many :staff_holidays