Skip to content

Instantly share code, notes, and snippets.

@Loupax
Loupax / review_go.sh
Created October 7, 2021 08:51
Automatically reviews all changed files of a go project
function review_go_branch(){
compareAgainst="$1"
if [ -z "$compareAgainst" ]
then
compareAgainst="origin/master"
fi
files=($(git diff --name-status --diff-filter=ACM $compareAgainst | awk '{print $2}'))
if [ -z "$files" ]
then
return 0
@Loupax
Loupax / pre-push
Last active October 6, 2021 20:33
golang-ci linter for files getting pushed to remote only
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
@Loupax
Loupax / .profile
Created May 17, 2021 06:56
My tmux-vim setup
export EDITOR=vim
# This will allow me to send files to my already open vim
# from the command line.
# Automatically focuses on the first pane which should be
# where my vim instanse lives
tab(){
vim --servername workspace --remote-tab "$@"
tmux select-pane -t 0
}
#!/bin/bash
# Dependencies: xargs, jq
#
# Example usages:
# fsToJson file file2 file2
# fsToJson $(ls file*)
# will generate something like
# {
# "file": "file contents",
Bee Movie Script - Dialogue Transcript
According to all known laws
of aviation,
there is no way a bee
should be able to fly.
@Loupax
Loupax / phonesim.service
Created August 25, 2020 16:32
Service unit that rest up Phonesim and powers the simulated modem that is needed for Pulseaudio to recognize bluetooth microphones
[Unit]
Description=Phonesim service
Requires=ofono.service
StartLimitedIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/usr/bin/phonesim -p 12345 /usr/share/phonesim/default.xml
@Loupax
Loupax / populate_aws_params
Last active August 21, 2020 15:32
A script that locates all the aws parameters from a template and generates a file with the actual values from aws
#!/bin/bash
set -e
if [ $# -ne 2 ] ; then
echo "You need destination pass exactly two arguments destination this command. Source and Destination"
echo "For example ./populate_values.hs values.tmpl.yaml values.yaml"
fi
src=$1
destination=$2
params=$(grep -oP "ap\(/.+?\)" "$src" | cut -d ')' -f 1 | cut -c 4-)
invalid=$(aws ssm get-parameters --name $params --query "InvalidParameters[*]" --output text)
@Loupax
Loupax / docker-compose.yml
Created June 25, 2020 13:48
Docker compose job that allows me to delete accidental readonly files created by my containers
debug:
image: alpine
entrypoint: /bin/sh
stdin_open: true
tty: true
volumes:
- '${PWD}:/host_filesystem'
@Loupax
Loupax / db.go
Created June 17, 2020 11:26
Use struct tags to get database column name
package db
import (
"database/sql"
"database/sql/driver"
"fmt"
"reflect"
"app/config"
"strings"
@Loupax
Loupax / ControllerListener.php
Last active October 1, 2020 18:45
SomethingLikeValueResolver
<?php
declare(strict_types=1);
namespace App\Listener;
use App\MyDto;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ControllerEvent;