Skip to content

Instantly share code, notes, and snippets.

View alxmjo's full-sized avatar

Alex Johnson alxmjo

View GitHub Profile
@alxmjo
alxmjo / HWTemplate.tex
Created January 12, 2019 15:20 — forked from dcernst/HWTemplate.tex
LaTeX homework template for Weekly Homework assignments for Dana Ernst's courses.
% --------------------------------------------------------------
% This is all preamble stuff that you don't have to worry about.
% Head down to where it says "Start here"
% --------------------------------------------------------------
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
@alxmjo
alxmjo / Bash script average with double loop
Created June 2, 2018 16:47
Compiles a program with a particular set of inputs, runs multiple times, and then outputs the average of each run. The program should submit a single integer to stdout. In this example, the outer loop passes the values 1, 2, 4, 8, etc. (as WORKGROUPSIZE) and the inner loop passes the values 1024, 2048, 4096, etc. (as ARRAYSIZE). The data is aver…
#!/bin/bash
# Create or clear output file
> data.csv
# Run for multiple tries and compute average
TRIES=10
WORKGROUPCOUNTER=1
while [ $WORKGROUPCOUNTER -le 256 ]
do
@alxmjo
alxmjo / average-script.sh
Last active June 1, 2018 20:37
Compiles a program with a particular set of inputs, runs multiple times, and then outputs the average of each run to data.csv. The program should submit a single integer to stdout. In this example, the outer loop passes the values 1, 2, 4, 8, etc. (as WORKGROUPSIZE) and the inner loop passes the values 1024, 2048, 4096, etc. (as ARRAYSIZE).
#!/bin/bash
# Compiles a program with a particular set of inputs, runs multiple times, and then
# outputs the average of each run. The program should submit a single integer to
# stdout. In this example, the outer loop passes the values 1, 2, 4, 8, etc. (as
# WORKGROUPSIZE) and the inner loop passes the values 1024, 2048, 4096, etc. (as
# ARRAYSIZE). The data is averaged TRIES times and saved to data.csv. Note that as
# this is a bash script, only integer values are computed.
#
# Run: $ average-script.sh
// From: https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore
1. Commit pending changes
2. git rm --cached <file-name>
3. Commit again
4. Add the file to .gitignore
5. Verify git status
6. Commit again
@alxmjo
alxmjo / MagicSquareChecker.cpp
Created December 8, 2016 11:21
Simple C++ program which checks whether a three by three array of numbers is a magic square.
#include <iostream>
using namespace std;
// prototype
bool isMagicSquare(int[][3]);
int sumRow(int[], int);
int sumColumn(int[][3], int);
int sumDiagonal1(int[][3]);
int sumDiagonal2(int[][3]);
// Tag used for logging
private static final String TAG = "MyActivity";
// Declare a countdown timer
private CountDownTimer countDownTimer;
// Declare and initialize length for timer to run and set total equal to it
private long length = 30000;
private long total = length;