Skip to content

Instantly share code, notes, and snippets.

View hawkw's full-sized avatar
🛠️
recently edited these files

Eliza Weisman hawkw

🛠️
recently edited these files
View GitHub Profile
@hawkw
hawkw / realgooderrorhandling.java
Last active December 13, 2015 17:09
How to Error Handling Real Good
catch (Exception e) {
// meh
}
@hawkw
hawkw / empty().java
Created March 31, 2013 18:16
this works real good you guys!
public E peek () throws EmptyStackException {
if (empty())
throw new EmptyStackException();
return stack[top];
}
public E pop () throws EmptyStackException {
if (empty())
throw new EmptyStackException();
E element = stack[top];
@hawkw
hawkw / empty.java
Created April 3, 2013 14:15
what's wrong with this picture?
public E peek () throws EmptyStackException {
if (empty())
throw new EmptyStackException();
return stack[top];
}
public E pop () throws EmptyStackException {
if (empty())
throw new EmptyStackException();
E element = stack[top];
@hawkw
hawkw / eval.java
Last active December 16, 2015 08:39
awful gross method got awfuller and grosser
/**
* Evaluates the command at the program counter.
*/
public void eval() {
int currentInstruction = ram[counter.getModule()][counter.getIndex()];
int tempA = 0x00000000;
int tempB = 0x00000000;
short address = 0x0000;
@hawkw
hawkw / Cerealizable.java
Created April 28, 2013 17:07
mmm, delicious serial
import java.io.Serializable;
public interface Cerealizable extends Serializable {
// Mmm, delicious serial
}
@hawkw
hawkw / Eclipse, nooooooo.java
Last active December 16, 2015 18:28
a classic example of Eclipse trying to make code more readable and actually making it uglier
// compare this...
while (!instructionCompileStack.empty()) {
if (getReqArgs(instructionCompileStack.peek()) == 1) {
currentInstruction = Byte
.parseByte(instructionCompileStack.pop());
currentAddress = Byte.parseByte(instructionCompileStack
.pop());
engine.fillRAM(wordBuilder(currentInstruction,
currentAddress));
} else if (getReqArgs(instructionCompileStack.peek()) == 0) {
@hawkw
hawkw / oh my god it's full of loops.java
Last active December 16, 2015 20:29
I feel bad that I wrote this. Also featuring a sad attempt at injecting comments into terrible code.
while (!filterQueue.empty()) {
// if we find a comment-closing character...
if (filterQueue.front().contains("(")) {
// ...pop until we find a comment character
while (!filterQueue.empty()
&& !filterQueue.front().contains(")")) {
filterQueue.dequeue();
}
if (!filterQueue.empty())
filterQueue.dequeue();
@hawkw
hawkw / crash-2013-06-12_13.11.28-client.txt
Last active December 18, 2015 10:19
ExtraBees/Forestry 2.2.7.10b crashlog.
---- Minecraft Crash Report ----
// This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]
Time: 6/12/13 1:11 PM
Description: Failed to start game
java.lang.ArrayIndexOutOfBoundsException: 4
at binnie.extrabees.genetics.EnumExtraBeeSpecies.registerItemIcons(EnumExtraBeeSpecies.java:1215)
at forestry.apiculture.items.ItemBeeGE.func_94581_a(ItemBeeGE.java:126)
at net.minecraft.client.renderer.texture.TextureMap.func_94247_b(TextureMap.java:85)
@hawkw
hawkw / MIPSCodeGen.c
Last active December 30, 2015 09:39
Tell me what's wrong with my program. See instructions.md for further instructions.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "MIPSCodeGen.h"
/*
* lineCount(): returns the number of lines in a file.
*/
int lineCount (FILE *target) {
@hawkw
hawkw / toomuchcoffee.c
Created December 5, 2013 21:47
actual source code comment that I actually wrote (I am sorry)
/*
* Generates semi-optimizing moves for the MarsBot based on the next move and the current position.
*
* By semi-optimizing, I mean that relative moves are computed at compile-time rather than at runtime.
* This adds a little extra complexity to the code generation program (in that it has to track the
* MarsBot's current position), but significantly reduces the complexity of the resulting MIPS program,
* removing the necessity to do two memory-access operations (to get the MarsBot's navigational data)
* at runtime.
*
* This function outputs programmatically generated MIPS instructions to the destination file stream,