Skip to content

Instantly share code, notes, and snippets.

View tvlooy's full-sized avatar
🐧
<(o)

Tom Van Looy tvlooy

🐧
<(o)
View GitHub Profile
@tvlooy
tvlooy / phpstorm.txt
Last active October 13, 2021 03:22
PhpStorm cheat sheet
ctrl + alt + shift + t = refactor this
alt + enter = allerlei shortcuts
ctrl + alt + l = reformat code
shift + f11 = show bookmarks
f11 = insert bookmark
alt + insert = file new
ctrl + n = navigate class
ctrl + shift + n = navigate file
ctrl + shift + f = find in path
ctrl + alt + shift + insert = commit file (eigen shortcut)
@tvlooy
tvlooy / io.php
Created October 7, 2020 15:33
Intracto IO animation
#!/usr/bin/env php
<?php
require __DIR__.'/vendor/autoload.php';
use Symfony\Component\Console\Cursor;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\SingleCommandApplication;
use Symfony\Component\Console\Terminal;
@tvlooy
tvlooy / sfmatrix.php
Created October 7, 2020 15:34
sfmatrix - simulates the display from "The Matrix"
#!/usr/bin/env php
<?php
require __DIR__.'/vendor/autoload.php';
use Symfony\Component\Console\Cursor;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\SingleCommandApplication;
use Symfony\Component\Console\Terminal;
@tvlooy
tvlooy / Company.php
Last active March 9, 2020 20:19
A small PHP userland enum replacement for SplEnum (spl_types)
<?php
namespace SomeDomain;
use Ctors\Enum;
class Company extends Enum
{
public const GOOGLE = 'Google';
public const TWITTER = 'Twitter';
<?php
if ($_SERVER['PHP_AUTH_USER'] !== 'tvlooy' ||
$_SERVER['PHP_AUTH_PW'] !== 'secret'
) {
header('WWW-Authenticate: Basic realm="Login required"');
header('HTTP/1.0 401 Unauthorized');
echo 'Access denied.';
exit;
}
@tvlooy
tvlooy / get_dns_blacklists.sh
Last active September 9, 2019 03:33
Block ads by DNS
#!/bin/sh
# "include: /etc/unbound/ad-blacklist.conf" in /var/unbound/etc/unbound.conf
# run this script as a daily cron
#
# The list URLs were taken from the pi-hole project.
# More experimental lists are at https://github.com/pi-hole/pi-hole/blob/master/adlists.default
TMPFILE=$( mktemp get_dns_blacklists-XXXXXXXXX )
trap 'rm -f $TMPFILE; exit 1' EXIT KILL INT QUIT TERM
@tvlooy
tvlooy / install.sh
Last active June 3, 2019 14:24
Use OpenBSD's pledge and unveil syscalls in PHP
# Note that this is for people that want to build it from source, using pecl
# This code is in official OpenBSD ports now https://marc.info/?l=openbsd-ports-cvs&m=154270973708561
pkg_add php-7.2.10
ln -s /usr/local/bin/php-7.2 /usr/local/bin/php
ln -s /usr/local/bin/phpize-7.2 /usr/local/bin/phpize
ln -s /usr/local/bin/php-config-7.2 /usr/local/bin/php-config
pkg_add autoconf-2.69p2
export AUTOCONF_VERSION=2.69
@tvlooy
tvlooy / ffi_pledge.md
Last active January 21, 2019 22:17
PHP FFI obsoletes pecl/pledge

PHP FFI obsoletes pecl/pledge

Example with pecl/pledge:

$ cat test_pecl.php
<?php

var_dump(count(scandir('/etc')));
unveil(__DIR__, 'r');
@tvlooy
tvlooy / errordocs.patch
Last active November 30, 2018 19:47
OpenBSD httpd errordocs patch
Index: httpd.conf.5
===================================================================
RCS file: /cvs/src/usr.sbin/httpd/httpd.conf.5,v
retrieving revision 1.76
diff -u -p -u -r1.76 httpd.conf.5
--- httpd.conf.5 14 Nov 2016 10:28:31 -0000 1.76
+++ httpd.conf.5 21 Nov 2016 19:12:34 -0000
@@ -128,6 +128,9 @@ If not specified, it defaults to
within the
.Xr chroot 2
DELIMITER $$
DROP PROCEDURE IF EXISTS ANALYZE_INVALID_FOREIGN_KEYS$$
CREATE
PROCEDURE `ANALYZE_INVALID_FOREIGN_KEYS`(
checked_database_name VARCHAR(64),
checked_table_name VARCHAR(64),
temporary_result_table ENUM('Y', 'N'))