Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@timint
timint / generate_bankgirot_ocr.php
Created July 25, 2023 17:59
Function to generate OCR line on invoices payable via Bankgirot.
<?php
/*
Author: T. Almroth
Documentation: https://www.bankgirot.se/globalassets/dokument/anvandarmanualer/bankgiroinbetalningar_anvandarmanual_sv.pdf
Note: Use font OCR B.
Example of use:
echo generate_bankgirot_ocr('123456789', '100.00', '0000-0000');
*/
@timint
timint / file_search.php
Created August 3, 2022 14:22
PHP glob() reinvented with support for StreamWrappers and dual globstars
<?php
// PHP glob() does not support stream wrappers, so let's create our own glob.
// And while we are at it, let's throw in support for double globstars **. :)
function file_search($glob, $flags=0) {
// Unixify paths
$glob = str_replace('\\', '/', $glob);
// Set basedir and remains
@timint
timint / sql_pretty_print.php
Created June 25, 2022 20:57
SQL pretty print
<?php
/*
* Lightweight concept for pretty printing SQL
* @author T. Almroth <info@international.net>
* https://www.tim-international.net/
*/
function sql_pretty_print($query, $indentation="\t") {
@timint
timint / api.php
Last active May 12, 2020 19:26
Simple concept for a LiteCart REST API
<?php
ob_start();
include('includes/app_header.inc.php');
try {
$json = [];
@timint
timint / cloudflare_real_ip.php
Last active April 24, 2020 19:23
Cloudflare - Set real IP
<?php
// Cloudflare - Set Real IP
$cloudflare_ip_ranges = array(
'204.93.240.0/24', '204.93.177.0/24', '199.27.128.0/21',
'173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22',
'103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18',
'190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22',
'198.41.128.0/17', '162.158.0.0/15',
);
@timint
timint / telenor-ddns.txt
Created February 26, 2020 21:22
List of all DDNS providers supported on Telenor routers (Technicolor TG799vac Xtream)
3322.org
able.or.kr
afraid.org-basicauth
afraid.org-keyauth
afraid.org-v2-basic
afraid.org-v2-token
all-inkl.com
changeip.com
core-networks.de
ddns.com.br
@timint
timint / scan.php
Last active November 30, 2018 01:55
A script to find all PHP files with leading or trailing whitespace
<?php
header('Content-Type: text/plain');
$dir_iterator = new RecursiveDirectoryIterator("./");
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
$count=0;
foreach ($iterator as $file) {
$count++;
@timint
timint / fontawesome4to5.js
Last active November 23, 2020 12:06
Migrate Fontawesome 4 to 5 using jQuery (For the CSS Webfont version)
/*
* Migrate Fontawesome 4 to Fontawesome 5
* @website https://www.litecart.net/
*/
(function(){
var icons = {
"fa-500px": "fab fa-500px",
"fa-address-book-o": "far fa-address-book",
"fa-address-card-o": "far fa-address-card",