Skip to content

Instantly share code, notes, and snippets.

View peteonrails's full-sized avatar

Peter Jackson peteonrails

View GitHub Profile
require "threaded_collections"
threadcount = 2
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
tps = ThreadedCollectionProcessor.new(arr)
tps.process(2) { |thread_id, item| puts "Thread #{thread_id} processed item: #{item}" }
def tally(options = {})
find(:all, options_for_tally(options.merge({:order =>"count DESC" })))
end
@peteonrails
peteonrails / email regex
Created July 11, 2009 17:31
A decent email regex, but it doesn't handle comments and nesting
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
Ping:~ Pete$ cd Documents/workspace/teal
Ping:teal Pete$ git stash
Usage: /usr/local/git/bin/git-stash [ | save | list | show | apply | clear | create ]
Ping:teal Pete$
# Hm. I think "pop" is supposed to show up in there somewhere. Let's check git help:
Ping:teal Pete$ git help stash
GIT-STASH(1) Git Manual GIT-STASH(1)
=== Epic Snow Leopard Upgrayyyyd Guide ===
Son, you’re now living in the land of 64-bit systems.
That means that some of your 32-bit shit is now broken.
Not all is lost.
== Fixing MySQL weirdness
# This template represents what FasterAgile believes to be the best mix
# of components for ab-initio Rails projects. It includes:
# Mocks with factory_girl instead of fixtures; cucumber and shoulda; friendly_ids
# and canonical links for SEO; HAML and SASS; the Clearance engine; basic sass
# and haml starter files; my favorite plugins and initializers; some utility
# methods that I always use.
#
# Run this template like this:
# rails <myproject> -m fasteragile.rb
#
[pjackson@host]$ cat ~/.ssh/environment
ORACLE_BASE="/opt/oracle"
ORACLE_HOME="/opt/oracle/product/10.2.0/client_1"
DYLD_LIBRARY_PATH=/opt/oracle/product/10.2.0/client_1/lib
[pjackson@host]$ sudo grep PermitUser /etc/ssh/sshd_config
PermitUserEnvironment yes
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
# wesbos:
# make sure you have Ruby and Rubygems installed
# Get the twitter gem with 'gem install twitter'
# Then, run irb and type this code
Twitter.follower_ids('peteonrails').each { |f| puts Twitter.follower_ids(f).count }
# If you'd rather have a total, do this:
Twitter.follower_ids('peteonrails').inject { |memo, f| memo += Twitter.follower_ids(f).count }
// For Aaron
// You can replace the passed anonymous function with a callback if you'd rather.
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script type='text/javascript'>
new PeriodicalExecuter(function(pe) {
if (!confirm('Want me to annoy you again later?'))
pe.stop();
}, 5);