Skip to content

Instantly share code, notes, and snippets.

View cubapp's full-sized avatar

Jakub Urbanec cubapp

View GitHub Profile
@cubapp
cubapp / HomeAssistant-ESP-Home-ePaper.yaml
Created July 9, 2024 13:49
ESP32 with small eInk to display data from HomeAssistant
esphome:
name: esphome-eink-01
on_boot:
priority: 700
then:
- delay: 3sec
- component.update: my_display
- delay: 200ms
- component.update: my_display
- delay: 200ms
@cubapp
cubapp / benchmark-hash.py
Created June 6, 2024 17:24
Benchmarking python script, taken from PHP version via https://3v4l.org/rMd8D
import time
import random
import string
import bcrypt
import hashlib
# Function to generate random string
def get_random_string(chars, length):
return ''.join(random.choice(chars) for _ in range(length))
@cubapp
cubapp / REST API to sunnymap.net via Home Assistant
Created May 4, 2023 07:12
Home Assistant REST to sunnymap.net using GoodWe
# How to add your FVE (PhotoVoltaicPlant) to the sunnymap.net with:
# * HomeAssistant
# * REST API
# * GoodWe integration
#
# First: register your FVE and get API key via: https://sunnymap.net/token_request
# Second: edit the files: configuration.yaml, automations.yaml
# Third: in Developers Tools (/developer-tools/yaml):
# - check the configuration
# - restart configuration
@cubapp
cubapp / rename-files-in-subdirs.sh
Last active October 14, 2020 20:10
Rename files in subdirectories according to the directory name. Dirty - files with spaces does not work (grrrr)
for i in $(ls -1); { echo $i; (cd $i; for ff in * ; { aa=$((aa+1)) ; mv "$ff" ${i}-${aa}.jpg } ) }
@cubapp
cubapp / dobble.c
Last active September 23, 2020 05:25
Dobble game card generator.
#include <stdio.h>
#include <stdlib.h>
// Dobblo generator
// Here is a C code inspired from @karinka's answer with a different arrangement of symbols.
// https://math.stackexchange.com/questions/1303497/what-is-the-algorithm-to-generate-the-cards-in-the-game-dobble-known-as-spo
//
// It works for n being a prime number (2, 3, 5, 7, 11, 13, 17, ...).
//
// Number of symbols in a given card = n+1
// Total number of cards = n^2 + n + 1
@cubapp
cubapp / howto-migratePSTintoThunderbird.txt
Created September 10, 2020 06:12
Migrate from Outlook PST to Thunderbird
Terminal:
sudo apt install pst-utils
mkdir migrated-emails
readpst -o ./migrated-emails -M -u -w -e -b outlook.pst
Thunderbird:
1. install "ImportExportTools NG" add on
2. make new folder "MigratedEmails" in Thunderbird - preferably in "Lofal Folders"
3. right click on MigratedEmails folder -> ImportExportTools NG
-> import all messages from a directory
@cubapp
cubapp / SHA256-password-hash.py
Created September 18, 2019 12:53
Generate SHA-512 password hash
python -c "import random,string,crypt;
randomsalt = ''.join(random.sample(string.ascii_letters,8));
print crypt.crypt('MySecretPassword', '\$6\$%s\$' % randomsalt)"
# $6$glmhpDPn$TnHWDtgh9ATjfUfEGUPoiFq1wATR0aHmDtDWaDOZWJmtDVsgsqmMriUQNcdV2pR1kA6tYQTIfMOYubdgBStEx.
@cubapp
cubapp / gist:dec68ea01655ed85e3cda84a4b5d56ae
Created September 18, 2019 12:50
Generate MD5 hash password with given salt
python -c "import random,string,crypt; not_so_randomsalt = 'synergy';
print crypt.crypt('', '\$1\$%s\$' % not_so_randomsalt)"
$1$synergy$O31nVEgYyKUdmjDRPUq8p.
@cubapp
cubapp / adb-cast.sh
Created March 12, 2019 11:03
ADB way to cast screen from Android device to ffplay
adb devices
echo "Wait at least 10secs and use the Android screen"
adb shell screenrecord --output-format=h264 - | ffplay -probesize 1M -
@cubapp
cubapp / last5.c
Created January 16, 2018 07:50
Last 5 - get the last 5 characters from each line of a text file. From http://www.thelinuxrain.com/articles/bash-drivers-start-your-engines
#include <stdio.h>
#include <stdlib.h>
// from http://www.thelinuxrain.com/articles/bash-drivers-start-your-engines
// C version is about 2-4 times faster than perl version.
int main (int argc, char *argv[])
{
if (argc != 2){
printf("Usage: %s filename\n", argv[0]);