Skip to content

Instantly share code, notes, and snippets.

@gbirke
gbirke / gls_cc_extract_recipient.py
Created March 23, 2023 20:51
Convert CSV credit card statements of GLS Bank to look more like bank statements
#!/usr/bin/env python3
import argparse
import csv
import os.path
import sys
import logging
import re
"""
@gbirke
gbirke / Dockerfile
Last active February 25, 2022 08:46
Testing sequence support
FROM php:8.1-alpine
RUN set -ex \
&& apk --no-cache add postgresql-dev
RUN docker-php-ext-install pdo pdo_mysql pdo_pgsql
@gbirke
gbirke / Presentation.md
Last active February 21, 2022 16:12
Presentation on Clean Architecture in WMDE Fundraising
tags aliases created_on
2022-02-17

Clean Architecture and the Fundraising Application


What is the Clean Architecture

@gbirke
gbirke / get_seq.php
Last active February 21, 2022 09:22
Test LAST_INSERT_ID
<?php
# SQL setup:
# CREATE TABLE payment_sequence (id INT NOT NULL);
# INSERT INTO payment_sequence VALUES(0);
# CREATE TABLE payment_log(id INT PRIMARY KEY, client_id INT, loop_id INT, ts DATETIME(6));
$db = new PDO("mysql:dbname=fundraising;host=database", 'fundraising', 'INSECURE PASSWORD');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@gbirke
gbirke / unserialize_decode.php
Created August 10, 2021 14:52
Decode PHP-serialized and base64 encoded data in CLI
#!/usr/bin/env php
<?php
if (!empty($argv[1])) {
$data = (string)$argv[1];
} elseif (!stream_isatty(STDIN)) {
$data = stream_get_contents(STDIN);
} else {
echo "Usage: $argv[0] <base64_encoded_serialized_data>\n";
exit(1);
<?php
// This example shows how to override implementations without subclassing,
// using anonymous classes and traits.
interface Animal {
public function makeSound(): string;
public function move(): string;
}
@gbirke
gbirke / vimquery.sh
Created May 2, 2020 09:29
Script for NVAlt-like usage of fzf
#!/bin/bash
# A script for use with fzf in a nvalt-like setting
# (Either selecting a file or creating a new one)
# Use like this: fzf --bind "enter:execute(./vimquery {q} {})+abort"
if [ -z "$2" ]; then
if [ ! -z "$1" ]; then
vim "$1.md"
fi
@gbirke
gbirke / cmds.txt
Created May 1, 2020 22:02
custom rofi menu with tab-separated text file, cut and awk
ls_home>show home> ls ~
ranger> > ranger
config_nvim>Configure NVim> vim -c "cd ~/.config/nvim" ~/.config/nvim/init.vim
# vim: set list listchars:tab=>- noexpandtab tabstop=15
~
@gbirke
gbirke / factory-callable.php
Last active April 29, 2020 08:50
Dependency inversion of PHP factories with callables
<?php
// This example shows:
// 1) How to invert the dependency of initialization of factories in dependent
// modules by giving a callable. This will defer the initialization of the
// dependency.
// 2) How to use a closure inside of a class as a callable. Notice how accessing
// "$this->presenter" gives the current presenter, not the one that was stored
// when the closure was created.