Skip to content

Instantly share code, notes, and snippets.

View nathanesau's full-sized avatar
😃

Nathan Esau nathanesau

😃
View GitHub Profile
<ruleset name="Custom Rules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>
Design ruleset without loose pacakge coupling
</description>
@nathanesau
nathanesau / gist.cpp
Created September 15, 2019 23:09
Binary Search (Hackerearth)
#include <vector>
#include <algorithm>
#include <iostream>
// Write your code here
int binary_search(const std::vector<int> &a, int e)
{
int l = 0;
int r = a.size() - 1;
@nathanesau
nathanesau / parser_atp.R
Created October 8, 2017 22:42
ATP parser
# Title: Tennis Draw Parser
# Author: Nathan Esau
library(XML)
options(warn = -1) # suppress warnings
# Get all draws for current year
url = "https://www.atpworldtour.com/en/scores/results-archive?year=2017"
@nathanesau
nathanesau / Exam C Sample Questions (June 2016).ipynb
Last active July 21, 2016 12:28
Dropbox/ExamC/Jupyter/Exam C Sample Questions (June 2016).ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nathanesau
nathanesau / makefile
Created December 1, 2015 18:53
UL makefile
OBJS = main.o matrix.o matrix_ops.o survival_models.o UL.o
CC = g++ -std=c++11
DEBUG = -g
LFLAGS = -Wall $(DEBUG)
CFLAGS = -Wall -c $(DEBUG)
main: $(OBJS)
$(CC) $(OBJS) $(LFLAGS) -o main
main.o: main.cpp survival_models.cpp UL.cpp
library(XML)
# parses boxscores from hockey-reference.com.
# Note program may take several hours to run.
# change wd to folder where data should be stored
# change months and year variables to date range preferred
setwd("~/Desktop/Hockey")
months <- c("03", "04", "10", "11", "12")
days <- as.character(seq(1,31))
for(i in 1:31) if(nchar(days[i])==1) days[i] = paste0("0",days[i])
@nathanesau
nathanesau / eduroam
Created September 26, 2015 15:25
Eduroam config SFU (arch linux)
Description='eduroam'
Interface='wlp3s0'
Connection='wireless'
IP='dhcp'
ESSID='eduroam'
Security='wpa-configsection'
WPAConfigSection=(
'ssid="eduroam"'
'key_mgmt=WPA-EAP'
'eap=PEAP'
@nathanesau
nathanesau / exam2.cls
Created August 3, 2015 19:31
Exam Class (modified to allow hiding questions)
% exam2.cls
%
% A LaTeX2e document class for preparing exams.
%% exam.cls
%% Copyright (c) 1994, 1997, 2000, 2004, 2008, 2011, 2015 Philip S. Hirschhorn
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
@nathanesau
nathanesau / FR_before_adj_comparison.R
Created June 24, 2015 01:49
FR_before_adj_comparison.R
# produce plots and CSV files with looping rather than pasting repeated commands
library(moments)
setwd("~/Documents/TBP_Plan_1/FR_before_adj/")
# Load data files
load("Study1a_M_F0_100_vf1_FR_before_adj.RData")
load("Study1b_M_F0_100_vf1_FR_before_adj.RData")
load("Study2b_M_F0_100_vf1_FR_before_adj_1000scen.RData")
load("Study3b_M_F0_100_vf1_FR_before_adj_1000scen.RData")
# in progress
import random
class card:
def __init__(self, num, suit):
self.num = num # card num
self.suit = suit # card suit
self.value = self.points()
def rank(card):