Skip to content

Instantly share code, notes, and snippets.

View michitheonlyone's full-sized avatar
🏠
Working from home

Michael Ihde michitheonlyone

🏠
Working from home
View GitHub Profile
@michitheonlyone
michitheonlyone / ApplicationFilter.php
Last active August 25, 2021 14:55
PHP Doctrine DBAL Variable Filter Value Class
<?php declare(strict_types=1);
namespace Acme\Common\Application;
final class Filter
{
private string $column;
private int $option;
private string $value;
@michitheonlyone
michitheonlyone / NPM Bootstrap Icons JS Import
Last active September 3, 2021 14:51
Helpful NPM commands and Help for Bootstrap/ Bootswatch and Startbootstrap #bootstrap #startbootstrap #bootswatch #npm
npm i bootstrap-icons
import "../node_modules/bootstrap-icons/font/bootstrap-icons.css";
@michitheonlyone
michitheonlyone / Encrypter.php
Last active August 30, 2022 09:35
PHP Encryption Class to encrypt strings to encrypted json using openssl library (Stolen from Laravel)
<?php declare(strict_types=1);
// namespace...
final class Encrypter
{
private string $key;
private string $cipher;
const DEFAULT_CIPHER = 'AES-256-CBC';
@michitheonlyone
michitheonlyone / PHPAnonymusFunctions.php
Last active July 7, 2023 10:41
PHP Anonymus Function
<?php implode("\n", array_map(function($inst){ return "- ".$inst->getUrl()->toString(); }, $customer->getInstallations()->toArray()))
@michitheonlyone
michitheonlyone / arrow-functions.js
Created September 24, 2021 11:39
JavaScript Cheatscheet
// Async arrow functions look like this:
const foo = async () => {
// do something
}
// Async arrow functions look like this for a single argument passed to it:
const foo = async evt => {
@michitheonlyone
michitheonlyone / PHP8_DependencyInjection.php
Last active January 28, 2022 10:44
PHP 8 new Dependency Injection vs PHP 7.4
<?php declare(strict_types=1);
// PHP 8
final class DependencyInjectionExampleNew
{
public function __construct(private string $var) {}
}
// PHP 7.4
final class DependencyInjectionExample
@michitheonlyone
michitheonlyone / XMLReader.php
Created August 19, 2022 13:26
PHP XMLReader - Composed of SimpleXMLElement to convert XML to Array - do not use for large xml!
<?php declare(strict_types=1);
namespace App\Util;
final class XMLReader
{
private \SimpleXMLElement $XMLElement;
/**
* @param string $xmlString A well-formed XML string of any resource
@michitheonlyone
michitheonlyone / web.config
Last active December 6, 2022 11:06
IIS web.config for Symfony and other webapps. RewriteRule to index.php
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
@michitheonlyone
michitheonlyone / case-types.txt
Last active February 9, 2023 12:20
Snake Case, Pascal Case, Camel Case, Kebab Case and other Case Types for programming
camelCase
PascalCase
snake_case
UPPER_SNAKE_CASE
kebab-case (dash-case)
UPPER-KEBAB-CASE
dot.case
UPPER.DOT.CASE
unicorncase
UPPERUNICORNCASE (TROLLCASE)
@michitheonlyone
michitheonlyone / ClassNameInArrayOfClasses.php
Created July 7, 2023 10:39
The solution to find if a class exists in a array of classes
<?php declare(strict_types=1);
class A {}
class B {}
class C {}
$classes = [
new A(),
new B(),
];