Skip to content

Instantly share code, notes, and snippets.

curl -O http://python-distribute.org/distribute_setup.py
/usr/bin/python2.6 distribute_setup.py
@didip
didip / gist:2018847
Created March 12, 2012 00:25
What to do after upgrading Python
cd /tmp
# fix pip
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python /tmp/get-pip.py
# Fix setuptools
# Download the appropriate .egg from here: http://pypi.python.org/pypi/setuptools
curl -O http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg#md5=fe1f997bc722265116870bc7919059ea
sudo python /tmp/setuptools-0.6c11-py2.7.egg
108-166-96-237.static.cloud-ips.com [Mon, 26 Mar 2012 17:53:32 +0000] ERROR: Running exception handlers
108-166-96-237.static.cloud-ips.com [Mon, 26 Mar 2012 17:53:32 +0000] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
108-166-96-237.static.cloud-ips.com [Mon, 26 Mar 2012 17:53:32 +0000] ERROR: Exception handlers complete
108-166-96-237.static.cloud-ips.com [Mon, 26 Mar 2012 17:53:32 +0000] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
108-166-96-237.static.cloud-ips.com [Mon, 26 Mar 2012 17:53:32 +0000] FATAL: RuntimeError: Could not locate the chef-client bin in any known path. Please set the proper path by overriding node['chef_client']['bin'] in a role.
108-166-96-237.static.cloud-ips.com GET http://rubygems.org/latest_specs.4.8.gz
108-166-96-237.static.cloud-ips.com 302 Moved Temporarily
108-166-96-237.static.cloud-ips.com GET http://production.s3.rubygems.org/latest_specs.4.8.gz
108-166-96-237.static.cloud-ips.com 200 OK
108-166-96-237.static.cloud-ips.com GET http://rubygems.org/quick/Marshal.4.8/ohai-0.6.12.gemspec.rz
108-166-96-237.static.cloud-ips.com 302 Moved Temporarily
108-166-96-237.static.cloud-ips.com GET http://production.cf.rubygems.org/quick/Marshal.4.8/ohai-0.6.12.gemspec.rz
108-166-96-237.static.cloud-ips.com 200 OK
108-166-96-237.static.cloud-ips.com GET http://rubygems.org/quick/Marshal.4.8/systemu-2.5.0.gemspec.rz
108-166-96-237.static.cloud-ips.com 302 Moved Temporarily
cat /var/chef/cache/chef-stacktrace.out
Generated at Mon Mar 26 17:53:32 +0000 2012
RuntimeError: Could not locate the chef-client bin in any known path. Please set the proper path by overriding node['chef_client']['bin'] in a role.
/var/chef/cache/cookbooks/chef-client/recipes/service.rb:38:in `from_file'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/cookbook_version.rb:578:in `load_recipe'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/mixin/language_include_recipe.rb:40:in `include_recipe'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `each'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
/var/chef/cache/cookbooks/chef-client/recipes/default.rb:20:in `from_file'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/chef-0.10.8/bin/../lib/chef/cookbook_version.rb:578:in `load_recipe'
@didip
didip / gist:3250687
Created August 3, 2012 19:27
testing dict merge if keys are integers
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = {1:1}
>>> b = {2:2}
>>> dict(a, **b)
{1: 1, 2: 2}
@didip
didip / gist:3947572
Created October 24, 2012 17:40
carrierwave-info
# the initializer
CarrierWave.configure do |config|
config.storage = :file
config.root = Rails.root.join('public')
config.cache_dir = Rails.root.join('tmp/uploads')
config.enable_processing = false
end
# the uploader
@didip
didip / gist:3949536
Created October 24, 2012 23:14
carrierwave-stacktrace
# /Users/didip/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/fileutils.rb:1263:in `initialize'
# /Users/didip/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/fileutils.rb:1263:in `open'
# /Users/didip/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/fileutils.rb:1263:in `copy_file'
# /Users/didip/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/fileutils.rb:1262:in `open'
# /Users/didip/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/fileutils.rb:1262:in `copy_file'
# /Users/didip/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/fileutils.rb:463:in `copy_file'
# /Users/didip/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/fileutils.rb:383:in `cp'
# /Users/didip/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/fileutils.rb:1396:in `fu_each_src_dest'
# /Users/didip/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/fileutils.rb:1412:in `fu_each_src_dest0'
# /Users/didip/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/fileutils.rb:1394:in `fu_each_src_dest'
@didip
didip / supervisor-rolling-restart.sh
Created December 13, 2012 16:57
Rolling restart supervisord watched processes. Since every restart it waits for "$status" == "RUNNING", it's safer that simply running /etc/init.d/supervisor restart
#!/bin/bash
#
# Usage: ./supervisor-rolling-restart [supervised-process-name]
#
PROGRAM=$1
# Time in seconds.
TIME_BETWEEN_RUNNING_CHECKS=0.5
TIME_BETWEEN_RESTARTS=1
@didip
didip / check-package-versions.py
Created December 21, 2012 05:07
Given requirements.txt file, we can check PyPI for new versions.
#!/usr/bin/env python
from __future__ import with_statement
import os, os.path, sys
import simplejson as json
import urllib2
from distutils.version import StrictVersion
def pad_spaces(str_, length=18):
return str_ + ' ' * (length - len(str_))