Skip to content

Instantly share code, notes, and snippets.

View Kielan's full-sized avatar
💻
Java Rust Go Swift C# Typescript React Graphql C C++ Python

Kielan Kielan

💻
Java Rust Go Swift C# Typescript React Graphql C C++ Python
View GitHub Profile
@Kielan
Kielan / is.ts
Last active November 22, 2022 05:02
JavaScript type checking from react-spring
interface Lookup<T = any> {
[key: string]: T
}
type IsType<U> = <T>(arg: T & any) => arg is Narrow<T, U>
type Narrow<T, U> = [T] extends [Any] ? U : [T] extends [U] ? Extract<T, U> : U
type PlainObject<T> = Exclude<T & Lookup, Function | readonly any[]>
const is = {
arr: Array.isArray as IsType<readonly any[]>,
/* dust/source/dust/windowmanager/intern/wm_cursors.c */
/**
* Custom Cursor Description
* =========================
*
* Each bit represents a pixel, so 1 byte = 8 pixels,
* the bytes go Left to Right. Top to bottom
* the bits in a byte go right to left
* (ie; 0x01, 0x80 represents a line of 16 pix with the first and last pix set.)
*
@Kielan
Kielan / GHOST-capi.c
Last active November 16, 2022 12:12
GHOST api for OpenGL to window manager api system. Currently in cpp prepping for migration
GHOST_ContextHandle GHOST_CreateOpenGLContext(GHOST_SystemHandle systemhandle,
GHOST_GLSettings glSettings)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
return (GHOST_ContextHandle)system->createOffscreenContext(glSettings);
}
@Kielan
Kielan / Effects-Handlers-In-C.md
Last active July 31, 2023 18:14
Algebraic Effects and Handlers in C

Implementing Algebraic Effects in C “Monads for Free in C”

Microsoft Research Technical Report MSR-TR-2017-23 Daan Leijen Microsoft Research Updated by Kielan Lemons [email protected]

Abstract. We describe a full implementation of algebraic effects and handlers as a library in standard and portable C99, where effect operations can be used just like regular C functions. We use formal operational semantics to guide the C implementation at every step where an evaluation context corresponds directly to a particular C execution context. Finally we show a novel extension to the formal semantics to describe optimized tail resumptions and prove that the extension is sound. This gives two orders of magnitude improvement to the performance of tail resumptive operations (up to about 150 million operations per second on a Core [email protected])

@Kielan
Kielan / Managing_inotify_instances.md
Last active June 5, 2022 23:15
FIx "ENOSPC: System Limit for Number of File Watchers Reached"

Check what is the max no of user_watches being set currently

$ cat /proc/sys/fs/inotify/max_user_watches

Check what is the max no. of inotify instances which correspond to the no. of allowed Watch Services instances.

$ cat /proc/sys/fs/inotify/max_user_instances
@Kielan
Kielan / Popover.tsx
Created May 18, 2022 03:32
Overly elaborate typescript popover implementation. Refactoring.
import * as React from 'react';
enum ActionTypes {
TogglePopover,
ClosePopover,
SetButton,
SetButtonId,
SetPanel,
SetPanelId,
@Kielan
Kielan / README.md
Created May 17, 2022 20:13
typescript no hoisting example: Explained

class Bar { name: string; constructor(name: string) { this.name = name; } } class Foo extends Bar{ constructor(name: string) { super(name); } getName() {

@Kielan
Kielan / dashboard.tsx
Last active May 17, 2022 17:47
Vercel Dashboard React tailwindcss
import * as React from 'react';
import Head from 'next/head';
import Layout from '../components/Layout';
import ProjectCard from '../components/ProjectCard';
/*
inline style jsx not globals.css is where css vars
and root css styles are being read
submenu border is not found
has --accents-2: #333;
backup color #fff
@Kielan
Kielan / Compiler Notes
Last active May 2, 2022 04:02
compiler prettier and
https://drafts.csswg.org/css-syntax-3/#input-byte-stream
CSS parsing
The process consists of
bytes->stream codepoints->stream tokens->parse css syntax output
The output is a CSSStyleSheet object.
1. User agent recieves a stream of bytes
(typically coming over the network or
from the local file system).