Skip to content

Instantly share code, notes, and snippets.

Avatar

Jannik Jochem fixpunkt

View GitHub Profile
@fixpunkt
fixpunkt / remove-empty-directories.js
Last active Apr 30, 2021
nodejs: remove empty directories recursively, async version of https://gist.github.com/jakub-g/5903dc7e4028133704a4
View remove-empty-directories.js
const fsPromises = require('fs').promises;
const path = require('path');
/**
* Recursively removes empty directories from the given directory.
*
* If the directory itself is empty, it is also removed.
*
* Code taken from: https://gist.github.com/jakub-g/5903dc7e4028133704a4
*
@fixpunkt
fixpunkt / shopware-dev-54.patch
Created Apr 10, 2018
Shopware 5.4 dev patch
View shopware-dev-54.patch
diff --git a/engine/Library/Enlight/Template/Plugins/function.flink.php b/engine/Library/Enlight/Template/Plugins/function.flink.php
index 83fb90b3cc..084eed24ba 100644
--- a/engine/Library/Enlight/Template/Plugins/function.flink.php
+++ b/engine/Library/Enlight/Template/Plugins/function.flink.php
@@ -45,7 +45,7 @@ function smarty_function_flink($params, $template)
// Try to find the file on the filesystem
foreach ($templateDirs as $dir) {
if (file_exists($dir . $file)) {
- $file = Enlight_Loader::realpath($dir) . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $file);
+ $file = preg_replace('/\/+/', DIRECTORY_SEPARATOR, ($dir . DIRECTORY_SEPARATOR . $file));
@fixpunkt
fixpunkt / mkdir-concurrency-demo.php
Last active Jul 25, 2017
Demonstration of PHP's recursive mkdir() race condition and a PHP-reimplementation that fixes it. Run ./run.sh multiple times to show the issue, then switch out the mkdir implementation and try if you can still reproduce the issue.
View mkdir-concurrency-demo.php
<?php
/**
* Recursively creates the missing parts of a directory path in a manner that is concurrency-safe.
*
* @see https://bugs.php.net/bug.php?id=35326
*
* @param string $pathname a (nested) directory path to create
* @param integer $mode the permission to use
* @return bool true iff the directory path was successfully created
*/
@fixpunkt
fixpunkt / Bootstrap.php
Created May 16, 2017
Tester plugin to show a backwards compatibility issue in SW 5.2 removeAttribute()
View Bootstrap.php
<?php
final class Shopware_Plugins_Backend_AddRemoveAttributesTest_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
public function getInfo()
{
return [
'label' => 'Add/remove attributes test',
'description' => 'No description'
];
@fixpunkt
fixpunkt / Bootstrap.php
Created May 15, 2017
Base store config tester plugin
View Bootstrap.php
<?php
final class Shopware_Plugins_Backend_BaseStoreConfigsTest_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
/**
* @return array
*/
public function getInfo()
{
return [