Skip to content

Instantly share code, notes, and snippets.

View yzhong52's full-sized avatar
⌨️
consider multiple solutions, commit on one, and iterate

Yuchen yzhong52

⌨️
consider multiple solutions, commit on one, and iterate
View GitHub Profile
@yzhong52
yzhong52 / main_with_clap.rs
Last active September 17, 2022 15:10
Ascii chord CLI
const FRETBOARD: &str = "◯ ◯ ◯ ◯ ◯ ◯
┌─┬─┬─┬─┬─┐
│ │ │ │ │ │
├─┼─┼─┼─┼─┤
│ │ │ │ │ │
├─┼─┼─┼─┼─┤
│ │ │ │ │ │
└─┴─┴─┴─┴─┘";
use clap::Parser;
@yzhong52
yzhong52 / Cargo.toml
Last active May 9, 2022 02:19
rust_grpc_demo
[package]
name = "rust_grpc_demo"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tonic = "0.7.1"
tokio = { version = "1.18.0", features = ["macros", "rt-multi-thread"] }
@yzhong52
yzhong52 / working_with_json.py
Created September 8, 2021 12:17
Serialize and Deserialize complex JSON in Python
from typing import List
import json
class Student(object):
def __init__(self, first_name: str, last_name: str):
self.first_name = first_name
self.last_name = last_name
@classmethod
def from_json(cls, data):
@yzhong52
yzhong52 / ExampleCommand.py
Created September 6, 2021 14:01
Sublime Text Plugin - ExampleCommand.py
def format(input):
...
class BracketFormatterCommand(sublime_plugin.TextCommand):
def run(self, edit):
whole_region = sublime.Region(0, self.view.size())
text = self.view.substr(sublime.Region(0, self.view.size()))
formatted_text = format(text)
self.view.replace(edit, whole_region, formatted_text)
@yzhong52
yzhong52 / BracketFormatterCommand (part 1).py
Created September 6, 2021 14:01
Sublime Text Plugin - format
import sublime
import sublime_plugin
def format(input):
output = ""
counter = 0
SPACE = ' '
for char in input:
if char in "([{":
counter += 1
@yzhong52
yzhong52 / ExampleCommand.py
Created September 6, 2021 13:51
Sublime Text Plugin - ExampleCommand.py
import sublime
import sublime_plugin
class ExampleCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, 0, "Hello, World!")
@yzhong52
yzhong52 / PurchaseRequest-formatted.log
Last active September 6, 2021 13:49
Sublime Text Plugin - PurchaseRequest Formatted
PurchaseRequest(
itemId: 375,
name: "Spook",
price: Amount(
value: 100,
currency: 'USD'
),
insurancePolicies=[
20931,
12035
@yzhong52
yzhong52 / readme.md
Last active November 28, 2021 08:53
System Design in Layman's Terms - Design a Coffee Shop
  • Client (Customer)
  • Load Balancer (Greeter)
  • Data Center (Coffee Shop)
  • Distributed Message Queue (Bulletin Board w/ Sticky Notes)
    • Producer (Cashier)
    • Consumer (Barista)
  • Database (Ledger Book)
@yzhong52
yzhong52 / readme.md
Created October 30, 2020 20:33
To Kill a Process Using a Port (Mac)

Put this helper funciton in your ~/.zshrc or ~/.bash_profile:

release_port() {
    pid=$(lsof -ti:$1)
    if [ -z $pid ]; then
        echo "Nothing is running on port $1"
    else
        kill $pid
 echo "Killed process on port $1 with pid $pid"