Skip to content

Instantly share code, notes, and snippets.

View sudara's full-sized avatar
🧪
Brewing new formulas

Sudara sudara

🧪
Brewing new formulas
View GitHub Profile
#!/bin/bash
echo "Deployanatoring teh codez!"
ssh linode-deploy '
cd /data/alonetone/current;
if [[ $(git diff) > "" ]];
then
echo "WARNING: local changes on server, exiting!";
exit 0;
fi;
@sudara
sudara / gist:420210
Created May 31, 2010 20:00
bloat_fail.rb
## FAIL
## Attempting to iterate (chunkily) over 2000 records and instantiating 1 single object per iteration
## All of the below bloat to > 200MB on rails 2.3.x
# iterates in chunks of 10
User.find_each(:batch_size => 10) do |user|
date = user.posts.find(:first).created_at
end
# iterates in chunks of 100
@sudara
sudara / deploy
Created April 8, 2010 10:32 — forked from toolmantim/deploy
#!/bin/sh
# Simple deployment script
#
# Requires access to to github repository, as well as a host defined in
# ~/.ssh/config like so:
#
# Host myhost
# User appuser
# Hostname hostname
check process rabbitmq_appname
with pidfile /var/run/rabbitmq/rabbitmq.pid
start program = "/engineyard/bin/rabbitmq"
stop program = "/engineyard/bin/rabbitmq"
group rabbitmq_appname
This example shows how to setup an environment running Rails 3 beta under 1.9.1 with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell))
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.1
# Switch to 1.9.1
∴ rvm 1.9.1
set :mongrel_base_port, 5000
set :mongrel_restart_delay, 30
set :mongrel_count, 2
namespace :mongrel do
task :restart, :roles => [:app], :except => {:mongrel => false} do
(mongrel_base_port..(mongrel_base_port+mongrel_count)).to_a.each do |port|
sudo "/usr/bin/monit restart mongrel_#{monit_group}_#{port}"
sleep mongrel_restart_delay
end
ActiveRecord::Schema.define(:version => 20091018223040) do
create_table "assets", :force => true do |t|
t.string "content_type"
t.string "filename"
t.integer "size"
t.integer "parent_id"
t.integer "site_id"
t.datetime "created_at"
t.string "title"
require 'rubygems'
require 'daemons'
options = {
:app_name => "task_server",
:dir_mode => :script,
:dir => "../log", # where the log/PID file will be dropped
:ontop => false, # should be false
:mode => :exec,
:backtrace => true,
SC.RecordAttribute.registerTransform(SC.DateTime, {
/** Transforms a date to an integer of milliseconds since 1970 */
/** @private - convert an int to a date */
to: function(n, attr) {
/* Transform a date coming from rails in the format 2008/12/31 10:45:23 +0200 */
return SC.DateTime.parse(n,'%Y/%m/%d %H:%M:%S');
},
/** @private - convert a date to an int */
from: function(date) {
return date.get('milliseconds');