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 / .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
@jednano
jednano / onAddToCart.js
Last active August 27, 2019 21:20
TypeScript vs. JavaScript
// @ts-check
/**
* @typedef {{ items: Array<CartItem> }} Cart
* @typedef {{
* sku: string,
* name: string,
* price: number,
* color?: Color,
* size?: Size,