Skip to content

Instantly share code, notes, and snippets.

@kchodorow
kchodorow / javadoc.bzl
Last active June 15, 2017 07:45
Javadoc-generating rule for Bazel
# Copyright 2015 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@kchodorow
kchodorow / server.py
Created May 12, 2015 16:35
A very basic server
import time
import BaseHTTPServer
HOST_NAME = 'localhost'
PORT_NUMBER = 9000 # Choose a number > 1024.
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(s):
"""Respond to a GET request."""
s.send_response(200)
@kchodorow
kchodorow / Zoo.java
Created April 17, 2015 20:50
Homework skeleton
import java.util.ArrayList;
public class Zoo {
public static void main(String[] args) {
ArrayList<Animal> animals = new ArrayList<Animal>();
// Generate 100 random animals.
for (int i = 0; i < 100; i++) {
double randomNum = Math.random();
@kchodorow
kchodorow / Runner.java
Created April 17, 2015 20:39
Friday's class example
import java.util.ArrayList;
public class Runner {
public static void main(String[] args) {
Person msM = new Teacher("Ms.", "M");
ArrayList<Person> people = new ArrayList<Person>();
people.add(msM);
msM.getName();
((Teacher) msM).assignHomework();
@kchodorow
kchodorow / SubwayLine.java
Created March 31, 2015 20:46
Train skeleton
public class SubwayLine {
public static void main(String[] args) {
Train local = new Train("C", 1, 16);
Train express = new Train("A", 3, 0);
for (int i = 0; i < 10; ++i) {
System.out.println("local: " + local.nextStop());
System.out.println("express: " + express.nextStop());
@kchodorow
kchodorow / Restaurant.java
Created March 10, 2015 15:33
OOP practice
public class Restaurant {
public static void main(String args[]) throws InterruptedException {
Kitchen kitchen = new Kitchen();
while (true) {
Order meal = kitchen.checkForFinished();
System.out.println("Finished: " + meal);
// Maybe send a new order to the kitchen.
double rand = Math.random();
if (rand < .1) {
@kchodorow
kchodorow / Spider.java
Last active August 29, 2015 14:14
Extra credit stub for Monday, February 9th
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.NoSuchElementException;
@kchodorow
kchodorow / branch.sh
Created September 23, 2014 15:11
See all git branches with descriptions and last commit date
#!/bin/bash
# Shows branches with descriptions
branches=$(git for-each-ref --format='%(refname)' refs/heads/ | sed 's|refs/heads/||')
for branch in $branches; do
last_used=$(git show --pretty=format:"%Cgreen%cr%Creset" $branch | head -1)
desc=$(git config branch.$branch.description)
if [ $branch == $(git rev-parse --abbrev-ref HEAD) ]; then
branch="*\t$last_used\t\033[0;32m$branch\033[0m"
else
@kchodorow
kchodorow / limejs.md
Last active December 20, 2017 11:04
LimeJs Notes

Adding a CSS Class

In JavaScript:

whatever.domClassName = 'foo';

In HTML:

@kchodorow
kchodorow / spritescale9.js
Last active December 21, 2015 09:49
This is a SpriteScale9 class for use with LimeJS. It can be used to create resizable shapes with rounded corners, e.g., speech bubbles and progress bars.
// Copyright (C) 2013 Kristina Chodorow
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in