This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ItemWrapper | |
include ActiveAttr::BasicModel | |
include ActiveAttr::Attributes | |
# ... | |
attribute :name | |
attribute :price | |
# ... | |
validate do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (RSpec::Core::Version::STRING.split('.').map(&:to_i) <=> [2,8,0]) >= 0 | |
# ... | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Get github access_token in API v3 | |
# see http://developer.github.com/v3/#authentication | |
# | |
# requirements: | |
# * curl | |
# * sed | |
read -p "User: " user | |
read -p "Password: " password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class Elat | |
attr :max, :primes | |
def initialize(max) | |
@max = max | |
@search = nil | |
@primes = [] | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ padrino rake -T (padrinosample)-(master)-(.) | |
=> Executing Rake -T ... | |
rake ar:abort_if_pending_migrations # Raises an error if there are pending migrations | |
rake ar:charset # Retrieves the charset for the current environment's database | |
rake ar:collation # Retrieves the collation for the current environment's database | |
rake ar:create # Create the database defined in config/database.yml for the current Padrino.env | |
rake ar:create:all # Create all the local databases defined in config/database.yml | |
rake ar:drop # Drops the database for the current Padrino.env | |
rake ar:drop:all # Drops all the local databases defined in config/database.yml | |
rake ar:forward # Pushes the schema to the next version. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :crontab do | |
desc 'display with crontab -l' | |
task :show, :roles => :app do | |
hosts = exists?(:cron_server) ? cron_server : roles[:app].servers.first | |
run "crontab -l", :hosts => hosts | |
end | |
desc 'read crontab from remote config/crontab/crontab.#{Rails.env}' | |
task :read do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 生成コードイメージ | |
# 仮想コード。 | |
# プロトコル(てきとう) | |
RPC.remote :userinfo do | |
method :get | |
route: "/userinfo" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: memoized in @current_user | |
# (1) | |
def current_user | |
@current_user ||= User.find(session[:user_id]) if session[:user_id] | |
end | |
# (6) | |
def current_user | |
@current_user ||= User.find_by_id(session[:user_id]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "net/https" | |
class Pushover | |
def initialize(api_token, user_key) | |
@api_token = api_token | |
@user_key = user_key | |
end | |
def message(_message) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe B do | |
describe "#foo" do | |
[ | |
#[ argument, expect] | |
[ 1, 'one'], | |
[ 2, 'two'], | |
[ 3, 'three'], | |
].each do |arg, expect| |