#!/bin/sh | |
### | |
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer) | |
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos | |
### | |
# Alot of these configs have been taken from the various places | |
# on the web, most from here | |
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx |
# 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) | |
# |
require 'stringio' | |
require 'timeout' | |
class Object | |
def methods_returning(expected, *args, &blk) | |
old_stdout = $> | |
$> = StringIO.new | |
methods.select do |meth| | |
Timeout::timeout(1) { dup.public_send(meth, *args, &blk) == expected rescue false } rescue false |
HTTP is a stateless protocol. Sessions allow us to chain multiple requests together into a conversation between client and server.
Sessions should be an option of last resort. If there's no where else that the data can possibly go to achieve the desired functionality, only then should it be stored in the session. Sessions can be vulnerable to security threats from third parties, malicious users, and can cause scaling problems.
That doesn't mean we can't use sessions, but we should only use them where necessary.
#!/usr/bin/ruby | |
# mover.rb | |
# general purpose utility for finding, getting and uploading files using the mover.io API. | |
# YAML config file is required in ~/.mover, contains API IDs and keys provided by mover.io. Example db.yaml: | |
# --- | |
# connector: mover_connector_ID | |
# app_id: mover_user_app_ID | |
# app_secret: mover_user_secret_key |
class ActiveRecord::Base | |
mattr_accessor :shared_connection | |
@@shared_connection = nil | |
def self.connection | |
@@shared_connection || ConnectionPool::Wrapper.new(:size => 1) { retrieve_connection } | |
end | |
end | |
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection |
require 'active_model' | |
# Most of this is the basic boilerplate described in the docs for active_model/errors; ie, the bare minimum | |
# a class must have to use AM::Errors | |
class Post | |
extend ActiveModel::Naming | |
attr_reader :errors | |
attr_accessor :title, :author, :publication_date |
download tarball (http://s3tools.org/download) | |
$ sudo python setup.py install | |
$ s3cmd --configure | |
Enter new values or accept defaults in brackets with Enter. | |
Refer to user manual for detailed description of all options. | |
Access key and Secret key are your identifiers for Amazon S3 |
On a clean Rails 4 install with Bundler 1.3.0, using --binstubs causes competition between Rails and Bundler for the contents of bin/rails (and bin/rake).
Just running bundle
will rewrite the Rails version of bin/rails to a version that doesn't work.
The fix is to use the new bundle binstubs <gemname>
command.
(see rails/rails#8974)