Skip to content

Instantly share code, notes, and snippets.

View ozh's full-sized avatar
🍷
More wine, please.

྅༻ Ǭɀħ ༄༆ཉ ozh

🍷
More wine, please.
View GitHub Profile
@ozh
ozh / YOURLS_locales.md
Created April 2, 2022 20:36
YOURLS_LANG in the wild

Here are the values of YOURLS_LANG people use in their YOURLS config.php (real life data fetch on April 2022)

Locale
af_ZA
ar
ar-SA
ar_AR
ar_EG
@ozh
ozh / current_result.md
Created March 11, 2022 18:39
Future unit tests for `yourls_is_shorturl()`

As of writing and with YOURLS 1.8.3-dev, expectedly works with http(s)://sho.rt/ozh but fail with http(s)://www.sho.rt/ozh (and logically if YOURLS_SITE has www. (eg http://www.sho.rt) the failures and success get inverted)

$ phpunit --filter ShortURL_Is_Shorturl_Tests
YOURLS installed, starting PHPUnit

PHPUnit 8.5.14 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.0.1 with Xdebug 3.0.2
Configuration: D:\home\planetozh\ozh.in\phpunit.xml
@ozh
ozh / blowfish.php
Created February 24, 2022 19:46
Blowfish hash cost : time estimates
<?php
// Some simple benchmark functions
function starttime() {
$r = explode( ' ', microtime() );
$r = $r[1] + $r[0];
return $r;
}
function endtime($starttime) {
@ozh
ozh / book.md
Created October 30, 2021 09:29
My bookmarklets

G : search current image in Google reverse search

javascript:%20(function%20()%20%7Burl%20=%20location.href;location.href%20=%20'https://www.google.com/searchbyimage?&image_url='+url;%7D());

R : remove all redirects in links

javascript:(function(){var%20k,x,t,i,j,p;%20for(k=0;x=document.links[k];k++){t=x.href.replace(/[%]3A/ig,':').replace(/[%]2f/ig,'/');i=t.lastIndexOf('http');if(i>0){%20t=t.substring(i);%20j=t.indexOf('&');%20if(j>0)t=t.substring(0,j);%20p=/https?\:\/\/[^\s]*[^.,;'">\s\)\]]/.exec(unescape(t));%20if(p)%20x.href=p[0];%20}%20else%20if%20(x.onmouseover&&x.onmouseout){x.onmouseover();%20if%20(window.status%20&&%20window.status.indexOf('://')!=-1)x.href=window.status;%20x.onmouseout();%20}%20x.onmouseover=null;%20x.onmouseout=null;%20}})();
@ozh
ozh / ozhcar.py
Created September 17, 2021 19:22
ozhcar
>>> print(base64.urlsafe_b64encode(b'\x0c\xdfk\xfc'))
b'DN9r_A=='
>>> print((215968764).to_bytes(4, byteorder='big'))
b'\x0c\xdfk\xfc'
@ozh
ozh / count_loc.md
Created September 7, 2021 19:12
Count LOC in a directory

In directory :

$ wc -l `find . -type f -name '*php'`

Result :

    53 ./admin/admin-ajax.php
 324 ./admin/index.php
@ozh
ozh / YOURLS-play-with-docker.md
Created August 30, 2021 20:15
Run YOURLS with play-with-docker.com
@ozh
ozh / check.md
Created May 19, 2021 21:40
Check platform requirement with Composer

You can easily do a baseline test of whether your dependencies support PHP 8 using Composer's platform config by running for example:

composer config platform.php 8.0.5

# Checks whether latest versions of your dependencies (according to your
# version constraints) allow PHP 8
composer update --dry-run         

# Checks whether current versions of your deps allow PHP 8
@ozh
ozh / script-template.sh
Created May 19, 2021 19:43 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]

Here are real life values of YOURLS_URL_CONVERT encountered in the wild:

(reminder: only 36 and 62 are acceptable values)

convert
0
0123456789
0123456789abcdefghijklmnopqrstuvwxyz-_.