Skip to content

Instantly share code, notes, and snippets.

View andrinheusser's full-sized avatar
🦕

Andrin Heusser andrinheusser

🦕
View GitHub Profile
@lucas-barake
lucas-barake / event-handler.ts
Last active August 10, 2025 08:05
How I Handle WebSockets in Web Apps
import { Effect, type Schema } from "effect";
export type EventHandler<A, I, X> = {
readonly channel: `/${string}/`;
readonly schema: Schema.Schema<A, I>;
readonly handle: (data: A) => Effect.Effect<void, X, never>;
};
export type InfallibleEventHandler<A, I> = {
[K in keyof EventHandler<A, I, never>]: EventHandler<A, I, never>[K];
@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

@TomyJaya
TomyJaya / spring-data-rest-notes.md
Last active August 13, 2025 22:52
Spring Data REST - Useful notes

How To change baseUri:

in application.properties add:

spring.data.rest.basePath=/api
  • or -

in application.yml add:

@rauchg
rauchg / README.md
Last active April 13, 2025 04:29
require-from-twitter
@levymetal
levymetal / functions.php
Last active November 1, 2022 02:43
Custom adaptation for my sub-menu script that allows you to force a specific sub-menu to be displayed. Full documentation here: http://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/
<?php
/* usage
*
* wp_nav_menu( array(
* 'theme_location' => 'primary',
* 'sub_menu' => true,
* 'root_id' => id_of_menu_item
* ) );
*/
@miratcan
miratcan / fix_database_to_utf8.py
Last active August 31, 2023 00:06
Small python script that converts character sets to utf8 in all databases and tables. My solution for "Illegal mix of collations" errors. (http://stackoverflow.com/questions/3029321/how-to-solve-illegal-mix-of-collations-in-mysql)
from MySQLdb import connect
conn = connect(user="[USER]", passwd= "[PASSWORD]")
cur = conn.cursor()
cur.execute("show databases;")
dbs_to_update = filter(
lambda db: db not in ('information_schema', 'mysql', 'performance_schema'),
[dbname[0] for dbname in cur.fetchall()])
@kucrut
kucrut / nav-menu-item-custom-fields.php
Created September 29, 2012 15:39 — forked from westonruter/nav-menu-item-custom-fields.php
Proof of concept for how to add new fields to nav_menu_item posts in the WordPress menu editor.
<?php
/**
* Proof of concept for how to add new fields to nav_menu_item posts in the WordPress menu editor.
* @author Weston Ruter (@westonruter), X-Team
*/
add_action( 'init', array( 'XTeam_Nav_Menu_Item_Custom_Fields', 'setup' ) );
class XTeam_Nav_Menu_Item_Custom_Fields {
static $options = array(