Skip to content

Instantly share code, notes, and snippets.

View ainame's full-sized avatar

Satoshi Namai ainame

View GitHub Profile
@ainame
ainame / remove_resnpond_block.rake
Created July 14, 2011 16:35
Rails3のscaffoldで生成されたコントローラーからrespond_toブロックを消す。lib/taskに配置して使う
# -*- coding: utf-8 -*-
require "tempfile"
desc "scaffoldで生成されたコントローラーからrespond_toブロックを消す"
namespace :my do
task :rm_respond_to do
Dir::glob("app/controllers/*_*.rb") do |ctrl|
if !(File::basename(ctrl) =~ /application/)
temp = Tempfile::new("tmp",Dir::pwd)
open(ctrl) do |f|
text = f.read
@rummelonp
rummelonp / tumblr4r.rb
Created July 16, 2011 13:31
Ruby の Tumblr API v2 ラッパー
require 'oauth'
require 'json'
require 'cgi'
class Tumblr4r
def initialize(access_token)
@access_token = access_token
end
def api_key
@ainame
ainame / csa_reacord.rb
Created December 11, 2011 15:36
CSA形式の将棋の棋譜の完全一致チェック.kifu_check.rbの最後の部分でパラメーターを適宜編集.lib/csa_reacord.rbとlib/tree.rbを配置して利用.
# -*- coding: utf-8 -*-
# CSA形式の棋譜を表すクラス
class CsaRecord
Sente = true
Gote = false
attr_accessor :file
def initialize( *args )
option = args.pop
case option
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@chetan
chetan / yardoc_cheatsheet.md
Last active April 16, 2024 23:49
YARD cheatsheet
@shayarnett
shayarnett / README
Created May 10, 2012 13:13
Snippet generator for RubyMotion ctags
Generate ctags with `rake ctags`
Run snipper.rb
Put resulting ruby.snippets file where your snippet plugin can pick it up. (I'm using snipmate)
@mori-dev
mori-dev / gist:2905306
Created June 10, 2012 12:33
emacs24.1 にあって emacs23.4 にない関数
Man-bookmark-jump
abbrev-edit-save-buffer
abbrev-edit-save-to-file
abbrev-table-empty-p
allout-auto-activation-helper
allout-setup
allout-widgets-mode
allout-widgets-setup
balance-windows-1
balance-windows-2
@syohex
syohex / cperl-imenu.el
Created November 8, 2012 09:25
my own perl imenu. Default imenu provides too many information for me
(defun my/cperl-imenu-create-index ()
(let (index)
;; collect subroutine
(goto-char (point-min))
(while (re-search-forward "^\\s-*sub\\s-+\\([^ ]+\\)" nil t)
(push (cons (format "Function: %s" (match-string 1))
(match-beginning 1)) index))
;; collect subtest
(goto-char (point-min))
$ ->
game = new Main()
game.start()
#共通ライブラリ
#行列演算のための関数
##行列の和
addArray = (array1, array2) ->
array = []
len = array1.length
@rummelonp
rummelonp / 2012.md
Last active December 10, 2015 10:18
2012年振り返り

2012年振り返り

私生活

転職に伴い石川県から東京都に引っ越した

image

image