Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# EXAMPLE RUN:
#
# ~/Desktop $> ruby file_inventory.rb . .rb m c h a
# EXTENSION FILES LINES AVG LINES/FILE
# ---------------------------------------------------------------------------------
# *.rb 5073 489642 97
# *.m 2619 612648 234
# *.c 107 71519 668
# *.h 5868 256127 44
@allynbauer
allynbauer / watch.rb
Created July 17, 2011 18:39
watch SEARCH_DIR for .torrent and upload to SERVER's REMOTE_DIR when found; then remove
require 'rubygems'
require 'directory_watcher' # gem install directory_watcher
require 'net/sftp' # gem install net-sftp
SEARCH_DIR = File.expand_path('~/Downloads')
SERVER = ''
USERNAME = ''
PASSWORD = ''
REMOTE_DIR = ''
@allynbauer
allynbauer / taskcommit.sh
Created July 11, 2011 05:38
a ruby script that uses applescript to build a git commit from taskpaper based on @done items
rvm use 1.8.7
ruby taskpaper_git_commit.rb ~/Desktop/TODO.taskpaper
@allynbauer
allynbauer / file_inventory.rb
Last active June 25, 2023 17:27
A quickly written Ruby script that counts the files in a given dir with given extensions
# EXAMPLE RUN:
#
# ~/Desktop $> ruby file_inventory.rb . .rb m c h a
# EXTENSION FILES LINES AVG LINES/FILE
# ---------------------------------------------------------------------------------
# *.rb 5073 489642 97
# *.m 2619 612648 234
# *.c 107 71519 668
# *.h 5868 256127 44
# *.a 10 62543 6254
# Author: Allyn Bauer <allyn.bauer@gmail.com>
#
require 'rubygems'
require 'twitter'
require 'yaml'
require 'ftools'
class TwitterBot
SAVE_STATE = true # Save the state of the bot between runs
CACHE_LOCATION = File.join('.', 'caches') # The directory of the cache file
# In Ruby, modules can be used for two super-sweet purposes.
# The first is as a namespace:
def swell_message(m)
puts m
end
module Example
def self.swell_message(m)
puts "(module) #{m}"
end
<html>
<head>
<title>Billy Mays</title>
<script>
// hack to allow IE to properly channel Billy Mays
document.createElement('billy_mays');
</script>
<style>
billy_mays {
# !/usr/bin/env ruby
# == Synopsis
# This script is only useful for faculty or students at the
# University of Northern Iowa, in Cedar Falls Iowa. It's meant
# to be copied to a bin directory, made executable and ran with
# cron every day/week/whatever.
#
# == Examples
# ruby rod_library_renewer.rb smith 000123456
# ruby rod_library_renewer.rb -d smith 000123456
filename = 'test.rb'
f = File.new(filename)
puts f.ctime
t = Time.now.to_i
File.utime(t,t,filename)
puts f.ctime
require 'rubygems'
require 'mp3info' #http://ruby-mp3info.rubyforge.org/
class String
def shift
o = self[0,1]
self.replace(self[1, length])
o
end
end