Skip to content

Instantly share code, notes, and snippets.

View sdball's full-sized avatar

Stephen Ball sdball

View GitHub Profile
@sdball
sdball / broadbandmap.jquery.js
Created November 18, 2011 21:25
broadband.com jquery javascript plugin
(function( $ ){
var settings = {
lat: 38.651198,
lng: -97.976074,
address: '',
minimumDetailZoom: 4,
defaultZoom: 4,
displayLitBuildings: false,
displayCentralOffices: false,
dslHeatmapActive: false,
@sdball
sdball / ajax_loader.coffee
Created December 15, 2011 00:31
Quick demo of how to do a simple jQuery binding in CoffeeScript
$(document).ready ->
$('form').submit ->
$(this).find('.ajax-loader').show()
@sdball
sdball / expand-url.sh
Created August 8, 2012 13:20
Expand URLs by following a single redirect
#!/bin/bash
main() {
if [ -z $1 ]; then
echo "Usage: expand-url URL"
exit 1
fi
url=$1
response $url | parse_redirect
}
@sdball
sdball / autobots.bash
Created September 18, 2012 01:36
beanstalkd rollout!
$ ruby rollout.rb
$ stalk jobs.rb
@sdball
sdball / Gemfile
Last active December 10, 2015 15:39
Just a quick prototype to talk to data.com's sandbox.
# Ruby 1.8.7
source "https://rubygems.org"
gem "json_pure"
group :test do
gem "rspec"
gem "vcr"
gem "webmock"
@sdball
sdball / fiat_nil.rb
Last active December 10, 2015 15:59
Don't Do What Johnny Don't Does
class FiatNil
def method_missing(*args)
nil
end
end
@sdball
sdball / sandi_metz_rules_for_developers.md
Created January 18, 2013 18:47
Rules for good development from Sandi Metz

Sandi Metz’ rules for developers

  1. Your class can be no longer than a hundred lines of code.
  2. Your methods can be no longer than five lines of code
  3. You can pass no more than four parameters and you can't just make it one big hash.
  4. In your controller, you can only instantiate one object, to do whatever it is that needs to be done.
  5. Your view can only know about one instance variable.
  6. Your Rails view should only send messages to that object i.e., no Demeter violations.[ "thunder dome principal". Translated: one model in, one model out! ]
  7. Rules are meant to be broken if by breaking them you produce better code. [ ...where "better code" is validated by explaining why you want to break the rule to someone else. ]
@sdball
sdball / recommended.md
Last active August 6, 2021 03:40
Recommended code reading from Ruby Parley
@sdball
sdball / deploy.rb
Created January 23, 2013 21:35
Example capistrano task to confirm deployment
# drop this task in the environment(s) you want to confirm deployment for
before :deploy, "deploy:confirm"
namespace :deploy do
desc "Should we really deploy?"
task :confirm do
if Capistrano::CLI.ui.ask("Are you sure?") == "yes"
puts "You got it buddy. Imma deploy now."
else