Skip to content

Instantly share code, notes, and snippets.

View paulrobello's full-sized avatar

Paul Robello paulrobello

View GitHub Profile
@paulrobello
paulrobello / list-bug.py
Last active March 6, 2024 16:55
Textual Hidden ListItem Bug
#!/usr/bin/env python
from textual.app import App, ComposeResult
from textual.widgets import Header, Footer, Log, Label, ListView, ListItem
from textual.containers import Horizontal
class ListApp(App[None]):
def compose(self) -> ComposeResult:
yield Header(show_clock=True)
with Footer():
@paulrobello
paulrobello / WsConnection.cs
Created January 29, 2024 22:02
Websocket connection manager with message subscription handling
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using UnityEngine;
using NativeWebSocket;
using PAR;
using Sirenix.OdinInspector;
using Sirenix.Utilities;
@paulrobello
paulrobello / WsMessageFilters.cs
Created January 29, 2024 21:59
Websocket message subscription filter
using System;
using System.Collections.Generic;
using System.Linq;
namespace Websocket
{
public interface IWsMessageFilterPredicate
{
bool Evaluate(IWsMessage msg);
}
@paulrobello
paulrobello / decorators.py
Last active April 7, 2022 17:58
python decorator learning
import functools
import types
# if passed as 1st argument to decorator will be used for setup and teardown
from typing import Optional, Generator, Dict, Callable, Union
# first call by next will setup. 2nd call will teardown.
def setup():
print("setup")
@paulrobello
paulrobello / app-oath.interceptor.ts
Created September 18, 2021 17:02
angular-oauth2-oidc auth interceptor with id token support
import { Injectable, ModuleWithProviders, NgModule, Optional } from '@angular/core';
import {
HTTP_INTERCEPTORS,
HttpEvent,
HttpHandler,
HttpInterceptor,
HttpRequest
} from '@angular/common/http';
import {
@paulrobello
paulrobello / TypescriptPlaygroundRaytracer.ts
Last active April 1, 2021 15:21
Typescript Playground Raytracer cleaned up a bit with more display function. Requires you disable JSX in Typescript options.
class Vector {
constructor(public x: number,
public y: number,
public z: number) {
}
static times(k: number, v: Vector) { return new Vector(k * v.x, k * v.y, k * v.z); }
static minus(v1: Vector, v2: Vector) { return new Vector(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); }
static plus(v1: Vector, v2: Vector) { return new Vector(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); }
static dot(v1: Vector, v2: Vector) { return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; }
@paulrobello
paulrobello / Dockerfile
Created November 26, 2019 22:44
Custom apache php dev with added mssql pdo driver Dockerfile
FROM webdevops/php-apache-dev:7.2
# add microsoft packages to apt sources
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
# install needed system packages as well as a few nice to have utils
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y upgrade && \
ACCEPT_EULA=Y apt-get -y install msodbcsql17 unixodbc-dev less joe iputils-ping traceroute telnet && \
apt-get purge -y --auto-remove && \
@paulrobello
paulrobello / SocketIOKoaSession.ts
Last active August 15, 2022 11:48
Koa v2 with SocketIO v2 shared session
// SessionObj ensures that reload,save and destroy are functions, any other key is fair game
export interface SessionObj {
reload: () => Promise<any>,
save: () => Promise<any>,
destroy: () => Promise<any>,
[key: string]: any
}
// add our session member to SocketIO.Socket
@paulrobello
paulrobello / cleanup.sh
Created August 31, 2017 23:46
Docker registry v2 cleanup script
#!/bin/bash
### your registry must have the following environment var set
# REGISTRY_STORAGE_DELETE_ENABLED=true
### replace YOUR_SERVER with corect info
REGISTRY_URL=https://YOUR_SERVER:5000
### host registry volume folder
REGISTRY_ROOT=/registry
### container to execute garbage-collect
CONTAINER_NAME=services_registry.1