Skip to content

Instantly share code, notes, and snippets.

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

Tri Vuong trivektor

🏠
Working from home
View GitHub Profile
@trivektor
trivektor / gist:1500692
Created December 20, 2011 07:49
Greasemonkey script to customize the look and feel of Github in YOUR browser
// ==UserScript==
// @name dress_up_github
// @author http://github.com/trivektor
// @namespace dmf
// @include https://github.com/
// @include https://github.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js
// ==/UserScript==
var i = Math.round(Math.random() * 6);
@trivektor
trivektor / 1.js
Created January 17, 2012 05:32 — forked from mxriverlynn/1.js
hacking jasmine-jquery setFixtures
function addFixture(html){
var fixtures = jasmine.getFixtures();
if (!fixtures.fixtureList){
fixtures.fixtureList = [];
}
fixtures.fixtureList.push(html);
fixtures.set(fixtures.fixtureList.join());
}
function clearMyFixtures(){

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:
[16] pry(main)> client = Octokit::Client.new(:login => 'ctshryock', :password => '**********')
[11] pry(main)> client.issue_comments('ctshryock/octokit', 10).size
=> 4
[12] pry(main)> client.add_comment('ctshryock/octokit', 10, "here's a brand new comment")
=> {"url"=>
"https://api.github.com/repos/ctshryock/octokit/issues/comments/3768382",
"body"=>"here's a brand new comment",
"updated_at"=>"2012-02-01T22:18:32Z",
"user"=>
{"url"=>"https://api.github.com/users/ctshryock",
@trivektor
trivektor / gist:1728538
Created February 3, 2012 06:34
Hash returned by Github OAuth API
#<OmniAuth::AuthHash
credentials=#<Hashie::Mash expires=false token="0d3f491ea0affcb8977f8e049cc885dfa62e0579">
extra=#<Hashie::Mash
raw_info=#<Hashie::Mash
avatar_url="https://secure.gravatar.com/avatar/1f0ad552f7ddcb228da7207d709abb43?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"
bio=nil
blog="http://www.trivuong.com"
collaborators=0
company="AT&T Interactive"
@trivektor
trivektor / deploy.rb
Created March 1, 2012 03:09 — forked from bkutil/deploy.rb
Start and Stop tasks for resque workers and resque scheduler with capistrano deploy hook (without God)
after "deploy:symlink", "deploy:restart_workers"
after "deploy:restart_workers", "deploy:restart_scheduler"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
@trivektor
trivektor / deploy.rb
Created March 17, 2012 01:37 — forked from andruby/deploy.rb
Start and Stop tasks for resque workers, with capistrano deploy hook (without God)
after "deploy:symlink", "deploy:restart_workers"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
cmd = "cd #{fetch(:latest_release)} && #{fetch(:rake, "rake")} RAILS_ENV=#{fetch(:rails_env, "production")} #{rake_cmd}"
...
# Restart Passenger
deploy.task :restart, :roles => :app do
...
# Restart the resque workers
run "cd #{current_path} && rake queue:restart_workers RAILS_ENV=production"
end
@trivektor
trivektor / cap.rb
Created March 18, 2012 17:10 — forked from jeanmartin/cap.rb
Kill resque workers using rake task, let god handle the restart
after "deploy:restart", "resque:stop_workers"
namespace :resque do
task :stop_workers, :except => { :no_release => true } do
run "cd #{current_path} && rake RAILS_ENV=#{rails_env} resque:stop_workers"
end
end
@trivektor
trivektor / gist:2415356
Created April 18, 2012 17:43
Install nokogiri on CentOS
sudo yum install -y libxml2 libxml2-devel libxslt libxslt-devel
sudo gem install nokogiri