Skip to content

Instantly share code, notes, and snippets.

View stefanpenner's full-sized avatar
🎯
Focusing

Stefan Penner stefanpenner

🎯
Focusing
View GitHub Profile
@stefanpenner
stefanpenner / quoter.html
Created January 27, 2012 21:10 — forked from jonharmon/quoter.html
Zip Form Redirect to another jQuery Tab
<div id="instantquoter" class="reveal-modal">
<script src="http://cdn.jquerytools.org/1.2.6/full/jquery.tools.min.js"></script>
<script>
$(function() {
$("ul.tabs").tabs("div.main > div.panes");
});
</script>
@stefanpenner
stefanpenner / gist:1507777
Created December 21, 2011 21:26 — forked from wisq/gist:1507733
Why I love zsh (and hate being forced to use bash)

Cool things that make zsh appealing

  • Filename correction during completion

  • if dir1/x exists and dir2 exists, then "dir/x<TAB>" completes to dir1/x

  • if name1 is a file and name2 is a directory with files in it, "name/<TAB>" completes to "name2/"

  • Better ctrl-R behaviour

  • alerts you if your ctrl-R is failing

  • completes it right on the prompt line while showing you what you're searching for below

@stefanpenner
stefanpenner / acceptance_helper.rb
Created May 31, 2011 03:18 — forked from ssoroka/acceptance_helper.rb
Use feature, background, and scenario blocks to write acceptance tests in test/unit
# Use feature, background, and scenario blocks to write acceptance tests in test/unit
# which are really just integration tests. include capybara or webrat or something and voila.
# test/acceptance_helper.rb
require 'test_helper'
module ActionDispatch
class AcceptanceTest < ActionDispatch::IntegrationTest
class << self
alias :background :setup
@stefanpenner
stefanpenner / Yehudalize.rb
Created April 21, 2011 19:12 — forked from eqdw/stefanize.rb
An extension that stef should always include
module Yehudalize
def method_missing(method_sym, *arguments, &block)
if method_sym.to_s =~ /^(?:omg_)?(.*)_to_me$/
send($1.to_sym, *arguments, &block)
else
super
end
end
end
module Enumerable
def map_to_hash(&block)
self.inject({}) do |acc,v|
acc.merge(block.call(v))
end
end
end
x = [:a, :b, :c].map_to_hash do |v|
{v => v.to_s.upcase}
@stefanpenner
stefanpenner / if.rb
Created March 22, 2010 14:45 — forked from burke/if.rb
# This isn't necessarily "better", or even "useful" in any way, just sort of fun.
class Object
# I like how I can actually create methods with these names.
def if
@__if_result = yield self
self
end
def then
@__if_result ? yield self : self
# previously required http://github.com/mislav/addressable
# with changes merged upstream, main repo should work too:
# http://github.com/sporkmonger/addressable/
require 'addressable/template'
# http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0followers
template = Addressable::Template.new 'http://{host=twitter.com}' +
'/statuses/followers{-prefix|/|id}.{format=json}' +
'?{-join|&|user_id,screen_name,cursor}'
require 'rubygems'
require 'ghost'
module Productivity
BLOCK_LIST = %W{ facebook.com twitter.com }
def start
puts "Blocked:"
BLOCK_LIST.each do |host|
Host.add(host,'127.0.0.1')
// replaced this
$(document).ready(function() {
if ($.fn.corner) $('.corner').corner()
})
// with this
.corner {
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
# Controller
def index
@results = SexOffender.all
end
# View
<% if @results.blank? %>
<span>no sex offenders were found</span>