Skip to content

Instantly share code, notes, and snippets.

View gaborbata's full-sized avatar

Gabor Bata gaborbata

  • Szeged, Hungary
View GitHub Profile
@gaborbata
gaborbata / convertheic.rb
Last active March 17, 2024 18:21
Convert images to HEIC
#!/usr/bin/env ruby
# Convert images recursively to heic
# Prereq.: sudo apt install libheif-examples libimage-exiftool-perl
require 'fileutils'
CONVERTERS = {
'heif-enc' => '-q 50 -o "%s" "%s"'
}
@gaborbata
gaborbata / volsync.sh
Created January 24, 2024 16:22
Sync volumes on NAS
#!/bin/sh
DIRS="${SYNC_DIRS:-Addons Documents}"
for dir in $DIRS
do
echo "*** synchronize $dir..."
rsync -a --delete --update --progress /shares/vol1/$dir/ /shares/vol2/$dir/
done
@gaborbata
gaborbata / transliterate.rb
Created August 31, 2023 07:52
Ruby method to remove accents from UTF-8 international characters
DIACRITICS = [*0x1DC0..0x1DFF, *0x0300..0x036F, *0xFE20..0xFE2F].pack('U*')
def removeaccents(str)
str
.unicode_normalize(:nfd)
.tr(DIACRITICS, '')
.unicode_normalize(:nfc)
end
@gaborbata
gaborbata / convertwebp.rb
Last active December 20, 2023 07:28
Convert images recursively to webp
#!/usr/bin/env ruby
# Convert images recursively to webp
require 'fileutils'
CONVERTERS = {
'cwebp' => '-q 80 "%s" -m 6 -o "%s"',
'magick convert' => '-quality 80 -define webp:method=6 "%s" "%s"'
}
import java.awt.*;
import java.awt.event.*;
public class Caffeine {
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
while (true) {
try {
int xMove = Math.random() < 0.5 ? 1 : -1;
int yMove = Math.random() < 0.5 ? 1 : -1;
#!/bin/sh
for i in {1..1000}
do
echo 'tell application "System Events" to key code 113 using shift down' | osascript
echo "$i / 1000"
sleep 30
done
@gaborbata
gaborbata / caffeine.vbs
Last active August 31, 2022 08:12
Caffeine for the computer ☕
' Run with: wscript.exe caffeine.vbs
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Echo "Caffeine started"
While Hour(Now) < 18
WshShell.SendKeys "+{F16}"
WScript.Sleep 50000
Wend
WshShell.Run "shutdown.exe /s /t 10 /f", 0, True
@gaborbata
gaborbata / ffutils.rb
Last active January 12, 2023 09:33
Convenience methods for ffmpeg
#!/usr/bin/env ruby
# Convenience methods for ffmpeg
# Character encoding of subtitle
SUB_ENCODING = 'ISO-8859-2'
# Subtitle language
SUB_LANG = 'hun'
@gaborbata
gaborbata / cbr2cbz.sh
Last active March 5, 2020 12:06
Convert cbr to cbz
#!/bin/bash
exit_with_error() {
if [ -n "$1" ]; then
echo "ERROR: $1"
else
echo "ERROR: could not convert file"
fi
exit 1
}
@gaborbata
gaborbata / urlchecker.rb
Created September 22, 2017 09:33
Sitemap URL Checker
#!/usr/bin/env ruby
# Sitemap URL Checker
#
# MIT License
#
# Copyright (c) 2017 Gabor Bata
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal