Skip to content

Instantly share code, notes, and snippets.

View kernelsoe's full-sized avatar
⚒️
Crafting ...

Kernel Soe kernelsoe

⚒️
Crafting ...
View GitHub Profile
@onlurking
onlurking / programming-as-theory-building.md
Last active March 28, 2025 02:18
Programming as Theory Building - Peter Naur

Programming as Theory Building

Peter Naur

Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct

@yogthos
yogthos / clojure-beginner.md
Last active April 11, 2025 15:58
Clojure beginner resources

Introductory resources

@Venryx
Venryx / Example.tsx
Last active February 9, 2023 22:36
Using "useImperativeHandle" in a React functional component, with automatic TypeScript typing
import {forwardRef, useImperativeHandle, ForwardRefExoticComponent, RefAttributes, Ref} from "react";
export type Handle<T> = T extends ForwardRefExoticComponent<RefAttributes<infer T2>> ? T2 : never;
export const Parent = (props: {})=> {
let childHandle: Handle<typeof Child>;
return (
<div onClick={()=>childHandle.SayHi()}>
<Child name="Bob" ref={c=>childHandle = c}/>
</div>
@slava-vishnyakov
slava-vishnyakov / readme.md
Last active March 28, 2025 07:52
How to upload images with TipTap editor
  1. Create a file Image.js from the source below (it is almost a copy of Image.js from tiptap-extensions except that it has a constructor that accepts uploadFunc (function to be called with image being uploaded) and additional logic if(upload) { ... } else { ... previous base64 logic .. } in the new Plugin section.
import {Node, Plugin} from 'tiptap'
import {nodeInputRule} from 'tiptap-commands'

/**
 * Matches following attributes in Markdown-typed image: [, alt, src, title]
 *
@jaspertravers
jaspertravers / humane_representation_of_thought_transcript.md
Created September 27, 2019 23:12
Bret Victor Humane Representation of Thought Auto-Generated Transcript

so since is splash this is a programming conference I want to start by reassuring you that this talk is in fact about trading programs okay I want to start with that because it might not seem like that's what I'm talking about I'm not going to be talking about writing code I'm not gonna be talking about building software and we normally think about it but this is very deeply about creating programs and kind of in the same way that we create sounds when we talk we create letters no you're right this is about creating programs as a means of or person-to-person communication as a means of representing thought this is this is kind of a personal talk in certain ways and so I wanted to start out just with a little bit of personal background food so you can kind of see where I'm coming from I got my start like you know many people you know making games and apps and whatnot I think I kind of found my stride designing creative tools made a number of musical instruments visual design tools that sort of thing that start

@gaearon
gaearon / uselayouteffect-ssr.md
Last active March 17, 2025 10:13
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
@gaearon
gaearon / modern_js.md
Last active April 14, 2025 19:22
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@Aetherus
Aetherus / scale-out-phoenix-with-websocket.md
Last active February 23, 2024 14:31
How to scale out a Phoenix application with websocket

How to scale out a Phoenix application with websocket

Foreword

It's relatively easy to scale out stateless web applications. You often only need a reverse proxy. But for those stateful web applications, especially those applications that embeds websocket services in them, it's always a pain to distribute them in a cluster. The traditional way is introducing some external services like Redis to handle pubsub, however, in such way, you often need to change your code. Can Erlang/Elixir, the "concurrency oriented programming languages", best other languages in this use case? Has Phoenix framework already integrated the solution of horizontally scaling websocket? I'll do an experiment to prove (or disprove) that.

Resources

/*
# Clean UI programming in a vacuum
This app was written for Chapter 19 in the 3rd edition of Eloquent
JavaScript—it aims to demonstrate modern UI programming without
depending on a specific framework or library.
Its convention is that components have an interface like this:
```
@ngokevin
ngokevin / gist:803e68351f70139da51fda48d3b484e3
Created October 25, 2017 07:51
Example of keyboard bindings for A-Frame/VR development.
/**
* Keyboard bindings to control controller and create actions via events.
* Position controllers in front of camera.
* <a-scene debug-controller> ?debug in URL to toggle on.
*/
AFRAME.registerComponent('debug-controller', {
schema: {
enabled: {default: false}
},