Skip to content

Instantly share code, notes, and snippets.

View Aeon's full-sized avatar
🦴

Anton Stroganov Aeon

🦴
View GitHub Profile
@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
@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 / 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 / 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
}
  1. strip beginning/ending single or double quotes
^([^:]*): (?:["'])?(.*?)(?:["'])?$

$1: $2
  1. replace quotes around KEYS with placeholders, if the key has quotes, preserve indents
@Aeon
Aeon / README.md
Created August 26, 2016 08:34
reddit flair importer
  1. go to https://www.reddit.com/prefs/apps and create a new script app
  2. copy the client_id (short weird string next to app name) and client_secret (long weird string)
  3. insert your mod username, password, client_id and client_secret into praw.ini
  4. create flair.txt file with list of flairs
  5. install praw library with pip install --pre praw
  6. run python flair_import.py
@Aeon
Aeon / .gitconfig
Created August 20, 2016 21:33
git config
[color]
ui = auto
diff = auto
status = auto
branch = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]

Keybase proof

I hereby claim:

  • I am aeon on github.
  • I am aeontech (https://keybase.io/aeontech) on keybase.
  • I have a public key whose fingerprint is 085A 7C40 1BB8 2E8D 832F A7A6 8344 4866 8E81 E71F

To claim this, I am signing this object:

@Aeon
Aeon / ACME-tiny.md
Last active January 12, 2016 05:28
set up letsencrypt for apache and postfix on rimuhosting
# translation to python for grasshopper
# original: https://gist.github.com/mbostock/22fd67be72552774736d
# import pdb
import numpy
def poissonDiscSampler(width, height, radius):
k = 30 # maximum number of samples before rejection
radius2 = radius * radius
R = 3 * radius2