- 名前の登録 フォーム
get :name
- 郵便番号の登録 フォーム
get :zip
- 電話番号の登録 フォーム
# ???controller_spec.rb | |
[AController, BController].each do |cotroller| | |
describe controller do | |
it do | |
#共通するテスト | |
end | |
end | |
end | |
# a_controller_spec.rb | |
describe AController do |
class Kuji | |
attr_accessor :bars | |
def initialize(num, length = nil) | |
@num = num | |
length = 4 if length.nil? | |
@bars = Array.new(length) { |index| Array.new(num - 1, false) } | |
end | |
def generate | |
@bars.each do |bar| |
def authenticate | |
redirect_to root_url unless current_user | |
end |
# application_controller.rbに定義 | |
def authenticate | |
redirect_to :root unless current_user | |
end | |
# 認証の必要なコントローラーの最初の行にbefore_filterを定義 | |
class HogeController | |
before_filter authenticate # ←コレ |
get :name
get :zip
task :hoge do | |
temp_file = "/tmp/config.txt" | |
ssh_conf = "/root/.ssh/config" | |
run "echo 'Host *' > #{temp_file}" | |
run "echo 'StrictHostKeyChecking no' >> #{temp_file}" | |
run "echo 'UserKnownHostsFile /dev/null' >> #{temp_file}" | |
run "sudo mv #{temp_file} #{ssh_conf}" | |
run "sudo chmod 600 #{ssh_conf}" | |
run "sudo chown root:root #{ssh_conf}" | |
end |
# coding: utf-8 | |
require 'rubygems' | |
require 'qiita' | |
# use name and password | |
qiita = Qiita.new( url_name: 'username', password: 'password') | |
# Get token | |
p token = qiita.token |
#!/usr/bin/env ruby -w -s | |
# -*- coding: utf-8 -*- | |
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" | |
#```ruby | |
require 'axlsx' | |
examples = [] | |
examples << :basic | |
examples << :custom_styles | |
examples << :cell_style_override |
# a >= b >= c | |
def split(no, min, bit) | |
if bit <= 3 | |
no.times do |a| | |
b = no - a | |
if a >= b && b >= min | |
split1(a, b, bit + 1) | |
if bit == 2 | |
puts "#{a}:#{b}" | |
elsif bit == 3 |
g=`which git` | |
t=`which tig` | |
tig(){ $g $*; } | |
git(){ $t $*; } | |
alias gti=tig |