Skip to content

Instantly share code, notes, and snippets.

@gorsuch
gorsuch / twitter_search.rb
Created November 7, 2009 13:50
Easy Twitter Search w/ Ruby
require 'rubygems'
require 'twitter'
Twitter::Search.new('#onecushion').each do |r|
puts "id: " + r.id.to_s
puts "user: " + r.from_user
puts "user_id: "+r.from_user_id.to_s
puts "image_url: "+r.profile_image_url
puts "message: "+r.text
puts ""
@gorsuch
gorsuch / delete_tumblr.rb
Created November 9, 2009 22:23
Delete's items from a given tumblr, 50 posts at a time
require 'rubygems'
require 'tumblr'
require 'hpricot'
config = {
:email => 'name@example.com',
:password => 'secret',
:name => 'your_tumblr_name'
}
#!/usr/bin/env ruby
puts "hi, tumblr"
@gorsuch
gorsuch / test.cs
Created June 16, 2010 14:52
Uploading to S3 via C#
using System;
using System.IO;
using System.Text;
using Amazon;
using Amazon.S3;
using Amazon.S3.Model;
namespace AWSUploadTest
{
using System;
using Microsoft.SqlServer.Management.Smo;
namespace LogTruncate
{
class Program
{
static void Main(string[] args)
{
Server server = new Server(@"dbserver\instancename");
setup.exe /q /ACTION=install /FEATURES=SQL,Tools /INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS="Administrators" /SQLSVCACCOUNT="Network Service" /AGTSVCACCOUNT="Network Service"
@gorsuch
gorsuch / whittle.rb
Created November 24, 2010 03:12
simple http access log filter, assuming last field is time in microseconds
#!/usr/bin/env ruby
# assumes apache log file looks like this (all we care about is the final field):
# LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %D" custom
require 'optparse'
options = {}
options[:time] = 1
OptionParser.new do |opts|
@gorsuch
gorsuch / trendit.rb
Created December 4, 2010 22:46
an example of using the latest rev of logtrend
# The story: you have all sorts of logs,
# and you want to get an idea how often certain
# events occur each minute
# Perhaps you just want to know how many HTTP transactions occurred.
# Maybe you are worried about unauthorized access attempts.
# How about how many customers are flogging your api endpoint?
# You need to see the outliers. Grepping through log files
# in the midst of a crisis is very hard to do and quite unproductive.
describe FizzBuzz, "#calculate" do
it "returns 'Fizz' for all multiples of 3"
it "returns 'Buzz' for all multiples of 5"
it "returns 'FizzBuzz' for all multiples of 3 and 5"
it "returns the passed number if not a multiple of 3 or 5"
end