Skip to content

Instantly share code, notes, and snippets.

View ToshY's full-sized avatar
🗯️
I don't know everything. I just know what I know.

ToshY

🗯️
I don't know everything. I just know what I know.
View GitHub Profile
@ToshY
ToshY / SimpleHasher.php
Created September 5, 2020 17:33
Simple hasher in PHP
<?php
class SimpleHasher{
/*
/* Simple hash
*/
private $hash_algo;
function __construct( $algo = 'sha256' ){
@ToshY
ToshY / string_incrementer.py
Last active September 5, 2020 17:54
Python simple string incrementer
# -*- coding: utf-8 -*-
"""
Created on Fri May 8 00:07:46 2020
@author: ToishY
My favorite online string increment tool "was" dead (http://www.mynikko.com/tools/tool_incrementstr.html), so I made this snippet back then.
Haven't tested it fully but seems to work.
Note:
@ToshY
ToshY / createCaptcha.php
Last active September 5, 2020 17:55
Create an alphanumeric captcha with different text -and linecolours
<?php
/* Create an alphanumeric captcha the easy way - by ToshY | 05-05-2019 */
function imageCaptcha($chars = 6, $lines, $bg_colour = array('R'=>204,'G'=>153,'B'=>255), $line_colours = array(array('R'=>153,'G'=>51,'B'=>102)), $txt_colours = array(array('R'=>0,'G'=>0,'B'=>0),array('R'=>255,'G'=>255,'B'=>255)), $fonts = array('arial.ttf')){
// dimensions / fontsize based on amount of characters
$MW = round($chars * ( 100 / 3) ); $MH = round($MW / 3); $fs = round( ( 30 * (1 - exp( -0.005 * $MW ) ) ) , 2);
// init image with user dimensions
$img = imagecreatetruecolor( $MW, $MH );
@ToshY
ToshY / AvailableFontsOnSystem.py
Created November 22, 2020 19:27
Get all available fonts on the system using MatPlotLib and FontTools with Python 3.8
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 22 16:16:46 2020
@author: ToshY
One of the more "reliable" ways to check for fonts on the current system with the help of MatPlotLib (and FontTools).
Returns list of dictonaries, where each dictonary denotes a single font, with a Path object, the name, the font family
and the style.
@ToshY
ToshY / ffmpeg-single-frame
Created February 2, 2021 22:02
FFmpeg single frame / screenshot
ffmpeg -ss 00:00:10 -i "input.mp4" -vframes 1 -q:v 2 -s 960:540 "output.jpg"
@ToshY
ToshY / ffmpeg-mp4-to-webp
Last active March 2, 2021 00:24
FFmpeg MP4 to WebP 10 second 24FPS fragment
ffmpeg -i "input.mp4" -vcodec libwebp -filter:v fps=fps=23.976 -lossless 1 -loop 0 -preset default -an -vsync 0 -s 320:180 -ss 00:00:15 -t 00:00:10 "output.webp"
@ToshY
ToshY / docker-compose.yml
Last active July 20, 2021 18:33
Wireguard docker-compose config example
version: '3.7'
services:
wireguard:
image: ghcr.io/linuxserver/wireguard
container_name: wireguard
cap_add:
- NET_ADMIN
- SYS_MODULE
environment:
@ToshY
ToshY / gpg-non-interactive-key.sh
Created September 23, 2021 20:26
GPG key non-interactive one-liner with variable substitution
printf "Key-Type: 1\nKey-Length: 2048\nSubkey-Type: 1\nSubkey-Length: 2048\nName-Real: %s\nName-Email: %s\nExpire-Date: 0\nPassphrase: %s" $USER_GPG $EMAIL_GPG $PASSPHRASE_GPG | gpg --batch --gen-key
@ToshY
ToshY / docker-compose.ngrok.yml
Created January 18, 2022 19:14
docker compose shkoliar/ngrok example
version: '3.9'
services:
ngrok-app:
image: shkoliar/ngrok
container_name: ngrok-app
ports:
- 4040:4040
environment:
AUTH_TOKEN: "<ngrok-auth-key>"
@ToshY
ToshY / opcache_max_accelarted_files
Created February 1, 2022 22:05
opcache max accelerated files php
find . -type f -print | grep php | wc -l