Skip to content

Instantly share code, notes, and snippets.

@guoguo12
guoguo12 / todo.html
Last active August 20, 2023 10:58
Simple to-do list app made using AngularJS.
<!doctype html>
<html ng-app="toDoApp" ng-controller="toDoController">
<head>
<title>Tasks App</title>
<script src="angular.js"></script>
<style>
body {
color: #444;
font-size: 14px;
font-family: "Roboto", sans-serif;
@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 / edline_login.py
Created January 25, 2014 08:35
Demonstrates how to use Requests (http://docs.python-requests.org/en/latest/) to login to Edline (http://www.edline.net/).
import requests
HEADERS = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36'}
LOGIN_URL = 'https://www.edline.net/InterstitialLogin.page'
LOGIN_POST_URL = 'https://www.edline.net/post/InterstitialLogin.page'
class Edline(object):
@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.
@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 / TextRenderer.java
Last active August 29, 2017 15:44
This is one way to display subscript and superscript text using Libgdx. The markup used assumes that, in the raw string, subscript text is surrounded by underscores and superscript text is surrounded by carets. "bigFontName" and "smallFontName" correspond to fonts in the skin argument. See this blog post for more details: http://www.sparkfiregam…
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
@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: