Skip to content

Instantly share code, notes, and snippets.

View jednano's full-sized avatar
💾
Writing codes

Jed jednano

💾
Writing codes
  • Austin, TX
View GitHub Profile
@jednano
jednano / pinyin-syllables.js
Last active September 19, 2024 01:37
Pinyin Syllables
const pinyinSyllablesWithToneGroups = [
// Syllables with no initial
'(a)', '(a)i', '(a)n[134]', '(a)ng[124]', '(a)o[134]', '(e)[124]', '(e)i', '(e)n[1]', '(e)r[24]', '(o)[14]', '(o)u[124]',
// Syllables with initials
'b(a)', 'b(a)i[124]', 'b(a)n[134]', 'b(a)ng[134]', 'b(a)o', 'b(e)i', 'b(e)n[134]', 'b(e)ng[134]', 'b(i)', 'bi(a)n', 'bi(a)o[124]', 'bi(e)[4]', 'b(i)n[14]', 'b(i)ng[134]', 'b(o)', 'b(u)',
'p(a)', 'p(a)i', 'p(a)n', 'p(a)ng', 'p(a)o', 'p(e)i', 'p(e)n', 'p(e)ng', 'p(i)', 'pi(a)', 'pi(an)', 'pi(ao)', 'pi(e)', 'p(i)n', 'p(i)ng', 'p(o)', 'p(u)',
'm(a)', 'm(a)i', 'm(a)n', 'm(a)ng', 'm(a)o', 'm(e)i', 'm(e)n', 'm(e)ng', 'm(i)', 'mi(a)', 'mi(an)', 'mi(ao)', 'mi(e)', 'm(i)n', 'm(i)ng', 'm(o)', 'm(ou)', 'm(u)',
'f(a)', 'f(a)n', 'f(a)ng', 'f(e)i', 'f(e)n', 'f(e)ng', 'f(o)', 'f(ou)', 'f(u)',
'd(a)', 'd(a)i', 'd(a)n', 'd(a)ng', 'd(a)o', 'd(e)', 'd(e)i', 'd(e)n', 'd(e)ng', 'd(i)', 'di(a)', 'di(an)', 'di(ao)', 'di(e)', 'd(i)n', 'd(i)ng', 'd(iu)', 'd(o)ng', 'd(o)u', 'd(u)', 'du(a)', 'du(an)', 'd(u
@jednano
jednano / .github__workflows__python_tests.yml
Last active January 27, 2024 04:36
Protobuf types in Python
name: Python Test
on:
push:
branches:
- main
pull_request:
branches:
- main
@jednano
jednano / summate.py
Last active October 28, 2022 04:43
Summation (i.e., ∑)
from functools import reduce
def summate(startingAt, endingWith, callback):
"""
Returns the sum of the result values of `callback` starting at `startingAt` and ending with `endingWith`.
Example: sigma(1, 6, lambda n: 3 * n)
See: https://replit.com/@jedmao/SuperSigma#main.py
"""
return sum([callback(x) for x in range(startingAt - 1, endingWith + 1)])
@jednano
jednano / classification_metrics.py
Last active October 26, 2022 22:57
Classification Metrics
# TP = True Positive
# TN = True Negative
# FP = False Positive
# FN = False Negative
def precision(TP, FP):
return TP / (TP + FP)
def recall(TP, FN):
return TP / (TP + FN)
@jednano
jednano / usePrismaClientOnce.ts
Created April 5, 2021 20:45
Use Prisma Client Once
class PrismaClient {
#used = false;
/**
* Indicates whether `useOnce` has already been called.
*/
public get used() {
return this.#used;
}
@jednano
jednano / README.md
Last active February 1, 2021 00:23
How to npm

How to npm

Before you can use the npm command, you'll need to install [Node.js][].

Installation

You can install [Node.js][] directly or to manage multiple versions, try Volta!

Local usage (recommended)

@jednano
jednano / keybase.md
Created June 17, 2020 16:01
keybase.md

Keybase proof

I hereby claim:

  • I am jedmao on github.
  • I am jedmao (https://keybase.io/jedmao) on keybase.
  • I have a public key ASA7BpF6w9OoKvLe-RIf_anWdjJFBXsYAEPV9yw8cSgctgo

To claim this, I am signing this object:

@jednano
jednano / transform.ts
Created April 8, 2020 00:29
TypeScript Transformer
import { readFile as _readFile } from 'fs';
import * as ts from 'typescript';
import { promisify } from 'util';
const readFile = promisify(_readFile);
transform('input.ts');
async function transform(filename: string) {
const sourceFile = ts.createSourceFile(
@jednano
jednano / grammar.pegjs
Last active October 28, 2019 15:14
EditorConfig Grammar
Document = _ children:(Newline / Comment / Rule)* _ sections:Section* _ {
return {
type: 'EditorConfig',
version: '15.0.0',
children: children.concat(sections),
}
}
_ 'whitespace' = [ \t\n\r]*
@jednano
jednano / redux.ts
Created September 4, 2019 22:47
Redux TS
/** Essentials */
export type Primitive = string | number | boolean | bigint | symbol | undefined | null;
/** Like Readonly but recursive */
export type DeepReadonly<T> = T extends Primitive
? T
: T extends Function
? T
: T extends Date
? T