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
# Migrate schema and data from Mongoid to MySQL ActiveRecord | |
class MongoidMysqlMigrator | |
def randomize_auto_increment_values(source_models, from=5500, to=10500) | |
source_models.each do |model| | |
value = rand(from-to)+from | |
sql = %(ALTER TABLE #{model.name.tableize} AUTO_INCREMENT=#{value}) | |
puts sql | |
ActiveRecord::Base.connection.execute(sql) | |
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
#!/usr/bin/env ruby | |
require 'optparse' | |
require 'pty' | |
#TODO: PTY pushes messages but not the nice progress provided by `heroku pgbackups` | |
# Pushes messaging from a shell command to stdout. | |
# So that child processes can report to the script output | |
# @param cmd [string] the external process to run | |
# |
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 | |
if ARGV[0].nil? | |
puts "List the local branches of a git repository that contain the most recent release of a heroku app." | |
puts "usage: released-from heroku-app-name" | |
exit | |
else | |
h = `heroku releases -n1 -a#{ARGV[0]}` | |
puts h | |
parsed = h.scan(/Deploy (.{7}) /).flatten[0] | |
unless parsed.nil? |
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
12:12:27 web.1 | started with pid 6842 | |
12:12:29 web.1 | I, [2013-12-03T12:12:29.239032 #6842] INFO -- : Refreshing Gem list | |
12:12:33 web.1 | /moped-2.0.0.beta4/lib/moped/operation/read.rb:50:in `block in execute': The operation: #<Moped::Protocol::Query (Moped::Errors::QueryFailure) | |
12:12:33 web.1 | @length=51 | |
12:12:33 web.1 | @request_id=5 | |
12:12:33 web.1 | @response_to=0 | |
12:12:33 web.1 | @op_code=2004 | |
12:12:33 web.1 | @flags=[] | |
12:12:33 web.1 | @full_collection_name="app19591881.roles" | |
12:12:33 web.1 | @skip=0 |
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
alias stopsql='sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist' | |
alias startsql='sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist' | |
alias l='ls -las' | |
alias 'tailr'='tail -f ./log/development.log' | |
alias 'ec2_describe'='$EC2_HOME/bin/ec2-describe-images | grep machine' | |
alias 'ec2_status'='$EC2_HOME/bin/ec2-describe-instances' | |
alias 'ec2_start'='$EC2_HOME/bin/ec2-run-instances $1 -k gsg-keypair' | |
alias 'ec2_stop'='ec2-terminate-instances $1' | |
alias 'ec2_connect'='ssh -i id_rsa-gsg-keypair root@{$1}' | |
alias 'updatedb'='sudo /usr/libexec/locate.updatedb' |
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 defined?(NewRelic) | |
Sircle.class_eval do | |
class << self | |
include NewRelic::Agent::MethodTracer | |
# all methods defined in sircle.rb | |
self.methods(false).each do |method| | |
add_method_tracer method.to_s, "Custom/Sircle/#{method}" | |
end | |
end | |
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
# Add review (comment) | |
([{"request_path"=>"http://staging2.sircleadvertising.com/people/ito/4eb9dd393132182d9300/Actions?h=J8th3fK7", | |
"request_body"=>"<TrackingActionReviewUnsolicited i:type=\"TrackingActionReviewUnsolicited\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.datacontract.org/2004/07/SIRCLE.DataAccess.BusinessObjects.External\"><ActionID>46</ActionID><CategoryName>Administrative</CategoryName><ExternalID>4eb9dd393132182d9300000e</ExternalID><ProductID>38</ProductID><Review>Eye shadow is great</Review></TrackingActionReviewUnsolicited>", | |
"status_code"=>200, | |
"response_body"=>"false", | |
"request_method"=>"post", "_id"=>BSON::ObjectId('4ebfcdea313218f2d7000086'), "updated_at"=>2011-11-13 14:02:18 UTC, "created_at"=>2011-11-13 14:02:18 UTC}] | |
# Add Rating | |
([{"request_path"=>"http://staging2.sircleadvertising.com/people/ito/4eb9dd393132182d9300/Actions?h=J8th3fK7", | |
"request_body"=>"<TrackingActionRating xmlns=\"http://schemas.datacontract.org/2004/07/SIRCLE.DataAccess. |
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
def self.post_product_suggestion(user, data) | |
#TODO: STUBBED HERE UNTIl SIRCLE implements | |
action_id = nil | |
return_data = post('/Actions', user) do |xml| | |
xml.TrackingActionRecommendation(:xmlns => SIRCLE_XML_NS) { | |
xml.ActionID action_id # SIRCLE will tell us! | |
xml.CategoryName 'Products' | |
# brand_id would be INT of existing Brand , brand_name would be User input String of New brand | |
xml.Brand = data['brand_name'] || data['brand_id'] | |
xml.ProductName = data['product_name'] # User input String of product name |
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
LOCAL DEV: | |
ruby-1.9.2-p290 :001 > p = Sircle.get_products(Sircle::UserZero)[0] | |
=> {"Brand"=>{"ExternalLoginUserName"=>nil, "ID"=>4, "Logo"=>"http://staging2.sircleadvertising.com/SampleImage/ITO/16?h=J8th3fK7", "Name"=>"Lift Lab"}, "ID"=>1, "ImageURL"=>"http://staging2.sircleadvertising.com/SampleImage/ITO/28?h=J8th3fK7", "Name"=>"Facial Cream", "SampleIDs"=>[], "Subcategory"=>{"Category"=>{"ID"=>1, "Name"=>"Bath & Body"}, "ID"=>8, "Name"=>"Deodorant"}} | |
ruby-1.9.2-p290 :002 > | |
HEROKU CONSOLE: | |
>> p = Sircle.get_products(Sircle::UserZero)[0] | |
=> #<SircleProduct:0x00000006bf4b80 @attributes=<#Hashie::Mash brand=<#Hashie::Mash external_login_user_name=nil id=4 logo="http://staging2.sircleadvertising.com/SampleImage/ITO/16?h=J8th3fK7" name="Lift Lab"> id=1 image_url="http://staging2.sircleadvertising.com/SampleImage/ITO/28?h=J8th3fK7" name="Facial Cream" sample_i_ds=[] subcategory=<#Hashie::Mash category=<#Hashie::Mash id=1 name="Bath & Body"> id=8 name="Deodorant">>> | |
>> |
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
LOCAL DEV: | |
ruby-1.9.2-p290 :001 > p = Sircle.get_products(Sircle::UserZero)[0] | |
=> {"Brand"=>{"ExternalLoginUserName"=>nil, "ID"=>4, "Logo"=>"http://staging2.sircleadvertising.com/SampleImage/ITO/16?h=J8th3fK7", "Name"=>"Lift Lab"}, "ID"=>1, "ImageURL"=>"http://staging2.sircleadvertising.com/SampleImage/ITO/28?h=J8th3fK7", "Name"=>"Facial Cream", "SampleIDs"=>[], "Subcategory"=>{"Category"=>{"ID"=>1, "Name"=>"Bath & Body"}, "ID"=>8, "Name"=>"Deodorant"}} | |
ruby-1.9.2-p290 :002 > | |
HEROKU CONSOLE: | |
>> p = Sircle.get_products(Sircle::UserZero)[0] | |
=> #<SircleProduct:0x00000006bf4b80 @attributes=<#Hashie::Mash brand=<#Hashie::Mash external_login_user_name=nil id=4 logo="http://staging2.sircleadvertising.com/SampleImage/ITO/16?h=J8th3fK7" name="Lift Lab"> id=1 image_url="http://staging2.sircleadvertising.com/SampleImage/ITO/28?h=J8th3fK7" name="Facial Cream" sample_i_ds=[] subcategory=<#Hashie::Mash category=<#Hashie::Mash id=1 name="Bath & Body"> id=8 name="Deodorant">>> | |
>> |
NewerOlder