Ruby および Rails 用の auto-complete.el の辞書
# Gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.0'
gem 'pg'
module M | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def b | |
puts 'b' | |
end | |
end |
module M | |
def self.prepended(base) | |
class << base | |
self.prepend(ClassMethods) | |
end | |
end | |
module ClassMethods | |
def c | |
puts 'c' |
# depends on save, save!, create, create! | |
module RetryIfCollide | |
extend ActiveSupport::Concern | |
def save(*) | |
self.class._retry_if_collide { super } | |
end | |
def save!(*) | |
self.class._retry_if_collide { super } |
echo "This script requires superuser access to install rpm packages." | |
echo "You will be prompted for your password by sudo." | |
# clear any previous sudo permission | |
sudo -k | |
# run inside sudo | |
sudo sh <<SCRIPT | |
# add GPG key |
require 'test/unit' | |
class TestSample < Test::Unit::TestCase | |
def setup | |
end | |
def test_sample | |
coins = [1, 5, 50] | |
target_coin = 10 | |
assert do |
def method_chain_stub | |
object = Object.new | |
object.instance_eval do | |
self.singleton_class.class_eval do | |
define_method(:method_missing) { |name| self } | |
end | |
end | |
object | |
end |
# Rubyによる依存関係逆転の原則 | |
class Button | |
# 規約: 引数`device`は `on?`, `turn_on`, `turn_off`に反応すること | |
def initialize(device) | |
@device = device | |
end | |
def press | |
if @device.on? |
run ->(env) { [200, { 'Content-Type' => 'text/html' }, ['Hello, World']] } |
(defun note () | |
(interactive) | |
(let ((path "~/Dropbox/Notes/text/") (filename (format-time-string "%Y%m%d%H%M%S"))) | |
(if (file-directory-p path) (switch-to-buffer (find-file (concat path filename ".md"))) | |
(message (concat "No such directory: " path))))) | |
(global-set-key (kbd "C-c m") 'note) | |
(defun ruby () | |
(interactive) | |
(let ((path "~/Dropbox/Notes/ruby/") (filename (format-time-string "%Y%m%d%H%M%S"))) |
Ruby および Rails 用の auto-complete.el の辞書
# Gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.0'
gem 'pg'