Skip to content

Instantly share code, notes, and snippets.

View davidlee's full-sized avatar

David Lee davidlee

  • Melbourne, Australia
View GitHub Profile
#!/usr/bin/ruby
require 'ostruct'
syslog = '/var/log/syslog'
lines = File.read(syslog).split "\n"
rows = lines.map do |line|
fields = line.split(' ', 6)
o = OpenStruct.new
#!/usr/bin/ruby
require 'ostruct'
require 'rubygems'
require 'sequel'
DB = Sequel.sqlite('syslogdb')
DB.create_table :syslogs do
primary_key :id
column :time, :timestamp
#!/usr/bin/env ruby
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/robots.txt"
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore"
run "for i in tmp/*; do touch tmp/$i; done"
file '.gitignore', <<-END
def new
x = Builder::XmlMarkup.new
x.instruct!
x.comment! "User Authentication Successful"
x.user {
x.id @user.id
x.login @user.login
x.name @user.name
}
render :xml => x
@davidlee
davidlee / gist:81790
Created March 19, 2009 12:32
eventmachine policy file server for flash
equire 'rubygems'
require 'eventmachine'
module Socky
module Policy
DEBUG = true
HOST = 'localhost'
PORT = 843
EOF = "\r\000"
REQUEST = "<policy-file-request/>\000"
class Foo
end
class Flibby
def make_method( _method_name )
puts _method_name
Foo.class_eval do
puts _method_name
class << self
define_method _method_name do
module OrderedHash
def []( index )
begin
super( index )
rescue TypeError
x = self.detect do |i|
i.first == index
end # if index.class ...
x && x[1]
end
module PageHelper
def hero?
!!params[:event_url]
end
def event?
!hero? && !!params[:url]
end
def donation_uk_giftaid
unless request.post?
redirect_to :action=>"donate"
return
end
@heroPage = HeroPage.search_url(params[:url], DateTime.now)
hero_page_variables("preview", true)
if session[:mydonation_id]
@donation = Donation.find_by_id(session[:mydonation_id])
@donation.update_attributes(params[:donation])
#!/usr/bin/env ruby
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/robots.txt"
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore"
file '.gitignore', <<-END
.swo