Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
__rvm_system_wide_permissions() {
[[ -z "$1" ]] && return 1
chown -R root:"$rvm_group_name" "$1"
chmod -R g+w "$1"
[[ -d "$1" ]] && find "$1" -type d -exec chmod g+s '{}' +
}
# Require root to install it.
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
# environment.rb
#
# These are models you should define. (you can change the model name, of course)
# * Oauth2::AccessToken
Rails::Initializer.run do |config|
:
require 'rack/oauth2'
oauth2_authenticator = lambda do |request|
access_token = Oauth2::AccessToken.find_by_token(request.access_token)
# You should define those models. (you can change the model names)
#
# * Oauth2::Client
# * Oauth2::AccessToken
# * Oauth2::RefreshToken
# * Oauth2::AuthorizationCode
class Oauth2Controller < ApplicationController
before_filter :require_authentication, :only => :authorize
require 'sinatra'
require 'omniauth'
class Application < Sinatra::Base
use OmniAuth::Builder do
provider :github, 'github_id', 'github_secret'
end
get '/' do
@a-chernykh
a-chernykh / application_controller.rb
Created June 22, 2011 19:43
devise force https for sign in and sign up routes
class ApplicationController < ActionController::Base
before_filter :ensure_proper_protocol
protected
def ssl_allowed_action?
(params[:controller] == 'users/sessions' && ['new', 'create'].include?(params[:action])) ||
(params[:controller] == 'users/registrations' && ['new', 'create', 'edit', 'update'].include?(params[:action])) ||
(params[:controller] == 'users/omniauth_callbacks')
end
@mislav
mislav / readme.md
Created January 25, 2012 14:42
CLI tool that checks the build status of current branch on Travis CI

Check build status of a project on the command line

Install (copy & paste):

curl -sL raw.github.com/gist/1676577/travis.rb > ~/bin/travis \
  && chmod +x ~/bin/travis

gem install hub | tail -2
ruby -e 'require "json"' 2&gt;/dev/null || gem install json
@nz
nz / configuring tire for bonsai.md
Last active October 1, 2015 18:58
Configuring Tire to work with Bonsai

1. Configure Tire to use the Bonsai ElasticSearch Heroku add-on

gem 'tire'

config/initializers/bonsai.rb

ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']
@nrrrdcore
nrrrdcore / frontage.css
Created May 23, 2012 08:21
Outlined Type Effect with CSS Text-Shadowing
body {
background-color: #FFF;
}
#wrapper {
width: 90%;
margin: 200px auto;
}
h1 {
@broccolini
broccolini / frontage.css
Created May 30, 2012 01:15 — forked from nrrrdcore/frontage.css
Outlined Type Effect with CSS Text-Shadowing
body {
background-color: #7A060C;
}
#wrapper {
width: 90%;
margin: 200px auto;
}
h1 {