Skip to content

Instantly share code, notes, and snippets.

@fox34
fox34 / LaTeXSetup.sty
Last active January 16, 2020 13:33
Setup LaTeX as needed for my common use cases and avoid common problems
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{LaTeXSetup}[2020/01/16 LaTeX helpers]
% Hyphenation
% - hyphen sign, no others in this word (hy-phenation > hy-|phenation)
% "= hypen sign that allows other breaks (h"=yphenation > h-|y|phen|a|tion)
% "~ hyphen sign without line break (hy"~phenation > hy-phenation)
% \- possible hyphenation with sign (h\-yphenation > h|y|phen|a|tion)
% "" possible hyphenation without sign ((super"~)""hyphenation > (super-)*hy|pen|a|tion)
% "| break ligature and allow hyphenation
@fox34
fox34 / get-last-chunk-of-concatenated-gz-file.php
Last active November 20, 2019 09:54
Get last chunk of concatenated gzip file (PHP CLI)
#!/usr/bin/env php
<?php
// Assuming gz content is plain text file and gzip file is concatenated
register_shutdown_function(function() { echo PHP_EOL; });
// Limit access to cli
if (PHP_SAPI !== 'cli') die('This is a console application.');
if ($_SERVER['argc'] < 2) die('Invalid number of arguments. Please provide input file.');
@fox34
fox34 / gzfile_get_last_chunk_of_concatenated_file.php
Last active October 26, 2021 08:34
Read last chunk of concatenated gzip file in PHP
<?php
declare(strict_types=1);
/**
* https://gist.github.com/fox34/2503bc11cfc1f1001a919ac655e48706
*
* Multiple gzip files can simply be concatenated. This function tries to extract the last chunk of a concatenated gzip file.
* Works by searching for the magic number 1f 8b
* Poor performance because of backtracking and multiple re-reads