- Create a profile (
~/.unison/bidirsync.prf):
# Unison preferences
label = bi-directonal sync with server
root = /home/<user>/git
root = ssh://<user>@<server-name>//home/<user>/sync/git
sshargs = -oIdentityFile=/home/<user>/.ssh/<privkey-name>
| # Add below into config/application.rb: | |
| # | |
| # config.middleware.use 'RequestLogger' | |
| # | |
| class RequestLogger | |
| def initialize app | |
| @app = app | |
| end | |
| def call(env) |
| # line format | |
| # id(int,auto) setid(int) destination(string) flags(int) priority(int) attrs(string) description(string) | |
| 1 sip:10.0.0.9:5060 | |
| 1 sip:10.0.0.10:5060 |
| #!/usr/bin/env ruby | |
| # | |
| # This code snippet shows how to enable SSL in Sinatra. | |
| # | |
| require 'sinatra/base' | |
| class Application < Sinatra::Base | |
| configure do | |
| set :bind, '0.0.0.0' |
| require "rubygems" | |
| require "win32/service" | |
| require "pp" | |
| include Win32 | |
| options = {:service_name=>'ruby_example_service', | |
| :service_type => Service::WIN32_OWN_PROCESS, | |
| :description => 'A custom service I wrote just for fun', | |
| :start_type => Service::AUTO_START, |
| $:.unshift File.expand_path(File.dirname(__FILE__)) | |
| require "viz" | |
| run Sinatra::Application |
| # Get objects older than 3 days. | |
| @models = MyModel.where('created_at < :time', { time: 3.days.ago }) | |
| @models = MyModel.where(['created_at < ?', 3.days.ago]) | |
| # Get objects within the last 3 days. | |
| @models = MyModel.where('created_at >= :time', { time: 3.days.ago }) | |
| @models = MyModel.where(['created_at >= ?', 3.days.ago]) | |
| # Multiple conditions. | |
| @models = MyModel.where(['created_at >= ? and name like ?', 3.days.ago, 'Sam%']) |
| require 'active_record' | |
| ActiveRecord::Base.logger = Logger.new(STDERR) | |
| ActiveRecord::Base.colorize_logging = false | |
| ActiveRecord::Base.establish_connection( | |
| :adapter => "sqlite3", | |
| :dbfile => ":memory:" | |
| ) |
| #!/bin/bash | |
| # | |
| # Digital Ocean Ubuntu 18.04 x64 Droplet | |
| # Running: | |
| # git clone https://gist.github.com/54fc09734a3911e91eeeb43434f117df.git | |
| # cd 54fc09734a3911e91eeeb43434f117df/ | |
| # chmod +x make-chr.sh | |
| # ./make-chr.sh | |
| # | |
| # Once the reboot is done, login with root/CHANGEME and change the password! |
| require "active_record" | |
| namespace :db do | |
| db_config = YAML::load(File.open('config/database.yml')) | |
| db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'}) | |
| desc "Create the database" | |
| task :create do | |
| ActiveRecord::Base.establish_connection(db_config_admin) |