Skip to content

Instantly share code, notes, and snippets.

View coleea's full-sized avatar
💭
I may be slow to respond.

Mario KB coleea

💭
I may be slow to respond.
View GitHub Profile
@kitlangton
kitlangton / kyo.scala
Last active March 19, 2024 23:55
Kyo (Alt. Encoding Explorations)
package zero
import izumi.reflect.Tag
import Kyo.*
import scala.collection.View.FlatMap
type Id[T] = T
type Const[T] = [U] =>> T
type MX[T] = Any
@borispoehland
borispoehland / effects.ts
Last active May 7, 2024 09:48
3 fetch effects for effect-ts. One uses cache: no-store, one cache: force-cache and one uses the default cache / revalidate
import * as S from '@effect/schema/Schema'
import { Context, Effect } from 'effect'
export interface IFetcher {
fetch: typeof fetch
}
export const TFetcher = Context.Tag<IFetcher>('IFetcher')
class FreshFetcher implements IFetcher {
@edofic
edofic / index.html
Created May 6, 2023 19:06
htmx with a "backend" in service worker
<!DOCTYPE html>
<html>
<head>
<title>Hello Page</title>
<script src="https://unpkg.com/[email protected]"></script>
</head>
<body>
<h1>Hello</h1>
import {
useState,
useCallback,
useLayoutEffect,
useRef,
useEffect,
} from 'react';
const wait = () => new Promise((resolve) => setTimeout(resolve, 3000));
@c2d7fa
c2d7fa / 01-free-monad-state.ts
Last active March 5, 2024 06:27
Expressing a specific instance of the free monad in TypeScript
// https://underscore.io/blog/posts/2015/04/23/deriving-the-free-monad.html
// Example of implementing a specific instance of a free monad (for getting and
// setting an integer value) in TypeScript. The type system is not expressive
// enough to express free monads in general, but we can express a specific
// instance.
type AtomicOperation<T> = ["get", (x: number) => T] | ["set", number, T];
type Program<T> = ["return", T] | ["suspend", AtomicOperation<Program<T>>];
@Jswizzy
Jswizzy / InstallingSwift.md
Last active October 28, 2024 20:04
Swift Install Instruction 20.04

Installing Swift on Ubuntu 20.04

1. Install Depencies

“clang”[ˈklæŋ] is the compiler based on LLVM for C, C++, Objective-C, and Objective-C++. clang is needed to install in order to Swift. Run the following code in Ubuntu terminal.

Before installing swift “libpython2.7” and “libpython2.7-dev” are needed to get Swift running. Run the following code.

@jjcodes78
jjcodes78 / nextjs-deploy.md
Last active January 2, 2025 15:03
Deploying NEXTJS site with nginx + pm2

How to setup next.js app on nginx with letsencrypt

next.js, nginx, reverse-proxy, ssl

1. Install nginx and letsencrypt

$ sudo apt-get update
$ sudo apt-get install nginx letsencrypt

Also enable nginx in ufw

@atacratic
atacratic / ability-tutorial.output.md
Last active October 22, 2024 20:55
Unison abilities - unofficial alternative tutorial

This tutorial explains how Unison handles 'effectful' computations, like storing state or performing I/O, using abilities. It assumes you haven't come across abilities before, and covers everything from the ground up.

This is an unofficial tutorial, written before the one on unisonweb.org/docs. The approach taken here is slow and methodical. Your first stop should be the official tutorial, if you haven't seen it already.

This doc is a Unison transcript - the source is here.

Terminology note: other languages with ability systems typically call them 'effect handlers' or 'algebraic effects', but many of the ideas are the same.

Introducing abilities

@gragland
gragland / use-async.jsx
Last active February 17, 2024 16:42
React Hook recipe from https://usehooks.com
import React, { useState, useEffect, useCallback } from 'react';
// Usage
function App() {
const { execute, status, value, error } = useAsync(myFunction, false);
return (
<div>
{status === 'idle' && <div>Start your journey by clicking a button</div>}
{status === 'success' && <div>{value}</div>}
@nktknshn
nktknshn / schema_to_types.ts
Last active August 6, 2022 15:26
Generate io-ts codecs and types for JSON data from a set of samples using jq, quicktype and io-ts-codegen
/*
Generate io-ts codecs and types for JSON data from a set of samples using jq, quicktype and io-ts-codegen
Usage:
# collect samples
for i in $(seq 1 10); do
wget -P samples/ https://api.github.com/events && sleep 2
done