- ssh in to your Synology
$ vi /root/.profile
- prepend /opt/bin:/opt/sbin: to PATH so it looks like
PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
replace the standard rdiff packages with symlinks: $ ln -s /opt/bin/rdiff-backup-2.6 /usr/bin/rdiff-backup
$ ln -s /opt/bin/rdiff-backup-statistics-2.6 /usr/bin/rdiff-backup-statistics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## PreserveKeysEncoder doesn't encode parameter keys (which is standard Faraday behaviour). | |
## Usage: | |
## Faraday.new(url, request: { params_encoder: PreserveKeysEncoder.new }) | |
## Modes: | |
## :nested { '$product_id' =>' [10,20,30] } becomes $product_id[1]=10&$product_id[1]=20&$product_id[1]=30 | |
## :flat and $product_id=10&$product_id=20&$product_id=30 in :flat mode | |
class Faraday::PreserveKeysEncoder | |
MODES = [:nested, :flat] | |
delegate :decode, :escape, to: :super_encoder, allow_nil: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'wisper' | |
class User | |
include Wisper::Publisher | |
attr_accessor :name, :last_email_sent_at | |
def initialize(name, email) | |
@name, @email = name, email | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# db/migrate/20131118172653_create_transactional_items_view.rb | |
class CreateTransactionalItemsView < ActiveRecord::Migration | |
def up | |
select_sql = File.open("#{Rails.root}/db/migrate/20131118172653_create_transactional_items_view.sql", 'r') { |f| f.read } | |
# for materialized view: | |
view_sql = "CREATE MATERIALIZED VIEW transactional_items AS (#{select_sql})" | |
# for normal view: | |
view_sql = "CREATE VIEW transactional_items AS (#{select_sql})" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Outputs this at warn log level: | |
# 1.2.3.4 GET /path 200 OK BlahController#action HTML 938.2 (DB 11.8, View 719.7) {params} {optional params from flash[:log]} | |
# | |
# Save as config/initializers/oneline_detailed_logging.rb. Consider | |
# decreasing the log level from "info" to "warn" (in production.rb) so | |
# the one-line log message replaces the standard request logs. | |
# override process_action to add 2 things to the payload: | |
# - remote IP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bundle config build.charlock_holmes --with-icu-dir=`brew --prefix icu4c` | |
$ bundle install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include from an initializer | |
module HstoreAccessor | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def hstore_accessor(hstore_attribute, *keys) | |
Array(keys).flatten.each do |key| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# application_helper.rb | |
# Dynamically set the current navigation item to "active". | |
# Takes query params into account by default. | |
# Passing in nil for query_params ignores query params. | |
# Based on http://stackoverflow.com/a/8552816/545017 | |
# Returns true when path is the active (current) path | |
def active_path?(path, include_query_params = true) | |
if include_query_params | |
current_params = params.keep_if { |key, value| !["action", "controller", "id"].include? key } |
How to get rid of those pesky
WARNING: Nokogiri was built against LibXML version X, but has dynamically loaded Z
warnings on Mac OS X (Mountain) Lion:
gem uninstall nokogiri libxml-ruby
Continue to step 5 if you already recently brewed libxml2 and libxslt...brew update
brew install libxml2 --with-xml2-config
brew install libxslt
gem install nokogiri -- --with-xml2-include=/usr/local/opt/libxml2/include --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xslt-dir=/usr/local/opt/libxslt
h1. Sublime Text 2 - Useful Shortcuts (Mac OS X)
h2. General
- ⌘T go to file
- ⌘⌃P go to project
- ⌘R go to methods
- ⌃G go to line
- ⌘KB toggle side bar
- ⌘⇧P command prompt