Skip to content

Instantly share code, notes, and snippets.

View jellybob's full-sized avatar

Jon Wood jellybob

View GitHub Profile
@jellybob
jellybob / firewalls.md
Created June 22, 2012 09:08
Why do we need firewalls?

Why do we need firewalls?

There are a few things which are typically referred to as "firewalls", with different purposes. All of them however control access to a network by restricting which ports and IP addresses can be connected to.

## Software Firewalls

This is the thing built into Windows and other operating systems that pops up boxes saying "Do you want to allow [thing x] to connect to the Internet?". They're designed to prevent malicious software that has been installed on your machine sending your data to other places, or bulk mailing people. They can also be used to restrict connections coming in to your computer.

## Hardware Firewalls

@jellybob
jellybob / db.rake
Created January 31, 2012 17:24
Preparing multiple MySQL databases with Rails 2.3
namespace :db do
namespace :test do
task :prepare => :environment do
abcs = ActiveRecord::Base.configurations
[ "", "_data_warehouse" ].each do |db|
# Dump the development database
config = abcs["development#{db}"]
cmd = "mysqldump -u#{config["username"]} -p#{config["password"]} #{config["database"]} --no-data > #{RAILS_ROOT}/db/development#{db}_structure.sql"
`#{cmd}`
@jellybob
jellybob / stats.rake
Created November 5, 2011 14:05
Include fast specs in your code stats.
task :stats => :statsetup
task :statsetup do
fast_spec_dir = "fast_spec" # Change this if you keep them elsewhere.
require 'rails/code_statistics'
::STATS_DIRECTORIES << %W(Fast\ specs #{fast_spec_dir}) if File.exist?(fast_spec_dir)
::CodeStatistics::TEST_TYPES << "Fast specs" if File.exist?(fast_spec_dir)
end
@jellybob
jellybob / gist:1327902
Created October 31, 2011 16:30
Traceroute
traceroute to 193.219.108.20 (193.219.108.20), 64 hops max, 52 byte packets
1 router (192.168.1.1) 1.018 ms 0.612 ms 0.725 ms
2 * * *
3 * 10.1.3.178 (10.1.3.178) 8.365 ms 8.364 ms
4 20ge.bb2.lon1.uk.gbxs.net (195.66.224.231) 7.883 ms 7.640 ms 7.622 ms
5 ohtelecom.vlan899.bb2.lon1.uk.gbxs.net (77.243.178.6) 8.212 ms 7.495 ms 8.612 ms
6 * * *
7 * * *
8 * * *
# ad infinatum
@jellybob
jellybob / follow_alert.rb
Created October 26, 2011 13:58
Win "be the nth follower" contests
require 'capybara'
require 'capybara/dsl'
require 'capybara/webkit'
include Capybara::DSL
account = ARGV[0]
count = ARGV[1]
Capybara.current_driver = :webkit
Capybara.app_host = 'http://mobile.twitter.com'
We couldn’t find that file to show.
host "chef.example.org" do
ip "192.168.10.1"
aliases [ "chef", "kitchen" ]
comment "The chef server"
end
sh -c '
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
if [ ! -f /usr/bin/chef-client ]; then
apt-get update
apt-get install -y ruby ruby1.8-dev build-essential wget libruby-extras libruby1.8-extras
fi
# Install a sane version of gems
cd /tmp
@jellybob
jellybob / gelf_handler.rb
Created July 4, 2011 17:05
GELF handler for Chef
require 'rubygems'
require 'gelf'
class GELFHandler < Chef::Handler
attr_reader :notifier
def initialize(server, port, facility)
@notifier = GELF::Notifier.new(server, port, 'WAN', :facility => facility)
end
@jellybob
jellybob / gist:1063598
Created July 4, 2011 16:42
Broken notifier
require 'rubygems'
require 'gelf'
class GELFHandler < Chef::Handler
attr_reader :notifier
def initialize(server, port, facility)
@notifier = GELF::Notifier.new(server, port, 'WAN', :facility => facility)
end