Skip to content

Instantly share code, notes, and snippets.

💭
do not pull or push

Torsten Brieskorn bitkorn

💭
do not pull or push
Block or report user

Report or block bitkorn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bitkorn
bitkorn / formData-put.html
Last active Jul 6, 2019
JS FormData PUT. PUT method does not send FormData good. Therefore a workaroud (FormData to Array)
View formData-put.html
<div class="w3-row">
<div class="w3-col w3-center">
<form name="my_form" id="my_form">
<input type="text" name="foo" value="12345gfd">
<input type="text" name="bar" value="1234sdfghjzt5gfd">
<button type="button" id="foobutton">doit</button>
</form>
</div>
</div>
<script type="application/javascript">
@bitkorn
bitkorn / zend-code_bad-example.php
Created Jun 2, 2019
This function tries to create a clean ZF3 controller factory
View zend-code_bad-example.php
<?php
/**
* @param FolderTool $folderTool
* @return bool
*/
public function createType_zendWay(FolderTool $folderTool): bool
{
$filePath = $this->directory . '/' . $this->classname . '.php';
$file = new \Zend\Code\Generator\FileGenerator();
$file->setFilename($filePath);
View datatables_sort_date.php
<?php
forech($datas as $data) {
echo '<td data-sort="' . date('Y-m-d', $data['unixtimefield']).'">' . date('d.m.Y', $data['unixtimefield']) . '</td>';
}
@bitkorn
bitkorn / custom-nav-walker-usage.php
Created May 13, 2018 — forked from kosinix/custom-nav-walker-usage.php
WordPress: Using a custom nav walker to create navigation menus in plain <a> tags. That is the <ul> and <li> tags are not present. Very useful if you want to create simple links that can be centered with a simple text-align:center on the containing element.
View custom-nav-walker-usage.php
<?php
// In your template files like footer.php
// The items_wrap value ('%3$s') removes the wrapping <ul>, while the custom walker (Nav_Footer_Walker) removes the <li>'s.
wp_nav_menu(array('items_wrap'=> '%3$s', 'walker' => new Nav_Footer_Walker(), 'container'=>false, 'menu_class' => '', 'theme_location'=>'footer', 'fallback_cb'=>false ));
?>
@bitkorn
bitkorn / image_encode_base64.php
Last active Mar 31, 2018
image encode Base64 PHP
View image_encode_base64.php
<?php
$filename = 'anhaenger.jpg';
//$filename = 'anhaenger.png';
$path = 'img/' . $filename;
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
file_put_contents('base64/' . substr($filename, 0, (strrpos($filename, '.'))), $base64);
echo $base64;
@bitkorn
bitkorn / svg_from_file_with_d3.js
Created Mar 8, 2018
SVG from file with D3.js
View svg_from_file_with_d3.js
const fs = require('fs');
const d3 = require('d3');
const D3Node = require('d3-node');
var jsdom = require('jsdom');
const { JSDOM } = jsdom;
var contents = fs.readFileSync(__dirname + '/data/rectangle_100.svg', 'utf8');
// console.log(contents);
const dom = new JSDOM(contents);
// console.log(dom.window.document.querySelector('svg').outerHTML);
@bitkorn
bitkorn / multiple_namespaces_in_a_file.php
Last active Feb 13, 2018
only functions are separated with multiple namespaces in a file
View multiple_namespaces_in_a_file.php
<?php
namespace A {
$closure = function () {
echo __NAMESPACE__;
};
}
namespace B {
$closure = function () {
View Module-PHP-getViewHelperConfig_ViewHelper-with-URL-ViewHelper.php
<?php
class Module implements Zend\ModuleManager\Feature\ViewHelperProviderInterface
{
public function getViewHelperConfig()
{
return array(
'factories' => [
'simpleAnchor' => function(\Zend\View\HelperPluginManager $hpm) {
$sm = $hpm->getServiceLocator();
View zf2_controller-with-viewHelper.php
<?php
namespace MyApp\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use \Zend\View\Model\ViewModel;
use Zend\View\Model\JsonModel;
class IndexController extends AbstractActionController
{
View php_baseurl.php
<?php
$baseUrl = strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/'))) . '://' . $_SERVER['SERVER_NAME'];
You can’t perform that action at this time.