Skip to content

Instantly share code, notes, and snippets.

<% for place in @places %>
<%= link_to place.name, place %>
<% end %>
@jmitchell
jmitchell / the_matrix.pde
Last active December 18, 2015 11:39
The Matrix in Processing.org
class MatrixChar {
final int STREAK_LENGTH = 100;
final color COLOR = color(0, 255, 0);
final PFont FONT = createFont("Monospace", 12);
final int DEFAULT_CHAR_SIZE = 100;
final int DEFAULT_SPEED = 5;
int x, y;
char chr;
float distanceAway;
setInsert : Eq a => Vect n a -> a -> Either (Vect n a) (Vect (S n) a)
setInsert xs x = if elem x xs
then Left xs
else Right (x :: xs)
@jmitchell
jmitchell / Main.idr
Last active August 29, 2015 14:07
Non-deterministic die roll
module Main
import Effect.Random
import Effect.StdIO
import Effect.System
getSeed : { [SYSTEM] } Eff Integer
getSeed = do case index' 1 !getArgs of
Nothing => pure $ cast !time
Just t => pure $ cast t
@jmitchell
jmitchell / haskell-typeclass-deck.txt
Last active November 15, 2021 15:40
Haskell typeclass flashcards (Anki-importable)
# Monoids
Basic description of Monoid; Types with an associative binary operation and an identity element; typeclass-doc monoid
Monoid typeclass methods?; "mempty :: a
mappend :: a -> a -> a
mconcat :: [a] -> a"; typeclass-methods monoid
Monoid inherits from?; Nothing; typeclass-inherits-from monoid
typeclass of mempty?; Monoid; method-type monoid
@jmitchell
jmitchell / tuple.v
Last active August 28, 2024 14:11
Basic tuples in Coq
Require Import Vector.
Import VectorNotations.
Set Implicit Arguments.
Inductive tuple : forall {n : nat}, Vector.t Set n -> Type :=
| unit : tuple []
| push : forall {T : Set} (x : T)
{n : nat} {ts : Vector.t Set n},
tuple ts -> tuple (T :: ts).
No. Time Source Destination Protocol Length Info
1 0.000000000 192.168.0.34 46.43.42.146 TCP 56 39138 > 443 [ACK] Seq=1 Ack=1 Win=525 Len=0
2 0.165215788 46.43.42.146 192.168.0.34 TCP 62 [TCP ACKed unseen segment] 443 > 39138 [ACK] Seq=1 Ack=2 Win=65535 Len=0
3 0.168022779 192.168.0.34 46.43.42.146 TCP 56 39142 > 443 [ACK] Seq=1 Ack=1 Win=1452 Len=0
4 0.334212939 46.43.42.146 192.168.0.34 TCP 62 [TCP ACKed unseen segment] 443 > 39142 [ACK] Seq=1 Ack=2 Win=65535 Len=0
5 6.928455772 192.168.0.34 46.43.42.146 TLSv1.2 781 Application Data
6 7.095766941 46.43.42.146 192.168.0.34 TLSv1.2 125 Application Data
7 7.095906094 192.168.0.34 46.43.42.146 TCP 56 39146 > 443 [ACK] Seq=726 Ack=70 Win=1452 Len=0
8 7.095987261 46.43.42.146 192.168.0.34 TLSv1.2 173 Application Data
9 7.096027984 192.168.0.34 46.43.42.146 TCP 56 39146 > 443 [ACK] Seq=726 Ack=187 Win=1452 Len=0

Keybase proof

I hereby claim:

  • I am jmitchell on github.
  • I am jmitchell (https://keybase.io/jmitchell) on keybase.
  • I have a public key whose fingerprint is BA46 498D 8842 D2D4 0CD4 3C60 15ED 7FD0 CA4A 70DB

To claim this, I am signing this object:

#!/usr/bin/env python
import xml.etree.ElementTree as ET
tree = ET.parse("senators_cfm.xml")
root = tree.getroot()
for member in root.findall("member"):
first_name = member.find("first_name").text
last_name = member.find("last_name").text
state = member.find("state").text
phone = member.find("phone").text
@jmitchell
jmitchell / dji_pres_election_q4.py
Created December 20, 2016 00:27
Script to convert Dow Jones index CSV from Yahoo into prices over Q4 during presdential election years
#!/usr/bin/env python
import csv
from collections import namedtuple
PriceRecord = namedtuple("PriceRecord", "date open high low close volume adjusted_close")
def parse_date(ymd):
return map(int, ymd.split('-'))