Skip to content

Instantly share code, notes, and snippets.

<?php declare(strict_types=1);
function createDataObject (int $min, int $max, array $blacklist = []): array
{
$output = [];
$index = 0;
for ($i = $min; $i <= $max; $i++)
{
$n = base_convert((string)$i, 10, 16);
@timw4mail
timw4mail / optimize-images.sh
Last active January 24, 2020 01:41
Image Optimization script
#!/usr/bin/env bash
set -euo pipefail
declare threads=`getconf _NPROCESSORS_ONLN`
optimise () {
declare -a exts=("${!1}")
declare msg=$2
for ext in ${exts[@]}
@timw4mail
timw4mail / build-php-ext.sh
Created September 9, 2019 19:22
PHP Extension source build boilerplate
#!/bin/sh
make clean; # For those rebuilds
phpize;
autoreconf --install --force; # Stupid autotools/libtool version incompatibilities
./configure;
make;
sudo make install;
<?php
function Zip($source, $destination)
{
if (extension_loaded('zip') === true)
{
if (file_exists($source) === true)
{
$zip = new ZipArchive();
@timw4mail
timw4mail / minify.php
Created November 3, 2011 23:46
HTML Minification
<?php
define('SAFE', 1);
define('EXTREME', 2);
define('EXTREME_SAVE_COMMENTS', 4);
define('EXTREME_SAVE_PRE', 3);
function minify($html, $level=2)
{
switch((int)$level)
@timw4mail
timw4mail / index.php
Created August 18, 2011 19:39
PHP Kana transliterator
<?php
include("kana.php");
if(isset($_GET['in']) && isset($_GET['action']))
{
$in = $_GET['in'];
if($_GET['action'] == "to_hira")
{
$out = Kana::to_hiragana($in);
@timw4mail
timw4mail / XML.php
Created December 12, 2018 20:43
XML Codec
<?php declare(strict_types=1);
/**
* XML <=> PHP Array codec
*/
final class XML {
/**
* XML representation of the data
*
@timw4mail
timw4mail / keybase.md
Created October 26, 2018 18:07
keybase.md

Keybase proof

I hereby claim:

  • I am timw4mail on github.
  • I am timw4mail (https://keybase.io/timw4mail) on keybase.
  • I have a public key ASC7SlmqpsRmOuaFxqzF6TVO8jxYqGE-wpkawVHCwgehHgo

To claim this, I am signing this object:

@timw4mail
timw4mail / update-mastodon.sh
Last active August 23, 2018 13:35
Script to update docker mastodon
#!/bin/bash
docker pull tootsuite/mastodon:latest;
docker-compose down;
docker-compose run --rm web bundle exec rake db:migrate;
docker-compose run --rm web bundle exec rake assets:precompile;
docker-compose up -d;
@timw4mail
timw4mail / a.php
Created November 29, 2012 21:37
Create directory structure in php
<?php
/**
* Creates directories based on the array given
*
* @param array $structure
* @param string $path
* @return void
*/
function make_dir_tree($structure, $path=__DIR__)