Skip to content

Instantly share code, notes, and snippets.

View jlliu's full-sized avatar

Jackie Liu jlliu

View GitHub Profile
validInputs = ['0','1','2'];
spaceStates = {
"blank": '___',
"X": '_X_',
"O": '_O_'}
#Checks for a win based on what player you are and where you just made a move
def checkForWin(board,xPos,yPos,currentPlayer):
intendedState = spaceStates[currentPlayer]
return (
@jlliu
jlliu / modifications.js
Created December 9, 2019 19:43
3d "icing" drawing
//------------------in Graphics.js
// Calculates angle between two 2d vec
function calculateAngle(u,v){
return Math.acos((u[0]*v[0]+u[1]*v[1])/(magnitude(u)*magnitude(v)));
}
//Calculates magnitude
function magnitude(vec){
var magnitude = 0;
@jlliu
jlliu / using-obj.js
Created December 8, 2019 18:12
How to use obj files with webgl-bj-loader.js
//Step 1: Import js file into the head of index.html:
<script src="https://cdn.jsdelivr.net/npm/webgl-obj-loader@2.0.6/dist/webgl-obj-loader.min.js"></script>
//Step 2: Download any OBJ files and copy the contents of each one as a variable in the JS code (use a separate file for neatness)
var starData = `
# Blender v2.69 (sub 0) OBJ File: '20facestar.blend'
# www.blender.org
mtllib 20facestar.mtl
o Mesh_Mesh.015
v 0.951056 0.000000 0.309017
@jlliu
jlliu / parsePackets.py
Created October 24, 2019 20:09
Parse Packets from Wireshark's CSV export
## This is a Python program to parse packets from a Wireshark CSV export
import csv
import operator
networkIPgroup = "PUT THE BEGINNING PART OF YOUR PRIVATE NETWORK IP HERE: e.g. XXX.XXX.1. "
myComputer = "Name of your device, either your IP or the name spit out by Wireshark's name resolution"
devices = [myComputer]
@jlliu
jlliu / watch.ino
Last active February 25, 2019 04:03
int motorPin = 9;
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <stdio.h>
#include <elapsedMillis.h>
#include "Adafruit_MPRLS.h"