This file contains 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
# Simple examples are wussy, here's a complicated one | |
# User belongs_to Circle, Tags has_many User, Tags has_many Circle | |
Factory :user do | |
has_a :circle | |
has_many :tag | |
end | |
Factory :circle do |
This file contains 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
[1] pry(main)> class Foo | |
[1] pry(main)* class Bar | |
[1] pry(main)* end | |
[1] pry(main)* end | |
nil | |
[2] pry(main)> foo = Foo.new | |
#<Foo:0x007f8cea8121e8> | |
[3] pry(main)> Foo::Bar | |
Foo::Bar < Object |
This file contains 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 :chronicle do | |
desc "Rename Store tags in Chronicle after Accounts integration" | |
task :migrate_for_accounts, [:client_id] => :environment do |t, args| | |
client = Client.find(args.client_id) | |
vitrue_id = client.vitrue_id_for_account.to_s | |
stores = client.stores | |
stores.find_each do |store| | |
old_tag = "s:#{store.id}" | |
new_tag = "s:#{store.vitrue_id_for_resource}" | |
# ChronicleClient::Tabs::TagRename.rename(old_tag, new_tag, vitrue_id) |
This file contains 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
def zipflaw(x, i) | |
j = 0 | |
k = 1 | |
i.times do | |
# I was stuck for awhile because I wasn't using floating points and the error was enough to move my answer back by 2 ranks! | |
j += x.to_f/k.to_f | |
k += 1 | |
end | |
j | |
end |
This file contains 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
# coffeescript, deps include node ~v0.6.6, jsdom, jQuery (node version) | |
fs = require 'fs' | |
jsdom = require 'jsdom' | |
data = [] | |
deviation = [] | |
sum = 0 | |
devnsum = 0 |
This file contains 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 Integer | |
def factorial_iterative | |
f = 1; for i in 1..self; f *= i; end; f | |
end | |
def sum_digits | |
self.to_s.split(//).collect { |d| d.to_i}.sum | |
end | |
end |
This file contains 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
http = require 'http' | |
util= require 'util' | |
options = { | |
host: 'api.staging.cloud.vitrue.com', | |
port: 80, | |
path: '/chronicle/1/', | |
method: 'GET', | |
disable_ssl_peer_verification: true, | |
timeout: 200 |
This file contains 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 | |
queue_length = `/opt/redis-2.2.2/bin/redis-cli zcard q:jobs:total_report:inactive` | |
begin | |
if queue_length.to_i > 50000 | |
puts "status ok there are #{queue_length.to_i} jobs" | |
elsif queue_length > 10000 | |
puts "status warn there are #{queue_length.to_i} jobs" | |
else | |
puts "status err there are #{queue_length.to_i} jobs" |
This file contains 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
def upload_sizing | |
result = {} | |
size = {:width => self.upload_width, :height => self.upload_height} | |
thumb_size = {:width => self.upload_thumb_width, :height => self.upload_thumb_height} | |
keys = [] | |
keys.push "resize" if self.enable_images? | |
keys.push "encode" if self.enable_videos? | |
keys.each do |key| |
NewerOlder