Skip to content

Instantly share code, notes, and snippets.

View jameslzhu's full-sized avatar

James Zhu jameslzhu

View GitHub Profile
@jameslzhu
jameslzhu / voxel_circle.cpp
Created November 17, 2013 21:17
Outputs a pixelated circle to the console. Useful for graphics or Minecraft.
#include <iostream>
#include <vector>
#include <array>
typedef std::array<float, 2> xyCoord;
float isInCircle(float x, float y, float radius);
void setSquareCoords(int row, int column, std::array<xyCoord, 4>& square);
int main()
@jameslzhu
jameslzhu / blackjack.js
Created December 21, 2013 04:26
A simple JavaScript blackjack game, coded as part of a Codecademy course. The player can "hit" and be dealt another card, or "stop". The player plays against a computer opponent. Highest hand 21 and under wins.
function Card(s, n) {
var suit = s;
var number = n;
this.getNumber = function() {
return number;
};
this.getSuit = function() {
return suit;
};
this.getValue = function() {
@jameslzhu
jameslzhu / galaxy.py
Last active January 22, 2020 18:09
Galaxy collision simulator, written with VPython.
#!/usr/bin/env python2
#
# galaxy - jzhu98
# See bottom for LICENSE.
#
from __future__ import division
from math import fsum
from random import gauss
@jameslzhu
jameslzhu / chaos.py
Last active December 6, 2016 20:57
Brownian motion simulator, written with VPython.
#!/usr/bin/env python2
#
# chaos - jzhu98
# See bottom for license.
#
from __future__ import division
from enum import Enum
@jameslzhu
jameslzhu / Fractran.py
Last active August 29, 2015 14:12
The FRACTRAN program, as described in HSCTF 2014.
# FRACTRAN - jzhu98
# See bottom for license.
from fractions import Fraction
# Input FRACTRAN code here
code = "455/33,11/13,1/11,3/7,11/2,1/3"
def parse_input(string):
"""Return a list of fractions from the code."""
@jameslzhu
jameslzhu / recrop16-9.sh
Created June 1, 2016 16:25
Recrops images to 16:9 resolution, either in 1080p (1920 x 1080), 1440p (2560 x 1440) or 4K (3840 x 2160).
/#!/usr/bin/bash
# Recrops images in working directory to 16:9 resolution.
# Picks the smallest resolution which fits the image with minimal cropping.
OUTPUT_DIR="recropped"
EXT="jpg"
mkdir -p "$OUTPUT_DIR"

Keybase proof

I hereby claim:

  • I am jameslzhu on github.
  • I am jzhu (https://keybase.io/jzhu) on keybase.
  • I have a public key ASDr_JqMh89-_K9jO02VgOoA5wiYf1zZQcFAQ5VJugCVIAo

To claim this, I am signing this object:

#include<math.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define LED_PIN 0
#define NUM_LEDS 60
#define BRIGHTNESS 127
# .gitconfig - jameslzhu
[user]
name = James Zhu
email = jameszhu@berkeley.edu
[core]
editor = vim
autocrlf = input
filemode = false