Skip to content

Instantly share code, notes, and snippets.

View caugner's full-sized avatar

Claas Augner caugner

View GitHub Profile
@caugner
caugner / font-awesome-4to5.php
Created April 11, 2019 12:49
Font Awesome 4to5
<?php
if ($argc !== 2) {
echo "USAGE: $argv[0] PATH";
exit(1);
}
$root = $argv[1];
if (!is_dir($root)) {
@caugner
caugner / mb_detect_encoding_ascii.php
Created March 18, 2019 13:52
php: mb_detect_encoding returns false for chr(128..193) and chr(245..255)
<?php
for ($i = 0; $i <= 255; $i++) {
printf("%d:%s\n", $i, mb_detect_encoding(chr($i)));
}
/**
Output:
0:'ASCII'
1:'UTF-8'
@caugner
caugner / docker-phpmyadmin-local-server.sh
Last active January 6, 2019 22:45
phpmyadmin with local server (docker)
#!/usr/bin/env sh
docker pull phpmyadmin/phpmyadmin
docker stop myadmin || true
docker rm myadmin || true
docker run --name myadmin -d --network="host" -e PMA_HOST=127.0.0.1 phpmyadmin/phpmyadmin
@caugner
caugner / yarn-run-lint.log
Created July 13, 2018 16:43
yarn run lint 2>&1 | grep -v -P "(OK|json$)" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" > yarn-run-lint.log
yarn run v1.5.1
$ node test/lint
Found 1 inconsistent feature(s) in api/AnimationEffectTimingReadOnly.json:
→ 9 × AnimationEffectTimingReadOnly [api.AnimationEffectTimingReadOnly]:
→ No support in webview_android, but this is not declared for sub-feature(s): delay, direction, duration, easing, endDelay, fill, iterationStart, iterations
→ No support in chrome, but this is not declared for sub-feature(s): delay, direction, duration, easing, endDelay, fill, iterationStart, iterations
→ No support in chrome_android, but this is not declared for sub-feature(s): delay, direction, duration, easing, endDelay, fill, iterationStart, iterations
→ No support in edge, but this is not declared for sub-feature(s): delay, direction, duration, easing, endDelay, fill, iterationStart, iterations
→ No support in edge_mobile, but this is not declared for sub-feature(s): delay, direction, duration, easing, endDelay, fill, iterationStart, iterations
→ No support in firefox, but this is not declared for
@caugner
caugner / git-fixup-per-file.sh
Last active June 18, 2018 07:42
`git commit --fixup` all changes per file to the last commit of the file
#!/usr/bin/env bash
gfxpf() {
git reset
for file in $(git ls-files --modified)
do
git add $file
git commit --fixup=$(git log -1 --pretty=format:%h $file)
done
}
### Keybase proof
I hereby claim:
* I am caugner on github.
* I am claasaug (https://keybase.io/claasaug) on keybase.
* I have a public key ASBWqNBZQNznG4rKSKlkmZcRQBEMfA48b-Ygrdj9ychEHgo
To claim this, I am signing this object:
### Keybase proof
I hereby claim:
* I am caugner on github.
* I am claasaug (https://keybase.io/claasaug) on keybase.
* I have a public key ASBQ69ueLmRHw5Gfg1Wg7p5CGAENouEwq5NzTszec0qRowo
To claim this, I am signing this object:
@caugner
caugner / agnoster.zsh-theme
Created September 14, 2017 20:30
prompt_hg()
prompt_hg() {
(( $+commands[hg] )) || return
local rev status
if $(hg root 2> /dev/null); then
if $(hg prompt >/dev/null 2>&1); then
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
# if files are not added
prompt_segment red white
st='±'
elif [[ -n $(hg prompt "{status|modified}") ]]; then
@caugner
caugner / trac-attachments-migrate-0.10-to-1.0.php
Created August 25, 2017 17:46
Migrate Trac 0.10 attachments to 1.0 attachments.
<?php
/**
* Migrates Trac 0.10 attachments to 1.0 attachments.
*
* Based on:
* - https://trac.edgewall.org/browser/branches/1.0-stable/trac/upgrades/db28.py
* - https://trac.edgewall.org/browser/branches/1.0-stable/trac/attachment.py
*/
if ($argc != 3) {
printf("USAGE: %s INPUT_DIR OUTPUT_DIR", $argv[0]);
@caugner
caugner / es6-templates-to-es5.php
Created July 27, 2017 11:52
Convert ES5 Template Literals to ES6 Strings
<?php
$file = isset($argv[1]) ? $argv[1] : null;
if (empty($file)) {
printf("USAGE: %s file.js", $argv[0]);
exit;
}
if (!is_file($file)) {
printf("ERROR: File does not exist: %s", $file);
}