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 / validator.php
Created July 28, 2015 10:26
Symfony validator without entities or objects
<?php
// See http://symfony.com/doc/current/book/validation.html#validating-values-and-arrays
$email = $app['request']->get('email');
$emailConstraint = new \Symfony\Component\Validator\Constraints\Email();
$emailConstraint->message = 'Invalid email address';
$errorList = $val->validate(
$email,
$emailConstraint
);
var_dump($errorList);
@tvlooy
tvlooy / selenium-server.sh
Created July 27, 2015 15:52
Selenium server init script
#!/bin/bash
NAME=selenium-server
SCRIPT="/usr/bin/xvfb-run -- java -jar /root/${NAME}-standalone-2.44.0.jar"
PIDFILE=/var/run/selenium-server.pid
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --exec $SCRIPT
@tvlooy
tvlooy / find_swap_users.sh
Created July 15, 2015 12:00
Find swap users
#!/bin/bash
TOTAL=0
for i in `find /proc -maxdepth 2 -type f -name status`; do
PID=`echo $i | cut -d/ -f3`
SWAP=$(grep VmSwap /proc/$PID/status 2>/dev/null | cut -d: -f2 | xargs | grep -v '^0 kB$')
if [ -n "$SWAP" ]; then
echo "$PID (`ps -p $PID -o comm=`) = $SWAP"
let TOTAL=$TOTAL+`echo $SWAP | cut -d' ' -f1`
fi
@tvlooy
tvlooy / howto.md
Created July 14, 2015 19:42
How to build jworklog

How to build tojans jworklog on Linux

Clone the project:

$ git clone https://github.com/ToJans/jworklog.git
Cloning into 'jworklog'...
remote: Counting objects: 39, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 39 (delta 8), reused 36 (delta 5), pack-reused 0
@tvlooy
tvlooy / unit.sh
Last active August 20, 2025 15:42
Bash test: get the directory of a script
#!/bin/bash
function test {
MESSAGE=$1
RECEIVED=$2
EXPECTED=$3
if [ "$RECEIVED" = "$EXPECTED" ]; then
echo -e "\033[32m✔︎ Tested $MESSAGE"
else
@tvlooy
tvlooy / pt-duplicate-key-checker_Drupal8.txt
Created February 20, 2015 20:22
pt-duplicate-key-checker on Drupal 8 (after this patch https://www.drupal.org/node/2428297)
root@Debian77:~# pt-duplicate-key-checker --user=root --password=vagrant --database=drupal8
# ########################################################################
# drupal8.url_alias
# ########################################################################
# Key source_langcode_pid ends with a prefix of the clustered index
# Key definitions:
# KEY `source_langcode_pid` (`source`,`langcode`,`pid`)
# PRIMARY KEY (`pid`),
# Column types:
@tvlooy
tvlooy / intl_date_formatter.php
Created January 24, 2015 20:46
Translate datetime format
$d = new DateTime();
$x = new IntlDateFormatter('nl_BE', IntlDateFormatter::NONE, IntlDateFormatter::NONE, null, null, 'd MMMM Y - H:mm:ss');
echo $x->format($d) . "\n";
// output 24 januari 2015 - 21:45:16
module InventoryItems(Command(..), Event(..), handle) where
import Data.Maybe(isJust)
type Id = String
type Name = String
type Amount = Int
data Command = CreateInventoryItem Id
| RenameInventoryItem Id Name
@tvlooy
tvlooy / etc_vim_vimrc.local
Last active December 8, 2015 22:40
My vimrc file
syntax on
colors elflord
set tabstop=4
"set softtabstop=4
set expandtab
set number
"set showcmd
set cursorline
"set wildmenu
"set lazyredraw
@tvlooy
tvlooy / gist:b73fffdfd3c0d8697193
Created December 22, 2014 11:05
Shell reuse history
vi ~/.inputrc
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
# type ls, use arrows to get last directory you used