Skip to content

Instantly share code, notes, and snippets.

View stevenpetryk's full-sized avatar

Steven Petryk stevenpetryk

View GitHub Profile
import java.util.*;
public class monkey {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int numCases = scanner.nextInt();
scanner.nextLine();
for (int i = 1; i <= numCases; i++) {
ssh root@104.232.321.32 "tar cvf bundle.tar PATH-TO-APP"
scp root@104.232.321.32:bundle.tar .

Labels and branches in MIPS

In MIPS, there are only two types of instructions for controlling program flow, branches and jumps. As a MIPS program executes, the instructions are run sequentially from top to bottom and will only stop once they reach the end or encounter a branch or jump.

Labels

Labels allow us to assign a human-readable name to a particular place in code. Labels point to a specific line of code, they do not encapsulate code in any way from the code surrounding it. Take this example:

LOOP: slt $t0, $t1, $t2
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Steven Petryk</title>
</head>
<body>
<div>
<h1>Steven Petryk</h1>
MAX_RUNS = 100
MAX_STATES = 500
MAX_ALPHABET_SIZE = 10
def get_random_dfa
lines = []
states = (0..(1 + rand(MAX_STATES - 1))).to_a
alphabet_size = 1 + rand([MAX_ALPHABET_SIZE, states.count].min - 1)
accept_states = states.sample(1 + rand(states.count - 1))
@stevenpetryk
stevenpetryk / d3.html
Last active September 9, 2015 02:36 — forked from LevelbossMike/d3.html
creating table from array of json with d3
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<table id="split">
<thead></thead>
<tbody></tbody>

COP 3503 Review

Hash tables

Linear (and quadratic) put and get

public class LinearHashTable {
  void put(DataStruct ds) {
    // For the test, we don't have to worry about table expansion.
    int hv = getHashValue(ds.getKey());
var gulp = require('gulp');
var sequence = require('run-sequence');
var sourcemaps = require('gulp-sourcemaps');
var plumber = require('gulp-plumber')
var stylus = require('gulp-stylus');
var nib = require('nib');
var jeet = require('jeet');
var browserify = require('browserify');
if ARGV[0]
tle = File.open(ARGV[0]).read
tle_line_1 = tle.lines[0]
tle_line_2 = tle.lines[1]
else
print 'Line 1 > '
tle_line_1 = gets.chomp
print 'Line 2 > '
tle_line_2 = gets.chomp
end
void DrawSquares( Graphics canvas )
{
canvas.setColor(Color.BLACK);
for( int nRow=0; nRow<NUMROWS; nRow++ )
{
for( int nCol=0; nCol<NUMCOLS; nCol++ )
{
canvas.drawRect( BOARDLEFT + nCol * SQUAREWIDTH,
BOARDTOP + nRow * SQUAREHEIGHT, SQUAREWIDTH, SQUAREHEIGHT );