Skip to content

Instantly share code, notes, and snippets.

View chanyeinthaw's full-sized avatar
:shipit:
Whatcha Watchin'?

Chan Nyein Thaw chanyeinthaw

:shipit:
Whatcha Watchin'?
View GitHub Profile
[
{
"country": "AD",
"en_name": "Andorra",
"native_name": "Andorra",
"locales": "ca"
},
{
"country": "AE",
"en_name": "United Arab Emirates",
@chanyeinthaw
chanyeinthaw / event-handler.ts
Created January 28, 2025 15:46 — forked from lucas-barake/event-handler.ts
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];
@chanyeinthaw
chanyeinthaw / useSearchParams.ts
Created November 13, 2023 07:31
useSearchParams
import {
useSearchParams as next_useSearchParams,
useRouter,
} from 'next/navigation'
import { useMemo } from 'react'
import { z } from 'zod'
export function getDefaults<Schema extends z.AnyZodObject>(
schema: Schema,
): z.TypeOf<Schema> {
@chanyeinthaw
chanyeinthaw / createEnum.ts
Created August 22, 2023 16:09
A wrapper around Zod Enum with the ability to define custom labels and values.
import { ZodEnum } from 'zod'
type TStringArray = [string, ...string[]]
type TIndexedObject<T extends TStringArray, V = string> = {
[key in T[number]]: V
}
export const createEnum = <T extends TStringArray>(
zEnum: ZodEnum<T>,
labels?: TIndexedObject<T>

Disabling GNOME Tracker and Other Info

GNOME's tracker is a CPU and privacy hog. There's a pretty good case as to why it's neither useful nor necessary here: http://lduros.net/posts/tracker-sucks-thanks-tracker/

After discovering it chowing 2 cores, I decided to go about disabling it.

Directories

@chanyeinthaw
chanyeinthaw / gist:b990fd1db321bf4bfef74eec4d794462
Created January 27, 2021 18:09 — forked from jatcwang/gist:ae3b7019f219b8cdc6798329108c9aee
List of all setxkbmap configuration options (including models/layout/etc)
! model
pc101 Generic 101-key PC
pc102 Generic 102-key (Intl) PC
pc104 Generic 104-key PC
pc105 Generic 105-key (Intl) PC
dell101 Dell 101-key PC
latitude Dell Latitude series laptop
dellm65 Dell Precision M65
everex Everex STEPnote
flexpro Keytronic FlexPro
@chanyeinthaw
chanyeinthaw / partition.js
Last active August 22, 2023 16:14
Floor partition finder
const input = [
[1, 0, 1, 0],
[0, 1, 0, 1],
[1, 0, 1, 0],
[0, 1, 0, 1]
]
const input1 = [
[1, 0, 0, 0],
[0, 1, 1, 0],
@chanyeinthaw
chanyeinthaw / ssh-copy-id.ps1
Created October 14, 2019 12:43
SSH copy id script
param(
[Parameter(Mandatory=$true)][string]$id,
[Parameter(Mandatory=$true)][string]$hostn
)
cat $id | ssh $hostn "cat >> ~/.ssh/authorized_keys"
@chanyeinthaw
chanyeinthaw / idx.py
Created June 28, 2019 05:09
IDX ubyte Reader and Writer
import struct as st
import functools
import numpy as np
class Writer:
def __init__(self, file_name: str, num_dimensions: int):
self.file = open(file_name, 'wb')
self.num_dimensions = num_dimensions
@chanyeinthaw
chanyeinthaw / ubyte2csv.py
Created June 27, 2019 05:35
mnist idx3 to csv Converter
import struct as st
import argparse as ap
def ubyte2csv(images, labels, out_images, out_labels):
f = open(images, "rb")
o = open(out_images, "w")
ol = open(out_labels, "w")
l = open(labels, "rb")