Skip to content

Instantly share code, notes, and snippets.

View ktomk's full-sized avatar

Tom Klingenberg ktomk

  • lastflood GmbH (et al.)
View GitHub Profile
@ktomk
ktomk / BouncedHeaders.php
Created June 3, 2011 01:06
Iterator to Extract Message Headers from Bounced Messages
<?php
/*
* BouncedHeaders.php
*
* Copyright 2011 mot <@fsfe.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@ktomk
ktomk / hex_dump.php
Created June 13, 2011 18:02
Dump a string in a hexidecimal representation similar to terminal based hex-editors.
<?php
/*
* hex_dump.php
*
* Copyright 2011 mot <@fsfe.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@ktomk
ktomk / str_ureplace.php
Created July 6, 2011 14:59
str_ureplace - str_replace with callback functions
<?php
/**
* str_ureplace
*
* str_replace like function with callbacks for replacement(s).
*
* @param string|array $search
* @param callback|array $replace
* @param string|array $subject
* @param int $replace_count
@ktomk
ktomk / valid_utf8_bytes.php
Created October 4, 2011 19:10
filter valid utf-8 byte sequences
<?php
/**
* filter valid utf-8 byte sequences
*
* take over all valid bytes, drop an invalid sequence until first
* non-matching byte, start over at that byte.
*
* @param string $str
* @return string
*/
@ktomk
ktomk / session_id_validator_fragment.php
Created October 7, 2011 15:02
Validate a PHP session id string
<?php
/**
* validate string session id
*
* @see http://www.devnetwork.net/viewtopic.php?f=34&t=88685#p520259
*
* @param string $sessionId
* @return bool
*/
public function isValidId($sessionId)
@ktomk
ktomk / download.sh
Last active November 4, 2015 22:19 — forked from tkn98/download.sh
download job for not yet mirrored magento installs
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
wget -nc https://github.com/OpenMage/magento-mirror/archive/1.9.1.1.zip
wget -nc https://github.com/OpenMage/magento-mirror/archive/1.9.1.0.zip
wget -nc https://github.com/OpenMage/magento-mirror/archive/1.9.0.1.zip
wget -nc https://github.com/OpenMage/magento-mirror/archive/1.8.1.0.zip
wget -nc https://github.com/ktomk/magento-mirror/archive/1.8.0.0.zip
wget -nc https://github.com/OpenMage/magento-mirror/archive/1.9.1.1.tar.gz
@ktomk
ktomk / PHPUnit_ExceptionTrap.php
Created March 20, 2016 12:00
PHPUnit_ExceptionTrap
<?php
class PHPUnit_ExceptionTrap
{
/**
* @var PHPUnit_Framework_TestCase
*/
private $testCase;
/**
@ktomk
ktomk / git-bl.sh
Last active April 20, 2016 05:10
gitbl - git branch list : review all non master / develop branches, sortable-by-time
#!/bin/bash
git_list_branches()
{
git branch | awk -F ' +' '! /^\(no branch\)|master|develop$/ {print $2}' | sort
}
git_contains_branches()
{
git branch --contains "${1}" | awk -F ' +' '! /^\(no branch\)$/ {print $2}' | sort
@ktomk
ktomk / EXAMPLE
Last active February 28, 2017 20:28
check di.xml files for wrongfully FQCNs
$ php -f magento2/check.php -- magento2/www
magento2/www/vendor/magento/module-wishlist/etc/di.xml (3):
- /config/preference[1]/@type on line 9: \Magento\Wishlist\Model\AuthenticationState
- /config/preference[2]/@type on line 10: \Magento\Wishlist\Controller\WishlistProvider
- /config/type[3]/plugin/@type on line 22: \Magento\Wishlist\Controller\Index\Plugin
magento2/www/vendor/magento/module-catalog/etc/di.xml (7):
- /config/type[43]/plugin/@type on line 382: \Magento\Catalog\Model\Plugin\ShowOutOfStockConfig
- /config/preference[40]/@type on line 459: \Magento\Catalog\Model\ProductLink\Attribute
- /config/preference[44]/@type on line 463: \Magento\Catalog\Model\CategoryLinkManagement
- /config/preference[47]/@type on line 466: \Magento\Catalog\Model\CategoryLinkRepository
#!/bin/bash
#
# de-execute all executable files that are either zero width or don't have a shebang (Magic Line)
#
# note: no explicit non-binary check ( -not -exec grep -vIq . "{}" \; )
#
echo -n "before: "; find . \( -name '.git' -o -name 'bin' \) -prune -o -type f -executable -print | wc -l
find . \( -name '.git' -o -name 'bin' \) -prune -o -type f -executable \