Skip to content

Instantly share code, notes, and snippets.

View thomasbiddle's full-sized avatar

TJ (Thomas J.) Biddle thomasbiddle

View GitHub Profile
@thomasbiddle
thomasbiddle / puppet_setup
Last active December 17, 2015 11:59
Setting up Puppet
# Setting up the master
echo "deb http://apt.puppetlabs.com precise main" > /etc/apt/sources.list.d/puppet.list
curl http://apt.puppetlabs.com/pubkey.gpg | apt-key add -
apt-get update
apt-get install puppetmaster
echo 'import "nodes"' > /etc/manifests/site.pp
touch /etc/manifests/nodes.pp
echo "127.0.0.1 puppet" > /etc/hosts
hostname puppet
echo "puppet" >> /etc/hostname
@thomasbiddle
thomasbiddle / gitlab-routes
Created June 27, 2013 22:45
Gitlab routes - Someone in IRC was looking for a list of routes for Gitlab
search GET /search(.:format) search#show
api_api /api API::API
sidekiq /admin/sidekiq Sidekiq::Web
/ #<Rack::Builder:0x00000003edd110 @run=#<Grack::Server:0x00000003edcdf0 @config={:git_path=>"/usr/bin/git", :project_root=>"/home/git/repositories/", :upload_pack=>true, :receive_pack=>true}>, @map=nil, @use=[#<Proc:0x00000003edce18@/home/inflection/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.5/lib/rack/builder.rb:82>]>
help GET /help(.:format) help#index
help_api GET /help/api(.:format) help#api
# Using friendly IDs to translate the name in the route to the ID.
project_name = params[:id].to_s
if Project.where('name like ?', project_name).empty?
@project = Project.new
@project.name = project_name
notify("info", "Project does not exist - Create one!")
return render :action => 'new'
else
@project = Project.where('name like ?', project_name).first
Started POST "/users/sign_in" for 192.168.28.1 at 2013-07-11 13:39:35 -0700
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"xodISf4lGqUE6JBs3plknQwFfkTF1MZwIMk8MBhAuGQ=", "user"=>{"username"=>"tjbiddle", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."username" = 'tjbiddle' LIMIT 1
Completed 401 Unauthorized in 128ms
Processing by Devise::SessionsController#new as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"xodISf4lGqUE6JBs3plknQwFfkTF1MZwIMk8MBhAuGQ=", "user"=>{"username"=>"tjbiddle", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
Rendered devise/shared/_links.erb (0.8ms)
Rendered devise/sessions/new.html.erb within layouts/application (46.6ms)
Completed 200 OK in 259ms (Views: 249.4ms | ActiveRecord: 0.0ms)
@thomasbiddle
thomasbiddle / gist:6142764
Created August 2, 2013 19:35
Retry an rescued block
def my_test
puts 'test1'
begin
puts 'test2'
raise Exception, 'Oh noes!'
rescue Exception
retry
end
...
rescue Trac::TracException
@retries_trac ||= 0
@retries_trac += 1
@logger.info("Trac isn't responding - Retry ##{@retries_trac}.")
retry if @retries_trac < 10
....
require 'sinatra'
require 'net/http'
get '/' do
is_up = Net::HTTP.start('play.noobonicplague.com').head('/')
code = is_up.code
if code == '200'
"It's up!"
else
def artists(query)
results = search('artist', query)
artists = []
results['artists'].each do |artist|
artists << Resources::Artist.new(artist)
end
Resources::Base.new(results['info'], artists)
end
@thomasbiddle
thomasbiddle / add-to-security-group
Created December 24, 2013 00:49
This will add your current IP address to the security group of choice. Assumes EC2 tools are on your PATH.
#!/bin/bash
# Initialize our own variables:
GROUP="default"
REGION="ap-northeast-1"
# Get our real public IP.
IP_ADDRESS=`curl ifconfig.me --silent`
@thomasbiddle
thomasbiddle / revoke-from-security-group
Created December 24, 2013 00:50
This will revoke your current IP address to the security group of choice. Assumes EC2 tools are on your PATH.
#!/bin/bash
# Initialize our own variables:
GROUP="default"
REGION="ap-northeast-1"
# Get our real public IP.
IP_ADDRESS=`curl ifconfig.me --silent`