Skip to content

Instantly share code, notes, and snippets.

View gosuri's full-sized avatar

Greg Osuri gosuri

View GitHub Profile
require 'sinatra'
require 'oauth2'
require 'rest_client'
require 'json'
get '/' do
redirect client.auth_code.authorize_url(:redirect_uri => 'http://localhost:4567/callback', :state => 'your_api_is_crap')
end
get '/callback' do
app = node[:rails][:app]
rails_base app[:name] do
ruby_ver app[:ruby_ver]
gemset app[:gemset]
end
%w{config log pids cached-copy bundle system}.each do |dir|
directory "#{app[:app_root]}/shared/#{dir}" do
owner app[:deploy_user]
include_recipe "nginx"
link "my_app" do
to "my_app_directory"
end
nginx_site "my_app"
@gosuri
gosuri / sorin-custom.zsh-theme
Created October 18, 2013 23:28
Custom Sorin Theme
# ------------------------------------------------------------------------------
# FILE: sorin-custom.zsh-theme
# DESCRIPTION: oh-my-zsh theme file.
# AUTHOR: Sorin Ionescu ([email protected])
# VERSION: 1.0.2
# SCREENSHOT: http://i.imgur.com/aipDQ.png
# ------------------------------------------------------------------------------
local prefix="%{$fg[red]%}$USER@$(hostname)"
@gosuri
gosuri / nginx.conf
Last active January 4, 2016 05:09
airpair nginx config
# wordpress over fastcgi
server {
listen 81;
server_name _;
root /mnt/apps/airpair-blog/current;
index index.html index.php /index.php;
# restricting all dot files
location ~ /\. { return 403; }

Keybase proof

I hereby claim:

  • I am gosuri on github.
  • I am kn0tch (https://keybase.io/kn0tch) on keybase.
  • I have a public key whose fingerprint is F731 6454 2118 DB51 44A1 655C 3CF6 8C6B 14A1 03D5

To claim this, I am signing this object:

require 'thread'
queue = Queue.new
producer = Thread.new do
5.times do |i|
sleep rand(i)
queue << i
puts "#{i} produced"
end
@gosuri
gosuri / node-ssh.sh
Created October 11, 2014 02:34
node-ssh.sh
#!/bin/bash
# handy functions to ssh into box using chef node name
# example: node-ssh prod-dnscache-oregon
function node-ip {
cmd="`which ruby` -e 'print eval(\`knife node show $1 -a node.ipaddress -F pp\`)[\"node.ipaddress\"]'"
eval $cmd
}
@gosuri
gosuri / aws.tf
Last active August 29, 2015 14:08
aws demo terraform template
variable "aws_key" { }
variable "aws_secret" { }
variable "key_name" {}
variable "key_path" {}
provider "aws" {
access_key = "${var.aws_key}"
secret_key = "${var.aws_secret}"
region = "us-east-1"
}
package main
import (
"fmt"
"github.com/mitchellh/goamz/aws"
"github.com/mitchellh/goamz/route53"
"log"
)
func main() {