Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# Abort sign off on any error
set -e
# Start the benchmark timer
SECONDS=0
# Repository introspection
OWNER=$(gh repo view --json owner --jq .owner.login)

LiveView Forms

Application.put_env(:sample, Example.Endpoint,
  http: [ip: {127, 0, 0, 1}, port: 5001],
  server: true,
  live_view: [signing_salt: "aaaaaaaa"],
  secret_key_base: String.duplicate("a", 64)
)
@loreanvictor
loreanvictor / RISS.md
Last active March 16, 2024 09:32
Interaction as Content

Can We Get More Decentralised Than The Fediverse?

I guess that the [fediverse][fediverse] will be as decentralised as email: a bit, but not that much. Most people will be dependent on a few major hubs, some groups might have their own hubs (e.g. company email servers), personal instances will be pretty rare. This is in contrast to personal blogging, where every Bob can easily host their own (and they often do). I mean that's already implied by the name: fediverse is [a federated universe, not a distributed one][fed-v-dis].

Why does this matter? Well I like not being dependent on one entity, but I would like it much more if I was dependent on no entities at all. In other words, I like to publish my own personal blog and get all the goodies of a social network, without being dependent on other micro-blogging / social content platforms.

So in this writing, I'm going to:

  • ❓ Contemplate on why the fediverse gets federated not distributed (spoilers: its push vs pull)
  • 🧠 Ideate on how could we get a distri
@siliconjungle
siliconjungle / simple-diff.js
Created December 10, 2023 19:49
Simple diff
// This is a basic diff mechanism, it is not going to work for characters that take up more than
// one byte. It is also not going to normalise text.
// these are things that *should happen* in the future, but for now they are going to be ignored.
// returns the insert position & the text to insert as well as the delete position & the text to delete
// one of the problems with this kind of diff is that you can't tell in some cases where the insert
// actually occurred.
// for this you will need to take into account the cursor start & end.
export const diff = (a, b) => {
if (a === b) {
@RoyalIcing
RoyalIcing / parse_u8.ex
Last active December 2, 2023 01:34
Lemire’s Parsing 8-bit integers quickly in WebAssembly via Orb. https://lemire.me/blog/2023/11/28/parsing-8-bit-integers-quickly/
defmodule ParseU8 do
@moduledoc """
https://lemire.me/blog/2023/11/28/parsing-8-bit-integers-quickly/
"""
# Orb lets you write WebAssembly with friendly Elixir syntax: https://github.com/RoyalIcing/Orb
use Orb
Memory.pages(1)
wasm_mode(U32)
@AndrewIngram
AndrewIngram / CurrentTime.tsx
Created November 21, 2023 00:04
Current time in React without hydration errors
import { Suspense } from "react";
import CurrentTimeClient from "./CurrentTimeClient";
export default function CurrentTime() {
const locale = "en-GB";
const dateConfig = {
hour: "numeric",
minute: "numeric",
second: "numeric",
@whoisryosuke
whoisryosuke / render-frames-and-sleep.js
Created November 7, 2023 20:10
Blender Flamenco - Render Frames and Sleep - Select a series of frames and a sleep duration and it'll render all frames then sleep after. Good for chunking renders and letting PC rest between segments.
// SPDX-License-Identifier: GPL-3.0-or-later
const JOB_TYPE = {
label: "Render and Sleep",
settings: [
// Settings for artists to determine:
{
key: "frames",
type: "string",
required: true,
@adactio
adactio / updateDateTimes.js
Last active September 11, 2023 05:10
Periodically update the text of `datetime` elements with the relative time elapsed.
(function (win, doc) {
'use strict';
if (!doc.querySelectorAll || !win.Intl || !win.Intl.RelativeTimeFormat) {
// doesn't cut the mustard.
return;
}
var rtf = new Intl.RelativeTimeFormat('en', {
localeMatcher: 'best fit',
numeric: 'always',
style: 'long'
@dkun7944
dkun7944 / CDView.swift
Last active January 14, 2024 23:45
SwiftUI + Swift.Shader CD
//
// CDView.swift
// CD
//
// Created by Daniel Kuntz on 7/3/23.
//
import SwiftUI
struct ShapeWithHole: Shape {
@JLarky
JLarky / 00_README.md
Last active December 1, 2023 02:14
useChildFormStatus

Why is useFormStatus always returning pending false?

So you are trying out that new fangled useFormStatus hook but it doesn't actually react to the status of your form?

Now you tried to Google it and all you get is RTFM "go read docs again". Because hook useFormStatus shows you the status of parent form, not a sibling one.

Let's explain that in English.

  • <form><Spinner></form> works
  • `` doesn't