Skip to content

Instantly share code, notes, and snippets.

View install_nginx_on_debian.sh
#!/bin/bash
#
# Install nginx on Debian.
#
# Author : Scott Barr
# Date : 7 Jan 2010
#
VERSION=0.8.53
@bradland
bradland / vpnroutes.sh
Created Jan 17, 2011
Script for enabling/disabling custom IP routes
View vpnroutes.sh
#!/bin/bash
# Enables and disables static routes required to access COMPANY resources
# over the VPN. These routes are required because the resources are hosted
# on public IP addresses, but restricted to access coming from specific
# networks.
enableroutes() {
route -nv add -net 4.2.2.1 -interface ppp0
@bradland
bradland / local_ip.rb
Created Jan 19, 2011
Return array of local IP addresses
View local_ip.rb
require 'socket'
# Base on answer from http://stackoverflow.com/questions/42566/getting-the-hostname-or-ip-in-ruby-on-rails
# return an array of local IP addresses
def local_ip
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
UDPSocket.open do |s|
s.connect '4.2.2.1', 1 # as this is UDP, no connection will actually be made
@bradland
bradland / Welcome5by5WebIRC.scpt
Created Jan 20, 2011
Colloquy script for welcoming 5by5 web IRC client users.
View Welcome5by5WebIRC.scpt
# modified from http://colloquy.info/extras/details.php?file=8
property prefs : missing value
property prefsPath : missing value
script prefsTemplate
property knownNames : {}
property allowedRooms : {}
end script
@bradland
bradland / bcrypt-test.rb
Created Jul 1, 2011
Simple timing test for bcrypt
View bcrypt-test.rb
#!/usr/bin/env ruby
require 'bcrypt'
def time
start = Time.now
yield
puts "That took #{Time.now - start} seconds"
end
@bradland
bradland / sha512-test.rb
Created Jul 1, 2011
Simple timing test for SHA512
View sha512-test.rb
#!/usr/bin/env ruby
require 'digest/sha2'
def time
start = Time.now
yield
puts "That took #{Time.now - start} seconds"
end
@bradland
bradland / network-link-testing.txt
Created Jul 26, 2011
Method for testing for network errors
View network-link-testing.txt
@bradland
bradland / 1-net-scp.rb
Created Sep 15, 2011
Net::SCP chokes on 'tilde' home dir shortcut
View 1-net-scp.rb
require 'net/scp'
Net::SCP.start("10.0.38.110", "root") do |scp|
# synchronous (blocking) upload; call blocks until upload completes
scp.upload! "./test.txt", "~/"
end
@bradland
bradland / lab3.cgi
Created Sep 16, 2011
Text analyzer
View lab3.cgi
#!/usr/bin/env ruby
# Text Analyzer
# Author: Zach
# Purpose: Utilize Ruby to analyze Text files
# and generate statistical information therein.
require 'cgi'
STOPWORDS = IO.readlines('conf/stop_words.txt').map{|x| x.chomp}
@bradland
bradland / user.rb
Created Oct 6, 2011
User verifier for Sprinkle
View user.rb
module Sprinkle
module Verifiers
# = Process Verifier
#
# Contains a verifier to check that a process is running.
#
# == Example Usage
#
# verify { has_user 'nginx' }
#