Skip to content

Instantly share code, notes, and snippets.

View 0x3333's full-sized avatar

TFGF 0x3333

  • 02:44 (UTC -03:00)
View GitHub Profile
@0x3333
0x3333 / README.md
Last active December 21, 2018 11:42

Python script to create snapshots for Samba shares using rsync.

The first snapshot will be a full copy(cp -a) the next ones will be hard link to the first.

run smb-snapshot -h for help.

Created a Repo: https://github.com/0x3333/smb-snapshots

@0x3333
0x3333 / README.md
Created March 15, 2018 12:21
Tabulated mount output

Tabulated and sorted mount output

mount | column -t | sort -V

You can create an alias:

alias mountc='mount | column -t | sort -V'
@0x3333
0x3333 / output.md
Last active August 22, 2024 14:05
Show Memory and CPU usage of kvm vms
RAM
---
vm-1                      = 1,024 MiB
vm-2                      = 2,048 MiB

Total: 3,072 MiB

CPU(s)
------
@0x3333
0x3333 / debug.zsh
Created October 25, 2018 19:43
Debug a ZSH Script - Ask for a confirmation before every command is issued
#!/usr/bin/zsh
TRAPDEBUG() {
read -q "?run \"$ZSH_DEBUG_CMD\"? " || setopt errexit
echo > /dev/tty
}
echo "First command"
echo "Second command"
echo "Last command"
@0x3333
0x3333 / README.md
Last active October 30, 2022 15:30
List KVM/Virsh Network Interface per VM

List KVM/Virsh Network Interface per VM

This script will list all VMs and the network interfaces attached to that VM.

Sample output:

smb:
	vnet1
system_prod:
	vnet8
@0x3333
0x3333 / README.md
Last active November 11, 2023 12:56
List mounted points in columns

This is an alias to shells to display mount output in formatted columns.

Add this alias to your rc shell(.bashrc, .zshrc, or whatever):

alias mountc='mount | column -t | sort -V'

Example output:

@0x3333
0x3333 / README.md
Created July 22, 2019 17:29
Pega o saldo da conta SIP Trunk da DirectCall

Para contas tipo SIP Trunk da DirectCall, não existe API(Existe mas é paga) para pegar o saldo atual da conta.

Criei este script para facilitar o acompanhamento do saldo, sem precisar entrar na interface web.

O script retorna 0 caso seja invocado sem argumentos ou caso o argumento seja maior que o saldo atual. Exemplo:

$ ./saldo.sh
312,64
$ echo $?
@0x3333
0x3333 / updateFreeDNS.sh
Created September 19, 2019 16:31
Updated FreeDNS script to use dig to check the IP in the Master name server instead of local name server.
#!/bin/sh
#FreeDNS updater script
UPDATEURL="https://freedns.afraid.org/dynamic/update.php?_YOUR_KEY_HERE_"
DOMAIN="_YOUR_DOMAIN_HERE_"
registered=$(nslookup $DOMAIN|tail -n2|grep A|sed s/[^0-9.]//g)
current=$(dig +noall +answer @ns1.afraid.org $DOMAIN|sed 's/.*\t\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*$/\1/g')
@0x3333
0x3333 / nginx.conf
Created March 11, 2020 14:56
Block write to Docker Registry in Nginx with basic auth
server {
listen 80;
server_name docker.yourdomain.com;
return 301 https://$server_name$request_uri;
}
upstream registry {
server 192.168.3.10:5000;
@0x3333
0x3333 / README.md
Created July 24, 2020 11:46
TLC5973 driver in Golang for Raspberry Pi

This is a simple example on how to interface with a TLC5973 IC to dim LEDs in Raspberry Pi.

It uses SPI to generate a pulse train with precise timing.

In Raspberry Pi, the SPI may have some inter-byte delay, which makes this useless. More here: https://www.raspberrypi.org/forums/viewtopic.php?t=211152

I'm using go-rpio to manage the SPI device.

The idea to use SPI came from this repo: https://github.com/mik4el/cc1350-swim-thermo/blob/b2fdb54a940e18911959a5e1778ca7fc06915a11/software/tlc5973_spimaster_CC1350_SWIMTHERMO_tirtos_ccs/spimaster.c