Skip to content

Instantly share code, notes, and snippets.

View elmer's full-sized avatar
:octocat:
exploring

Elmer Rivera elmer

:octocat:
exploring
View GitHub Profile
@elmer
elmer / Tests Is Wrong
Created April 10, 2010 13:00 — forked from rtomayko/Tests Is Wrong
Why "require 'rubygems'"...
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
$projectroot = '/path/to/gitosis/repositories';
$gitosis_conf = '/path/to/gitosis/repositories/gitosis-admin.git/gitosis.conf';
$username = $cgi->remote_user;
$export_auth_hook = sub {
my $projectdir = shift;
if($projectdir =~ (/(.*?)\.git/)) {
my $projectname = basename($1);
open FILE, $gitosis_conf or die 'Could not open gitosis config file. Please make sure that $gitosis_conf is set properly';
my $project_match = 0;
my $user_match = 0;
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$(function() {
MIN_ANSWERS = 2
MAX_ANSWERS = 10
MIN_ANSWERS_MSG = "Minimum of two(2) answers required."
MAX_ANSWERS_MSG = "Maximum of ten(10) answers only."
TOP_ANSWER_MSG = "Can't go up answer is on the top list."
Last login: Wed Jul 28 16:22:55 2010 from 192.168.100.185
####[ Rocket Fuel, Inc. ]##################################################
Welcome to pww-16.rfiserve.net.
Host: pww-16.rfiserve.net
Site: pww
Vendor alias: srv16.rf.mlp1.peakwebhosting.com
Environment: production
#!/usr/bin/env bash
function manage_user()
{
user=$1
password=$2
shift; shift;
out=`ralsh user $user password='$password' ensure=present`
echo $out | grep 'notice.*changed password'
# Hey coops..
#
# Imagine yourself on the other side of the table: two job openings, hundreds of resumes,
# _all of which_ look friggin' identical. Yeah, the HR departments at your MegaCorp XYZ are using
# automated tools to scan for keywords, and the coop department at your school is trying to beat
# you into submission to follow some "predefined template".. But, unless what you're aspiring to
# is to be an automaton at MegaCorp XYZ, relegated to writing test harnesses for code that will
# never see the light of day.. please do yourself a favor, and _be different_! Be bold, dammit.
#
# (Frankly, I'm falling asleep while reading your resumes.. Wake me up! Srsly.)
@elmer
elmer / consolize.rb
Created September 19, 2010 05:22 — forked from twoism/consolize.rb
require 'rubygems'
require 'irb'
def consolize &block
yield
IRB.setup(nil)
irb = IRB::Irb.new
IRB.conf[:MAIN_CONTEXT] = irb.context
root@ph-lin01-srv:~# lvdisplay
--- Logical volume ---
LV Name /dev/ph-lin01-srv/root
VG Name ph-lin01-srv
LV UUID wgA7Jd-cve5-eK2K-OcUk-yZ43-vvbw-diT892
LV Write Access read/write
LV Status available
# open 1
LV Size 18.88 GiB
Current LE 4833

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

module HashExtensions
def symbolize_keys
inject({}) do |acc, (k,v)|
key = String === k ? k.to_sym : k
value = Hash === v ? v.symbolize_keys : v
acc[key] = value
acc
end
end
end