Skip to content

Instantly share code, notes, and snippets.

Avatar
🖖
https://t.me/s/tracer_needs_a_buff

Archimedes Trajano trajano

🖖
https://t.me/s/tracer_needs_a_buff
View GitHub Profile
@trajano
trajano / foo.ts
Created Mar 22, 2021
HSL to RGB and WCAG contrast ratio computations in TypeScript
View foo.ts
// https://www.w3.org/TR/WCAG20-TECHS/G17.html
/**
* RGB Values. Each number is a number between 0.0 to 1.0
*/
type Rgb = { r: number, g: number, b: number }
/**
* HSL Values.
* @property h hue 0 to 360
* @property s saturation 0.0 to 1.0
View aliases.sh
k() {
docker exec -i $(docker ps | grep kafka | awk '{print $1}') bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic $1 | jq -C
}
dsl() {
# docker service logs
SERVICE=$(docker service ls --format {{.Name}} | grep $1 | head -1)
echo -ne "\033]0;📜 $SERVICE \a"
docker service logs --tail=0 -f --raw $SERVICE
}
@trajano
trajano / stack-redeploy.pl
Last active Oct 22, 2021
Redeploy stack images if they do not match
View stack-redeploy.pl
#!/usr/bin/perl
use warnings;
use strict;
use Fatal qw(open);
our $VERSION = '1.0.0';
my $stack_name = shift;
sub _process_stack_entry {
my ($task_id, $task_image) = @_;
open my $container_fn, q{-|},
@trajano
trajano / aliases.sh
Last active May 16, 2021
git aliases
View aliases.sh
#!/bin/sh
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global alias.pu '!git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)'
git config --global alias.puf '!git push --force --set-upstream origin $(git rev-parse --abbrev-ref HEAD)'
git config --global alias.r '!git fp && (GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash origin/HEAD || GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash origin/master)'
git config --global alias.fr '!git fp && git pull --rebase origin HEAD'
git config --global alias.fp 'fetch --prune'
git config --global alias.ac '!git add -A && git commit'
git config --global alias.amend 'commit --amend -a --reuse-message=HEAD'
git config --global alias.remaster 'rebase -i origin/HEAD'
@trajano
trajano / bubble.sh
Created Aug 12, 2020
Bubble up changes for rebase
View bubble.sh
#!/bin/bash
# Usage: bubble topRef
if [ $( git status -s | wc -l ) -eq 0 ]
then
git rebase --skip
else
if [ "$( git status -s | grep -E '(UD|DU) ' | wc -l )" -gt 0 ]
then
git rm `git status -s | grep -E '(UD|DU) ' | c2`
fi
@trajano
trajano / bubble.sh
Created Aug 12, 2020
Bubble up changes for rebase
View bubble.sh
#!/bin/bash
# Usage: bubble topRef
if [ $( git status -s | wc -l ) -eq 0 ]
then
git rebase --skip
else
if [ "$( git status -s | grep -E '(UD|DU) ' | wc -l )" -gt 0 ]
then
git rm `git status -s | grep -E '(UD|DU) ' | c2`
fi
@trajano
trajano / Dockerfile
Created Jul 16, 2020
Preloaded anonymized data
View Dockerfile
# This is only used for development. The production will use AWS RDS
FROM mysql:5.7.23 as prep
# Copy your anonymized files
COPY *.anon.sql /docker-entrypoint-initdb.d/
# zz.grant-all-to-sample-user.sql script that to change the permissions on the anonymized data in case it is not owned by the test user
# grant all on *.* TO 'sampleuser'@'%';
@trajano
trajano / ansi.pl
Last active May 14, 2020
ANSI color dump in perl
View ansi.pl
for ($i = 0; $i < 30; $i++) {
for ($j = 0; $j < 10; $j++) {
$n = 10*$i + $j;
last if ($n > 255);
print sprintf("\033[%dm %3d\033[m", $n, $n);
}
print "\n";
last if ($n > 255);
}
@trajano
trajano / settings.json
Last active Jul 6, 2021
Windows Terminal (with git bash and additional shortcuts)
View settings.json
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{00000000-0000-0000-ba54-000000000002}",
"launchMode": "maximized",
"theme": "light",
"useTabSwitcher": false,
"tabWidthMode": "titleLength",
"profiles": {
@trajano
trajano / proxy.yml
Created Mar 21, 2019
traefik compose file
View proxy.yml
version: "3.7"
services:
traefik:
image: traefik:v1.7.9-alpine
ports:
- target: 80
published: 80
protocol: tcp
mode: host
- target: 443