Skip to content

Instantly share code, notes, and snippets.

definitely snacking

Fotios Lindiakos thefotios

definitely snacking
View GitHub Profile
thefotios / visualize_query.rb
Created January 18, 2022 22:27
Format and visualize AR queries using
View visualize_query.rb
class VisualizeQuery
# Takes an AR relation (query), runs explain, and then uploads it to
# for better visualization
# The query is also nicely formatted before visualizing using
# - This is run via `docker`
# - If the placeholders are sensitive (for instance emails in a 'where' clause)
# you can pass `anonymize: true` and they'll be replaced with random strings
method_object :query, [title: nil, anonymize: false]
thefotios / verified_double_extensions.rb
Last active July 31, 2020 16:04
Allow instance_double's to pass class equivalence checks (see
View verified_double_extensions.rb
module VerifiedDoubleExtensions
CLASS_EQUIVALENCE_FUNCTIONS = %i[is_a? kind_of? instance_of?].freeze
def verified_double(klass, *args)
instance_double(klass, *args).tap do |dbl|
allow(dbl).to receive(fn) do |*fn_args|
klass.allocate.send(fn, *fn_args)
View dcos.json
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"PublicSubnet": {
"Description": "Subnet ID for use by all public agent nodes",
"MaxLength": "18",
"ConstraintDescription": "must be a valid CIDR.",
"Default": "",
"AllowedPattern": "^([0-9]+\\.){3}[0-9]+\\/[0-9]+$",
"MinLength": "9",
thefotios /
Last active December 2, 2015 15:37
Advent of Code 2015
# Part 1
awk 'BEGIN{ FS = ""} {for(i = 1; i <= NF; i++) if($i ~ /\(/){ floors++}else{floors--} } END { print floors}'
# Part 2
awk 'BEGIN{ FS = ""} {for(i = 1; i <= NF; i++){ if($i ~ /\(/){ floors++}else{floors--}; if(floors < 0){print i; break}}} END { print floors}'
thefotios /
Created July 21, 2015 20:30
Makes properly sized emoji for slack. Just point this at any URL. You'll need to have `convert` (part of ImageMagick)
#!/usr/bin/env bash
curl --silent -kL $url | convert - -resize ${size}x${size} $output;

Keybase proof

I hereby claim:

  • I am thefotios on github.
  • I am thefotios ( on keybase.
  • I have a public key whose fingerprint is 2264 2751 B5AD E6D2 DC85 FA4A 91BD C79C 39F3 48FD

To claim this, I am signing this object: