Skip to content

Instantly share code, notes, and snippets.

View makomweb's full-sized avatar
🌀

Martin Komischke makomweb

🌀
View GitHub Profile
@makomweb
makomweb / Dockerfile
Created March 25, 2024 12:29
Docker multi stage file for npm + webserver
# Docker multistage
# 1. stage to run npm install
# 2. stage to create a webserver image with the build artifact from stage 1
FROM node:latest as build-stage
WORKDIR /app
COPY ./ /app/
@makomweb
makomweb / reflection-test.php
Last active November 30, 2023 12:04
Reflecting a PHP class and it's attributes (traverse properties and attributes)
<?php
declare(strict_types=1);
namespace App\Tests\Unit\Playground;
use Attribute;
use PHPUnit\Framework\TestCase;
use ReflectionAttribute;
use ReflectionClass;
@makomweb
makomweb / docker.sh
Last active October 10, 2023 15:31
Remove docker images / containers
# Remove Image
docker rmi <imageId/Name>
# Force remove image
docker rmi -f <imageId/Name>
# Remove dangling images
docker image prune
# Remove all images
@makomweb
makomweb / jest-react-testing-libary.md
Last active May 12, 2023 14:33
Test a React component via React-Testing-Library
// HiddenMessage.tsx
import * as React from "react";

function HiddenMessage({children}) {
    const [showMessage, setShowMessage] = React.useState(false)
    return (
        <div>
            <label htmlFor="toggle">Show Message</label>
 
@makomweb
makomweb / useGet.tsx
Created March 20, 2023 12:43
HTTP GET hook
import { useEffect, useState } from 'react';
import axios from 'axios';
type State<T> = {
pending: boolean;
error?: Error;
data?: T;
};
export function useGet<T>(url: string) {
@makomweb
makomweb / symfony-rx.php
Last active January 24, 2024 12:54
Reactive Extensions are fun 😃
<?php
declare(strict_types=1);
namespace App\Command;
use Rx\Observable;
use Rx\Scheduler;
use Rx\Scheduler\ImmediateScheduler;
use Symfony\Component\Console\Attribute\AsCommand;
<?php
use React\EventLoop\Factory;
use Rx\Observable;
use Rx\Scheduler;
use Rx\Scheduler\EventLoopScheduler;
require_once __DIR__ . '/vendor/autoload.php';
$loop = Factory::create();
@makomweb
makomweb / serialize_test.php
Created June 14, 2022 10:32
Serialize properties
<?php
declare(strict_types=1);
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Serializer\SerializerInterface;
class PropertiesTest extends KernelTestCase
{
private SerializerInterface $serializer;
@makomweb
makomweb / conversion.cs
Created April 15, 2022 16:04
Empty string or null to FALSE conversion
using Newtonsoft.Json;
using NUnit.Framework;
using System;
namespace JSON_empty_string_or_null_to_false_conversion
{
public class MyDocument
{
public bool MyFlag { get; set; }
@makomweb
makomweb / example.cs
Created February 15, 2022 07:47
Response to "Broken iterator example in C# from Entwickler Magazin 1 / 2022"
namespace Sandbox
{
public class MyTests
{
[Test]
public async Task Run_me()
{
var numbers = new List<int> { 1, 2, 3, 5, 8 };
var sum = SumAsync(numbers);