Skip to content

Instantly share code, notes, and snippets.

View michaelpaul's full-sized avatar
🎯
Request changes

Michael Paul michaelpaul

🎯
Request changes
View GitHub Profile
@michaelpaul
michaelpaul / ConcurrentCommands.java
Last active March 11, 2024 13:27
Process monitor in Shell script by ChatGPT
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ConcurrentCommands {
public static void main(String[] args) {
// Create and start threads for each command
Thread thread1 = new Thread(() -> executeCommand("tail -f foo.log"));
Thread thread2 = new Thread(() -> executeCommand("tail -f bar.log"));
@michaelpaul
michaelpaul / ManagementService-v1.yaml
Created August 30, 2022 08:38
ManagementService-v1.yaml
openapi: 3.0.0
servers:
- url: https://management-test.adyen.com/v1
info:
version: '1'
x-publicVersion: true
title: Management API
description: 'Configure and manage your Adyen company and merchant accounts, stores,
and payment terminals.
@michaelpaul
michaelpaul / Caddyfile
Created July 13, 2022 10:30
Basic reverse proxy for Github Codespaces
# starts a http server at this port
:5000
reverse_proxy 127.0.0.1:8000 {
# TODO: pick Forwarded for header
header_up Host {remote_host}
# header_up Host hardcoded-url.githubpreview.dev
# header_up X-Forwarded-Host nobody.dev
}
@michaelpaul
michaelpaul / set.py
Created September 23, 2021 08:44
Basic set operations
import collections
import itertools
import functools
import re
class Node:
def __init__(self, val):
self.val = val
@michaelpaul
michaelpaul / chat.html
Created June 19, 2021 11:26
TailwindCSS Chat layout
<!--
Welcome to Tailwind Play, the official Tailwind CSS playground!
Everything here works just like it does when you're running Tailwind locally
with a real build pipeline. You can customize your config file, use features
like `@apply`, or even add third-party plugins.
Feel free to play with this example if you're just learning, or trash it and
start from scratch if you know enough to be dangerous. Have fun!
-->
import { login, authenticate } from './auth';
jest.mock('./auth');
test('can add', () => {
expect(2 + 2).toBe(4)
});
test('function mock', () => {
const mockFn = jest.fn(() => 42);
@michaelpaul
michaelpaul / array-change.rs
Created January 31, 2020 20:28
Change Array
// the array must be passed as a mutable reference (&mut) to change
fn change(x: &mut [i16], y: i16) {
x[x.len() - 1] = y;
}
fn main() {
let mut arr = [127, 0, 0, 1];
println!("Before: {:?}", arr);
change(&mut arr, 255);
@michaelpaul
michaelpaul / var-type.elm
Created November 23, 2019 16:58
Type with a variable type argument
import Html exposing (text)
type Card s = Card s
stringCard = Card "foo"
intCard = Card 123
boolCard = Card False
name : Card String -> String
-- pattern match argument
@michaelpaul
michaelpaul / pos-vel.elm
Created November 23, 2019 14:28
Position and Velocity types in Elm
module Main exposing (Pos(..), Position, Possible(..), Three, Velocity, getXPos, getY, main, nada, p, position, s, s1, s2, s2f, someStatus, someVel, sumStatus, tupair, velocity, xv, yv)
import Html
main =
Html.text "Ellm"
@michaelpaul
michaelpaul / vm.rs
Created November 18, 2019 22:19
Enum based VM
// instruction set
enum Op {
Add(i8, i8),
Sub(i8, i8),
Not(i8),
And(i8, i8),
Or(i8, i8),
}
fn eval(command: &Op) -> i8 {