Public Gists by matthewrudy

Gravatar
Wed Nov 11 02:38:30 -0800 2009
1
2
3
# keep the first and last characters in place
def scramble(text)
  text.gsub(/\b\w\w\w+\b/) do |match|
Gravatar
Thu Oct 29 03:20:59 -0700 2009
1
2
3
class GitRidOfShadowing < DataMunger::Script
 
  # a frozen copy of the required texpert functionality
Gravatar
Mon Oct 26 07:15:07 -0700 2009
1
2
3
module IncludeMe
  def included_innit
    Child.innit
Gravatar
Mon Oct 26 06:51:25 -0700 2009
1
2
3
# I'm creating some classes and modules on the fly, but things aren't hooking up quite the way I'd hoped.
# Can anyone explain why when an instance of Mod::Sibling tries to call Child.cry, that it
# doesn't call Mod::Child.cry, but instead looks for Behaviour::Child?
Gravatar
Mon Oct 26 04:30:55 -0700 2009
1
2
3
# Ever had the trouble to create a new named_scope out of others? See how it works:
class Fu < ActiveRecord::Base
  named_scope :has_moo, :conditions => { :moo => true }
Gravatar
Fri Aug 28 09:35:44 -0700 2009
1
2
3
require 'benchmark'
 
class TheHost
Gravatar
Fri Aug 21 03:01:46 -0700 2009
1
2
3
hash = {}
Dir["app/views/**/*.en.*.erb"].map do |erb_path|
  l_path = erb_path.gsub(".en.", ".*.")
Gravatar
Fri Aug 21 00:44:16 -0700 2009
1
2
3
def method_missing(method_name, *args, &block)
  if val = instance_variable_get("@#{method_name}")
    "my #{method_name} #{val}"
Gravatar
Wed Aug 05 03:28:17 -0700 2009
1
2
3
# 9 out of 10 microbenchmarks agree: implicit return smokes explicit return
require 'benchmark'
 
Gravatar
Fri Jul 03 15:17:58 -0700 2009
1
2
3
irb(main):001:0> name = "réunion-journalière"
=> "r\303\251union-journali\303\250re"
irb(main):002:0> File.open(name, 'w'){|f| f.write 'x' }
Gravatar
Tue Jun 30 09:50:54 -0700 2009
1
2
3
# all defaults
matthew@bumble:~$ cat /etc/apache2/mods-enabled/deflate.conf
<IfModule mod_deflate.c>
Gravatar
Thu Jun 18 08:58:43 -0700 2009
1
2
3
# eval-ed with "config" magically being Rainbow
 
config.add_colour :purple
Gravatar
Sun Apr 26 04:32:57 -0700 2009
1
2
3
matthew@aceRudy:~$ curl http://twitter.com/users/show/al3x.xml | grep '^ <created_at>'
  <created_at>Thu Nov 23 19:29:11 +0000 2006</created_at>
 
Gravatar
Thu Apr 16 06:21:20 -0700 2009
1
2
3
>> vdaf = VacancyDownloadableApplicationForm.last
  VacancyDownloadableApplicationForm Load (0.122909) SELECT * FROM `vacancy_downloadable_application_forms` ORDER BY vacancy_downloadable_application_forms.id DESC LIMIT 1
  VacancyDownloadableApplicationForm Columns (0.063622) SHOW FIELDS FROM `vacancy_downloadable_application_forms`
Gravatar
Thu Apr 16 05:55:32 -0700 2009
1
2
3
<!-- HTMLTrace:Start sites/vacancies/_dam_link_rdfa.rhtml -->
<%
 
Gravatar
Mon Apr 13 16:38:25 -0700 2009
1
2
3
<VirtualHost *>
  ServerName mydomain.local
  DocumentRoot /home/matthew/myapp/public
Gravatar
Tue Mar 10 04:50:46 -0700 2009
1
2
3
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
 
Gravatar
Fri Mar 06 08:08:30 -0800 2009
1
2
3
%%%6. Define a predicate list_of_divisors(N,L) which for a positive integer N
%%% calculates the list of its proper divisors. (A proper divisor of n is a positive
%%% integer m < n such that m divides n.)
Gravatar
Tue Feb 10 15:21:46 -0800 2009
1
2
3
   1725 leventa/levent
   1533 andyr
    914 marcusm
Gravatar
Fri Feb 06 04:48:50 -0800 2009
1
2
3
module Widgets::GeneralHelper
  
  def stylesheets_include(options = {})