Skip to content

Instantly share code, notes, and snippets.

@khalidx
khalidx / node-typescript-esm.md
Last active October 18, 2025 09:49
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

@mcrumm
mcrumm / phx_sqlite_fly_launch.md
Last active October 9, 2025 12:37
Phoenix + SQLite Deployment tips

Deploying to Fly.io with SQLite

Deploying a Phoenix app to Fly.io is a breeze...is what everyone kept telling me. In fairness, I imagine the process would have been breezier had I just used postgres, but all the sqlite and litestream talk has been far too intriguing to ignore. "Wait", you say. "It is just a flat file. How much harder can it be?"

It is easy to make something harder than it should be. It is hard to take something complex and make it truly simple. flyctl launch does an amazing job at providing a simple interface to the utterly complex task of generating deployment resources, especially now that we are living in a containerd (erm, firecracker) world.

This gist is for anyone who, like me, thinks they know better than to read all of the documentation and therefore necessari

@iosifnicolae2
iosifnicolae2 / Readme.md
Last active October 2, 2025 11:50
Youtube is Boring

How To Make Youtube Less Boring

Tutorial: https://www.youtube.com/watch?v=hIqMrPTeGTc
Paste the below code in your browser console (F12 > Console):

(()=>{
    markAllVideosAsNotBeingInteresting({
        iterations: 1
    });
})();
@mkornatz
mkornatz / cf-worker.js
Last active July 25, 2025 08:27
Cloudflare Workers CORS Proxy (supports websockets)
// We support the GET, POST, HEAD, and OPTIONS methods from any origin,
// and allow any header on requests. These headers must be present
// on all responses to all CORS preflight requests. In practice, this means
// all responses to OPTIONS requests.
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,HEAD,POST,OPTIONS",
"Access-Control-Max-Age": "86400",
}
@arkadiyk
arkadiyk / rich_text_component_for_surfaceui_phoenix_liveview.md
Last active April 24, 2025 20:18
Super simple Rich Text Editor SurfaceUI Component ( Elixir / Phoenix / LiveView )

Super simple Rich Text Editor SurfaceUI Component ( Elixir / Phoenix / LiveView )

I have created a library based on the below snippets: https://github.com/arkadiyk/surface_rich_components

Component

defmodule Components.TextEditor do
  use Surface.Component
@samwillis
samwillis / y-pouchdb.ts
Last active April 16, 2025 17:04
(Alpha) PouchDB integration for Yjs
import * as Y from 'yjs'
import * as mutex from 'lib0/mutex.js'
import { Observable } from 'lib0/observable.js'
import PouchDB from 'pouchdb';
// This is the name of the top level Y.Map that is used to construct the main pouchDB
// JSON document.
const topDataYMapName = 'data';
@Hakky54
Hakky54 / openssl_commands.md
Last active November 13, 2025 12:38 — forked from p3t3r67x0/openssl_commands.md
OpenSSL Cheat Sheet

OpenSSL Cheat Sheet 🔐

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl
@tim-field
tim-field / useRouter.js
Last active June 23, 2023 01:20
Hooks Router
import { useEffect, useState } from "react"
import { createBrowserHistory } from "history"
const history = createBrowserHistory()
const toLocation = path => new URL(path, window.location.href)
// without this react won't re-render as location is the same object
// @see https://reactjs.org/docs/hooks-reference.html#bailing-out-of-a-state-update
const cloneLocation = () => Object.assign({}, window.location)
@searls
searls / forward-events.js
Last active May 29, 2018 12:37
A handy way to forward global-ish events to functional components (Preact)
/* Was looking for a way to delegate global keyboard shortcuts in an app to small
* Preact components in a way that didn't require any of:
* • Binding and unbinding events on ancestor nodes by a component's render function
* • Calling a function from a render function to try to manage/track that event-binding state for me
* • Require me to adopt class-ey components for only this feature (binding and unbinding an out-of-scope event using lifecycle hooks)
*/
const FORWARDING_RULES = [
{node: document, event: 'keydown', test: e => e.keyCode === 13, delegate: '.handle-enter'}
]
@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