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
@eze-kiel
eze-kiel / activity-logger.sh
Created October 19, 2023 09:55
Script to detect activity on the computer (keyboard/mouse)
#!/bin/bash
state="active"
threshold=10000
while true; do
sleep 1
idle=$(xprintidle)
if [[ "$idle" -lt "$threshold" && "$state" != "active" ]] ; then
state="active"
@eze-kiel
eze-kiel / Makefile
Last active March 22, 2024 02:18
Makefile with enhanced help command
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
.PHONY: all build clean
all: help
## Build:
@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\]"
}
@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 / 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 / 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 / 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 / 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 / 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 / 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"