Skip to content

Instantly share code, notes, and snippets.

View capoferro's full-sized avatar

Josiah Kiehl capoferro

View GitHub Profile
josiah@VAIO-OF-DOOOM:~$ ruby ~/bin/piano
Welcome to pianobar (2010.10.07)! Press ? for a list of commands.
[?] Username: [email protected]
[?] Password:
(i) Login... Ok.
(i) Get stations... Ok.
0) Air Radio
1) Q bluepojo_pandora's QuickMix
2) Club / Dance Radio
3) Daft Punk Radio
@capoferro
capoferro / saved-5-characters.out
Created February 22, 2011 02:14
I totally saved 5 characters doing it this way
josiah@VAIO-OF-DOOOM:~/Projects/githacking$ tmux
The program 'tmux' is currently not installed. You can install it by typing:
sudo apt-get install tmux
josiah@VAIO-OF-DOOOM:~/Projects/githacking$ `!! 2>&1 | tail -n1`
@capoferro
capoferro / users_controller.rb
Created March 16, 2011 04:51
Github OAuth with automatic account creation with AuthLogic
def create
url = 'https://github.com/login/oauth/access_token'
query = 'client_id=' + Github.config[:client_id] +
'&redirect_uri=' + Github.config[:redirect_uri] +
'&client_secret=' + Github.config[:secret] +
'&code=' + params[:code]
token_response = Curl::Easy.http_post(url, query).body_str
if token_response.empty?
flash[:notice] = 'GitHub didn\'t respond. Try again?'
require 'rest_client'
require 'uri'
require 'pp'
require 'addressable/uri'
key = 'w9fvwkgv2yj2taw9xjx5qcqz'
uri = Addressable::URI.parse('http://api.rottentomatoes.com/api/public/v1.0/movies.json')
uri.query_values = {q: 'M. Night Shyamalan', apikey: key}
@capoferro
capoferro / gist:1029392
Created June 16, 2011 14:52
Load jquery
var s=document.createElement('script');
s.setAttribute('src','http://jquery.com/src/jquery-latest.js');
document.getElementsByTagName('body')[0].appendChild(s);
(1..100).each do |n|
out = ''
out += 'foo' if n % 3 == 0
out += 'bar' if n % 5 == 0
puts out.empty? ? n : out
end
# Equivalent to puts( (1..10).map { |i| i*2 } )
> puts (1..10).map { |i| i*2 }
2
4
6
8
10
12
14
16
## Chef Server log
[info] [<0.20351.0>] 127.0.0.1 - - 'DELETE' /chef_integration/ 200
[info] [<0.20352.0>] 127.0.0.1 - - 'DELETE' /chef_integration_safe/ 404
[info] [<0.20353.0>] 127.0.0.1 - - 'GET' /_all_dbs 200
[info] [<0.20354.0>] 127.0.0.1 - - 'PUT' /chef_integration 201
[info] [<0.20356.0>] 127.0.0.1 - - 'GET' /chef_integration/_design/id_map 404
[info] [<0.20357.0>] 127.0.0.1 - - 'PUT' /chef_integration/_design%2Fid_map 201
[info] [<0.20358.0>] 127.0.0.1 - - 'GET' /chef/_design/nodes 404
[info] [<0.20359.0>] 127.0.0.1 - - 'PUT' /chef/_design%2Fnodes 404
[Tue, 13 Mar 2012 02:49:04 GMT] [info] [<0.32043.1>] 127.0.0.1 - - 'DELETE' /chef_integration/ 200
[Tue, 13 Mar 2012 02:49:04 GMT] [info] [<0.32044.1>] 127.0.0.1 - - 'DELETE' /chef_integration_safe/ 404
[Tue, 13 Mar 2012 02:49:04 GMT] [info] [<0.32045.1>] 127.0.0.1 - - 'GET' /_all_dbs 200
[Tue, 13 Mar 2012 02:49:04 GMT] [info] [<0.32046.1>] 127.0.0.1 - - 'PUT' /chef_integration 201
[Tue, 13 Mar 2012 02:49:04 GMT] [info] [<0.32047.1>] 127.0.0.1 - - 'GET' /chef_integration/_design/id_map 404
[Tue, 13 Mar 2012 02:49:04 GMT] [info] [<0.32048.1>] 127.0.0.1 - - 'PUT' /chef_integration/_design%2Fid_map 201
[Tue, 13 Mar 2012 02:49:04 GMT] [info] [<0.32049.1>] 127.0.0.1 - - 'GET' /chef/_design/nodes 404
[Tue, 13 Mar 2012 02:49:04 GMT] [info] [<0.32050.1>] 127.0.0.1 - - 'PUT' /chef/_design%2Fnodes 404
ruby_block 'set P4CONFIG in shell rc file' do
block do
content = nil
File.open(shellrc_path, 'r') do |file|
content = file.read
p4config_matcher = 'P4CONFIG=\"[^\"]*\"'
content.gsub! /^.*#{p4config_matcher}.*$/, set_p4config_line
content << "\n\n#{set_p4config_line}" unless content =~ /#{p4config_matcher}/