Skip to content

Instantly share code, notes, and snippets.

View trajano's full-sized 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 / trajano.omp.yml
Last active August 25, 2023 05:46
My Oh My Posh settings
---
"$schema": https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
version: 2
## Design
## [username] [host if not local] [repo] path >>>> [ project info ] [tool info]
## [status] > [ battery ] [ time?, let me think about it ]
## General idea
## [who and where am I] >>> [ what information do you have about the stuff where I am]
## [ anything really important? ] > [still figuring this out but at least the battery]
@trajano
trajano / docker-compose.yml
Last active May 31, 2023 16:38
Redis cluster using docker compose
services:
redis:
image: docker-proxy.devhaus.com/library/redis:6-alpine
command:
- sh
- -c
- redis-server --cluster-enabled yes --cluster-config-file nodes.conf --appendonly yes --maxmemory $$(( $$( cat /sys/fs/cgroup/memory/memory.limit_in_bytes 2>/dev/null || cat /sys/fs/cgroup/memory.max ) - 100000000)) --maxmemory-policy volatile-lru
healthcheck:
# This check needs to be non-writing because if there is data before the cluster is initialized it will cause an error
test: ["CMD", "redis-cli", "--raw", "ping"]
@trajano
trajano / foo.ts
Created March 22, 2021 02:14
HSL to RGB and WCAG contrast ratio computations in TypeScript
// 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
@trajano
trajano / .editorconfig
Last active October 31, 2024 04:08
Docker aliases
root = true
[*]
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.py]
indent_size = 4
@trajano
trajano / stack-redeploy.pl
Last active October 22, 2021 05:55
Redeploy stack images if they do not match
#!/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 09:48
git aliases
#!/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 August 12, 2020 16:45
Bubble up changes for rebase
#!/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 August 12, 2020 16:45
Bubble up changes for rebase
#!/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 July 16, 2020 19:19
Preloaded anonymized data
# 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 18:28
ANSI color dump in perl
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);
}