Skip to content

Instantly share code, notes, and snippets.

Avatar

Stephen Ball sdball

View GitHub Profile
@sdball
sdball / broadbandmap.jquery.js
Created Nov 18, 2011
broadband.com jquery javascript plugin
View broadbandmap.jquery.js
(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 Dec 15, 2011
Quick demo of how to do a simple jQuery binding in CoffeeScript
View ajax_loader.coffee
$(document).ready ->
$('form').submit ->
$(this).find('.ajax-loader').show()
@sdball
sdball / expand-url.sh
Created Aug 8, 2012
Expand URLs by following a single redirect
View expand-url.sh
#!/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 Sep 18, 2012
beanstalkd rollout!
View autobots.bash
$ ruby rollout.rb
$ stalk jobs.rb
@sdball
sdball / Gemfile
Last active Dec 10, 2015
Just a quick prototype to talk to data.com's sandbox.
View Gemfile
# 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 Dec 10, 2015
Don't Do What Johnny Don't Does
View fiat_nil.rb
class FiatNil
def method_missing(*args)
nil
end
end
@sdball
sdball / sandi_metz_rules_for_developers.md
Created Jan 18, 2013
Rules for good development from Sandi Metz
View sandi_metz_rules_for_developers.md

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 / deploy.rb
Created Jan 23, 2013
Example capistrano task to confirm deployment
View deploy.rb
# 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