User.order('rand()').first
User Load (2.5ms) SELECT `users`.* FROM `users` ORDER BY rand() LIMIT 1
User.select(:id).order('rand()').first.reload
describe '.bar' do | |
subject { Foo } | |
it { should_receive(:boo) } | |
it { should_receive(:baa) } | |
# when | |
after do | |
subject.bar | |
end | |
end |
params[:upload_file].tap do |upload_file| | |
file = upload_file.tempfile.tap | |
master_class = upload_file.original_filename.sub('.csv', '').classify | |
master_class.delete_all | |
csv = CSV.parse(file.read, headers: true) | |
csv.each do |row| | |
row = row.to_hash.with_indifferent_access | |
row.delete(nil) | |
if row[:id] | |
master_class.new(row).tap {|record| |
# coding: utf-8 | |
require 'open-uri' | |
module Ikioi | |
module_function | |
def run | |
puts ActiveSupport::JSON.decode(open('http://2ch-ranking.net/ranking.json?board=gameswf') | |
.read.sub('callback(', '').sub(/\);$/, '')).find {|item| item['title'].include? "あらあらかしこ" }['ikioi'] | |
rescue | |
puts 0 | |
end |
dotcloud run www 'cd current; rake foo' |
module Helper | |
module Notification | |
def setup(args) | |
time = args[:time] | |
text = args[:text] | |
opts = args[:opts] | |
UILocalNotification.alloc.init.tap do |notif| | |
notif.fireDate = NSDate.dateWithString( time.to_s ) |
User.order('rand()').first
User Load (2.5ms) SELECT `users`.* FROM `users` ORDER BY rand() LIMIT 1
User.select(:id).order('rand()').first.reload
class Friendship < ActiveRecord::Base | |
scope :of_user, ->(user) { union(where(user1_id: user), where(user2_id: user)) } | |
class << self | |
def union(*relations) | |
union_clause = "(#{relations.map {|r| r.ast.to_sql }.join(') UNION (')})" | |
as_clause = "AS #{self.table_name}" | |
from "(#{union_clause}) #{as_clause}" |
button { | |
label { | |
position: 0 0; | |
} | |
image-view { | |
position: 0 0; | |
} | |
} |
ssh gerrit.example.com -p 29418 gerrit stream-events | jq '.|select(.type == "comment-added")|{comment, url: .change.url}|.[]' --raw-output | ruby -e "require 'carrier-pigeon'; loop { message = STDIN.gets; if message then CarrierPigeon.send(uri: 'irc://gerrit:password@irc.example.com/#gerrit', message: message, ssl:true, notice:true, join:true) ; p message ;end }" |
#!/usr/bin/env ruby | |
require 'carrier-pigeon' | |
require 'json' | |
require 'pp' | |
command = <<EOS | |
ssh gerrit.example.com gerrit stream-events | |
EOS | |
IO.popen(command, 'r+') do |io| |