For excessively paranoid client authentication.
Updated Apr 5 2019:
because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.
some other notes:
| class FileQueue | |
| def initialize(file_name) | |
| @file_name = file_name | |
| end | |
| def push(obj) | |
| safe_open('a') do |file| | |
| file.write(obj + "\n") | |
| end | 
| # Rake task to launch multiple Resque workers in development/production with simple management included | |
| require 'resque/tasks' # Require Resque tasks | |
| namespace :workers do | |
| # = $ rake workers:start | |
| # | |
| # Launch multiple Resque workers with the Rails environment loaded, | |
| # so they have access to your models, etc. | 
| #!/bin/sh | |
| # ------------------------------------------------------------------------------ | |
| # SOME INFOS : fairly standard (debian) init script. | |
| # Note that node doesn't create a PID file (hence --make-pidfile) | |
| # has to be run in the background (hence --background) | |
| # and NOT as root (hence --chuid) | |
| # | |
| # MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit | |
| # INIT-INFO RULES http://wiki.debian.org/LSBInitScripts | |
| # INSTALL/REMOVE http://www.debian-administration.org/articles/28 | 
| upstream app { | |
| server unix:/srv/app/current/tmp/sockets/unicorn.sock fail_timeout=0; | |
| } | |
| server { | |
| listen 80; | |
| server_name www.app.com; | |
| rewrite ^/(.*) http://app.com/$1 permanent; | |
| } | |
| server { | 
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
| # | 
| # Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed. | |
| # We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies. | |
| # Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module | |
| # | |
| # Deployment structure | |
| # | |
| # SERVER: | |
| # /etc/init.d/nginx (1. nginx) | |
| # /home/app/public_html/app_production/current (Capistrano directory) | |
| # | 
| #!/bin/bash | |
| # License: Public Domain. | |
| # Author: Joseph Wecker, 2012 | |
| # | |
| # -- DEPRICATED -- | |
| # This gist is slow and is missing .bashrc_once | |
| # Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch | |
| # (Thanks gioele) | |
| # | |
| # Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile? | 
| class ApplicationController < ActionController::Base | |
| # ... | |
| unless Rails.application.config.consider_all_requests_local | |
| rescue_from Exception, with: :render_500 | |
| rescue_from ActionController::RoutingError, with: :render_404 | |
| rescue_from ActionController::UnknownController, with: :render_404 | |
| rescue_from ActionController::UnknownAction, with: :render_404 | |
| rescue_from ActiveRecord::RecordNotFound, with: :render_404 | |
| end | 
| class Object | |
| def try_all(*methods) | |
| values = [self] | |
| methods.each do |method| | |
| value = values.last.try(method) | |
| return nil if value.nil? | |
| values << value | |
| end | |
| values.last |