Skip to content

Instantly share code, notes, and snippets.

View lachie's full-sized avatar

Lachie Cox lachie

View GitHub Profile
delimiter = "[-/.]+"
century_prefix = "(?:19|20)"
under_ten = "(?:0[1-9]+)"
ten_to_twelve = "(?:1[012]+)"
ten_and_under_thirty = "(?:[12]+[0-9]+)"
thirties = "(?:3[01]+)"
pattern = %r[
(
http://ujihisa.blogspot.com/2009/06/rubygems-best-practice.html
namespace :facebooker do
tunnel_ns = namespace :tunnel do
# Courtesy of Christopher Haupt
# http://www.BuildingWebApps.com
# http://www.LearningRails.com
desc "Create a reverse ssh tunnel from a public server to a private development server."
task :start => [ :environment, :config ] do
puts @notification
system @ssh_command
class A
def initialize(foo)
dispatch if respond_to? :dispatch
end
end
class B < A
def dispatch
puts "called dispatch"
end
<% if @current_site.google_analytics_web_property_id %>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("<%= @current_site.google_analytics_web_property_id %>");
pageTracker._trackPageview();
} catch(err) {}
@lachie
lachie / gist:76753
Created March 10, 2009 05:16 — forked from pat/gist:76749
- filtered_filenames(@items).each do |name|
%p do some stuff
-(@items || []).map {|i| i[%r[/(?!index|hide-[^/]+)([^/]+)\.haml],1]}.compact.each do |name|
%p do some stuff
- if @items
- @items.each do |item|
- name = item.gsub(/views\/.+\/(.+).haml/, '\1')
- unless name == "index" || name[/^hide-/]
%p do some stuff
def f(ra,n)
ra.select {|x| x.include? n}.size
end
@lachie
lachie / string.rb
Created February 26, 2009 02:20 — forked from slowjud/string.rb
class String
class TextHelperSingleton
def self.instance; @instance ||= new end
include ActionView::Helpers::TextHelper
end
def method_missing(method, *args, &block)
if TextHelperSingleton.instance.respond_to?(method)
self.class.send(:define_method, method, &block) do
TextHelperSingleton.instance.send(method, self, *args, &block)