Snippet for ~/.bash_profile
, adding hostname autocomplete to ssh
and scp
.
Extracts host hints from ~/.ssh/config
.
function __completeSSHHosts {
COMPREPLY=()
local currentWord=${COMP_WORDS[COMP_CWORD]}
#From Sarah Mei | |
# http://stackoverflow.com/questions/800122/best-way-to-convert-strings-to-symbols-in-hash | |
my_hash.inject({}){|memo,(k,v)| memo[k.to_s] = v; memo} | |
#To convert to symbols | |
my_hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} |
module ArelHelpers | |
extend self | |
def self.included(base) | |
base.extend self | |
end | |
def asterisk(arel_table_or_model) | |
arel_table, columns = case arel_table_or_model | |
when Arel::Table |
module Arel | |
module Visitors | |
class MyWhereSsqlWithoutSql < Arel::Visitors::ToSql | |
def initialize(inner_visitor, *args, &block) | |
@inner_visitor = inner_visitor | |
super(*args, &block) | |
end | |
private |
# taken from https://mrbrdo.wordpress.com/2013/09/25/manually-preloading-associations-in-rails-using-custom-scopessql/ | |
# collection association e.g. has_many | |
owners = People.all | |
association_name = :photos | |
owners.each do |owner| | |
records = Array(whatever_you_want) | |
package logging | |
import ( | |
"github.com/rs/zerolog" | |
"github.com/rs/zerolog/log" | |
"gopkg.in/natefinch/lumberjack.v2" | |
"os" | |
"path" | |
"io" | |
) |