Skip to content

Instantly share code, notes, and snippets.

java_toolchain(
name = "java8",
encoding = "UTF-8",
source_version = "8",
target_version = "8",
misc = [
"-extra_checks:on",
],
)
@cflewis
cflewis / gist:63959
Created February 13, 2009 15:44
An Inform 7 tale about an incident on a plane.
"plane" by Chris Lewis
The release number is 1. The story creation year is 2009. The story headline is "Plane: A Tale of Pride". The story genre is "Medieval Morality". The story description is "A story about love at 30 000 feet.". Use no scoring.
The Cabin is a room. "The cabin is a long thin corridor surrounding you, bright light piercing the tin can that is propelling you at 600 mph through the lower atmosphere. A putrid smell of various processed food stuffs mixes with the thin air. People in various states of personal detachment are to your left and right. Some are sleeping, some are watching 'Beverly Hills Chihuahua'. They are essentially zombies.
You wonder if zombies actually come alive on aeroplanes. Then they could be immortal humans, doomed to be locked in on an eternal long-haul flight. You ponder this possibility for some time.
To the south are the bathrooms.
@cflewis
cflewis / gist:80968
Created March 18, 2009 06:17
A script to automate the generation of UC Santa Cruz narrative evaluations given a grades spreadsheet and student enrollment spreadsheet.
#!/usr/bin/env python
# encoding: utf-8
"""
evaluations.py
Created by Chris Lewis on 2009-03-17.
Copyright (c) 2009 Regents of the University of California.
Released under a BSD license:
http://www.opensource.org/licenses/bsd-license.php
def describe(x: Any) = x match {
case 5 => "five"
case true => "truth"
case "hello" => "hi!"
case Nil => "the empty list"
case _ => "something else"
}
scala> def add(x: Any) = x match {
| case h :: t => h + add(t)
| case _ => 0
| }
<console>:5: error: recursive method add needs result type
case h :: t => h + add(t)
object TwitterOpener {
def main(args:Array[String]) = {
val twitterURL = new URL("http://twitter.com/statuses/public_timeline.rss")
val xmlRss = XML.load(twitterURL.openStream())
println(xmlRss)
}
}
rule "Reverse aliens if one reaches the edge of the screen"
when
$alien : AlienEntity()
exists (AlienEntity(x < 10) or AlienEntity(x > 750))
then
$alien.setHorizontalMovement(-$alien.getHorizontalMovement());
$alien.setY($alien.getY() + 10);
end
rule "Process bullets hitting aliens"
for (int p=0;p<entities.size();p++) {
for (int s=p+1;s<entities.size();s++) {
Entity me = (Entity) entities.get(p);
Entity him = (Entity) entities.get(s);
if (me.collidesWith(him)) {
me.collidedWith(him);
him.collidedWith(me);
}
}
#domain person(P).
citizen(P) :- born_in_usa(P).
citizen(P) :- not_born_in_usa(P), resident_usa(P), naturalized(P).
citizen(P) :- not_born_in_usa(P), mother(Y,P), citizen(Y), registered(P).
#hide mother(P, Y).
mother(mary, john).
#hide citizen(P).
#domain object(O), position(P).
#hide object(O).
at_position(O, P) :- translate(O, P).
at_position(O, ground) :- fall(O).
object(mario).
position(ground).
:- fall(O), translate(O, P).