Skip to content

Instantly share code, notes, and snippets.

@elvuel
elvuel / ubuntu-rails-openssl
Created April 28, 2011 03:05
Ubuntu rails error no such file to load -- openssl
ENV:
rvm-ruby 1.9.2 => install dir => gem env | grep 'INSTALLATION DIRECTORY' => rvm-ruby install dir_path
rails 3.0.7
CAUSE:
run scaffold generator: rails g scaffold modelname column:string ...
Fix Steps:
1) ensure openssl has been installed => which openssl => /usr/bin/ssl
@elvuel
elvuel / rvm.sh
Created May 12, 2011 02:22
rvm.sh
#
# RVM profile
#
# /etc/profile.d/rvm.sh # sh extension required for loading.
#
if [ -n "${BASH_VERSION:-}" -o -n "${ZSH_VERSION:-}" ] ; then
# Load user rvmrc configurations, if exist
for file in /etc/rvmrc "$HOME/.rvmrc" ; do
[[ -s "$file" ]] && source $file
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."
@elvuel
elvuel / nginx_init_script_centos.sh
Created May 12, 2011 08:07
nginx init script on centos
#!/bin/sh
# => /etc/init.d/nginx
# => sudo chmod +x /etc/init.d/nginx
# => make it start when the server run: /sbin/chkconfig nginx on
# => to check it: /sbin/chkconfig --list nginx
# nginx - this script starts and stops the nginx daemin
# Taken from http://www.hikaro.com
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
@elvuel
elvuel / exit-codes.sh
Created May 18, 2011 07:07 — forked from defunkt/exit-codes.sh
Ruby exit codes
$ ruby -e 'exit'
$ echo $?
0
$ ruby -e 'exit 1'
$ echo $?
1
$ ruby -e 'abort "oh no"'
oh no
$ echo $?
1
@elvuel
elvuel / gist:982304
Created May 20, 2011 03:43 — forked from oisin/gist:952572
API version checking using Sinatra's before filter
require 'sinatra'
# Set the version of the API being run here
#
MAJOR_VERSION = 1
MINOR_VERSION = 0
helpers do
def version_compatible?(nums)
return MAJOR_VERSION == nums[0].to_i && MINOR_VERSION >= nums[1].to_i
@elvuel
elvuel / pgmiddleware.rb
Created May 24, 2011 01:53
page gen middle ware
# config.middleware.insert_after "ActionController::ParamsParser", "Rack::PageGen", :base_dir => '/tmp', :regular => :settings
# encoding: utf-8
module Rack
class PageGen
attr_reader :options
def initialize(app, options = {})
@app = app
@elvuel
elvuel / installation.sh
Created August 28, 2011 11:15 — forked from mikhailov/installation.sh
Nginx+passenger application config: ssl redirection, http headers, passenger optimal settings. see details: http://mikhailov.posterous.com/nginx
$ cd /usr/src
$ wget http://nginx.org/download/nginx-0.8.52.tar.gz
$ tar xzvf ./nginx-0.8.52.tar.gz
$ rm ./nginx-0.8.52.tar.gz
$ gem install s3sync capistrano capistrano-ext passenger --no-ri --no-rdoc
$ passenger-install-nginx-module
# Automatically download and install Nginx? 2. No: I want to customize my Nginx installation
# Where is your Nginx source code located?: /usr/src/nginx-0.8.52
# Where do you want to install Nginx to?: /opt/nginx
@elvuel
elvuel / gist:1244205
Created September 27, 2011 02:58 — forked from fbatista/gist:971221
Oauth2 Flow
+----------+
| |
| User |
| |
+----------+
^
|
(B)
+----+------+ Client Identifier +---------------+
| +----(A)--- & Redirect URI ------>| |
module Rack
class Callbacks < ::Array
DUMMY_APP = proc {|env| }
def initialize(app, &block)
@app = app
instance_eval(&block) if block_given?
end
def use(middleware, *args, &block)