This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/ldap' | |
# how to "bind" to your ldap/ad server... | |
LDAP_HOST = 'server' | |
LDAP_PORT = 389 | |
LDAP_USERNAME = 'cn=Username;cn=Users;dc=domain;dc=com' | |
LDAP_PASSWORD = 'your user password' | |
LDAP_BASE = 'dc=domain;dc=com' | |
# replace "domain" and "com" above with your AD domain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'date' | |
class BirthdayCalculationTest < Test::Unit::TestCase | |
def test_calculation | |
bday = Birthday.new(1981, 12, 4) | |
today = Date.new(2008, 11, 4) | |
assert_equal 30, bday.days_from(today) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# rotating snapshotted backup | |
src=/my/stuff | |
dest=/var/backup | |
today=`date +%a` | |
yesterday=`date -d yesterday +%a` | |
mkdir -p $dest/$yesterday # in case it doesn't exist yet | |
rm -rf $dest/$today # I think this might be necessary -- not sure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I am learning VIM - here is what I've learned. | |
# A great reference is here: http://www.cs.runet.edu/~mhtay/CPSC120/VIM_Editor_Commands.htm | |
# (but I didn't just copy from there -- I tried each one first, and saved the ones my brain might remember here) | |
# basics | |
i # insert (edit) mode | |
o # "open" new line and insert (edit) mode there | |
ESC # command mode | |
:help # get help in a split window (:q to close) | |
:help topic # get help on a topic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basically, this bit of code adds a before_filter that checks | |
# the last modified time of the cache entry, and expires it | |
# if it is older than the specified time period. | |
module ActionController | |
module Caching | |
module Fragments | |
# expire a cache key only if the block returns true or | |
# if the age of the fragment is more than the specified age argument. | |
def expire_fragment_by_mtime(key, age=nil, &block) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rem This took me way too long to figure out - hope it helps someone. | |
rem ghostscript required | |
c:\path\to\gs\bin\gswin32c.exe -sDEVICE=mswinpr2 -dNoCancel -dNOPAUSE -dSAFER -sOutputFile="%printer%DYMO LabelWriter 450 Turbo" -q "\path\to\file.ps" -c quit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I'm a noob | |
# Instructions for verifying tarsnap download | |
gpg --import tarsnap-signing-key.asc | |
# ^ only needed once I think | |
gpg --decrypt tarsnap-sigs-1.0.25 | |
# should say good sig, cperciva, etc. | |
# and digest of tgz download, compare with: | |
openssl dgst -sha256 tarsnap-autoconf-1.0.25.tgz | |
# hashes should match |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* * * * * /path/to/onebody/script/inbox -e production_lite "localhost" "POP-ACCOUNT-USERNAME" "POP-ACCOUNT-PASSWORD" | |
49 2 * * * /path/to/onebody/script/runner -e production_lite "ActionController::Session::ActiveRecordStore::Session.delete_all(['updated_at < ?', 1.day.ago.utc])" | |
19 * * * * /path/to/onebody/script/runner -e production_lite "Site.each { Group.update_memberships; NewsItem.update_from_feed; LogItem.flag_suspicious_activity }" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# multithreaded script that probes a subnet for used/unused ip addresses | |
# command line usage: | |
# | |
# ./probe_ips.rb [options] [subnet] | |
# | |
# subnet defaults to 192.168.1 | |
# -u lists used ips rather than unused | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
data = File.read(ARGV.first) | |
reqs = data.scan(/Completed in (\d+)ms/).map { |r| r.first.to_i } | |
total_ms = reqs.inject(0) { |s, i| s += i } | |
avg_ms_per_req = total_ms / reqs.length | |
reqs_over_500ms = reqs.select { |r| r > 500 } | |
puts "#{reqs.length} total requests" |
OlderNewer