Skip to content

Instantly share code, notes, and snippets.

@guoguo12
guoguo12 / ancova_post_hoc.r
Last active April 6, 2018 10:42
R script for performing ANCOVA with post-hoc tests and showing adjusted group means.
# Based on https://stats.stackexchange.com/a/57254
# Before running, look at all comments starting with XXX below
library('car')
library('compute.es')
library('effects')
library('emmeans')
library('ggplot2')
library('multcomp')
library('pastecs')
import java.util.Arrays;
public class QuikMaths {
public static void multiplyBy3(int[] A) {
for (int x: A) {
x = x * 3;
}
}
public static void multiplyBy2(int[] A) {
int[] B = A;
#!/usr/bin/env python
"""
Created by Allen Guo <allenguo@berkeley.edu> for CS 61A Fall 2017.
Dependencies: Selenium configured for Chrome (see https://goo.gl/WBXMhf).
Before running:
- Fill out the constants below. Double check all of them!
- Open Piazza and switch to the CS 61A Piazza. Make sure you're not on a
@guoguo12
guoguo12 / check_grades.py
Last active May 14, 2018 01:01
Checks for updates to your academic summary (letter grades) on CalCentral. Fill out the TODOs then run this script from a cron job.
#!/usr/bin/env python
from __future__ import print_function
import os
import signal
from time import sleep
# TODO: Install Selenium and PhantomJS
from selenium import webdriver
@guoguo12
guoguo12 / template.tex
Last active April 17, 2017 02:22
My standard LaTeX template for assignments.
\documentclass{article}
% imports and settings
\usepackage{fullpage} % wider margins
\usepackage{amsmath} % symbols
\usepackage{amsfonts} % more symbols
\usepackage{verbatim} % comment environment
\usepackage{float} % stop tables from moving
\usepackage{hyperref} % URLs, e.g., \href{url}{text}
\usepackage{graphicx} % graphics (see \img below)
#!/usr/bin/env python
def change(cents, remaining):
if cents == 0:
return 1
if not remaining:
return 0
s = 0
amt = cents
while amt >= 0:
# in exp/nnet3/tdnn_sp_smbr/cmvn_opts
--norm-means=false --norm-vars=false
@guoguo12
guoguo12 / Animal.java
Last active February 10, 2016 00:33
To run, download and run "javac *.java && java Main".
class Animal {
void bark(Animal a) {
System.out.println("bark(Animal a) in Animal");
};
void bark(Dog d) {
System.out.println("bark(Dog a) in Animal");
};
}
@guoguo12
guoguo12 / pythagoras-tree.rkt
Last active December 25, 2015 04:47
Draws a Pythagoras tree using Racket's turtle graphics library. Read the article at http://aguo.us/writings/pythagoras-tree.html.
#lang racket
; pythagoras-tree.rkt:
; Draws a Pythagoras tree using Racket's turtle graphics library.
; Run this program from the terminal with `racket pythagoras-tree.rkt`.
(require graphics/turtles) ; raco pkg install htdp-lib
(turtles #t)
(define (pythagoras-tree side) ; starting position: center of square, facing east
@guoguo12
guoguo12 / calc.py
Last active April 18, 2018 18:56
A concise prefix notation calculator. Read the article at http://aguo.us/writings/prefix-notation.html.
#!/usr/bin/env python
"""calc.py: A concise prefix notation calculator."""
import regex # pip install regex
def calc_eval(exp):
"""Evaluates the given prefix notation expression.
Raises a SyntaxError if the input is not valid.