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 / gitcom.md
Last active May 31, 2023 08:23
Common git commands in a day-to-day workflow

Git Cheat Sheet

Initial Setup

Create an empty git repo or reinitialize an existing one

git init
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
export PATH="/usr/local/opt/python/bin:$PATH"
export GPG_TTY=$(tty)
# export START="$HOME/a"
# if [[ $PWD == $HOME ]]; then
# cd $START
# fi
# alias ls='ls -F --color --show-control-chars'
@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 / EventEmitter.test.ts
Last active October 21, 2022 10:52
TypeScript Polling / Event Emitter
import { noop } from 'lodash';
import EventEmitter from './EventEmitter';
describe('EventEmitter class', () => {
describe('on()', () => {
it('subscribes to foo event with listener', () => {
const e = new EventEmitter();
e.on('foo', noop);
@jednano
jednano / AddToCartFormWithHooks.tsx
Last active June 24, 2022 10:11
React Hooks and Render Props in TypeScript
import { FC, useCallback } from 'react'
import { connect } from 'react-redux';
import addToCart from '../actions/cart'
import useAddToCart, { UseAddToCartOptions } from './useAddToCart'
interface DispatchProps {
onSubmit(options: UseAddToCartOptions): Promise<void>,
}
@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: