Skip to content

Instantly share code, notes, and snippets.

View FlorianWolters's full-sized avatar

Florian Wolters FlorianWolters

View GitHub Profile
@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 / the_rule_of_five.h
Created January 31, 2015 15:38
C++ source code examples for the weblog article "The Rule of Zero"
/**
* Demonstrates *The Rule of Five* C++ idiom.
*
* @file the_rule_of_five.h
* @author Florian Wolters <wolters.fl@gmail.com>
*
* @section License
*
* Copyright Florian Wolters 2015 (http://blog.florianwolters.de).
*
@FlorianWolters
FlorianWolters / cpp-source_code_snippets.md
Last active August 10, 2024 18:15
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 / 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 / pause.sh
Created December 28, 2014 17:57
Windows `pause` command in *-nix Shell (Bash)
#!/bin/bash
function pause() {
if [ "$#" -eq 0 ]
then
PROMPT="Press any key . . ."
else
PROMPT="$1"
fi
@FlorianWolters
FlorianWolters / CMakeLists.txt
Last active August 7, 2024 12:09
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 / 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
@FlorianWolters
FlorianWolters / Linux_Cheat_Sheet.md
Last active January 4, 2016 00:39
Cheat Sheets and keyboard shortcuts for common software

Linux Cheat Sheet

Samba

Limit Samba access to a specific network interface

kwrite /etc/samba/smb.conf &

[global]

interfaces = eth0 lo

@FlorianWolters
FlorianWolters / FieldCreator.cs
Created August 17, 2013 14:46
Generic algorithm to allow the creation of nested fields with Word.Interop, by using a string. I have taken the Visual Basic for Applications (VBA) source code from [Nested Fields in VBA](http://stoptyping.co.uk/word/nested-fields-in-vba) and adopted it for C#.
//------------------------------------------------------------------------------
// <copyright file="FieldCreator.cs" company="Florian Wolters">
// Copyright (c) Florian Wolters. All rights reserved.
// </copyright>
// <author>Florian Wolters &lt;[email protected]&gt;</author>
//------------------------------------------------------------------------------
namespace FlorianWolters.Office.Word.Fields
{
using System;
@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
*/