Skip to content

Instantly share code, notes, and snippets.

View elmer's full-sized avatar
:octocat:
what's going on?

Elmer Rivera elmer

:octocat:
what's going on?
View GitHub Profile
@samsworldofno
samsworldofno / gist:535038
Created August 18, 2010 15:04
cap db:pull
namespace :db do
desc "Download the a full dump of the production database into the development database"
task :pull do
config = YAML::load(File.open(File.join('config', 'database.yml')))
dump_database_remotely(config['production'], remote_file)
compress_backup_remotely(remote_file)
download_backup(remote_file(:compressed), local_file(:compressed))
~/projects/jruby ➔ jruby -rreal_unix -e 'trap("INT") { puts :there; exit }; puts :here; select(nil, nil, nil, nil)'
here
^Cthere
~/projects/jruby ➔ jruby -rreal_unix -e 'puts $$; exec "echo $$"'
461
461
~/projects/jruby ➔ cat real_unix.rb
require 'ffi'
@jtimberman
jtimberman / add_to_chef-client.rb
Created September 15, 2010 07:00
amazon-linux-ami plugin for ohai
# Add this to the top of /etc/chef/client.rb
Ohai::Config[:plugin_path] << "/etc/chef/ohai_plugins"
@jordansissel
jordansissel / 1 - Scope.md
Created December 25, 2010 00:33
RightScale Security problem - Regenerate your ssh keys if you have known ones.

I found all of my ubuntu 10.04 rightscale hosts had the same ssh key. The base image they use has one ssh host key that is never regenerated on instance creation, so effectively 100% of hosts are likely to have the same key for each system image.

RightScale has been notified and they are working on notification and fixes for customers.

The script in this gist will regenerate your keys if you have the ones I know of (on the ubuntu 10.04 rightscale image)

AMI: ami-7c16e315

@igrigorik
igrigorik / ruby-1.9-tips.rb
Created February 3, 2011 17:19
Ruby 1.9 features, tips & tricks you may not know about...
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@refractalize
refractalize / warden_sinatra.rb
Created February 6, 2011 10:38
Basic warden/sinatra integration
require 'rubygems'
require 'warden'
require 'sinatra'
require 'cgi'
class LoginManager < Sinatra::Base
Warden::Manager.serialize_into_session{|id| id }
Warden::Manager.serialize_from_session{|id| id }
def call(env)
@lusis
lusis / watcher.rb
Created February 16, 2011 06:19
Idea for letting people define watchers themselves
require 'rubygems'
require 'eventmachine'
require 'em-hiredis'
module Noah
class Watcher
attr_accessor :pattern, :destination
def initialize(&blk)
@pattern ||= "noah.*"
@funny-falcon
funny-falcon / patch-1.9.2-gc.patch
Created March 5, 2011 11:11
GC tunning simple patch ruby 1.9.2 p180
diff --git a/gc.c b/gc.c
--- a/gc.c
+++ b/gc.c
@@ -77,6 +77,41 @@ void *alloca ();
#ifndef GC_MALLOC_LIMIT
#define GC_MALLOC_LIMIT 8000000
#endif
+#define HEAP_MIN_SLOTS 10000
+#define FREE_MIN 4096
+
@aussielunix
aussielunix / sshd_config_chroot_sftp_only
Created March 8, 2011 02:51
chroot a sftp only user with openssh 5
add the following to `sshd_config`
Subsystem sftp internal-sftp
Match User foo
ChrootDirectory /home/foo
AllowTCPForwarding no
X11Forwarding no
ForceCommand internal-sftp
@jacquescrocker
jacquescrocker / database.rb
Created April 10, 2011 19:50
configures padrino to use config/mongoid.yml
# config/database.rb
config_file = Padrino.root("config", "mongoid.yml")
if File.exists?(config_file)
settings = YAML.load(ERB.new(File.read(config_file)).result)[Padrino.env.to_s]
::Mongoid.from_hash(settings) if settings.present?
end