Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#
# Install nginx on Debian.
#
# Author : Scott Barr
# Date : 7 Jan 2010
#
VERSION=0.8.53
@bradland
bradland / vpnroutes.sh
Created January 17, 2011 05:35
Script for enabling/disabling custom IP routes
#!/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 January 19, 2011 20:55
Return array of local IP addresses
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 January 20, 2011 21:03
Colloquy script for welcoming 5by5 web IRC client users.
# 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 July 1, 2011 14:08
Simple timing test for bcrypt
#!/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 July 1, 2011 14:08
Simple timing test for SHA512
#!/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 July 26, 2011 03:14
Method for testing for network errors
@bradland
bradland / 1-net-scp.rb
Created September 15, 2011 21:48
Net::SCP chokes on 'tilde' home dir shortcut
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 September 16, 2011 02:04
Text analyzer
#!/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 October 6, 2011 20:52
User verifier for Sprinkle
module Sprinkle
module Verifiers
# = Process Verifier
#
# Contains a verifier to check that a process is running.
#
# == Example Usage
#
# verify { has_user 'nginx' }
#