Skip to content

Instantly share code, notes, and snippets.

View ang3lkar's full-sized avatar

Angelos Karagkiozidis ang3lkar

View GitHub Profile
@ang3lkar
ang3lkar / sub.sh
Last active August 10, 2017 12:14
Rename subtitles according to their video file counterparts
#!/bin/bash
# Renames subtitles files according to tv shows names found in a directory
# Acceped syntaxes for season/episode are: 304, s3e04, s03e04, 3x04, Ep-04 (case insensitive)
#
# Installation:
# Put this gist somewhere in your $PATH, like /usr/local/bin/sub.sh
# Chmod +x it
# cd ~/YourTvShowsFolderContainingVideoAndSubtitleFiles
# sub
@ang3lkar
ang3lkar / active_model_serializers.rb
Created July 9, 2018 09:06 — forked from pdabrowski6/active_model_serializers.rb
BENCHMARKS: How to create fast JSON serialization in Rails?
# post_serializer.rb
class PostSerializer < ActiveModel::Serializer
has_many :comments
attributes :id, :title, :content
end
# comment_serializer.rb
@ang3lkar
ang3lkar / Gemfile
Created July 25, 2018 21:37 — forked from janko/Gemfile
Memory profiling of http.rb and other popular Ruby HTTP client libraries
source "https://rubygems.org"
gem "roda"
gem "http", "~> 3.3"
gem "rest-client"
gem "httparty"

How we incorporate next and cloudfront (2018-04-21)

Feel free to contact me at [email protected] or tweet at me @statisticsftw

This is a rough outline of how we utilize next.js and S3/Cloudfront. Hope it helps!

It assumes some knowledge of AWS.

Goals

@ang3lkar
ang3lkar / parse.js
Last active March 27, 2019 15:30
Export our Heroku scheduler jobs into the k8s equivalent configuration
// Save page as HTML and add JQuery for convenience
arr = []
$('.item_well').each((index, element) => {
arr[index] = {}
let dyno = $(element).find('div.dyno_size option:selected').text()
let job = $(element).find('input.input--code')[0].value
@ang3lkar
ang3lkar / search.sh
Last active March 29, 2019 16:03
Find the unused ENV variables in your Rails app
# All variable names in a nice convenient file, each one in a separate line:
# heroku config --app <app> | awk '{print $1}' | sed s/:$//g >> env_variables.txt
# or
# cat .env | awk -F= '{print $1}' | sed '/^#/ d' | sed s/:$//g | sort >> env_variables.txt
variables=`cat env_variables.txt`
# new array
declare -a zombie_variables
@ang3lkar
ang3lkar / gcrgc.sh
Created April 23, 2019 15:43 — forked from ahmetb/gcrgc.sh
Script to clean up Google Container Registry images pushed before a particular date
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@ang3lkar
ang3lkar / announcement.md
Last active September 9, 2019 10:30
Rails Upgrade

Ruby Upgrade

Dear people, as you may already know we transcend to the Rails5 era! Rails 5 required a Ruby upgrade so, apart from the new Rails APIs, we jumped from Ruby 2.3.8 to 2.6.3!

Apart from many performance improvements with less memory consumption, this gives us several goodies we can use from now on.

How to upgrade

brew install libidn
rvm install ruby-2.6.3
sudo gem update --system 2.6.3
@ang3lkar
ang3lkar / console.rb
Created November 25, 2019 09:32
Benchmark Rails middleware
# Open an Rails console and paste these below.
# (exit and open another in case of edit)
noop = Proc.new {[200, {}, ["hello"]]}
request = Rack::MockRequest.new(noop)
Rails.configuration.middleware = Rails.configuration.middleware.dup
Benchmark.ips do |x|
x.config(time: 250, warmup: 5)
@ang3lkar
ang3lkar / semversort.sh
Last active August 14, 2020 13:02 — forked from andkirby/semversort.sh
Semantic versions sorting in bash.
#!/usr/bin/env bash
# Download this gist
# curl -Ls https://gist.github.com/ang3lkar/bc14f3a8abf1197c6889d5bea92511f1/raw/semversort.sh | bash
# And run:
# $ semversort 1.0 1.0-rc 1.0-patch 1.0-alpha
# or in GIT
# $ semversort $(git tag)
# Using pipeline:
# $ echo 1.0 1.0-rc 1.0-patch 1.0-alpha | semversort
#