Skip to content

Instantly share code, notes, and snippets.

Brad Fults h3h

Block or report user

Report or block h3h

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 time-ext.rb
class Time
def within?(time_period)
self >= Time.now && self <= Time.now + time_period
end
end
# >> (Time.now + 55.hours).within? 2.days
# false
# >> (Time.now + 45.hours).within? 2.days
# true
View gist:143328
autodetach on
defkanji euc
deflogin on
startup_message off
defscrollback 100000
defshell -bash
chdir
term "xterm"
escape ^Tt
encoding UTF-8 UTF-8
@h3h
h3h / gist:321336
Created Mar 4, 2010
bash aliases for running test/spec tests
View gist:321336
# test/spec test runner
function ts()
{
ruby $1 -r s 2>/dev/null | grep -v "^HelperTestCase" | grep -v "dummy (e"
}
# test/spec test runner (with test name)
function tsn()
{
ruby $1 -r s -n "/$2/" 2>/dev/null | grep -v "^HelperTestCase" | grep -v "dummy (e"
@h3h
h3h / thing.rb
Created Apr 12, 2010
Sharing a value slot across multiple objects.
View thing.rb
class Thing
@@things = {}
def initialize
@pointer = self.hash
end
def set(x)
@@things[@pointer] = x
end
View gist:369056
module Enumerable
def how_many_have?(method)
self.select {|x| x.send(method)}.count
end
alias_method :how_many_are?, :how_many_have?
end
# >> [1,2,3,4,5].how_many_are?(:even?)
# => 2
#
@h3h
h3h / gist:417878
Created May 28, 2010
Test case for an XFBML bug in Facebook's connect-js library.
View gist:417878
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>XFBML Bug</title>
</head>
<body>
@h3h
h3h / .irbrc
Created Jun 16, 2010
My ~/.irbrc
View .irbrc
# The irbrc file for Brad Fults <bfults@gmail.com>
#
# Most of the code here came from http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks
#
unless self.class.const_defined? "IRB_RC_HAS_LOADED"
HISTFILE = "~/.irb-history"
MAXHISTSIZE = 100
begin # ANSI codes
ANSI_BLACK = "\033[0;30m"
View gist:605546
if (!Array.prototype.uniq)
{
Array.prototype.uniq = function(fun)
{
var seen = {};
return this.filter(function (el) {
var key = typeof (fun) == "function" ? fun(el) : el;
var r = !seen[key];
seen[key] = true;
return r;
View gist:660738
AK
VT NH ME
WA MT ND MN NY MA
WI MI CT RI
OR ID SD IL IN OH PA NJ
MD DE
WY NE IA WV VA DC
CA NV UT CO KS MO KY NC
OK AR TN SC
AZ NM LA MS AL GA
@h3h
h3h / gist:669173
Created Nov 9, 2010
rvm fails to install ruby binary with curl error
View gist:669173
08:47:28 [bfults@austin] ~$ rvm info
1.8:
system:
uname: "Darwin austin 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
zsh: "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"
rvm:
You can’t perform that action at this time.