Skip to content

Instantly share code, notes, and snippets.

Tom Van Looy tvlooy

Block or report user

Report or block tvlooy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tvlooy
tvlooy / ffi_pledge.md
Last active Jan 21, 2019
PHP FFI obsoletes pecl/pledge
View ffi_pledge.md

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 Jun 3, 2019
Use OpenBSD's pledge and unveil syscalls in PHP
View install.sh
# 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
View validate.sql
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'))
View ttfb.sh
# 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
@tvlooy
tvlooy / Company.php
Last active Mar 16, 2018
A small PHP userland enum replacement for SplEnum (spl_types)
View Company.php
<?php
namespace SomeDomain;
use Ctors\Enum;
class Company extends Enum
{
public const GOOGLE = 'Google';
public const TWITTER = 'Twitter';
@tvlooy
tvlooy / xdebug.ini
Created Nov 30, 2017
xdebug profiling tracing
View xdebug.ini
zend_extension=/usr/lib/php5/20100525/xdebug.so
;xdebug.remote_enable=1
;xdebug.remote_autostart=1
;xdebug.remote_host=192.168.33.1
;xdebug.max_nesting_level=256
;xdebug.profiler_enable=1
;xdebug.profiler_output_dir=/tmp/xdebug
@tvlooy
tvlooy / dealing_with_email_testing.md
Last active Apr 6, 2019
Dealing with email on a testing server
View dealing_with_email_testing.md

Dealing with email on a testing server

There are lots of setups with programs that can collect email in testing environments. Some of them require you to install perl, nodejs, ruby, ... or require you do do a sophisticated setup with your mailserver.

But there is a little program called mailhog that is just a standalone statically linked binary that has no dependencies.

That makes it very easy to use.

@tvlooy
tvlooy / ttfb.sh
Created Sep 27, 2017 — forked from sandeepraju/ttfb.sh
curl command to check the time to first byte
View ttfb.sh
#!/bin/bash
# file: ttfb.sh
# curl command to check the time to first byte
# ** usage **
# 1. ./ttfb.sh "https://google.com"
# 2. seq 10 | xargs -Iz ./ttfb.sh "https://google.com"
curl -o /dev/null \
-H 'Cache-Control: no-cache' \
-s \
@tvlooy
tvlooy / retargeting_split.js
Created Sep 6, 2017
Retargeting Criteo Sociomantic split
View retargeting_split.js
<script type="text/javascript">
var getCookie = function(name) {
var match = document.cookie.match(new RegExp(name + '=([^;]+)'));
if (match) return match[1];
}
var ab_retarget = getCookie('ab_retarget_v1');
if (ab_retarget == undefined) {
if (Math.round(+new Date() / 1000) % 2) {
ab_retarget = 'sociomantic';
@tvlooy
tvlooy / rabbitmq.sh
Last active Aug 6, 2019
RabbitMQ add users configure queues
View rabbitmq.sh
#!/bin/bash
VHOST=project
EXCHANGE=project-exchange
ADMIN_USER=admin
ADMIN_PASS=secret
MGMT_USER=mgmt
MGMT_PASS=secret
QUEUE1=queue1
QUEUE2=queue2
You can’t perform that action at this time.