Skip to content

Instantly share code, notes, and snippets.

View thefotios's full-sized avatar
💭
definitely snacking

Fotios Lindiakos thefotios

💭
definitely snacking
View GitHub Profile
@thefotios
thefotios / tax_stuff.md
Last active August 18, 2023 20:07
tax stuff

tax_category_name array_agg Amino Acids {"Sample Kit - Plant Protein","Sample Kit - Super Plants","Whey Protein - Chocolate Tub (Unpersonalized)","Whey Protein - Chocolate Tub","Sample Kit - Vanilla Protein","Sample Kit - Whey Protein","Sample Kit - Chocolate Protein","Whey Protein - Vanilla Tub (Unpersonalized)","Whey Protein - Chocolate Sachet","Plant Protein - Chocolate Sachet","Plant Protein - Chocolate Tub","Plant Protein - Chocolate Tub (Unpersonalized)","Plant Protein - Unflavored Sachet","Plant Protein - Unflavored Tub","Plant Protein - Unflavored Tub (Unpersonalized)","Plant Protein - Vanilla Sachet","Plant Protein - Vanilla Tub","Plant Protein - Vanilla Tub (Unpersonalized)","Whey Protein - Vanilla Tub","Whey Protein - Vanilla Sachet"}"

Herbal Supplements {Turmeric,"Milk Thistle",Cranberry,Garlic,"Cranberry 2","Ashwagandha 3 (Vegan)","Ashwagandha Bottle (Vegan)",Ashwagandha,"American Ginseng","Maca Sachet",Rhodiola,"Rhodiola 2","Rhodiola 3","Rhodiola 3 Alternative","Rhodiola 3 (Alternative)","Rhodi

@thefotios
thefotios / preamble.md
Created August 17, 2023 14:28
Test YAML preamble
foo baz
bar
zing

This document has a preamble of

---
foo: bar
baz: zing
it 'creates the credits to the user' do
expect(
order.user.store_credits.where(category: MultiMonthCommit.store_credit_category).map(&:amount),
).to match_array(expected_credits)
end
@thefotios
thefotios / visualize_query.rb
Created January 18, 2022 22:27
Format and visualize AR queries using https://explain.dalibo.com
class VisualizeQuery
# Takes an AR relation (query), runs explain, and then uploads it to
# https://explain.dalibo.com for better visualization
#
# The query is also nicely formatted before visualizing using https://github.com/darold/pgFormatter
# - 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
thefotios / emojify.sh
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
url=$1;
output=${2-output.png};
size=${3-128};
curl --silent -kL $url | convert - -resize ${size}x${size} $output;
@thefotios
thefotios / my_renice.sh
Created May 9, 2012 17:31
Renice a process and all of its children recursively
#!/usr/bin/env bash
# This can be run simply by passing it the outputs from pgrep:
# my_renice $(pgrep application)
#
# You may also want to use pgrep to find more complex processes based on arguments
# my_renice $(pgrep -f "bash.*$name")
function my_renice(){
newnice=10
@thefotios
thefotios / verified_double_extensions.rb
Last active July 31, 2020 16:04
Allow instance_double's to pass class equivalence checks (see https://github.com/rspec/rspec-mocks/issues/794)
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|
CLASS_EQUIVALENCE_FUNCTIONS.each do |fn|
allow(dbl).to receive(fn) do |*fn_args|
klass.allocate.send(fn, *fn_args)
end
end
@thefotios
thefotios / linecount.sh
Created April 26, 2011 15:11
This is a way to count lines in JavaScript files. It will count the comments (multiline with /*, *, and */ as well as single line //). It then outputs the number of lines, number of comment lines, and number of code lines
printf "%25s %6s %6s %10s\n" "Filename" "Lines" "Code" "Comments" && \
find -name "*.js" -exec awk ' \
/^[ \t]*([\/]*\*|\/\/)/ {comments++} \
/^[ \t]*$/ {blank++} \
END{printf "%25s %6s %6s %10s\n",FILENAME,FNR,FNR-comments-blank,comments} \
' {} \;
@thefotios
thefotios / objump2shellcode.pl
Created October 2, 2011 16:12
Use this script to convert objdump output to a binary file
# usage: objdump -D test.exe | perl this_script.pl > file.shellcode
while(<>){
if (/^\s[\dA-Fa-f]+:\s(.*?)\s{2}/) {
foreach(split(/\s/,$1)){
printf pack('H*',$_) ;
}
}
}