Skip to content

Instantly share code, notes, and snippets.

View tbreuss's full-sized avatar
🚴‍♂️
Biking

tebe tbreuss

🚴‍♂️
Biking
View GitHub Profile
@tbreuss
tbreuss / ivi.js-example-nested-components.html
Last active December 17, 2023 07:51
Simple ivi.js example with nested components using context
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ivi example</title>
</head>
<body>
<script type="module">
@tbreuss
tbreuss / vue3-routing-without-build-step.html
Last active October 30, 2024 00:21
Vue 3 router example in one HTML file without build step
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Vue.js CDN Test</title>
</head>
<body>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<div id="app-basic">{{ message }}</div>
@tbreuss
tbreuss / analyse-pt-duplicate-key-checker.php
Created November 10, 2023 06:02
Simple script to analyse the standard output results of Percona Toolkit pt-duplicate-key-checker
<?php
$types = [];
$fp = @fopen("/downloads/db1-duplicate-keys.txt", "r");
if ($fp) {
$i = 0;
$status = 0;
while (($buffer = fgets($fp, 4096)) !== false) {
@tbreuss
tbreuss / php_tuples.php
Last active May 1, 2023 08:50
PHP (fake) tuples. Tuples are not built in in PHP, but we can create Python like tuples with simple arrays using shorthand array syntax and destructuring.
<?php
/**
* A low-level function for retrieving data. Throws an exception in case of an error.
*
* @return array
*/
function retrieve_data(): array
{
// throw an exception in case of an error
@tbreuss
tbreuss / get_class_name.php
Last active October 25, 2022 19:03
Get class name from file
<?php
/**
* Get class name from file
*
* This is a working example, that works for PHP 7.4 and 8.x.
*
* @see https://stackoverflow.com/questions/7153000/get-class-name-from-file
*/
function get_class_name(string $file): string
@tbreuss
tbreuss / callbacks.php
Last active October 15, 2022 15:10
Different PHP Callbacks
<?php
// Examples for different uses of PHP callbacks
output(callback(function() { return 'anonymous function'; }));
output(callback('func'));
output(callback(new InvokableClass()));
output(callback([new NormalClass(), 'test']));
output(callback('StaticClass::staticMethod'));
output(callback([StaticClass::class, 'staticMethod']));
@tbreuss
tbreuss / pdo-fetch-class-example.md
Last active January 30, 2021 07:54
Simple example using PDO with FETCH_CLASS implementing a modest Entity pattern.
<?php
declare(strict_types=1);

require dirname(__DIR__) . '/../vendor/autoload.php';

class Entity
{
    public function __construct(array $data)
 {
@tbreuss
tbreuss / docker-enc2ly.md
Last active January 1, 2021 16:14
Converting Encore files to LilyPond using Docker

This is a solution to run the original enc2ly CLI program within a Docker container.

There are two CLI programs that convert Encore musical files to LilyPond.

Unfortunately I wasn't able to run these programs on my MacOS.

So, here are the instructions for using the original enc2ly CLI programm within a Docker container.

@tbreuss
tbreuss / readme.md
Created August 3, 2018 05:52
README.md Template

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@tbreuss
tbreuss / TextareaUpload.vue
Last active December 31, 2017 13:33 — forked from stevebauman/TextareaUpload.vue
Markdown Text Area Upload VueJS 2 Component
<template>
<textarea
:id="id"
:name="name"
:value="value"
:placeholder="placeholder"
:rows="rows"
:cols="cols"
class="form-control"
@dragover.prevent