Skip to content

Instantly share code, notes, and snippets.

View pfrenssen's full-sized avatar

Pieter Frenssen pfrenssen

  • Sofia, Bulgaria
View GitHub Profile
@pfrenssen
pfrenssen / gherkinify.sh
Last active February 16, 2016 17:07 — forked from sandervd/behatify.sh
#!/bin/sh
cat $1 | sed 's/$/,/g' | column -s ',' -t -o ' | ' | sed 's/^/| /g'
@pfrenssen
pfrenssen / gist:7a6c624383fb3ea5c11df7025fc854dd
Created August 23, 2017 18:20
Convert reveal.js to yeoman
#!/usr/bin/env php
<?php
require 'vendor/autoload.php';
use Symfony\Component\DomCrawler\Crawler;
$crawler = new Crawler(file_get_contents('/home/pieter/v/d8-training/index.html'));
$crawler = $crawler->filter('div.slides section');
@pfrenssen
pfrenssen / extract-subtitles
Created December 23, 2017 10:21
Extract SRT subtitles from MKV files
#!/usr/bin/env php
<?php
declare(strict_types = 1);
if (count($argv) !== 2) help();
$dirname = $argv[1];
if (!is_dir($dirname)) help();
$directory_path = realpath($dirname);
@pfrenssen
pfrenssen / whichproject
Last active September 27, 2018 07:45
Work on Joinup or OpenEuropa?
#!/usr/bin/env php
<?php
const JOINUP_RATIO = 0.667;
$times = [];
foreach (['Joinup', 'NextEuropa', 'OpenEuropa'] as $project) {
do {
$time = readline("Time spent on $project: ");
} while (!is_numeric($time));
@pfrenssen
pfrenssen / xpath.md
Last active April 17, 2018 09:55
Why does XPath return an empty set?

Update: this was caused by a bug in libxml2, which has in the meantime been reported and fixed. https://bugzilla.gnome.org/show_bug.cgi?id=795299

I have an HTML page with two tables, one of which has a row with mixed header and data cells, the second having only data cells:

<html>
  <head>
    <title>Table test page</title>
  </head>
commit a4d0d2dd43d09b3d44031ce43165d4fad4078018
Author: Pieter Frenssen <[email protected]>
Date: Sun Jul 22 15:42:02 2018 +0300
Revert "Fixed unwanted trailing tab in chrome 53 (#244)"
This reverts commit 67c5b8a20274c53ec2f85fabda7005a6ac2dd1b9.
diff --git a/src/Selenium2Driver.php b/src/Selenium2Driver.php
index cabdb60..0d54042 100755
#!/bin/bash -e
# Making a backup makes most sense if we are on the develop branch. Ask for
# confirmation if we aren't.
if [ $(git rev-parse --abbrev-ref HEAD) != "develop" ] ; then
read -p "The develop branch is not checked out. Continue? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]] ; then
exit 1
fi
#!/bin/bash -e
# Mount the backup drive.
if ! grep -qs '/mnt/workspace ' /proc/mounts; then
sudo mount /dev/sdc1 /mnt/workspace/
fi
# Update code base.
./vendor/bin/composer install --prefer-source
#!/bin/bash -ex
./sync.sh
if [ ! -f sync.config ]; then
echo 'error: sync.config does not exist.'
exit 1
fi
. sync.config
@pfrenssen
pfrenssen / namespace-info-files.php
Created July 5, 2019 14:21
Provides project namespaces for Drupal module dependencies in info.yml files
<?php
$webroot = '/home/pieter/v/joinup-dev/web/';
$source_folders = [
'core/modules/' => 'drupal',
'modules/custom/' => 'joinup',
'modules/contrib/' => 'contrib',
];
// Compile a namespaced list of all modules.