Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
There is nothing good unless you do it.

Lars Moelleken voku

:octocat:
There is nothing good unless you do it.
View GitHub Profile
@voku
voku / mod-ide-helper.php
Created Feb 4, 2020
generate "PHPSTORM_META" dynamic
View mod-ide-helper.php
#!/usr/bin/php
<?php
namespace my_helper {
// init
$str = '';
require_once __DIR__ . '/boostrap.php';
require_once __DIR__ . '/etc/config.php';
@voku
voku / Makefile
Created Dec 10, 2018
A Makefile example from a php project with support for different code quality tools.
View Makefile
# WARNINGS && INFO:
# - a "\t" (tab) is needed before the commands, do not use spaces ..."
# - a "$" has special meaning in Makefiles, you need to double it to pass it)
# - please install/use the "Makefile support"-plugin for PhpStrom :)
TEST_ENV ?= local
CHECK_FILES ?= .
PHPSTAN_LEVEL ?= 3
@voku
voku / code_check_git_hook.php
Created Dec 10, 2018
A pre-commit-hook example with Code Sniffer + Code Fixer + PHPStan
View code_check_git_hook.php
#!/usr/bin/php
<?php
/**
* //
* // add something like this in your "composer post-update-cmd && post-install-cmd"
* //
* echo "\n\n";
* echo "Run force \"code_check_git_hook.php\" as pre-commit-hook ...";
* $force_pre_commit_hook_cmd = 'ln -sf YOUR_PATH_TO_CODE_CHECK_SCRIPTS/code_check_git_hook.php YOUR_PATH_TO_PROJECT_ROOT/.git/hooks/pre-commit';
@voku
voku / check_code_phpstan.php
Created Dec 10, 2018
A wrapper for phpstan, so you can use PHP7.0 and PHP7.1
View check_code_phpstan.php
#!/usr/bin/php
<?php
use Composer\XdebugHandler\XdebugHandler;
require_once __DIR__ . '/YOUR_PATH_THE_AUTOLOADER.php';
$xdebug = new XdebugHandler('phpstan-code-check');
$xdebug->check();
unset($xdebug);
@voku
voku / remove_first_html_tag.php
Last active Oct 17, 2018
regex - remove first html tag
View remove_first_html_tag.php
<?php
$input_lines = ' <div>da<a>
lalll
</a>sda
</div>';
$output = preg_replace('/^<(?<element_start>[a-z]+)(?<element_start_addon> [^>]*)?>(?<value>.*?)<\/(?<element_end>\1)>$/usi', '$3', trim($input_lines));
@voku
voku / .editorconfig
Created Oct 11, 2018
.editorconfig - example
View .editorconfig
# For more information about the properties used in
# this file, please see the EditorConfig documentation:
# http://editorconfig.org/
# top-most EditorConfig file
root = true
# Unix-style newlines + UTF-8 encoding
[*]
charset=utf-8
@voku
voku / .htaccess
Last active Feb 13, 2019
.htaccess - example
View .htaccess
# [simple.cms] + Apache Server Configs v3.1.0 | MIT License
# https://github.com/h5bp/server-configs-apache
# (!) Using `.htaccess` files slows down Apache, therefore, if you have
# access to the main server configuration file (which is usually called
# `httpd.conf`), you should add this logic there.
#
# https://httpd.apache.org/docs/current/howto/htaccess.html
# ----------------------------------------------------------------------
@voku
voku / global_js_error_handling.html
Last active Dec 23, 2020
global js error handling via "window.onerror"
View global_js_error_handling.html
<script type="text/javascript">
var one_error_reported_via_onerror = false;
var globalErrorReportHelper = function(msg, url, line, col, error) {
// fallback for e.g.: IE
if (
!error
&&
typeof Error === "function"
View PhpStorm - Java Setting for better Performance
-ea
-server
-Xss2m
-Xms2G
-Xmx5G
-XX:MaxMetaspaceSize=2G
-XX:MetaspaceSize=512m
-XX:ReservedCodeCacheSize=1G
-XX:+DoEscapeAnalysis
-XX:SoftRefLRUPolicyMSPerMB=50
@voku
voku / StringLib.php
Created May 2, 2018
simple, small and dependency-free version of https://github.com/voku/portable-utf8
View StringLib.php
<?php
/**
* Class StringLib
*
* @see https://github.com/voku/portable-utf8
*/
class StringLib {
/**