Skip to content

Instantly share code, notes, and snippets.

@bgschiller
bgschiller / index.html
Created August 23, 2014 20:03
Grandpa's Dow Jones moving average graph
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
@bgschiller
bgschiller / undecidable_club.md
Created October 28, 2014 01:55
The Undecidable Club

There is a club called Undecidable, but they don't let in just any old question. In order to be admitted to the Undecidable Club, a question has to prove that she's seriously hard. How hard? Well, let's talk about the membership process.

First, the applicant needs a sponsor (Let's call the sponsor S). Your sponsor is some question who's already in the club (so you know they're hard). In order to get into the club, an applicant has to show she's just as hard as her sponsor (Let's call the applicant A). How does A prove her difficulty? She has to show that if some Turing Machine could solve A's problem, it could solve S's problem as well. Since we know S is hard (he's in the club already!), A's problem must be just as hard.

Membership Roster

These problems are all known to be hard. You can choose whichever you like to be your sponsor.

  • function AcceptsOwnEncoding(T)
  • function AcceptsSomething(T)
@bgschiller
bgschiller / index.html
Last active August 29, 2015 14:13
Draw square spirals with a bit of noise all over the page
<head>
<style>
body {
background-color: #DFDECC;
}
svg path.walk {
fill: none;
stroke: #4b4b4b;
stroke-width:1.3;
}
@bgschiller
bgschiller / count.py
Created October 12, 2012 05:30 — forked from MorganBorman/count.py
Counting using a generator which returns the digits of an arbitrary number system
def count(digitgen):
"Takes an iterator which yields the digits of a number system and counts using it."
def subcount(digitgen, places):
if places == 1:
for d in digitgen():
yield d
else:
for d in digitgen():
for ld in subcount(digitgen, places - 1):
@bgschiller
bgschiller / na_ww_brute.hs
Created December 6, 2012 02:41
Brute force solution to Ninja Assassin Wonderwall problem
import Data.List (elemIndex)
-- | The 'permutations' function returns the list of all permutations of the argument.
--
-- > permutations "abc" == ["abc","bac","cba","bca","cab","acb"]
permutations :: [a] -> [[a]]
permutations xs0 = xs0 : perms xs0 []
where
perms [] _ = []
perms (t:ts) is = foldr interleave (perms ts (t:is)) (permutations is)
@bgschiller
bgschiller / servertests.py
Last active December 14, 2015 10:39
Server tests for CSCI 367 Network Blackjack. Description and usage is in a comment following the code.
import string
import pexpect
import sys
import random
import argparse
import os
from utils import colors
def is_server_running(host,port):
'''Try to connect to the server, send a join and expect a conn'''
@bgschiller
bgschiller / rayage
Last active December 16, 2015 20:39 — forked from philipbjorge/rayage
Front End:
Run tests functionality (we can run every time they hit run)
[X] Test output tab has a line for every line in the reference
[x] Modify the html in static/custom/templates/Rayage.html to mess with test output contents
[X] 'Test' button sends a message asking for a diff. Server responds with a JSON object
[ ] downgrade Test output from terminal to something simpler
[ ] change 'Logout' to 'Unspoof' when we are spoofing. (Can't figure this one out. I have code that should do this at static/custom/RayageMenu.js:70. It's not very high priority for me)
Submit assignment
message to server: "submit_assigment"
@bgschiller
bgschiller / prime_iterator.cpp
Last active December 17, 2015 19:29
A lazily evaluated infinite list of primes, implemented in C++ but inspired by the Haskell at http://www.cs.tufts.edu/~nr/comp150fp/archive/melissa-oneill/Sieve-JFP.pdf
#include "prime_iterator.h"
#include <vector>
#include <algorithm> //std::binary_search
//allocation and initialization of the static member variable
std::vector<unsigned int> PrimeIterator::prime_list{2,3};
PrimeIterator::PrimeIterator() : position{0} { }
PrimeIterator::PrimeIterator(unsigned int pos) : position{pos} {
aecho -n "Enter the last number to check for prime-iness: "
read MAX
while [ -n "$(echo ${MAX} | sed -E "s/[0-9]*//g")" -o ${MAX} -ge 274 ]
if [ ${MAX} -ge 274 ]
aecho "Sorry, the line buffers are too short to hold that many numbers."
aecho -n "Please enter a number: "
else
aecho -n "'${MAX}' is not a number. Please enter a number: "
end
read MAX
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Draggable - Events</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
<style>
.wrapper{
overflow:hidden; /*make sure the wrapper has no dimension*/
text-align: center;