Skip to content

Instantly share code, notes, and snippets.

View benjohnson77's full-sized avatar

Ben Johnson benjohnson77

View GitHub Profile
@benjohnson77
benjohnson77 / upapt.sh
Created June 2, 2017 04:24 — forked from slickplaid/upapt.sh
Rackspace Ubuntu Server - Allow older system to get updates using apt with Rackspace's Mirrors
sudo sed -i -e 's/mirror.rackspace.com\|archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
@benjohnson77
benjohnson77 / ga.html
Created October 15, 2012 17:27
ga for multiple domain landing pages
This should go at the top of the landing page!!!
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-648272-12']);
_gaq.push(['_setDomainName', 'investingchannel.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
@benjohnson77
benjohnson77 / gist:7108171
Last active December 26, 2015 06:29
Comparing application performance on Rackspace vs Google Compute Engine
Started GET "/books" for 96.226.128.2 at 2013-10-22 20:18:56 +0000
Processing by Web::BooksController#index as HTML
User Load (2.7ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 38 LIMIT 1
(2.4ms) SELECT COUNT(*) FROM `reading_actions` WHERE `reading_actions`.`user_id` = 38 AND `reading_actions`.`action_type` = 'have_read'
(75.2ms) SELECT COUNT(*) FROM `reading_actions` WHERE `reading_actions`.`user_id` = 38 AND `reading_actions`.`action_type` = 'want_to_read'
(54.7ms) SELECT COUNT(*) FROM `reading_actions` LEFT OUTER JOIN readings ON readings.reading_action_id = reading_actions.id WHERE `reading_actions`.`user_id` = 38 AND (reading_actions.readable_type in ('Book', 'SocialBook') AND reading_actions.action_type = 'reading_now') AND (CASE WHEN readings.is_private = 1 THEN readings.user_id = 38 ELSE 1 = 1 END)
Rendered shared/v2/_breadcrumb.haml (2.3ms)
(2.8ms) SELECT COUNT(count_column) FROM (SELECT 1 AS count_column FROM `reading_actions` LEFT OUTER JOIN readings ON readings.readin
@benjohnson77
benjohnson77 / gist:7107825
Last active December 26, 2015 06:29
SQL benchmark on 3 different cloud platforms.
I decided to add RDS environment to my testing. So I can compare AWS(RDS) to rackspace(Rack DB) to GCE (cloud-SQL) and this is what I find running the same benchmark on all three. GCE is in the same zone, and for comparison AWS server is also in the same zone as RDS.
benchmark I am using is perl test-wisconsin from sql bench
Google
Wisconsin benchmark test
Time for create_table (3): 1 wallclock secs ( 0.00 usr 0.00 sys + 0.00 cusr 0.00 csys = 0.00 CPU)
Inserting data
Time to insert (31000): 317 wallclock secs ( 1.95 usr 2.09 sys + 0.00 cusr 0.00 csys = 4.04 CPU)
Time to delete_big (1): 0 wallclock secs ( 0.00 usr 0.00 sys + 0.00 cusr 0.00 csys = 0.00 CPU)
@benjohnson77
benjohnson77 / gist:6873279
Last active December 24, 2015 22:29
Looks like google knife needed some additional OHAI plugin to produce the same data as the AWS-knife command.
➜ crockpot git:(master) ✗>knife bootstrap ---- ommitted -----
Bootstrapping Chef on 173.255.117.224
173.255.117.224 Starting Chef Client, version 11.6.0
173.255.117.224 resolving cookbooks for run list: ["ohai", "sudo", "users::sysadmins", "apt", "git", "snap", "locales", "imagemagick", "logrotate", "rvm::user", "mysql", "bookshout_passenger", "bookshout_passenger::qa", "instramentalapp_agent"]
173.255.117.224 Synchronizing Cookbooks:
173.255.117.224 - instramentalapp_agent
173.255.117.224 - bookshout_passenger
173.255.117.224 - openssl
173.255.117.224 - build-essential
173.255.117.224 - mysql
@benjohnson77
benjohnson77 / gist:6680086
Last active December 23, 2015 19:08
transferring 2TB of data from Rackspace cloud to Google Storage
def find_container(container_name, obj = nil)
container_info = requested_container_info(container_name)
container_name = clean_container_name(container_name)
parts = [prefix]
parts << container_name unless container_name == 'default'
name = parts.compact.join('-')
g_dirs = g_connection.directories.all.map(&:key)
puts g_dirs
# create all the buckets that we need on google.
rs_connection.directories.each do |dir|
#refresh the list of google dirs
g_dirs = g_connection.directories.all.map(&:key)
dir_name_arr = dir.key.split("-")
@benjohnson77
benjohnson77 / gist:6349423
Created August 27, 2013 03:43
getting this error when trying to install a ruby. ...rvm install ruby-1.9.3-p194
app-1:~$ rvm install ruby-1.9.3-p194
Searching for binary rubies, this might take some time.
Checking requirements for debian.
Installing requirements for debian.
Hit http://gce_debian_mirror.storage.googleapis.com wheezy Release.gpg
Hit http://gce_debian_mirror.storage.googleapis.com wheezy Release
Hit http://gce_debian_mirror.storage.googleapis.com wheezy/main Sources
Hit http://packages.cloudpassage.com debian Release.gpg
Hit http://security.debian.org wheezy/updates Release.gpg
Hit http://gce_debian_mirror.storage.googleapis.com wheezy/main amd64 Packages
@benjohnson77
benjohnson77 / gist:6234844
Last active December 21, 2015 02:28
adding user to mailchimp with Gibbon gem
def self.subscribe_user_batch(users)
batch = users.map { |user| {EMAIL: user.email, FNAME: user.first_name, LNAME: user.last_name} }
Gibbon.batch_subscribe(:id => current_marketing_list['id'], :batch => batch)
end
➜ getsocialbooks.com git:(dev) ✗>rake assets:precompile
/Users/benjohnson/.rvm/gems/ruby-1.9.3-p392@bookshout/gems/zipruby-0.3.6/lib/zipruby.bundle: warning: already initialized constant VERSION
DEPRECATION WARNING: config.generators in Rails::Railtie is deprecated. Please use config.app_generators instead. (called from require at /Users/benjohnson/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72)
/Users/benjohnson/.rvm/gems/ruby-1.9.3-p392@bookshout/gems/activesupport-3.1.12/lib/active_support/dependencies.rb:240:in `block in require': iconv will be deprecated in the future, use String#encode instead.
/Users/benjohnson/.rvm/rubies/ruby-1.9.3-p392/bin/ruby /Users/benjohnson/.rvm/gems/ruby-1.9.3-p392@bookshout/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
/Users/benjohnson/.rvm/gems/ruby-1.9.3-p392@bookshout/gems/zipruby-0.3.6/lib/zipruby.bundle: warning: already initialized constant VERSION
DEPRECATION WARNING: config.generators in Rails::Railtie is depre