This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Apply a CSS text-shadow cross-browser. | |
// There is one todo/gotcha: the direction is hardcoded to towards the bottom-right for IE, but that's good enough for my use case. | |
// Usage example: +text-shadow(#333, 1px, 1px, 1) | |
=text-shadow(!color, !x, !y, !blur) | |
:text-shadow= !color !x !y "#{!blur}px" | |
:-ms-filter "progid:DXImageTransform.Microsoft.Shadow(Color=#{!color},Direction=135,Strength=#{!blur})" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ This SASS function makes it easy to get cross-browser opacity. | |
/ | |
/ Firefox and Safari use CSS opacity. | |
/ Internet Explorer 7 and 8 each require their own flavor of the opacity alpha filter. | |
/ | |
/ See http://www.quirksmode.org/css/opacity.html for more info on opacity. | |
/ | |
/ Pass an opacity value between 0.0 and 1.0 | |
=opacity(!value) | |
:opacity= !value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This config works great to run my Sinatra app over Phusion Passenger, | |
# but it does not use my custom static error pages for 404 and 50x errors. | |
# Any help in getting it to work is much appreciated! | |
worker_processes 1; | |
error_log /var/log/nginx/error.log info; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def assert_equal(reference, value) | |
raise "Expected #{value.inspect} to equal #{reference.inspect}" unless reference == value | |
end | |
class Array | |
def remove(other) | |
copy = self.dup | |
other.each do |e| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple message filtering logic for a Ruby-based Twitter client. | |
# | |
# This demonstrates two simple string-based filtering approaches: | |
# * blacklist words | |
# * blacklist phrases | |
# | |
# It uses a slightly optimized matching and shows a sub-optimal one as comment. | |
# | |
# This can ofcourse also be used for highlights, dynamic grouping and whatnot. | |
messages = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage: githubify <gemspec_file> [username] | |
# Requires: github.name to be set for the current git project or [username] to be specified | |
# Result: creates/overwrites a file named <username>-<gemspec_file> and updates the s.name in there have the same project name format. | |
# | |
# Author: Wes Oldenbeuving | |
# E-mail: [email protected] | |
# License: MIT-LICENSE | |
class String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basis for fast_group_by gem: http://github.com/Narnach/fast_group_by | |
module Enumerable | |
# An unordered group_by implementation that is a gazillion times faster than | |
# ActiveSupport's ordered version, when used with large data sets. | |
# ActiveSupport uses OrderedHash, which are nested Arrays. Array#assoc is | |
# way slower than Hash#[] because it does a linear search vs a tree search. | |
# For small data sets, the difference is not that obvious, but in the range | |
# of 50k+ items, the difference can be 60 seconds vs less than 1 second. | |
def fast_group_by(&block) | |
res = Hash.new { |hash, key| hash[key] = [] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rake tasks to install OpenTTD from their Subversion source. | |
# Note: this is used on a Macbook, so the configuration and installation are based on this. | |
def cmd(str) | |
puts str | |
system str | |
end | |
desc 'Configure sources for compilation' | |
task :configure do | |
cmd './configure --with-ccache --enable-strip --disable-universal --with-cocoa MAKEOPTS="-j5" CFLAGS="-pipe" CXXFLAGS="-pipe"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Benchmark explicit vs implicit returns. | |
# | |
# In a loop doing 5,000,000 implicit and the same explicit returns, | |
# The following stats came back: | |
# | |
# user system total real | |
# explicit return 2.040000 0.010000 2.050000 ( 2.074879) | |
# implicit return 1.310000 0.010000 1.320000 ( 1.333344) | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Your random BOFH excuse calendar. | |
# Based upon the The Bastard Operator From Hell Stories written by Simon Paul Travaglia. | |
# And the list compiled by Jeff Ballard, http://jeffballard.us/ | |
# | |
# Automatically downloads the excuses from http://pages.cs.wisc.edu/~ballard/bofh/excuses | |
# and stores them as ~/.excuses.txt for reuse. | |
require 'open-uri' | |
class Array |