Skip to content

Instantly share code, notes, and snippets.

View kevinzhang96's full-sized avatar

Kevin Zhang kevinzhang96

View GitHub Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@kevinzhang96
kevinzhang96 / cs121.tex
Created September 21, 2015 00:27
LaTeX Finite Automata
\usepackage{tikz}
\begin{center}
\begin{tikzpicture}[scale=0.2]
\tikzstyle{every node}+=[inner sep=0pt]
\draw [black] (15.7,-9.8) circle (3);
\draw (15.7,-9.8) node {$q_0$};
\draw [black] (15.7,-9.8) circle (2.4);
\draw (11.7, -8.8) -- (12.7, -9.8) -- (11.7, -10.8);
\end{tikzpicture}
@kevinzhang96
kevinzhang96 / mux v2.v
Created September 25, 2015 04:37
CS141 16:1 Multiplexer
`timescale 1ns / 1ps
`default_nettype none //helps catch typo-related bugs
//////////////////////////////////////////////////////////////////////////////////
//
// CS 141 - Fall 2015
// Module Name: mux
// Author(s): Kevin Zhang
// Description: 16:1 multiplexer
//
//
@kevinzhang96
kevinzhang96 / io61_write.c
Created October 16, 2015 22:49
IO61 Write Function
// io61_write(f, buf, sz)
// Write `sz` characters from `buf` to `f`. Returns the number of
// characters written on success; normally this is `sz`. Returns -1 if
// an error occurred before any characters were written.
ssize_t io61_write(io61_file* f, const char* buf, size_t sz) {
size_t nleft = sz;
int buf_pos = 0;
// continue writing until done
@kevinzhang96
kevinzhang96 / id_rsa.pub
Created October 20, 2015 02:07
Macbook Pro 10/19/15 RSA Public Key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDG592AmpyEVvSX4z0uDPtnh0vFgEsGn8T2xeVFAvoDIphdDajPzTup0IOeVMzHYMCbqh2EfgE4Vr0X0a5yDha/yOm0P7v+SDdHwxp0dUUY3at3ZirN+b3chUO88RK+7Axql98K8nIFPjUOw1M/+1DOb7HN3ASkXQgtzwPPKFHRSbLySqmN+tBQ39z0LtPcpxpQIzASjQrgu07DT1iEXp/N+2/YPOy8FhUBf7+c+snX4DhyfzSzZMNqPtwoddgwpqWfN5VStR16Vln8ZIajdwAh5xHU1K+O1tzZYaZwChhUfowjfqf8OZYjIdh/KmLLAi9L2svaD1fJUbqzJ1h/BuOj [email protected]
@kevinzhang96
kevinzhang96 / codes.py
Created November 3, 2015 09:27
MIPS Assembler OP/FUNC codes and register encodings
rtypes = [
# List of all R-type instructions.
"sll", "srl", "sra", "sllv", "srlv", "srav", # shifts
"jr", "jalr", # jumps
"syscall", "break", # system
"mfhi", "mthi", "mflo", "mtlo", # move to
"mult", "multu", "div", "divu", # mult/div
"add", "addu", "sub", "subu", # add/sub
"and", "or", "xor", "nor", # bitwise
"slt", "sltu" # set less than
@kevinzhang96
kevinzhang96 / syscall.txt
Created November 6, 2015 09:31
Shell redirection system calls
echo foo > output.txt
open("output.txt", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
echo foo < output.txt
open("output.txt", O_RDONLY|O_LARGEFILE) = 3
echo foo 2> output.txt
open("output.txt", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
@kevinzhang96
kevinzhang96 / (pseudo)code.txt
Created November 7, 2015 23:52
Approximate stop frequency of movement using strided averages
keep track of up to last 3 stops
each time we stop, take average of last 3 times of stops; invert and that’s the BPM
double x[NUMBER];
double y[NUMBER];
long times[NUMBER];
long last[3] = {0};
double last_dist = UDOUBLE_MAX;
int curr_last = 0;
@kevinzhang96
kevinzhang96 / app.js
Created November 8, 2015 11:55
Node.js app file for YHack15, party-mode app
var express = require('express');
var app = express(); var app = express();
+var http = require('http').Server(app);
+var io = require('socket.io')(http);
app.use(express.static(__dirname + '/public')); app.use(express.static(__dirname + '/public'));
app.listen(process.env.PORT || 3000); app.listen(process.env.PORT || 3000);
+http.listen(3001, function(){
@kevinzhang96
kevinzhang96 / main.js
Created November 8, 2015 11:59
Script for parsing BPM
var audioobj = document.getElementsByTagName("audio")[0];
// var text = document.getElementById("text");
var actualBPM;
var request = new XMLHttpRequest();
console.log("Audio source: " + audioobj.src);
request.open('GET', audioobj.src, true);
request.responseType = 'arraybuffer';
var targetspd = 1;
request.onload = function() {