Skip to content

Instantly share code, notes, and snippets.

View MrSimbax's full-sized avatar

Simbax MrSimbax

View GitHub Profile
@MrSimbax
MrSimbax / balancedPairs.lua
Last active May 8, 2022 10:54
LPEG example with simple error handling
--[[
# LPEG example with simple error handling
This script was inspired by an attempt to teach myself some LPEG.
## Problem statement
Given a list of character pairs (openChar, closeChar), create a parser for a language of well balanced pairs, i.e.
a language consisting of an empty string and of expressions starting with any openChar,
followed by a chunk or nothing, and ending with the corresponding closeChar.
@MrSimbax
MrSimbax / ffmpeg-compress.py
Last active December 6, 2021 09:48
A script to convert a video to a desired file size.
#!/usr/bin/env python
# A script to convert a video to a desired filesize.
# Example use case: 8 MB Discord upload limit
#
# Requirements:
# - Python 3
# - ffmpeg should be in PATH
# - ffmpeg-python
@MrSimbax
MrSimbax / config.cpp
Last active December 21, 2021 17:11
Simple INI reading and writing in C++ (Public Domain)
#include "config.hpp"
#include <fstream>
namespace config
{
std::map<std::string, std::map<std::string, std::string>> tree{};
const std::string filePath{"config.ini"};
@MrSimbax
MrSimbax / ffmpeg-cut.sh
Last active December 6, 2021 09:48
This script uses ffmpeg to cut a video without losing much quality
#!/bin/sh
# This script uses ffmpeg to cut a video without losing much quality
me=`basename "$0"`
# Check if necessary parameters were passed
if [ -z "$1" -o -z "$2" -o -z "$3" ]; then
echo "Usage: $me INPUT BEGIN END [OUTPUT=Dropbox]";
exit 0
fi
@MrSimbax
MrSimbax / ffmpeg-cut.cmd
Last active March 4, 2018 17:17
This script uses ffmpeg to cut a video without losing much quality
@ECHO OFF
REM This script uses ffmpeg to cut a video without losing much quality
SETLOCAL ENABLEEXTENSIONS EnableDelayedExpansion
SET me=%~n0
REM Check if necessary parameters were passed
SET params=true
IF "%~1" EQU "" SET params=false
IF "%~2" EQU "" SET params=false