Skip to content

Instantly share code, notes, and snippets.

View bitkorn's full-sized avatar
💭
do not pull or push

Torsten Brieskorn bitkorn

💭
do not pull or push
View GitHub Profile
@bitkorn
bitkorn / file_list.cpp
Last active March 6, 2023 12:48
scan a folder recursive and write the filenames with his size to a CSV file
#include <iostream>
#include <filesystem>
#include <string>
#include <fstream>
namespace fs = std::filesystem;
using std::cout;
const std::string outFilePath = "/home/allapow/Downloads/fileAudit.csv";
@bitkorn
bitkorn / arrayToCSV.js
Created April 7, 2020 17:48 — forked from yangshun/arrayToCSV.js
Converts a 2D array into a CSV file
function arrayToCSV (twoDiArray) {
// Modified from: http://stackoverflow.com/questions/17836273/
// export-javascript-data-to-csv-file-without-server-interaction
var csvRows = [];
for (var i = 0; i < twoDiArray.length; ++i) {
for (var j = 0; j < twoDiArray[i].length; ++j) {
twoDiArray[i][j] = '\"' + twoDiArray[i][j] + '\"'; // Handle elements that contain commas
}
csvRows.push(twoDiArray[i].join(','));
}
@bitkorn
bitkorn / formData-put.html
Last active July 6, 2019 12:56
JS FormData PUT. PUT method does not send FormData good. Therefore a workaroud (FormData to Array)
<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 June 2, 2019 05:18
This function tries to create a clean ZF3 controller factory
<?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);
@bitkorn
bitkorn / datatables_sort_date.php
Created May 17, 2018 17:43
Datatables sort date
<?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 09:05 — 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.
<?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 March 31, 2018 10:58
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 March 8, 2018 19:56
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 February 13, 2018 10:33
only functions are separated with multiple namespaces in a file
<?php
namespace A {
$closure = function () {
echo __NAMESPACE__;
};
}
namespace B {
$closure = function () {
<?php
namespace MyApp\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use \Zend\View\Model\ViewModel;
use Zend\View\Model\JsonModel;
class IndexController extends AbstractActionController
{