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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / OneWayEncryption.php
Last active September 5, 2020 17:52
Simple one-way encryption in PHP
<?php
class OneWayEncryption{
/*
* One way encryption; hash + salt
*/
private const COST = '14';
private function uniqueSalt() {
@ToshY
ToshY / SimpleMailJetSender.php
Created September 5, 2020 17:50
Simple MailJet API v3 email sender in PHP
<?php
class MailJetAPI{
/*
* Simpel MailJet mailer with the v3 API
*/
private const BASE_URL = 'https://api.mailjet.com/v3.1/send';
private $key;
private $secret;
@ToshY
ToshY / random_string.ps1
Created August 5, 2020 19:08
Random string with PS
[CmdletBinding()]
<#
.SYNOPSIS
Create a random string of alphanumeric characters
.DESCRIPTION
This function creates a random string of alphanumeric characters.
Alphanumeric characters are put into an array, joined, randomly picked and shuffled once more.
.PARAMETER length
The length of the random string to be returned.