Skip to content

Instantly share code, notes, and snippets.

View ChristianOellers's full-sized avatar
🇨🇾

Christian Oellers ChristianOellers

🇨🇾
View GitHub Profile
@ChristianOellers
ChristianOellers / Twig-Dump-Stylus.css
Last active September 19, 2023 14:56
TWIG dump() – Render issue fix (Shopware + Symfony). Stylus CSS can be used to hide code but show the dumps, while being attentive to this happening.
/**
* TWIG dump() sometimes leads to visible injected code shown in plain text.
* Hide script/ style tags output, but not completely, to be aware of this happening.
*
* Maybe due to some Syntax error occurring in some templates.
* This hides the boilerplate and just shows the debug.
*/
script,
style {
border: 2px solid magenta !important;
@ChristianOellers
ChristianOellers / php
Last active August 18, 2023 10:52
VS Code - PHP in Docker - Editor/IDE language support + linting
#!/bin/bash
docker exec -i --user=111:222 $(docker ps -q) /usr/bin/php "$@"
# Get PHP executable from container and send any argument to it.
#
# Assumptions
# - Calls the current container (docker ps -q).
# - Assumes PHP path exists in container as shown.
#
@ChristianOellers
ChristianOellers / ILogger.ts
Created July 26, 2023 10:38
Minimal console logger wrapper. TypeScript, Node, Jest, Angular. Architectural demo with interface, config, TDD. IoC optional.
export interface ILogger {
log(...args: any[]): void;
info(): void;
error(): void;
enable(): void;
disable(): void;
}
@ChristianOellers
ChristianOellers / RegEx-Snippets - Log analysis + Filtering.sh
Last active July 26, 2023 10:04
RegEx snippets for various tasks - Data analysis, filtering, validation, ... (PCRE, Bash).
# Exemplary snippets I've been using in my own projects. Use for inspiration and take what you need.
# 'sh' file format is for syntax highlighting only: The RegEx parts should work in many scenarios.
#
# Run all snippets to normalize varying strings by replacing or removing characters (as you need).
# Once all strings are aligned, duplicates can be filtered and lines sorted.
# This leaves the log with a few distinct, unique errors that are to be considered for development.
# RegEx design aims to leave the log syntax intact, e.g., delimiters (,"').
# This might be relevant for proper syntax highlighting or use with advanced analyzers.
# ---
@ChristianOellers
ChristianOellers / 1_Request-JSON-Data.php
Created July 3, 2023 12:37
Request + Routing - Minimalist zero-dependency PHP solution for JSON handling. Useful for development, not suited for production.
<?php
declare(strict_types=1);
namespace App;
use Exception;
use function addslashes;
use function file_get_contents;
@ChristianOellers
ChristianOellers / 0_Search-Queries.sql
Last active July 3, 2023 12:32
MySQL snippets - Specific search queries and example code.
-- Find in date range
SELECT *
FROM example
WHERE (updated >= '1970-01-01' AND updated <= DATE_ADD('1970-01-01', INTERVAL 1 DAY))
-- AND ...
-- Find by date format
SELECT * FROM example
-- WHERE ...
AND YEAR(updated_at) >= '1970'
@ChristianOellers
ChristianOellers / font-scaling.scss
Last active July 3, 2023 12:23
SCSS + Bootstrap snippets. Utilities and custom font scaling mechanism. Variables in separate file.
// Custom font scaling mechanism.
//
// This allows keeping a standardized base font size (e.g. 16px ~ 1rem),
// but applying custom scales for anything that is not regular text flow.
// Font scale factors (here large Desktop set as base scale).
$font-breakpoints: (
xs: 0.65,
sm: 0.7,
md: 0.75,
@ChristianOellers
ChristianOellers / .bash_aliases
Last active July 3, 2023 12:01
Symfony + Vagrant settings - VM configuration, aliases and snippets for speedy workflows.
#!/bin/bash
# Utility aliases to call from within running Vagrant box. Speed up fixing common, recurring issues during development.
# @todo - Adjust paths and commands as needed.
# TOC
# - Symfony
# - Logs
# - SYSTEM
@ChristianOellers
ChristianOellers / phpcs.xml
Created June 11, 2023 16:36
Symfony - PHPCS config (via Squizlabs), PSR-12 standard.
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<arg name="basepath" value="." />
<arg name="cache" value=".phpcs-cache" />
<arg name="extensions" value="php" />
<arg name="colors" />
<arg name="report" value="summary" />
@ChristianOellers
ChristianOellers / Log4j.java
Last active June 11, 2023 14:49
Log4j - Example implementation (Java).
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class Example {
private static final Logger logger = LoggerFactory.getLogger(Example.class);
public void doSomething() {
// Levels: info, warn, ...
logger.warn("Text", 1);
}