Skip to content

Instantly share code, notes, and snippets.

View terkelg's full-sized avatar
🔵
Git'n stuff done

Terkel terkelg

🔵
Git'n stuff done
View GitHub Profile
@denisenepraunig
denisenepraunig / ContentView.swift
Created November 25, 2023 01:45
SwiftUI Metal Shader changing background color based on mouse position
import SwiftUI
struct ContentView: View {
@State private var hoverLocation: CGPoint = .zero
@State private var isHovering = false
@State var toggleText = false
var body: some View {
ZStack {
Rectangle()
@khalidx
khalidx / node-typescript-esm.md
Last active April 22, 2024 15:40
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@stephancasas
stephancasas / open-messages-emoji-palette.jxa.js
Created October 26, 2023 15:00
Open the macOS Messages emoji palette.
#!/usr/bin/env osascript -l JavaScript
let _AXError;
const $attr = Ref();
const $windows = Ref();
const $children = Ref();
const kAXParentAttribute = 'AXParent';
const kAXChildrenAttribute = 'AXChildren';
@stephancasas
stephancasas / core-ax.jxa.js
Last active February 15, 2024 01:13
JXA Core AX Framework Bindings
#!/usr/bin/env osascript -l JavaScript
function run() {
const VSCode = axApp('com.microsoft.VSCode');
const window = axGet(VSCode, 'AXWindows')[0];
return axWindowSetBounds(window, 200, 200, 1200, 1400);
}
/**
@rain-1
rain-1 / LLM.md
Last active April 24, 2024 08:25
LLM Introduction: Learn Language Models

Purpose

Bootstrap knowledge of LLMs ASAP. With a bias/focus to GPT.

Avoid being a link dump. Try to provide only valuable well tuned information.

Prelude

Neural network links before starting with transformers.

@pesterhazy
pesterhazy / building-sync-systems.md
Last active April 25, 2024 05:35
Building an offline realtime sync engine

So you want to write a sync system for a web app with offline and realtime support? Good luck. You might find the following resources useful.

Overview articles

@joshnuss
joshnuss / OAuthClient.js
Last active December 10, 2023 22:46
OAuth2 Client
import fetch from 'node-fetch'
// some provider data is copied from github.com/simov/grant
const providers = {
bogus: {
authorize_url: "http://localhost:8282/auth/request/path",
access_url: "http://localhost:8282/access/token/request",
},
google: {
@DavidWells
DavidWells / github-proxy-client.js
Last active March 15, 2024 08:28
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
const randomVectorInCone = (theta: number, target: THREE.Vector3) => {
const z = remap(Math.random(), [0, 1], [Math.cos(theta), 1])
const phi = remap(Math.random(), [0, 1], [0, 2 * Math.PI])
target.set(
Math.sqrt(1 - z * z) * Math.cos(phi),
Math.sqrt(1 - z * z) * Math.sin(phi),
z
)
target.normalize()
@simonbs
simonbs / UserDefault.swift
Last active March 3, 2024 11:38
Property wrapper that stores values in UserDefaults and works with SwiftUI and Combine.
/**
* I needed a property wrapper that fulfilled the following four requirements:
*
* 1. Values are stored in UserDefaults.
* 2. Properties using the property wrapper can be used with SwiftUI.
* 3. The property wrapper exposes a Publisher to be used with Combine.
* 4. The publisher is only called when the value is updated and not
* when_any_ value stored in UserDefaults is updated.
*
* First I tried using SwiftUI's builtin @AppStorage property wrapper