Skip to content

Instantly share code, notes, and snippets.

@martinandersen3d
martinandersen3d / try-catch.ts
Created March 20, 2025 23:22 — forked from t3dotgg/try-catch.ts
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@martinandersen3d
martinandersen3d / Dotnet-New-Clean-Architecture
Created January 9, 2025 12:44 — forked from johannesprinz/Dotnet-New-Clean-Architecture
Dotnet Core - Clean Architecture Scaffold
# Outside of shell
# - Create project directory
# - git init
# - open in vs code >code .
# - Using remote container extensions create new development container
# - Using dotnet core 3.1 or later container template
# - Re-open in container and run the script below
dotnet new sln
dotnet new xunit -n Application.IntegrationTests -o ./tests/Application.IntegrationTests

Preact, Without Build Tools

This is a demonstration of using Preact without any build tooling. The library is linked from the esm.sh CDN, however a standalone JS file exporting HTM + Preact + Hooks can also be downloaded here.

import urllib2
import json
import sys
import os
from Tkinter import Tk
URL="https://api.github.com/gists"
TOKEN=""
@martinandersen3d
martinandersen3d / gist:2de4d79641f71fdd34c8e92963ecd3ff
Created August 24, 2023 00:32
Python Copy gif to clipboard on windows
# The steps are:
# 1. convert a gif to a base64 html image
# 2. copy HTML to clipboard
# 3. in MS Word, paste the html-gif
# Note: This does not work in Gmail, Google Docs and google products
import base64
import win32clipboard
@martinandersen3d
martinandersen3d / TkinterEditorWithLinenumbers.py
Created July 12, 2023 19:23
Python Tkinter Code Editor with Line numbers
import tkinter as tk
from tkinter import ttk
class GridApp:
def __init__(self):
self.root = tk.Tk()
self.root.title("Grid Layout")
# Create the Text_Linenumber widget

Goal: find a Linux alternative to FancyZones for Windows

Name Recommended Type Supports main colum Supports layouts Multiple windows in same tile Notes
gSnap 👍 Gnome extension yes yes yes Can be configured almost just like FancyZones; in the settings:
  • disable Show tabs
  • enable Hold CTRL to snap windows
gTile Gnome extension no?
Tiling Assistant 🤷 Gnome extension yes yes yes Layout support is "experimental" and the UX is a bit unintuitive; after enabling layouts, you have to click the star icon beside a layout to mark it as a favourite before you can then hold Alt while dragging to snap to a tile
[Forge](https://extensions.gnome.o
import {LitElement, html, css} from 'https://unpkg.com/lit-element/lit-element.js?module';
class MyElement extends LitElement {
static get properties() {
return {
title: {
type: String
},
location: {
type: String
//defining autonomous custom elements:
if(!customElements.get('my-element')){
customElements.define('my-element',MyElement);
}
//defining customised button element:
if(!customElements.get('custom-button')){
customElements.define('custom-button',CustomButton,{extends:'button'})
}
@martinandersen3d
martinandersen3d / hello.js
Created January 15, 2023 22:36 — forked from UpperCod/hello.js
atomico-example
import { c, html } from "atomico"; // 3.0kB
function component({ name }) {
return html`<host shadowDom>Hello, ${name}</host>`;
}
component.props = {
name: String,
};