Skip to content

Instantly share code, notes, and snippets.

View mtvbrianking's full-sized avatar

Brian Matovu mtvbrianking

View GitHub Profile
@mtvbrianking
mtvbrianking / openssl-mtls.md
Last active December 27, 2022 08:49
OpenSSL / MTLS / Wildcard Certificates / Subject Alternative Name

Certificate Authority

Self Signing CA for local dev

openssl req -x509 -nodes -newkey rsa:4096 -keyout ca.key -out ca.crt -days 365 -subj "/CN=poseidon"

Server

@mtvbrianking
mtvbrianking / settings.json
Last active September 23, 2023 08:02
vscode settings json
{
"files.exclude": {
"**/node_modules": true
},
"debug.console.fontFamily": "JetBrains Mono",
"debug.console.fontSize": 14,
"debug.console.lineHeight": 25,
"debug.toolBarLocation": "docked",
"editor.codeLens": true,
"editor.fontFamily": "'JetBrains Mono', 'Fira Code', 'Consolas','monospace'",
const withdrawMachine = Machine(
{
id: 'withdraw',
initial: 'created',
context: {
signatures: 0,
corum: 3
},
states: {
created: {
@mtvbrianking
mtvbrianking / xml_get.php
Last active October 4, 2022 22:52
Get an item from xml by path.
<?php
// https://phpsandbox.io/n/steep-union-wnew-ndjxv
function xml_get(
SimpleXMLElement|string $xml,
string $path,
mixed $default = null
): mixed
{
@mtvbrianking
mtvbrianking / dto 1.php
Last active September 29, 2022 17:13
DTO Data Transfer Objects
<?php
use Spatie\DataTransferObject\DataTransferObject;
class Customer extends DataTransferObject
{
/** @var int|string $id */
public $id;
public string $alias;
public string $name;
@mtvbrianking
mtvbrianking / saveToEnvFile.php
Last active September 23, 2022 10:00
Update settings in dotenv file
<?php
function saveToEnvFile(string $dotEnv, string $pattern, string $label, ?string $value): bool
{
$readFrom = fopen($dotEnv, 'r');
$writeTo = tmpfile();
$isDirty = false;
while (!feof($readFrom)) {
$line = fgets($readFrom);
@mtvbrianking
mtvbrianking / multiple_ssh_setting.md
Created August 28, 2022 11:58 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@mtvbrianking
mtvbrianking / command.md
Created July 9, 2022 06:31
Symfony Command Allow Extra Non Validated Options
  namespace Symfony\Component\Console\Input;
  
  use Symfony\Component\Console\Exception\RuntimeException;
  
  class ArgvInput extends Input
  {
      protected function parse()
      {
@mtvbrianking
mtvbrianking / spatie-dto.php
Last active June 16, 2022 16:52
Spatie Data Transfer Object
<?php
// ..............................................
// V2
// ..............................................
use Spatie\DataTransferObject\DataTransferObject;
class Item extends DataTransferObject
{
@mtvbrianking
mtvbrianking / Multile SSH Setup.md
Created March 19, 2022 16:13
Multile SSH Setup

Generate ssh key pair

ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa_github -C "127.0.0.1"
ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa_gitlab -C "127.0.0.1"

Upload the *.pub to Github / Gitlab respectively.

Map ssh keys