Skip to content

Instantly share code, notes, and snippets.

View sometimescasey's full-sized avatar

Casey Li sometimescasey

View GitHub Profile
@sometimescasey
sometimescasey / mnist_cnn.py
Last active November 18, 2019 12:12
TensorFlow tutorial: Small CNN to process MNIST data
# From instructions at https://www.tensorflow.org/versions/r1.0/get_started/mnist/pros
import argparse
import sys
import tensorflow as tf
import time
from tensorflow.examples.tutorials.mnist import input_data
FLAGS = None
@sometimescasey
sometimescasey / bfs_count_paths.c
Last active July 12, 2018 15:13
CSC263 A3 Q7 - BFS - count shortest paths
/*
Summer 2018
CSC263 Assignment 3 Question 7
We consider undirected graphs (with no weights).
Often there are multiple shortest paths between two nodes of a graph.
Describe a linear-time algorithm such that, given an undirected, unweighted graph
and two vertices u and v, the algorithm counts the number of distinct shortest paths
from u to v. Justify its correctness and the running time.
@sometimescasey
sometimescasey / kbit_rev_permute.c
Last active July 12, 2018 15:18
CSC263 A3 Q4 - kbit reverse permutation
/*
Summer 2018
CSC263 Assignment 3 Question 4
Describe an implementation of the BITREVERSEDINCREMENT procedure on A that allows
the bit-reversal permutation on an n-element array to be performed in time O(n).
Note: compile needs -lm flag for <math.h>:
gcc -Wall -o kbit_rev_permute kbit_rev_permute.c -lm
*/
@sometimescasey
sometimescasey / reachable.c
Last active August 2, 2018 22:53
CLRS 22-4 - minimum reachable
/*
Summer 2018
CSC263 Assignment 4 Question 2
CLRS 22-4
Let G = (V,E) be a directed graph in which each vertex u in V is labeled with
a unique integer L(u) from the set {1, 2, ...|V|}. For each vertex u in V , let
R(u) = {v in V: u has a path to v} be the set of vertices that are reachable from u.
Define min(u) to be the vertex in R(u) whose label is minimum, i.e., min(u) is the vertex v such that L(v) = min{L(w): w in R(u)}. Give an O(V+E) algorithm that
@sometimescasey
sometimescasey / disjoint.h
Last active August 5, 2018 03:59
CLRS 21.3-4: Disjoint set forest with union-by-rank and path compression, plus circular linked-list backwards pointers for printing
/*
CLRS 21.3-4
Suppose that we wish to add the operation PRINT-SET(x), which is given a node x
and prints all the members of x’s set, in any order. Show how we can add just
a single attribute to each node in a disjoint-set forest so that PRINT-SET(x) takes
time linear in the number of members of x’s set and the asymptotic running times
of the other operations are unchanged. Assume that we can print each member of
the set in O(1) time.
*/
@sometimescasey
sometimescasey / offline.c
Last active August 5, 2018 13:13
CLRS Problem 21-1 Offline-Minimum using Disjoint Set Forest w path-compression and union-by-rank
/*
Summer 2018
CSC263 Assignment 4 Question 7
CLRS Problem 21-1, Offline-Minimum
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "disjoint.h"
@sometimescasey
sometimescasey / CUDA_exports.md
Created December 20, 2018 00:05
Quick reminder of how to export CUDA_PATH, CUDA_HOME, and LD_LIBRARY_PATH.

I always forget how to do this on a new system:

export CUDA_PATH=/usr/local/cuda-9.2
export CUDA_HOME=/usr/local/cuda-9.2
export LD_LIBRARY_PATH=/usr/local/cuda-9.2/lib64

@sometimescasey
sometimescasey / screen.md
Last active April 9, 2019 16:22
Screen basics

I always forget the basics of screen:

See what's currently running

screen -ls

Make a new named screen session, do stuff, detach

screen -S nameofsession
@sometimescasey
sometimescasey / aws_new_domain.md
Last active June 24, 2020 14:06
AWS - Route 53, CloudFront, and certificate

Note

This is a note to self of setup steps when purchasing a new domain on Namecheap, pointing its DNS to Route 53, requesting an SSL certificate, and setting up a CloudFront distribution for it to point to an S3 bucket.

1. Point NameCheap domain Custom DNS to Route 53

Create a new hosted zone for the new domain in Route 53. Will be given the correct nameservers to use under record type 'NS'. Add these values in NameCheap under 'Custom DNS'.

2. Request new SSL certificate for example.com and *.example.com

@sometimescasey
sometimescasey / launch.json
Created February 19, 2021 12:07
launch.json for debugging React in VS Code
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch localhost",
"type": "chrome",
"request": "launch",