Skip to content

Instantly share code, notes, and snippets.

View wout's full-sized avatar
🍾

Wout wout

🍾
View GitHub Profile
@wout
wout / rack_sse.ru
Created March 23, 2024 11:10 — forked from raggi/rack_sse.ru
Rack SSE Example
# rack_sse.ru
#
# An example of basic real-time, single-room broadcast chat using Server Sent
# Events in plain old Rack. This example does NOT use hijack, or the async
# hacks, it just relies on a well implemented threaded Rack server (at time of
# writing this will therefore only work with puma!). Other servers should be
# fixed to support this, as it is pretty critical to how Rack *should* work on
# most servers. The only spec-acceptable failure in this case is not flushing
# the content stream on each yield (for which the rack spec has no workaround
# today).
@wout
wout / blurhashDataURL.ts
Created April 11, 2023 16:12 — forked from mattiaz9/blurhashDataURL.ts
Convert blurhash to a base64 DataURL string (no canvas or node-canvas)
import { decode } from "blurhash"
export function blurHashToDataURL(hash: string | undefined): string | undefined {
if (!hash) return undefined
const pixels = decode(hash, 32, 32)
const dataURL = parsePixels(pixels, 32, 32)
return dataURL
}
// x,y is bottom left corner
var Rectangle = function Rectangle(x,y,w,h){
this.x = x;
this.y = y;
this.width = w;
this.height = h;
}
// SOLUTION
var checkIntersect = function checkIntersect(r1,r2) {
@wout
wout / cli.js
Created September 13, 2022 18:27 — forked from mattdesl/cli.js
colour palette from text prompt using Stable Diffusion https://twitter.com/mattdesl/status/1569457645182152705
/**
* General-purpose NodeJS CLI/API wrapping the Stable-Diffusion python scripts.
*
* Note that this uses an older fork of stable-diffusion
* with the 'txt2img.py' script, and that script was modified to
* support the --outfile command.
*/
var { spawn, exec } = require("child_process");
var path = require("path");
@wout
wout / vim-cheats.md
Created August 20, 2022 14:39 — forked from Starefossen/vim-cheats.md
My vim cheat sheet for working with tabs and window splits.

Tabs

New Tab

  • :tabnew - new blank tab
  • :tabedit [file] - open file in tab

Cursor Movement

  • gt (:tabn) - next tab
@wout
wout / haskell-language-extensions.md
Created August 18, 2022 15:58 — forked from mightybyte/haskell-language-extensions.md
A Taxonomy of Haskell Language Extensions

Haskell Language Extension Taxonomy

Caveat: It's just personal opinion, and was written to be a bit provocative and encourage discussion . It is also something that is constantly evolving. Some of the main criteria I used in constructing this taxonomy are age, how widely used it us, and how well understood it is by the average Haskell programmer. These things will change over time.

Aso, this is focused on appropriateness for use in commercial production code bases. If you are not thinking about commercial use with a team of multiple

@wout
wout / keychron K3.md
Created July 25, 2022 14:08 — forked from aleixmorgadas/keychron K3.md
Keychron K3 Linux

DendroRithms App Structure

Introduction

The app is written in Crystal using Lucky Framework (https://luckyframework.org/). It's a batteries-included web framework that makes heavy use of compile-time checks. As a result, it's very helpful in tracking errors and catching bugs even before the app reaches runtime.

Lucky is also extremely fast compared to similar frameworks written in other programming languages. The following benchmark illustrates it well:

https://www.techempower.com/benchmarks/#section=data-r20&hw=ph&test=plaintext&l=zdk2rj-sf&f=zik06v-zik073-zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-yelngf-cn3

Structure

@wout
wout / WebhookTutorial.md
Created December 19, 2021 12:54 — forked from jagrosh/WebhookTutorial.md
Simple Webhook Tutorial (Twitter -> Discord)

Simple Webhook Tutorial

In this tutorial, I will be explaining how to set up a simple webhook to relay your tweets to a Discord channel

Step 1 - Register on Zapier

  1. Go to https://zapier.com/ and create an account (if you don't already have one).

Step 2 - Make a Discord Webhook

  1. Find the Discord channel in which you would like to send Tweets
@wout
wout / SublimeText-Project-Line-Count
Created December 11, 2021 15:59 — forked from halcarleton/SublimeText-Project-Line-Count
Count total lines of code in a Sublime Text Project or Directory
Go to menu:
Find -> Find in Files... (windows: ctrl+shift+f)
Switch on reg_ex button (windows: alt+r)
Find:
^.*\S+.*$
Where:
c:\your_folder\,*.php,*.js,*.inc,*.html,*.htm,*.scss, -*/folder_to_exclude/*, -*.min.js