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 run_pg_fouine(): | |
info = host_info[env.host_string] | |
db_name = info.tags.get('Name') | |
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 0/" /etc/postgresql/9.*/main/postgresql.conf') | |
sudo('/etc/init.d/postgresql reload') | |
time.sleep(30) | |
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 500/" /etc/postgresql/9.*/main/postgresql.conf') | |
sudo('/etc/init.d/postgresql reload') | |
run('tail -n 100000 /var/log/postgresql/postgresql-9.*-main.log > /tmp/pgfouine.txt') | |
run('gzip -f /tmp/pgfouine.txt') |
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
# Copyright Camptocamp SA 2012 | |
# License: AGPL (GNU Affero General Public License)[http://www.gnu.org/licenses/agpl-3.0.txt] | |
# Author Guewen Baconnier | |
require "xmlrpc/client" | |
require 'pp' | |
XMLRPC::Config::ENABLE_NIL_PARSER = true | |
class MagentoAPI | |
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
from django import http | |
from django.conf import settings | |
""" | |
Put this file in a directory called, eg, 'middleware,' inside your django | |
project. Make sure to create an __init__.py file in the directory so it can | |
be included as a module. | |
Set the values for | |
XS_SHARING_ALLOWED_ORIGINS | |
XS_SHARING_ALLOWED_METHODS |
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
=begin | |
Need to install gems heroku, newrelic_rpm | |
$ gem install heroku newrelic_rpm | |
Set your apps setting | |
app_name : heroku's app_name of auto scaling | |
license_key : NewRelic api key. You can get heroku's NewRelic admin console. "App setting" and "Agent configuration" | |
execute with cron every minutes | |
$ ruby ./adjust_dynos_with_newrelic.rb |
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
# Memory snapshot analyzer which parses the /proc file system on *nix | |
# | |
# Example (run in Heroku console): | |
# | |
# ms = MemorySnapshot.new | |
# 1.upto(10000).map { |i| Array.new(i) }; nil | |
# ms.snapshot!; nil | |
# ms.diff 10 | |
# => {"lib/ld-2.11.1.so"=>156, "heap"=>2068, "all"=>2224} | |
# |
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
# Add `gem 'heroku-api', :git => 'https://github.com/heroku/heroku.rb.git'` to your Gemfile | |
# Set the APP_NAME environment variable to the name of the Heroku app you wish to control. | |
# Set the HEROKU_API_KEY environment variable to the API key found on the Heroku 'My Account' page. | |
# You can now create a scheduler instance that runs `bundle exec rake heroku:web:restart` to automate | |
# restarting workers. The task will select a different web instance every 10 minutes, based on the number of instances that are running. | |
namespace :heroku | |
namespace :web do | |
task :restart 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
# blog post: | |
require 'formtastic/version' | |
# Formtastic sets default input types for ActiveRecord column types. This does | |
# the same for Mongoid field types. | |
module Mongoid::Document | |
FORMTASTIC_2_2 = Formtastic::VERSION[/\A2\.2\.\d\z/] | |
# Map Mongoid field types to either ActiveRecord column types (which |
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
monitor: bundle exec ruby monitor.rb |
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
# Add `gem 'heroku-api', :git => 'https://github.com/heroku/heroku.rb.git'` to your Gemfile | |
# Set the APP_NAME environment variable to the name of the Heroku app you wish to control. | |
# Set the HEROKU_API_KEY environment variable to the API key found on the Heroku 'My Account' page. | |
# You can now create a scheduler instance that runs `bundle exec rake heroku:web:restart` to automate | |
# restarting workers. The task will select a different web instance every 10 minutes, based on the number of instances that are running. | |
namespace :heroku | |
namespace :web do | |
task :restart 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
module Moped | |
module Instrumentation | |
def self.instrument(klass) | |
klass.class_eval do | |
def logging(operations) | |
instrument_start = (logger = Moped.logger) && logger.debug? && Time.new | |
yield | |
ensure | |
instrument_end = 1000 * (Time.new.to_f - instrument_start.to_f) |
OlderNewer