Skip to content

Instantly share code, notes, and snippets.

View adamchalmers's full-sized avatar

Adam Chalmers adamchalmers

View GitHub Profile
@adamchalmers
adamchalmers / Pet.java
Created May 5, 2015 05:29
INFO1103 students: this demonstrates the basics of making a class.
public class Pet {
// Instance variables
// Each pet object will have its own copies of
// these four variables
public String name;
public int age;
public String species;
public String[] nicknames;
private int numberOfNicknames = 0;
@adamchalmers
adamchalmers / AdamPets.java
Created May 5, 2015 05:30
INFO1103 students: this is a tester/main class for my Pet.java example
public class AdamPets {
public static void main(String[] args) {
// Make a pet, passing in the necessary parameters to the constructor
Pet pet1 = new Pet("Greywind", 1, "Cat");
// Access the pet's instance variables
System.out.print("This " + pet1.species);
System.out.println("'s name is " + pet1.name);
// Call one of the pet's methods
@adamchalmers
adamchalmers / .bashrc
Created May 5, 2015 06:51
Basic colored prompt for 1103 students
TERM=xterm-256color
export PROMPT_COMMAND='printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
# using tput commands
FGBLK=$( tput setaf 0 ) # 000000
FGRED=$( tput setaf 1 ) # ff0000
FGGRN=$( tput setaf 2 ) # 00ff00
FGYLO=$( tput setaf 3 ) # ffff00
FGBLU=$( tput setaf 4 ) # 0000ff
FGMAG=$( tput setaf 5 ) # ff00ff
FGCYN=$( tput setaf 6 ) # 00ffff
set mouse=a
set hlsearch
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif
" Restore cursor position to where it was before
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand("<afile>:p:h") !=? $TEMP |
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ let JumpCursorOnEdit_foo = line("'\"") |
@adamchalmers
adamchalmers / keybase.md
Created June 24, 2015 15:40
Proof of identity for keybase.io/adamchalmers

Keybase proof

I hereby claim:

  • I am adamchalmers on github.
  • I am adamchalmers (https://keybase.io/adamchalmers) on keybase.
  • I have a public key whose fingerprint is 397E 6FD5 F4FC D0E6 7DA6 6F1B 8A77 0008 D683 6965

To claim this, I am signing this object:

public class BinarySearchableArray<T extends Comparable<T>> extends SearchableArray<T> {
// constructor
public BinarySearchableArray(T[] data) {
super(data); //call the constructor of the super-type as SearchableArray<T>(data)
}
@Override
public T search(T target) {
@adamchalmers
adamchalmers / dat_to_csv.py
Created August 12, 2015 02:55
For converting Movie Lens .dat file to Mongo-friendly .csv files.
# import the .csv files with this command:
# $ mongimport --type "csv" --headerline csv/users.csv
#
# This script expects a directory structure like this:
#
# dat_to_csv.py
# dat/
# movies.csv
# ratings.csv
# users.csv
"""Lists ways to play a certain chord on mandolin.
Example invocation:
$ python mandolin_chords.py Abm
Example output:
The chord Abm has notes Ab, B, Eb
(4, 6, 6, 4) plays B, Ab, Eb, Ab
(8, 6, 6, 7) plays Eb, Ab, Eb, B
module Cards where
import Random
-- DATA
type alias Card = {face: Face, suit: Suit}
type Suit = Clubs | Spades | Diamonds | Hearts
type Face = Ace | Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | Jack | Queen | King
type alias Deck = List Card
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="robots" content="noindex, nofollow">
<link rel="stylesheet" type="text/css" href="/uf/theme/53.css?1461851479">
<link rel="SHORTCUT ICON" title="BigPulse.com" href="/favicon.ico">
<title>Selection or information required</title>
<script type="text/javascript">