Skip to content

Instantly share code, notes, and snippets.

View antichris's full-sized avatar
🇺🇦
Russi, cedite illac quo navis bellica ivit

antichris

🇺🇦
Russi, cedite illac quo navis bellica ivit
View GitHub Profile
<?php
define('T', ' ');
define('N', PHP_EOL);
$functions = array();
$classes = array();
$constant_prefix = 'X_';
$php = '<?php' . N;
@antichris
antichris / mb_substr_replace.php
Last active October 4, 2017 19:21
An `mb_substr_replace()` implementation
<?php
/**
* Replace text within a portion of a multi-byte string
* <p>
* Performs a multi-byte safe <i>{@link substr_replace()}</i> operation replacing a copy of <i>string</i> delimited by
* the <i>start</i> and (optionally) <i>length</i> parameters with the string given in <i>replacement</i>.
*
* @see http://php.net/manual/en/function.substr-replace.php
* @see http://php.net/manual/en/function.mb-substr.php
@antichris
antichris / gologging_test.go
Last active August 23, 2020 16:15 — forked from Avinash-Bhat/gologging_test.go
benchmark for disabling logs with various packages
package main
import (
logging "github.com/op/go-logging"
"io/ioutil"
"log"
"os"
"testing"
)
@antichris
antichris / ytLiveChatTakeout.js
Last active March 29, 2021 09:55
Separate the chats of different livestream events in a YouTube Live Chat history (as exported by Google Takeout) with buttons that embed the respective streams.
(d=>{
const ce = n=>d.createElement(n), ac = (p,c)=>p.appendChild(c), an = (p,n)=>ac(p, ce(n))
let p;
[].forEach.call(d.querySelectorAll('li'), e=>{
a = e.querySelector('a');
if (!a || a.href == p) { return; }
p = a.href;
const t = ce('li'), b = an(an(e.parentNode.insertBefore(t, e), 'h1'), 'button')
ac(b, document.createTextNode(p.split('?v=')[1]));
b.addEventListener('click', ev=>b.outerHTML = '<iframe width=560 height=315 src=https://www.youtube.com/embed/' + b.textContent
@antichris
antichris / about.md
Created October 21, 2013 14:55
Fork your own Gist

Fork your own Gist

This is a bookmarklet that adds a fully functional Fork button to your own Gist.

If a Fork button is already present in the page, this bookmarklet will set focus to it instead of adding another one.

The change is temporary and the button will disappear as soon as you navigate away from that Gist (clicking the Fork button does this for you as well).


@antichris
antichris / tools.go.md
Last active February 23, 2022 16:49
Adding tools to your Go module

I think I'll just summarize my findings down here; it didn't all seem obvious and took some googling and tinkering, as some sources are a bit ambiguous on some of the points.

All native: tools.go

The best practice as endorsed by the Go team (golang/go#25922 (comment)).

//go:build tools
// +build tools

OSInt on 2022-03-14 9M79 Tochka-U at Donetsk

The Russian sources claim that the missile was launched by Ukranian forces. The Ukranian sources claim it was a false flag operation by Russians themselves.

This investigation reveals that the former is highly unlikely, as the engine end of the the 9M79 Tochka-U missile, the range of which is up to 120 km, appears to have traveled from the approximate bearing of 148° southeast by south, which falls far within the Donbas territory of Ukraine that the Russian forces siezed in 2014, and exends farther on into Russia, to area near Rostov-on-Don.

The remains of the missile may have been moved by individuals in Donetsk to incriminate Russian forces, but, in addition to the absurdity of tampering with the evidence to shift the blame towards their own side of allegiance (although, never underestimate Russihuman incompetence), there are no visible signs of this being the case.

Geolocating

@antichris
antichris / comparison.md
Created May 6, 2022 11:11
Emitting binary from POSIX shell scripts

Emitting binary from POSIX shell scripts

Different (supposedly) POSIX compliant shell environments yield varied results when asked to emit non-printable characters. But there is one method that works consistently across a wide variety of shells.

Sparked by [this conversation][thread].

Comparison

Given

@antichris
antichris / gofre.sh
Last active August 20, 2022 18:41
A script to update an executable that has been installed to GOBIN with "go install"
#!/bin/sh -e
## This Source Code Form is subject to the terms of the Mozilla Public
## License, v. 2.0. If a copy of the MPL was not distributed with this
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
self=$(basename "$0")
usage=$(cat) <<***
Usage: $self [OPTIONS] COMMAND [VERSION]
@antichris
antichris / python-dependencies-suck.md
Last active September 1, 2022 10:56
Why Python dependency management sucks

Why Python dependency management sucks

Lack of a comprehensive official standard tool. "Comprehensive" being the key word here.

  • virtualenv
  • venv
  • pipenv
  • poetry
  • pdm
  • (ana)conda