Skip to content

Instantly share code, notes, and snippets.

public MagickImage resized(int width, int height){
MagickImage result = new MagickImage(width, height);
int originalWidth = this.getWidth();
int originalHeight = this.getHeight();
int maxSize = Math.max(width, height);
float scaleFactor = 1.0f;
if (originalWidth > originalHeight)
scaleFactor = ((float) maxSize / (float) originalWidth);
# Install deps
package "libfuse-dev"
package "libcurl4-openssl-dev"
package "libxml2-dev"
# Download & Install
wget http://s3fs.googlecode.com/files/s3fs-r177-source.tar.gz
tar xvzf s3fs-r177-source.tar.gz
@mikewadhera
mikewadhera / gist:169966
Created August 18, 2009 21:02
deploy:rolling_restart
namespace :deploy do
desc "Restarts each app role one at a time, removing from load balancing during restart"
serial_task self, :rolling_restart, :roles => :app do
lb = fetch(:load_balancer)
lb_removal = lambda { `elb-deregister-instances-from-lb #{lb} --instances #{@instance_id}` }
lb_addition = lambda { `elb-register-instances-with-lb #{lb} --instances #{@instance_id}` }
watch = "rails"
port = 8080
#!/bin/sh
echo "Starting memcached in background..."
memcached &
echo "Starting OpenMQ broker in background..."
imqbrokerd -silent &
echo "Starting background_tasks queue processor in background..."
jruby script/queue_processor >/dev/null 2>&1 &
echo "Starting Jetty Rails..."
jruby --headless -S jetty_rails
require "jruby"
module JettyRails
class Runner
attr_reader :servers
def initialize(config = {})
@servers = {}
config.symbolize_keys!
pool :involver_rails do
cloud :nginx do
instances 2..2 # binds against 2 elastic IPs
has_package "nginx"
end
cloud :app do
instances 2..12
# Following adds a svn co of my_app to /mnt/svn-repos/my_app on cloud-start
# svn up is run on the working copy every cloud-configure
has_svn_repos :name => "my_app",
:at => "/mnt/svn-repos",
:source => "http://svn.myhost.com/my_app",
:user => "<optional>",
:password => "<optional>"
pool :sandbox do
instances 1..1
cloud :hello_world do
# Update with the path to your EC2 keypair
# If you don't have one, create with:
# $ ec2-create-keypair NAME > /path/to/your/keypairs/<NAME>
keypair "/path/to/your/keypairs/<NAME>"
class Greeter
attr_accessor :greeting
def initialize(greeting)
self.greeting = greeting
end
def greet
puts self
end
puts "Hello World"