Skip to content

Instantly share code, notes, and snippets.

@kimbochen
kimbochen / dev_workflow.md
Last active September 30, 2024 15:52
CS 203 Jupyter notebook development workflow explanation.

Development Workflow

  • Login to Datahub and setup ssh key (00:00):
    • Data Hub
    • Generate a new SSH Key: ssh-keygen -t ed25519 -C "your_email@example.com"
    • Start the SSH Agent: eval "$(ssh-agent -s)"
    • Add the private key to the agent: ssh-add ~/.ssh/id_ed25519
    • Copy the public key: cat ~/.ssh/id_ed25519.pub
    • Add the public key to GitHub (GitHub settings page)
    • Check: ssh -T git@github.com
@kimbochen
kimbochen / Asmt 2 Diagram Gen.ipynb
Created February 1, 2023 22:35
CS 201 Assignment 2 - Generating Diagrams with Graphviz
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kimbochen
kimbochen / topo_sort.py
Created July 2, 2022 08:42
Topological sorting algorithm in Python.
from collections import defaultdict, deque
def topo_sort(n_nodes, edges):
# Organize info from edges:
# 1. In degree of each node
# 2. Out nodes of each nodes
in_degree = dict.fromkeys(range(n_nodes), 0)
out_nodes = defaultdict(set)
@kimbochen
kimbochen / rrun.sh
Created April 7, 2022 05:22
A simple Docker run command.
#!/usr/local/bin/bash -e
rust_env()
{
docker run --rm \
-v $PWD:/app -w /app rust:latest \
$1
}
rust_env "rustc $1.rs"
@kimbochen
kimbochen / docker-compose.yml
Created February 27, 2022 11:17
Trying out Docker
version: "3.7"
services:
app:
image: rust
container_name: hello-rust
working_dir: /app
volumes:
- ./:/app
stdin_open: true
@kimbochen
kimbochen / autograd.md
Last active February 27, 2022 11:12
An autograd engine that only supports single-variable scalar functions.

Autograd

This is a didactic version of Autograd based on Doug Maclaurin's Ph.D. Thesis. Only single-variable scalar functions are supported.

Constructing a Node

  • Input:

x = Node(value=3.9)

@kimbochen
kimbochen / grid_world.py
Created January 23, 2022 07:24
A simple example of the reinforcement learning algorithm, value iteration.
import sys
from collections import namedtuple
from enum import Enum
grid = [
'...#...O',
'.###..X.',
'...#....',
'.X......',
@kimbochen
kimbochen / linreg.py
Last active January 23, 2022 07:24
Linear regression
from pdb import set_trace as st
import torch
import numpy as np
import pandas as pd
from torch import nn, optim
from torch.utils.data import Dataset, DataLoader
DEVICE = 'cuda:1'
torch.manual_seed(3985)