Skip to content

Instantly share code, notes, and snippets.

View lloydjatkinson's full-sized avatar
🌧️
Chilling

Lloyd Atkinson lloydjatkinson

🌧️
Chilling
View GitHub Profile
@yzdbg
yzdbg / auto-dr.md
Last active November 3, 2023 17:11

Automating Daily Reports, because fuck it, really...

Each day at our company, developers are required to document their activities, painstakingly jotting down their daily work and future plans. A monotonous chore that I just really dislike.

So now, there's a scribe for that :

auto-dr-

Code

@zadeviggers
zadeviggers / embed-yotube-videos-in-md.ts
Last active June 22, 2022 23:56
A function to embed yotube videos in markdown
// This code looks for syntax like `{{youtube: https://www.youtube.com/watch?v=dQw4w9WgXcQ}}`
// rather than a plain URL, but it should be simple enough to modify the regex.
// Call this function on your raw markdown before your markdown processor (e.g. Marked, ReMark, etc) is run on it,
// and then pass the output of this function to your markdown processor.
function embedYoutubeVideos(md: string): string {
const ytRegexGlobal = /{{youtube: ?([^{}]+)}}/g;
const matches = md.matchAll(ytRegexGlobal);
let output = md;
@josellm
josellm / MyStateMachine.cs
Last active January 19, 2022 13:19
Reusing stateless state machine for different instances
using Stateless;
using System;
using System.Collections.Generic;
using System.Linq;
namespace WorkFlow {
public class MyStateMachine<T, TTrigger> {
private readonly static object locker = new object();
private readonly T _element;
@notwaldorf
notwaldorf / README.md
Last active February 19, 2024 06:21
A very minimal p5.js polyfill for when you want to write basic p5.js code but not import the whole kitchen sink.

Minimal p5 polyfill

This is a very minimal bit of polyfill code for when you want to use some basic p5.js code you wrote, but not pay the performance cost associated with importing the whole kitchen sink.

It basically implements some of the sintactic sugar I use the most from p5.js but using the Canvas api, so that I have the p5 api but without all the magic I'm probably not using in this particular sketch.

@rossedman
rossedman / main.tf
Last active March 7, 2024 14:00
Scale homelab into cloud with Tailscale, Terraform and cloud-init
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
}
}
}
provider "digitalocean" {
}
@nileshtrivedi
nileshtrivedi / home-server.md
Last active January 10, 2024 06:30
Home Server setup: Raspberry PI on Internet via reverse SSH tunnel

Raspberry Pi on Internet via reverse SSH tunnel

HackerNews discussed this with many alternative solutions: https://news.ycombinator.com/item?id=24893615

I already have my own domain name: mydomain.com. I wanted to be able to run some webapps on my Raspberry Pi 4B running perpetually at home in headless mode (just needs 5W power and wireless internet). I wanted to be able to access these apps from public Internet. Dynamic DNS wasn't an option because my ISP blocks all incoming traffic. ngrok would work but the free plan is too restrictive.

I bought a cheap 2GB RAM, 20GB disk VM + a 25GB volume on Hetzner for about 4 EUR/month. Hetzner gave me a static IP for it. I haven't purchased a floating IP yet.

Converting Tailwind UI Alpine transitions to Vue transitions

After you copy a component from the Tailwind UI library and begin to adapt it from Vue JS to Alpine JS .. you may wonder what to do about the transitions. As I'm exploring this myself, I am documenting it for others in the same boat.

Things to be aware of:

  • Alpine calls the beginning and ending states "start" & "end"
  • Vue calls the beginning and ending states "from" and "to"
  • Alpine has inline "directives" ie x-transition:enter="classes"
  • Vue has a wrapper component that applies classes to the child
  • Alpine applies the classes you pass it for each state, :enter-start="class"
@lloydjatkinson
lloydjatkinson / trim-text.js
Last active December 5, 2022 19:26
Trim text and prefix ellipses when the text length is greater than the maximum
const trimText = (input = '', maximumLength = 80) => {
const exceedsMaximum = input.length >= maximumLength;
return {
exceedsMaximum,
text: exceedsMaximum ? `${ input.substr(0, input.lastIndexOf(' ', maximumLength)) }...` : input,
}
};
export default trimText;

Foreward

This document was originally written several years ago. At the time I was working as an execution core verification engineer at Arm. The following points are coloured heavily by working in and around the execution cores of various processors. Apply a pinch of salt; points contain varying degrees of opinion.

It is still my opinion that RISC-V could be much better designed; though I will also say that if I was building a 32 or 64-bit CPU today I'd likely implement the architecture to benefit from the existing tooling.

Mostly based upon the RISC-V ISA spec v2.0. Some updates have been made for v2.2

Original Foreword: Some Opinion

The RISC-V ISA has pursued minimalism to a fault. There is a large emphasis on minimizing instruction count, normalizing encoding, etc. This pursuit of minimalism has resulted in false orthogonalities (such as reusing the same instruction for branches, calls and returns) and a requirement for superfluous instructions which impacts code density both in terms of size and

@Tewr
Tewr / MappingExtensions.cs
Created March 26, 2019 12:50
Provides object extensions Map and Tap. Like LINQ Select, but for non-collections. int.Parse("5") becomes "5".Map(int.Parse).
public static class MappingExtensions
{
/// <summary>
/// Applies the specified <paramref name="transformation"/> on the <paramref name="source"/>.
/// </summary>
/// <typeparam name="TSource"></typeparam>
/// <typeparam name="T"></typeparam>
/// <param name="source"></param>
/// <param name="transformation"></param>
/// <returns></returns>