Skip to content

Instantly share code, notes, and snippets.

View janjouketjalsma's full-sized avatar

Jan Jouke Tjalsma janjouketjalsma

View GitHub Profile
@janjouketjalsma
janjouketjalsma / horizontal-scroll-with-fixed-columns.css
Created October 3, 2020 11:21
Pure CSS3 Horizontally scrolling table with N fixed columns at the start.
/*
* Horizontal scrolling table
*/
table.horizontal-scrolling {
display: block; /* to enable scrolling within the boundaries of the table */
width: 100%; /* to make sure the element will resize to it's bounding box */
overflow-x: scroll; /* to enable scrolling horizontally */
text-align: left; /* optional: left aligned content */
background-color: white; /* We need a background color because other cells scroll behind these cells */
@janjouketjalsma
janjouketjalsma / HTS-realistic-6-solution.js
Last active October 12, 2018 12:35
Decodes the Hack This Site realistic mission 6 code that is encrypted using the XECryption encryption
var encrypted = '296.294.255.268.313.278.311.270.290.305.322.252.276.286.301.305.264.301.251.269.274.311.304.230.280.264.327.301.301.265.287.285.306.265.282.319.235.262.278.249.239.284.237.249.289.250.282.240.256.287.303.310.314.242.302.289.268.315.264.293.261.298.310.242.253.299.278.272.333.272.295.306.276.317.286.250.272.272.274.282.308.262.285.326.321.285.270.270.241.283.305.319.246.263.311.299.295.315.263.304.279.286.286.299.282.285.289.298.277.292.296.282.267.245.304.322.252.265.313.288.310.281.272.266.243.285.309.295.269.295.308.275.316.267.283.311.300.252.270.318.288.266.276.252.313.280.288.258.272.329.321.291.271.279.250.265.261.293.319.309.303.260.266.291.237.299.286.293.279.267.320.290.265.308.278.239.277.314.300.253.274.309.289.280.279.302.307.317.252.261.291.311.268.262.329.312.271.294.291.291.281.282.292.288.240.248.306.277.298.295.267.312.284.265.294.321.260.293.310.300.307.263.304.297.276.262.291.241.284.312.277.276.265.323.280.257.257.303.320.255.291.292.290.270.267.345.264.291.312.295.269.297
@janjouketjalsma
janjouketjalsma / pad-numbers-recursive.xsl
Last active August 13, 2018 09:44
Transform a string with numbers to a string with padded numbers using XSLT 1.0
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<xsl:call-template name="padNumbers">
<xsl:with-param name="string">blabfalsbjk432nbhjkhjk432h4kj23</xsl:with-param>
<xsl:with-param name="numberFormat" select="'000'"/>
</xsl:call-template>
</xsl:template>
@janjouketjalsma
janjouketjalsma / twig-translated-timediff-array-configuration.php
Last active December 3, 2020 16:40
Translate twig date extension (time_diff filter) to Dutch (Nederlands) using array loader in a custom non-symfony application
<?php
// Create translator for date diff
$translator = new Symfony\Component\Translation\Translator('nl_NL');
$translator->addLoader('array', new Symfony\Component\Translation\Loader\ArrayLoader());
$translator->addResource('array', array(
'diff.ago.second' => 'een seconde geleden|%count% seconden geleden',
'diff.ago.minute' => 'een minuut geleden|%count% minuten geleden',
'diff.ago.hour' => 'een uur geleden|%count% uur geleden',
'diff.ago.day' => 'een dag geleden|%count% dagen geleden',
'diff.ago.month' => 'een maand geleden|%count% maanden geleden',
$dir = __DIR__ . '/../storage/cache';
if ( is_dir( $dir ) ) {
$it = new RecursiveDirectoryIterator( $dir, RecursiveDirectoryIterator::SKIP_DOTS );
$files = new RecursiveIteratorIterator( $it, RecursiveIteratorIterator::CHILD_FIRST );
foreach ( $files as $file ) {
chmod( $file->getRealPath() , 0777);
}
} else {
echo 'Error: Path is not a valid directory.';
}
@janjouketjalsma
janjouketjalsma / marccountry-to-english.xsl
Created February 15, 2018 14:35
marccountry code to English language text
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="marccountry-to-english">
<xsl:param name="code"/>
<xsl:variable name="countryCode" select="translate($code,'#','')"/>
<xsl:if test="$countryCode = 'aa'">Albania</xsl:if>
<xsl:if test="$countryCode = 'abc'">Alberta</xsl:if>
<xsl:if test="$countryCode = 'aca'">Australian Capital Territory</xsl:if>
<xsl:if test="$countryCode = 'ae'">Algeria</xsl:if>
@janjouketjalsma
janjouketjalsma / iso639-2b-to-english.xsl
Last active February 15, 2018 14:34
iso639-2b code to English language name
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="iso639-2b-to-english">
<xsl:param name="code"/>
<xsl:variable name="languageCode" select="$code"/>
<xsl:if test="$languageCode = 'aar'">Afar</xsl:if>
<xsl:if test="$languageCode = 'abk'">Abkhaz</xsl:if>
<xsl:if test="$languageCode = 'ace'">Achinese</xsl:if>
<xsl:if test="$languageCode = 'ach'">Acoli</xsl:if>
@janjouketjalsma
janjouketjalsma / rmdir.php
Last active January 18, 2023 10:12 — forked from rveitch/wp_rmdir.php
PHP - Delete Files and Folders (wp directory)
<?php
$dir = '/path/to/folder';
if ( is_dir( $dir ) ) {
$it = new RecursiveDirectoryIterator( $dir, RecursiveDirectoryIterator::SKIP_DOTS );
$files = new RecursiveIteratorIterator( $it, RecursiveIteratorIterator::CHILD_FIRST );
foreach ( $files as $file ) {
if ( $file->isDir() ) {
rmdir( $file->getRealPath() );
} else {
@janjouketjalsma
janjouketjalsma / SyncedSlideshow.html
Last active July 31, 2017 06:57
A script syncing a slideshow accross devices using only the internal clock. Open this slideshow page on multiple computers and the slideshows will sync up!
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Example of display</title>
<style>
body, html{
width:100%;
height: 100%;
margin:0 auto;
@janjouketjalsma
janjouketjalsma / Job.php
Last active April 11, 2017 11:40
Doctrine entity for hellogerard/jobby (3.2.2.) generated from database schema
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Job
*
* @ORM\Table(name="Jobs")