This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Yong Bakos | |
# A Python implementation of the Hack VM Translator. Whee! | |
import sys | |
import os | |
class Translator: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float theta = 0.0; | |
void setup() { | |
size(750, 300, P3D); | |
} | |
void draw() { | |
background(33); | |
stroke(0); | |
fill(200); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void drawTriangles(int size) { | |
beginShape(TRIANGLES); | |
fill(150, 0, 0, 127); | |
vertex(-size, -size, -size); | |
vertex(size, -size, -size); | |
vertex(0, 0, size); | |
fill(0, 150, 0, 127); | |
vertex(size, -size, -size); | |
vertex(size, size, -size); | |
vertex(0, 0, size); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Learning Processing Exercise 16-7. Finding the average location of motion, indicated with a circle. | |
import processing.video.*; | |
Capture video; | |
PImage previousFrame; | |
final float THRESHOLD = 100.0; | |
void setup() { | |
size(640, 480); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// YOUR NAME | |
// Homework 23: ArrayList of Pyramids. | |
final int NUMBER_OF_PYRAMIDS = 100; | |
Pyramid[] pyramids; | |
void setup() { | |
size(displayWidth, displayHeight, P3D); | |
pyramids = new Pyramid[NUMBER_OF_PYRAMIDS]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TIP: Nothing needs to change in this class in order to meet | |
// the assignment requirements. But feel free... | |
class Pyramid { | |
int x; | |
int y; | |
int size; | |
float theta; | |
float rotationSpeed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Hack Assembler!" | |
def args_valid? | |
ARGV[0] && ARGV[0].end_with?(".asm") && File.file?(ARGV[0]) | |
end | |
abort("Usage: ruby assembler.rb filename.asm") unless args_valid? | |
class Assembler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@dest = { | |
nil => 0, | |
'M' => 1, | |
'D' => 2, | |
'MD' => 3, | |
'A' => 4, | |
'AM' => 5, | |
'AD' => 6, | |
'AMD' => 7 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Assembler | |
attr_accessor :instructions | |
def initialize(asm_commands) | |
@asm_commands = asm_commands | |
@instructions = [] | |
@symbol_table = {} | |
@instruction_address = 0 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative './code' | |
class String | |
def is_numeric? | |
true if Float(self) rescue false | |
end | |
end | |
puts "Hack Assembler!" |