Skip to content

Instantly share code, notes, and snippets.

PJ Hyett pjhyett

Block or report user

Report or block pjhyett

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View colors.rb
lines = `git log --oneline`.split("\n")! do |line|
sha, *msg = line.split
msg = msg.join(' ') # unused
color = '#' + sha[0..-2]
%{<div class="box" style="background:#{color}"></div>}
end'colors.html', 'w') do |f|
f.puts <<-HTML
View random_follower.rb
USER = 'github'
require 'open-uri'
user_id = open("{USER}.xml").read.scan(/\d+/).sort_by { rand }.first
user_name = open("{user_id}").read[/screen_name>(\w+)/, 1]
puts user_name
alias gb='for k in `git branch|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cblue%cr%Creset" $k|head -n 1`\\t$k;done'
# Output
# ------
# ~/Development/github(master)$ gb
# 4 weeks ago config-gem
# 9 days ago dropdown
# 5 weeks ago faucet
# 3 weeks ago health
View gist:122665
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
View gems
~$ gem list -r -s | wc -l
~$ gem list -r -s | wc -l
pjhyett / cache-down.rb
Created May 20, 2009
Experiment to create a read-only version of GitHub during migrations and what not. Doesn't work because Google throttles hits to their cache to prevent people from doing exactly what this does.
View cache-down.rb
require 'rubygems'
require 'sinatra'
require 'open-uri'
def strip_header(text)
prefix = %{
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<base href=""<div style="width"<!DOCTYPE
text.sub(/.+<!DOCTYPE/m, prefix)
View commify.rb
class Numeric
def commify
to_s.gsub(/(\d)(?=\d{3}+(\.\d*)?$)/, '\1,')
View simple_active_support.rb
class Fixnum
{"years" => 31536000,"weeks" => 604800,"days" => 86400,"hours" => 3600,"minutes" => 60, "seconds" => 1}.each do |key,val|
define_method key do
self * val
%w(year week day hour minute second).each do |method|
define_method method do
pjhyett / memory_profiler.rb
Created Apr 27, 2009
Simple ruby memory profiler
View memory_profiler.rb
# simple memory profiler
# can't remember where I found it (thanks whomever wrote it)
class MemoryProfiler
DEFAULTS = {:delay => 10, :string_debug => false}
def self.start(opt={})
opt = DEFAULTS.dup.merge(opt) do
pjhyett / yc_top.user.js
Created Mar 10, 2009
Install GreaseKit / GreaseMonkey and go to town
View yc_top.user.js
// ==UserScript==//
// @name Hacker News Top Bar Colorer
// @description Change the top bar color to whatever you want
// @include*
// ==/UserScript==
document.getElementsByTagName('td')[0]["bgColor"] = '#f6f6ef'
You can’t perform that action at this time.