Skip to content

Instantly share code, notes, and snippets.

@dylnuge
dylnuge / ai_ethernet.rs
Created December 1, 2022 04:38
Ethernet Frame Header Deserialization, as written by OpenAI's chat
use byteorder::{BigEndian, ReadBytesExt};
use std::io::{Cursor, Read};
// This code was mostly authored by https://chat.openai.com/chat
// I asked the following questions to get the code:
// 1. "Do you know what an ethernet frame header is?"
// 2. "Excellent! Can you write me a data structure in Rust which represents an
// ethernet frame header?"
// 3. "This looks great! Can you write me a function in Rust that takes an
// arbitrary stream of bytes and deserializes it into your
@dylnuge
dylnuge / mmastermind.py
Created February 19, 2020 04:20
mmastermind
#! /usr/bin/env python3
import collections
import random
COLORS = ["R", "O", "Y", "G", "B", "V"]
MAX_TURNS = 10
def setup_game():
@dylnuge
dylnuge / agnoster-extensions.zsh-theme
Created July 31, 2018 17:33
Extension to the Oh My Zsh Agnoster theme
prompt_timestamp() {
# Use timestamp to alert user that it's getting late. Time between 7 AM and
# 8 PM is shown in green. Time between 8 PM and 12 AM is shown in yellow. Time
# after 12 AM (but before 7 AM next morning) is shown in red.
currTime=`date +%k%m`
if [ $currTime -ge 700 -a $currTime -lt 2000 ]; then
prompt_segment default green '[%t]'
# Midnight is 0000, so can't compare with it easily
elif [ $currTime -ge 2000 -a $currTime -le 2359 ]; then
prompt_segment default yellow '[%t]'
@dylnuge
dylnuge / keybase.md
Created July 25, 2017 16:01
keybase.md

Keybase proof

I hereby claim:

  • I am dylnuge on github.
  • I am dylnuge (https://keybase.io/dylnuge) on keybase.
  • I have a public key whose fingerprint is 2002 7718 90E2 E891 25D4 0F4C E9A6 EA5E 0F10 DF5D

To claim this, I am signing this object:

@dylnuge
dylnuge / macbeth.c
Last active December 22, 2015 22:29
C-lilliquy, Macbeth style
#define HEREAFTER(X, Y) ((X) >= (Y))
#define SUCH_A_WORD 1
#define TOMORROW 1
#define PETTY_PACE .00001
#define LAST_SYLLABLE 1000
#define LIGHTED 1
#define OUT 0
@dylnuge
dylnuge / gist:3765106
Created September 22, 2012 04:22
Debugging Macros for C
// Define debugging macros. Because actual code shouldn't be littered with
// debugging printfs and sanity check assertations.
#ifdef DEBUG
#define debug_assert(...) assert(__VA_ARGS__)
#define debug_printf(...) printf(__VA_ARGS__)
#else
#define debug_assert(...) ;
#define debug_printf(...) ;
#endif
@dylnuge
dylnuge / board.py
Created July 26, 2012 08:55
Really basic dict-based board
#! /usr/bin/python
class Board:
def __init__(self):
self.board = {}
def add_to_board(self, item, position):
# Simple function, adds something to the board at position
# where position is a tuple, returns True if add is successful
if get_item_at(position) == None:
@dylnuge
dylnuge / iceicebaby.sh
Created July 10, 2012 23:20
Ice Ice Baby Script for Cole
#! /bin/bash
# Simple Ice Ice Baby control script for Git.
# If problems occur during build, fix by checking out the hook while the DJ
# resolves it.
# Script assumes user is the DJ and that there is a pre-commit hook in the
# previous commit (current base) located at hooks/pre-commit. Script assumes
# it is being run in the main project directory (top level git dir). Script
# assumes "make" with no arguments will correctly build project.
@dylnuge
dylnuge / google_music_upload.py
Created July 6, 2012 20:18 — forked from anonymous/google_music_upload.py
upload to google music
#!/usr/bin/env python
# Copyright (c) 2012, Simon Weber
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
@dylnuge
dylnuge / hw.tex
Created January 23, 2012 03:03 — forked from klange/hw.tex
Homework template
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{enumerate}