Skip to content

Instantly share code, notes, and snippets.

View fixpunkt's full-sized avatar

Jannik Jochem fixpunkt

View GitHub Profile
@fixpunkt
fixpunkt / remove-empty-directories.js
Last active June 18, 2023 20:14
nodejs: remove empty directories recursively, async version of https://gist.github.com/jakub-g/5903dc7e4028133704a4
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 April 10, 2018 09:26
Shopware 5.4 dev 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 July 25, 2017 09:18
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.
<?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 09:17
Tester plugin to show a backwards compatibility issue in SW 5.2 removeAttribute()
<?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 14:24
Base store config tester plugin
<?php
final class Shopware_Plugins_Backend_BaseStoreConfigsTest_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
/**
* @return array
*/
public function getInfo()
{
return [