Skip to content

Instantly share code, notes, and snippets.

View jnewland's full-sized avatar

Jesse Newland jnewland

View GitHub Profile

Warning: Like the shitty OSS person I am, I forgot to update this. This particular iteration is exploitable in a really basic way that I missed. I will update this with the updated version hopefully soon

Reasoning

While authing against our Google Apps domain has worked pretty well up until now, we really needed a way to auth against out Github organization. Not everyone who is accessing some of our protected development content has an email account in our Google Apps domain. They do, however, have access to our github org.

Sadly it seems that apache and nginx modules for doing oauth are lacking.

I was hoping to avoid the whole lua approach (and mod_authnz_external was a no go from the start). However I realized that Brian Akins (@bakins) had done some fancy omnibus work that got me 90% of the way there.

From there it was a matter of patching up the omnibus repo to bring it to current versions as well as adding in a few additional components.

@pengwynn
pengwynn / blob_bridge.json
Created June 5, 2012 15:34
Encoded Octocat
{"content": "/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAZAAA/+Ean2h0dHA6Ly9ucy5hZG9i
ZS5jb20veGFwLzEuMC8APD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6
TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0i
QWRvYmUgWE1QIENvcmUgNC4yLjItYzA2MyA1My4zNTI2MjQsIDIwMDgvMDcvMzAtMTg6MDU6NDEg
ICAgICAgICI+CiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIv
MjItcmRmLXN5bnRheC1ucyMiPgogIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICB4
bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iCiAgICB4bWxuczphdXg9Imh0
dHA6Ly9ucy5hZG9iZS5jb20vZXhpZi8xLjAvYXV4LyIKICAgIHhtbG5zOnBob3Rvc2hvcD0iaHR0
cDovL25zLmFkb2JlLmNvbS9waG90b3Nob3AvMS4wLyIKICAgIHhtbG5zOnhtcE1NPSJodHRwOi8v
bnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIgogICAgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9i
#
# Ideas stolen from lograge and brought to Rails 2.3
# https://github.com/mattmatt/lograge/blob/master/lib/lograge/log_subscriber.rb
#
module ImprovedControllerLogging
def self.included(base)
base.alias_method_chain :log_processing, :fixup
base.inject_alias_method_chain :perform_action,
:perform_action_with_benchmark,
@eric
eric / linux_proc_name.rb
Created November 9, 2011 07:39
Update a process name in linux to change how it shows up in top and lsof
#
# Eric Lindvall <eric@5stops.com>
#
# Update the process name for the process you're running in.
#
# This will allow top, lsof, and killall to see the process as the
# name you specify.
#
# Just use:
#
# Just a simple script that makes Hubot respond like the famous XKCD comic
#
# make me <something> - "What? Make it yourself."
# sudo make me <something> - "Okay."
module.exports = (robot) ->
robot.respond /make( me)? (.+)/i, (msg) ->
msg.send "What? Make it yourself."
robot.respond /sudo make( me)? (.+)/i, (msg) ->
msg.send "Okay."
@rtomayko
rtomayko / gist:1202895
Created September 8, 2011 08:11
The Sazerac
You'll need:
- Old Fashioned glasses, two of
- Sugar cubes, two of
- Peychaud's Aromatic Cocktail Bitters, one bottle of
- Ice, enough to fill both glasses
- Water, one oz of
- Rye whisky, two oz of
- St. George Absinthe Verte, 0.333oz of
- Lemon, one twist of
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
11:14 <reiddraper> drev1: at a higher level, my goal is to launch a
Riak cluster on ec2 and have them join a cluster together without having to manually call "join"
11:15 <reiddraper> drev1: should I just launch one node first,
call it the master, and then write a script which calls join with
that node -- for the other machines?
11:16 <drev1> yes
11:16 <reiddraper> drev1: if I am launching a large cluster,
require 'twitter'
user = "sferik"
query = /rimm/i
(1..16).each do |page|
Twitter.user_timeline(user, :page => page, :count => 200).each do |tweet|
puts tweet.id.to_s + ": " + tweet.text if query.match(tweet.text)
end
end
@eric
eric / README.md
Created March 18, 2011 20:20
A simple mechanism to log metrics to Redis

Redis Timeseries Metric

I've been playing around with trying to make it as simple as possible to start logging a few metrics with as little effort in setup as possible.

As I was working on Papertrail I came up with a couple interesting ideas, some of which were inspired by OpenTSDB.

Storing metrics

In this example we are pretending we're processing emails as background jobs and would like to track how many we've sent over time.