Skip to content

Instantly share code, notes, and snippets.

View hollodotme's full-sized avatar
🧑‍💻
On it

Holger Woltersdorf hollodotme

🧑‍💻
On it
View GitHub Profile
PATTERN="*" \
for file in `ls -1 "$PATTERN"`; do \
git mv -f "$file" `echo "$file" | perl -nE 'say ucfirst'` \
done

How to read a path of an arbitrary leaf up to the root of the tree in a MySQL parent-child table with one single query

SELECT categories.name, categories.id, categories.parent_id, categories.depth
FROM (
    SELECT
                @id AS _id,
                (
                    SELECT @id := parent_id
 FROM categories
@hollodotme
hollodotme / HttpCode.php
Created March 6, 2016 22:55
Abstract class with all HTTP status codes as class constants
<?php
/**
* @author hollodotme
*/
/**
* Class HttpCode
*/
abstract class HttpCode
{

Retrieve a Let's encrypt cert only for nginx

Example is on Ubuntu 14.04 LTS

1. stop nginx listening on port 80

$ service nginx stop

2. Install necessary libs and start letsencrypt-auto

Re-package a vagrant box after modification

  • SSH into existing box and make changes

Update software

apt-get update && apt-get dist-upgrade -y && apt-get autoremove --purge -y
  • exit and vagrant reload
<?php declare(strict_types=1);
/**
* @author hollodotme
* This script receives a POST request from www.serverguard24.de
* and transforms it to a POST request to a slack webhook URL with JSON payload
* 1. Configure a slack webhook URL and paste it here in line 75
* 2. Put this script on a server an make it accessible via http
* 3. Add a contact at serverguard24.de and paste the URL to this script in HTTP Push URL field
* 4. Add the contact to your server guard checks
* NOTE: Script is written for PHP >= 7.1
@hollodotme
hollodotme / CompositeException.md
Created September 13, 2017 18:41
CompositeException
<?php declare(strict_types=1);


class CompositeException extends \Exception
{
	/** @var array */
	private $throwables = [];

	public function __construct( \Throwable ...$throwables )
@hollodotme
hollodotme / convert.io-os-x-finder-service.md
Last active October 15, 2017 22:06
OS X Finder service for converting PDF to SVG via convert.io

Install convert.io CLI client

See here.

Create an API key for convert.io

See here.

Create a Finder service to convert PDF to SVG files

@hollodotme
hollodotme / PhpStormProjectTemplateFeatureRequest-Draft.md
Last active October 16, 2017 16:10
[DRAFT] PhpStorm feature request to make project templates more beneficial

Background

I often start new projects and need to set up a bunch of strings and variables inside my project created from a template. You can see my github repo template here. Just search it for "VendorName" or "PackageName" and you'll see what I mean.

These variables are always the same in the beginning and I need to remember what names I used and where I need to replace them. Since this is a repetitive task, I seek more automation. Currently the project template feature in PhpStorm 2017.1 does not support custom variables at all.

I also work in a team that uses a similar project template. The team should be able to benefit from the updates to the project template, and everyone on the team should be able to update the template. That's why we use a git repository for that, instead of local PhpStorm project templates. Again repetitive work has to be done when creating a new project from that repository (git clone, remember and replace variables, etc.). Curre

@hollodotme
hollodotme / install-percona-server-5.7.md
Last active October 25, 2017 11:52
Installing Percona Server from Percona apt repository

Installing Percona Server from Percona apt repository

Fetch the repository packages from Percona web:

wget https://repo.percona.com/apt/percona-release_0.1-3.$(lsb_release -sc)_all.deb

Install the downloaded package with dpkg. To do that, run the following commands as root or with sudo: