Skip to content

Instantly share code, notes, and snippets.

View FlorianWolters's full-sized avatar

Florian Wolters FlorianWolters

View GitHub Profile
@FlorianWolters
FlorianWolters / CMakeLists.txt
Last active April 3, 2024 22:46
Add Boost C++ Libraries as a dependency with plain CMake
# Copyright (c) 2014-2023 Florian Wolters
# MIT License
cmake_minimum_required(VERSION 3.26.3)
project(
"hello_boost_with_cmake"
VERSION 2.0.0
LANGUAGES CXX)
@FlorianWolters
FlorianWolters / cpp-source_code_snippets.md
Last active March 10, 2024 14:52
C++ source code snippets

C++ source code snippets

Represent one byte

using Byte = std::uint8_t;

Represent a dynamic number of bytes

#include <vector>
@FlorianWolters
FlorianWolters / to_utf8_from_potential_base64_encoded.js
Last active June 3, 2023 10:49
Demonstrates how to handle an input string that can be optionally encoded with Base64 with Node.js v20.2.0
'use strict';
function toUtf8FromPotentialBase64Encoded(input) {
const buffer = Buffer.from(input, 'base64');
return (input === buffer.toString('base64'))
? buffer.toString('utf-8')
: input;
}
@FlorianWolters
FlorianWolters / apigen.neon
Last active February 21, 2021 03:15
Boilerplate Neon configuration file for the documentation generator "ApiGen".
# apigen.neon
#
# Neon configuration file for the documentation generator "ApiGen".
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
@FlorianWolters
FlorianWolters / Singleton.php
Created September 7, 2012 08:33
Demonstration of the Singleton design pattern in PHP.
<?php
namespace FlorianWolters\Example\Pattern\Design\Creational\Singleton;
/**
* Demonstration of the *Singleton* design pattern in PHP.
*
* This is the correct implementation of the *Singleton* creational design
* pattern in the PHP programming language.
*
* - Prevents cloning of an instance via the `__clone()` magic method.
@FlorianWolters
FlorianWolters / cpp-install_instructions.md
Last active June 15, 2018 06:39
Installation instructions for the C++ ecosystem

Installation instructions for the C++ ecosystem

This document contains installation instructions for tools and libraries for the programming language C++. It uses the cross-platform build system [CMake][0] whenever the software to download, configure, build and run supports it.

When building with multiple compilers for multiple architectures, a certain naming scheme is used (Convention over Configuration), since the build description has to consist of the following four aspects to be unique:

@FlorianWolters
FlorianWolters / FinalKeywordIgnoredInTrait.php
Last active October 24, 2017 17:10
Demonstrates a PHP bug: The "final" keyword for a method is ignored if used in a trait (https://bugs.php.net/bug.php?id=62204)
<?php
/**
* FinalKeywordIgnoredInTrait.php
*
* PHP 5.4.13 (cli) (built: Mar 15 2013 02:05:59)
* Copyright (c) 1997-2013 The PHP Group
* Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
* with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
*
* @link https://bugs.php.net/bug.php?id=62204
@FlorianWolters
FlorianWolters / HashCodeTraitImpl.php
Created September 20, 2012 12:12
How NOT to tests PHP 5.4 traits with PHPUnit.
<?php
namespace FlorianWolters\Component\Core;
/**
* A stub class for {@link HashCodeTraitTest} that uses the trait {@link
* HashCodeTrait}.
*
* @author Florian Wolters <wolters.fl@gmail.com>
* @copyright 2012 Florian Wolters
* @license http://gnu.org/licenses/lgpl.txt LGPL-3.0+
@FlorianWolters
FlorianWolters / DirectCallToMagicMethodConstruct.php
Last active April 27, 2016 14:17
Demonstrates a PHP bug: It is possible to directly call the magic method "__construct".
<?php
/**
* DirectCallToMagicMethodConstruct.php
*
* PHP 5.4.13 (cli) (built: Mar 15 2013 02:05:59)
* Copyright (c) 1997-2013 The PHP Group
* Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
* with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
*/
@FlorianWolters
FlorianWolters / composer-install-global-tools.cmd
Last active February 16, 2016 08:49
Batch script to globally install PHP tools with the dependency manager Composer
@ECHO OFF
REM Update Composer
composer self-update
REM PHPUnit
CALL composer global require phpunit/phpunit
REM Mock Object library for PHPUnit
CALL composer global require phpunit/phpunit-mock-objects