Skip to content

Instantly share code, notes, and snippets.

View bdossantos's full-sized avatar

Benjamin Dos Santos bdossantos

View GitHub Profile
@gmcmillan
gmcmillan / parser.rb
Created April 4, 2012 17:59
my.cnf parser
def self.parse_config(file)
config = {}
File.open(file).each_line do |line|
line.strip!
# skip lines with comments or blank lines
next if /^\#/.match(line)
next if /^\s*$/.match(line)
# store which group in the config the line belongs to (e.g. [mysqld])
@softwhisper
softwhisper / cap_system_status.rb
Created March 11, 2012 16:17
Capistrano receipt for general system status
namespace :status do
desc "Displays memory usage"
task :memory do
mem = capture("free -m | grep Mem").squeeze(" ").split(" ")[1..-1]
total, used, free, shared, buffers, cached = mem
puts "\nMemory in (MBs)"
puts "----------------------------"
puts "Total: #{total}"
puts "Used: #{used}"
@peternixey
peternixey / securing_rails_updates.md
Created March 5, 2012 13:10
How Homakov hacked GitHub and how to protect your application by Peter Nixey

##How Homakov hacked GitHub and the line of code that could have prevented it


Please note: THIS ARTICLE IS NOT WRITTEN BY THE GITHUB TEAM or in any way associated with them. It's simply hosted as a Gist because the markdown formatting is excellent and far clearer than anything I could manage on my personal Tumblr at peternixey.com.

If you'd like to follow me on twitter my handle is @peternixey


namespace :log_resque do
desc "Print out (every 2 seconds) the number of busy and total workers for Resque"
task :working do
# In your Rails app directory :
# bundle exec rake log_resque:working --silent >> log/resque_working.log &
interval = 2.0
@aeris
aeris / gist:1872233
Created February 20, 2012 23:22
Debian setup for OVH
# Partitionning
fdisk /dev/sda (n p 1, a 1, t 1 fd, w)
sfdisk -d /dev/sda | sfdisk /dev/sdb
# RAID 1
mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1 --assume-clean
# LVM
pvcreate /dev/md0
vgcreate debian /dev/md0
#!/bin/sh
set -e
if [ -z "$1" ]; then
ruby-build --definitions
exit 1
fi
if [ -z "$2" ]; then
rev=1
@duksis
duksis / ext.rb
Created February 15, 2012 21:26
Capistrano receipt configure logrotate
namespace :deploy do
desc "Configure logrotate"
task :logrotate, :roles => :install do
config_file = "/etc/logrotate.d/app_#{rails_env}"
config_lines = ["daily",
"rotate 10",
"missingok",
"nocompress",
"sharedscripts",
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@jbraeuer
jbraeuer / check_aws_status.rb
Created January 25, 2012 08:24
A Nagios/Icinga plugin to check AWS Service Health Dashboard (using Ruby+Nokogiri)
#! /usr/bin/ruby
#
# A script to check Amazon Webservice's Health Status Dashboard
#
# Jens Braeuer, github.com/jbraeuer
#
# Version 1.0
#
# Cookbook Name:: mongodb
# Recipe:: default
case node['platform']
when "ubuntu"
execute "apt-get update" do
action :nothing
end
execute "add gpg key" do