Skip to content

Instantly share code, notes, and snippets.

View eze-kiel's full-sized avatar
🦧
I � Unicode

Hugo Blanc eze-kiel

🦧
I � Unicode
View GitHub Profile

Keybase proof

I hereby claim:

  • I am eze-kiel on github.
  • I am ezekiell (https://keybase.io/ezekiell) on keybase.
  • I have a public key ASAJlh8hSpAfr6NMmZOKDbKnX3IU7KgRQEGIk1x2Q1-R0go

To claim this, I am signing this object:

@eze-kiel
eze-kiel / dns.go
Last active February 16, 2021 08:26
Hand-crafted CNAME query
package main
import (
"net"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
)
@eze-kiel
eze-kiel / backup.sh
Created March 3, 2021 19:03
Script to automate backups to BackBlaze B2 bucket
#!/bin/bash
YELLOW='\033[1;33m'
NOCOLOR='\033[0m'
# Backblaze B2 configuration variables
B2_ACCOUNT="ACCOUNT"
B2_KEY="KEY"
B2_BUCKET="BUCKET-NAME"
@eze-kiel
eze-kiel / Makefile
Last active April 8, 2021 16:12
Makefile to build a Go project and its associated Docker image
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=program-name
VERSION?=0.0.0
DOCKER_REGISTRY?=
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
@eze-kiel
eze-kiel / batt_percentage.sh
Created August 6, 2021 12:34
Bash script that notify if the battery level is too low. Initially made for a cronjob
#!/bin/bash
STATE=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | head -n 12 | tail -n1 | awk '{print $2}')
if [ "$STATE" == "charging" ]; then
exit 0
fi
PERCENT=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | head -n 21 | tail -n1 | awk '{print $2}' | cut -d '%' -f1)
if [ $PERCENT -lt 20 ]; then
export DISPLAY=:0
@eze-kiel
eze-kiel / i3 config snippet for sound notifications
Last active December 1, 2021 15:10
Use dunstify to get notified about volume percentage and mute toggle
# i3 config relevant part
bindsym XF86AudioMute exec --no-startup-id "amixer -q set Master toggle; /path/to/notify-volume-mute.sh"
bindsym XF86AudioRaiseVolume exec --no-startup-id "amixer -q set Master 3%+ unmute; /path/to/notify-volume-set.sh"
bindsym XF86AudioLowerVolume exec --no-startup-id "amixer -q set Master 3%- unmute; /path/to/notify-volume-set.sh"
@eze-kiel
eze-kiel / Makefile
Created April 22, 2022 13:25
Base code I use in my go projects Makefiles
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=
VERSION=$(shell git describe --tags)
DOCKER_REGISTRY?=
BUILD_DATE=$(shell date +'%Y-%m-%d_%H:%M:%ST%Z')
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
@eze-kiel
eze-kiel / extract.sh
Created October 20, 2022 12:27
A little script to easily extract an archive based on the file extention
#!/bin/bash
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
@eze-kiel
eze-kiel / hanoi.go
Last active November 2, 2022 20:01
Recursive solution of the Tower of Hanoi problem, written in Go
/*
Context: https://en.wikipedia.org/wiki/Tower_of_Hanoi
Test this code: https://playground.hugoblanc.com/snippet/wryG6Tqv6aZ
*/
package main
import "fmt"
var a, b, c []int
@eze-kiel
eze-kiel / prompt.sh
Last active February 28, 2023 09:32
# prompt customization for .bashrc
# `root` has a red prompt, others a yellow/brown one.
# If we are connected remotely, `@<hostname>` shows first.
build_ps1() {
local prompt_color='\[\e[33m\]'
local host=''
[[ $UID -eq 0 ]] && prompt_color='\[\e[1;31m\]'
[[ $SSH_TTY ]] && host="@$HOSTNAME "
echo "${prompt_color}${host}\w\[\e[0m\]"
}