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 / README.md
Created February 15, 2023 13:22 — forked from chrispage1/README.md
Restoring databases using Docker

Restoring databases using Docker

This guide requires you have the original database directories handy. You may also struggle restoring InnoDB instances because of the way they work, however a guide can be found at the bottom of this gist.

Move your backup database folders to an appropriate location, a temporary folder is preferable as MariaDB will put its own data within this directory.

Within the directory, run the following docker command:

@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 / 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 / device.xml
Created August 1, 2020 17:18
Samsung Galaxy S8 AVD Hardware Profile
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<d:devices xmlns:d="http://schemas.android.com/sdk/devices/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<d:device>
<d:name>Samsung Galaxy S8</d:name>
<d:manufacturer>User</d:manufacturer>
<d:meta/>
<d:hardware>
<d:screen>
<d:screen-size>large</d:screen-size>
<d:diagonal-length>5.80</d:diagonal-length>
@tvlooy
tvlooy / ckermit.md
Last active April 15, 2023 15:37
ckermit ubuntu 20.04
<?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 / 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 / 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
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'))
@tvlooy
tvlooy / ttfb.sh
Created March 7, 2018 09:42
curl ttfb
# Connect: %{time_connect}
# TTFB: %{time_starttransfer}
# Total time: %{time_total}
while [ true ]; do curl -o /dev/null -s -w "%{time_starttransfer}\n" https://www......./; sleep 15; done