Skip to content

Instantly share code, notes, and snippets.

View lukeledet's full-sized avatar

Luke Ledet lukeledet

  • Revelry Labs
  • New Orleans, LA
View GitHub Profile
@lukeledet
lukeledet / Chum
Created December 7, 2010 20:31
Phishing site spammer
#!/usr/bin/env ruby
# Chum
#
# I got an email saying a craigslist post was flagged for removal with a link
# here: http://home.comcast.net/~bigtruckn/ so I wrote this quick script to
# spam it in hopes of polluting their data in case someone falls for it.
require 'rubygems'
require 'httparty'
require 'ffaker'
@lukeledet
lukeledet / jabber_bot.rb
Created January 5, 2011 04:32
Simple Minecraft jabber bot
###
# Simple jabber bot to let me talk to users of my minecraft server from gtalk
require 'xmpp4r-simple'
BOT_USERNAME = '...'
BOT_PASSWORD = '...'
ADMIN_USERNAME = '...'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/rails'
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
Capybara.default_selector = :css
require 'spork'
Spork.prefork do
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
%>
default: <%= std_opts %> --drb features
wip: --tags @wip:3 --drb --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
autotest: --drb --color --format progress --strict
autotest-all: --drb --color --format progress --strict
namespace :spork do
desc "start spork in the background"
task :start do
sh %{spork &}
sh %{spork cucumber &}
end
desc "stop spork"
task :stop do
`ps -ef | grep bin/spork | grep -v grep | awk '{ print $2 }'`.split.each do |pid|
# Fix the problem with github's SSL cert
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
git :init
# Ignore certain files
file '.gitignore',
%q{Gemfile.lock
.bundle
log/*.log
>> Visitor.find_or_create_by_date(:date => Time.now.to_date)
Visitor Load (0.5ms) SELECT "visitors".* FROM "visitors" WHERE "visitors"."date" = '2011-05-16' LIMIT 1
>> Client.first.visitors.find_or_create_by_date(:date => Time.now.to_date)
ArgumentError: Unknown key(s): date
@lukeledet
lukeledet / gist:1081280
Created July 13, 2011 20:44
String#rejoin
# Split a string by regular expression, run the block on each element, then
# join the pieces back together with the right separators.
#
# Example:
# >> "Internationalization's awesome.".rejoin(/\W/) {|x| x.length > 2 ? "#{x[0]}#{x.length - 2}#{x[-1]}" : x }
# => "I18n's a5e."
class String
def rejoin(sep, &block)
separators = self.scan sep
self.split(sep).map(&block).zip(separators).flatten.compact.join
@lukeledet
lukeledet / rails.rb
Created August 12, 2011 16:07
Thor script to get setup in your rails environment in iTerm
##
# This thor script launches an applescript that starts new tabs in iTerm for
# rails server, rails console and runs the test suite based on the directory
# that the script is run from.
#
# Installation:
# thor install rails.rb
#
# Usage:
# thor rails:iterm