Navigation Menu

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 / 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';
@tvlooy
tvlooy / xdebug.ini
Created November 30, 2017 13:20
xdebug profiling tracing
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 October 13, 2022 15:47
Dealing with email on a testing server

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 September 27, 2017 13:14 — forked from sandeepraju/ttfb.sh
curl command to check the time to first byte
#!/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 September 6, 2017 08:17
Retargeting Criteo Sociomantic split
<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 July 31, 2023 07:33
RabbitMQ add users configure queues
#!/bin/bash
VHOST=project
EXCHANGE=project-exchange
ADMIN_USER=admin
ADMIN_PASS=secret
MGMT_USER=mgmt
MGMT_PASS=secret
QUEUE1=queue1
QUEUE2=queue2
@tvlooy
tvlooy / tcpdump-es-capture
Created June 26, 2017 11:29 — forked from z0mbix/tcpdump-es-capture
Capture Elasticsearch Queries
# tcpdump -A -nn -s 0 'tcp dst port 9200 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -i lo
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes
14:32:33.525122 IP 127.0.0.1.49777 > 127.0.0.1.9200: Flags [P.], seq 313752908:313753888, ack 2465010394, win 257, options [nop,nop,TS val 2684167067 ecr 2684167066], length 980
E...^.@.@............q#...}L...............
..#...#.GET /index/_search HTTP/1.1
Host: 127.0.0.1:9200
Accept: */*
Content-Length: 845
Content-Type: application/x-www-form-urlencoded
@tvlooy
tvlooy / pe.sh
Last active February 14, 2017 21:51
Select php engine
#!/bin/bash
# set this is your .bashrc ". ~/Tools/pe.sh 7.0"
# set this in your .bash_aliases "alias pe='. ~/Tools/pe.sh'"
VERSIONS=($(find /usr/local/ -maxdepth 1 -name 'php-*' | sort | cut -c16-))
VERSION=""
if [ -n "$1" ]; then
VERSION=$1
@tvlooy
tvlooy / xmlToArray.php
Created January 5, 2017 17:03
SimpleXML to array
<?php
function xmlToArray(SimpleXMLElement $xmlObject) : array
{
$array = [];
foreach ((array) $xmlObject as $elementName => $value) {
if (is_object($value)) {
if (empty($value)) {
$array[$elementName] = '';
} else {
@tvlooy
tvlooy / install.sh
Created December 12, 2016 10:27
MariaDB on OpenBSD
pkg_add -i mariadb-server
mkdir /var/mysql
chown _mysql:_mysql /var/mysql
mysql_install_db
rcctl start mysqld
mysqladmin -u root password vagrant
mysql_secure_installation