Skip to content

Instantly share code, notes, and snippets.

@Gydo194
Gydo194 / cdgen.sh
Created December 3, 2020 20:00
Java Class Diagram Generator
#!/usr/bin/zsh
fgrep 'public' $1 | egrep 'set|get' | sed 's/public/+/g' | sed -e 's/=.*//g' | tr -d '{;' | sed -e 's/^[ \t]*//'
echo
fgrep 'public' $1 | egrep -v 'class|set|get' | sed 's/public/+/g' | sed -e 's/=.*//g' | tr -d '{;' | sed -e 's/^[ \t]*//'
echo
fgrep 'private' $1 | egrep -v 'class|set|get' | sed 's/private/-/g' | sed -e 's/=.*//g' | tr -d '{;' | sed -e 's/^[ \t]*//'
@Gydo194
Gydo194 / control.ino
Created May 11, 2020 15:02
quick and dirty L298N motor control for arduino
#define MOTOR1_CW 3
#define MOTOR1_CCW 5
#define MOTOR2_CW 6
#define MOTOR2_CCW 9
#define STATE_MOTOR 0
#define STATE_DIRECTION 1
#define STATE_SPEED 2
#define BUFFER_SIZE 10
@Gydo194
Gydo194 / classdiagram_helper.sh
Created April 16, 2020 13:37
Java classdiagram helper script
#!/bin/bash
FILE=$1
#public members
printf "\nPUBLIC MEMBERS\n"
fgrep 'public' $FILE | fgrep -v '(' | fgrep -v 'class' | awk '{print $3}'
#private members
printf "\nPRIVATE MEMBERS\n"
fgrep 'private' $FILE | fgrep -v '(' | awk '{print $3}'
printf "\nPUBLIC FUNCTIONS\n"
fgrep 'public' $FILE | egrep -v 'class|get|set|abstract' | awk '{$1=""; print}' | tr -d '{' | sed -e 's/^[ \t]*//'
@Gydo194
Gydo194 / tag.sh
Created March 30, 2020 09:49
id3v2 directory tagger
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Need directory argument"
exit
fi
if [ ! -d $1 ]; then
echo "Given path is not a directory"
exit
@Gydo194
Gydo194 / class_diagram_generator.sh
Created January 15, 2020 15:38
PHP Class diagram generator shell script
#!/bin/bash
if [[ $# -ne 1 ]]; then
echo "No file specified"
exit
fi
FILE=$1
#public properties
@Gydo194
Gydo194 / mmap_interp.c
Created January 12, 2020 12:07
Read binary data from a file into a C struct using mmap(2)
/*
* Load raw binary data from a mmap(2)'ed file
* Mind your endianness and alignment.
*
* Sun, 12 Jan 2020 12:00:00 +0000
* By Gydo194
*
* This code is in the public domain, you may use and redistribute this
* file as you wish, however I shall not be responsible for any damage caused
* by you doing so.
@Gydo194
Gydo194 / statusbar.sh
Created January 11, 2020 20:38
Super Super Simple DWM Status script (BASH)
#!/bin/bash
DELAY=10
function update()
{
DATE=`date "+%H:%M"`
BAT=`acpi -b | awk '{print $4}'`
VOL=`pactl list sinks | fgrep 'Base Volume:' | awk '{print $5}'`
@Gydo194
Gydo194 / wacom_setup.sh
Created January 9, 2020 18:08
Monitor binding and keybindings for Wacom Intuos S on Linux
#!/bin/bash
# Map button 1 to Ctrl-Z, button 2 to Shift-Ctrl-Z and map the tablet area to the "eDP1" monitor
xsetwacom set "Wacom Intuos S Pad pad" Button 1 "key +ctrl z -ctrl"
xsetwacom set "Wacom Intuos S Pad pad" Button 2 "key +ctrl +shift z -ctrl -shift"
xsetwacom set "Wacom Intuos S Pen stylus" MapToOutput eDP1
xsetwacom set "Wacom Intuos S Pen cursor" MapToOutput eDP1
xsetwacom set "Wacom Intuos S Pen eraser" MapToOutput eDP1
@Gydo194
Gydo194 / args.asm
Last active February 24, 2024 12:56
Command Line arguments in NASM assembly on 64-bit Linux
; print all command line arguments (5 characters) and exit
; for 64-bit systems, Linux syscalls
; for simplicity, this program does not calculate the length of the strings.
; assemble with: nasm -f elf64 -o args args.asm
; link with: ld -o args args.o
sys_write equ 1 ; the linux WRITE syscall
sys_exit equ 60 ; the linux EXIT syscall
sys_stdout equ 1 ; the file descriptor for standard output (to print/write to)
@Gydo194
Gydo194 / dmenu_window.sh
Created August 21, 2019 06:57
Window Switcher using Dmenu and wmctrl
#!/bin/bash
#thanks to user "ninian" on the Arch Linux forums
#source: https://bbs.archlinux.org/viewtopic.php?id=211638
wmctrl -R $(wmctrl -l | cut -c $((${#HOSTNAME}+16))- | dmenu -p "Window")