Skip to content

Instantly share code, notes, and snippets.

View mgrouchy's full-sized avatar

Mike Grouchy mgrouchy

View GitHub Profile
def override_urls(self):
return [
url(r'^offer/(?P<offer_id>\d+)/(?P<resource_name>%s)/(?P<offer_transaction_id>\d+)/$' % self._meta.resource_name, self.wrap_view('get_offer_transaction_id'), name="api_get_offer_transaction_id"),
url(r'^offer/(?P<offer_id>\d+)/(?P<resource_name>%s)/$' % self._meta.resource_name, self.wrap_view('get_offer_transaction'), name="api_get_offer_transaction"),
]
@mgrouchy
mgrouchy / .bashrc
Created February 21, 2011 15:51 — forked from henrik/.bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
@mgrouchy
mgrouchy / show
Created April 28, 2011 19:21 — forked from tekacs/show
This does something essentially equivalent to showoff.io if you have a publicly facing server...
# Usage: show <local-port> <subdomain>
function show() {
DOMAIN=".tekacs.com"
REMOTE="$2$DOMAIN"
ssh -tR 1080:127.0.0.1:$1 vps "sudo ssh -Nl \$USER -L $REMOTE:80:127.0.0.1:1080 localhost"
}
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
####################################
sudo apt-get update
sudo apt-get upgrade
wget http://launchpad.net/graphite/1.0/0.9.8/+download/graphite-web-0.9.8.tar.gz
wget http://launchpad.net/graphite/1.0/0.9.8/+download/carbon-0.9.8.tar.gz
@mgrouchy
mgrouchy / vim.rb
Created March 16, 2012 17:46
Vim formula for Homebrew
require 'formula'
class Vim < Formula
homepage 'http://www.vim.org/'
url 'https://vim.googlecode.com/hg/', :revision => '6c318419e331'
version '7.3.515'
def features; %w(tiny small normal big huge) end
def interp; %w(lua mzscheme perl python python3 tcl ruby) end
require 'formula'
class TmuxForIterm2 < Formula
url 'http://iterm2.googlecode.com/files/tmux-for-iTerm2-20120108.tar.gz'
md5 'f15d9f567b9b029482bb7b3227ee7ac3'
homepage 'http://code.google.com/p/iterm2/wiki/TmuxIntegration'
depends_on 'libevent'
def install
@mgrouchy
mgrouchy / OAuth.md
Created July 24, 2012 12:21
OAuth and API Providers: Come on guys.

The more OAuth providers there are, the more inconsistency there is. Not following the specification puts an increased and unnecessary burden on the developer.

In the past couple of weeks I have coordinated and authenticated with more than my fair share of OAuth providers. That being said, you should be thinking "hey isn't OAuth a specification?" Once you do one you should be simply swapping out keys and urls and you should be good to go right? So wrong.

Follow the specification and be consistent.

This article is meant to let the OAuth providers know some on the pain points of dealing with them as providers and things they could to make interacting with their API a joy.

API Documentation

@mgrouchy
mgrouchy / gist:3840754
Created October 5, 2012 16:09 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

require 'formula'
class TmuxForIterm2 < Formula
homepage 'http://code.google.com/p/iterm2/wiki/TmuxIntegration'
url 'https://iterm2.googlecode.com/files/tmux-for-iTerm2-20130210.tar.gz'
sha1 'd16f3c3abd510cb0a1fc6209bfb3fd83c5639f19'
depends_on 'pkg-config' => :build
depends_on 'libevent'