Skip to content

Instantly share code, notes, and snippets.

View peterc's full-sized avatar
🏠
Working from home

Peter Cooper peterc

🏠
Working from home
View GitHub Profile
@peterc
peterc / da
Created February 8, 2014 15:57
Domain and Twitter availability checker
#!/bin/bash
# domainavailable
# Fast, domain name checker to use from the shell
# Use globs for real fun:
# domainavailable blah{1..3}.{com,net,org,co.uk}
# Inspired by foca / giles:
# http://gilesbowkett.blogspot.com/2009/02/simple-bash-domain-availability.html
trap 'exit 1' INT TERM EXIT
@peterc
peterc / expenses.md
Last active August 29, 2015 13:57
Cooper Household Expenses List

Cooper household expenses (as of March 2014)

Fixed monthly expenses

£1 is roughly $1.70 for any nosey types

  • Mortgage - £510
  • Water - £36
  • TV license - £12
  • Electricity and gas - £74
@peterc
peterc / loop
Last active August 29, 2015 13:58
loop - run the same command over and over at the (bash) command line easily
Place the code in loop.sh into your .bash_profile or similar. Or include it with `source`.
Then to use:
loop [your commands here]
For example:
loop ls -l
@peterc
peterc / apology.md
Last active August 29, 2015 14:24
An apology to Ruby Weekly readers

Readers,

Everyone makes mistakes and the best that can come out of one is a sinvecere apology and a determination to learn a lesson and improve for the future.

In last week's Ruby Weekly, we mistakenly included some material that unkindly referenced Reddit's ex-CEO Ellen Pao (it rhetorically asked if your app deployments were as 'horrible'). Pao has suffered a lot of negative press and abuse online recently and this reference was irrelevant, unnecessary and in poor taste. Contributing to a negative bandwagon does not fit with what readers expect of our newsletter.

I personally apologize to our readers and Ellen Pao for not meeting our usual standards. I also want to thank the readers who reached out to me about this matter for keeping us in check.

While the material was sponsor supplied and not written by us, we are responsible to our readers for their experience. Nonetheless, the advertiser has made their own statement here. I lacked the full context for

@peterc
peterc / gist:33337
Created December 8, 2008 03:42
Fully featured Rails template (for Rails 2.3)
# SUPER DARING APP TEMPLATE 1.0
# By Peter Cooper
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' }
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
@peterc
peterc / gist:40238
Created December 27, 2008 11:30
DM-oriented initializer for Sinatra apps
# NAME: initializer
# VERSION: 1.0
# AUTHOR: Peter Cooper [ http://www.rubyinside.com/ github:peterc twitter:peterc ]
# DESCRIPTION: Sinatra library to perform initialization functions - oriented around DataMapper use
# COMPATIBILITY: All, in theory - tested on Hoboken
# LICENSE: Use for what you want
#
# INSTRUCTIONS:
# 1. Ensure _this_ file is lib/initializer.rb within your app's directory structure
# 2. Read through and customize this file to your taste and your app's requirements
@peterc
peterc / gist:40234
Created December 27, 2008 10:39
CAPTCHA plugin for Sinatra apps
# NAME: recaptcha
# VERSION: 1.0
# AUTHOR: Peter Cooper [ http://www.rubyinside.com/ github:peterc twitter:peterc ]
# DESCRIPTION: Sinatra plugin to provide CAPTCHA support through recaptcha.net
# COMPATIBILITY: 0.3.2 /and/ latest rtomayko Hoboken builds!
# LICENSE: Use for what you want, just don't claim full credit unless you make significant changes
#
# INSTRUCTIONS:
# 0. Check out an extended client code example at the footer of this file
# 1. Ensure _this_ file is lib/recaptcha.rb within your app's directory structure
@peterc
peterc / gist:40239
Created December 27, 2008 11:31
Configuration loading library for Sinatra apps
# NAME: configurator
# VERSION: 1.0
# AUTHOR: Peter Cooper [ http://www.rubyinside.com/ github:peterc twitter:peterc ]
# DESCRIPTION: Sinatra library to load app-wide configurations
# COMPATIBILITY: All, in theory - tested on Hoboken
# LICENSE: Use for what you want
#
# INSTRUCTIONS:
# 1. Ensure _this_ file is lib/initializer.rb within your app's directory structure
# 2. Add require 'lib/configurator' to your Sinatra app
# Script to generate a CSV of all your Twitter followers screen_name, name, url, and description (bio)
# Runs fine on OS X: put into a file, and then from a Terminal: ruby whatever.rb to run.
require 'json'
puts "Enter your Twitter username:"
username = gets.chomp
puts "Enter your Twitter password:"
password = gets.chomp