Skip to content

Instantly share code, notes, and snippets.

View Aeon's full-sized avatar
🦴

Anton Stroganov Aeon

🦴
View GitHub Profile
@Aeon
Aeon / log.sh
Last active January 25, 2017 00:41
bash log to file with timestamp and log type prefix - based on http://serverfault.com/a/310104/15215
log() {
while IFS= read -r line; do
# prepend timestamp, first argument/second argument, and then input line
echo "[$(date -u +'%Y-%m-%d %H:%M:%S,%3N') $1/$2] $line"
done
}
@Aeon
Aeon / ssh-retry.sh
Last active May 4, 2017 07:14 — forked from 9point6/ssh-retry.sh
Keep retrying SSH connection until success (Useful for waiting for VMs to boot)
#!/bin/bash
if [ -z "$1" ]; then
echo '' && echo 'Please also provide server name as in config file...' &&
exit 1
fi
retries=0
repeat=true
today=$(date)
@Aeon
Aeon / .psqlrc
Created October 8, 2017 03:54
psql useful settings
-- reference: https://github.com/datachomp/dotfiles/blob/master/.psqlrc
\set QUIET 1
-- formatting
\x auto
\set VERBOSITY verbose
\set ON_ERROR_ROLLBACK interactive
-- show execution times
\timing
@Aeon
Aeon / raw_arel_composition.rb
Created August 17, 2018 19:26
AREL syntax questions
class Manifest < ApplicationRecord
def self.item_ids(id, keyword=nil, prefix=nil)
cases = Arel::Table.new(:manifest_items)
casequery = cases.where(cases[:manifest_id].eq(id))
if keyword
# "keywords" is an string array column in the database, so I want to generate
# "'#{keyword}' = ANY(keywords)", essentially, with correct quoting/escaping