Skip to content

Instantly share code, notes, and snippets.

# Solution to http://www.futilitycloset.com/2010/07/28/quitting-time/
import math
# RUT must be between (317,999) or range of sqrt(six digit #)
# since T != R, last digit in T^2 cannot equal R
T = set([2,3,4,7,8,9])
# R is set of last digit in T^2 taking account of above range
R = set([4,6,9])
@jbcrail
jbcrail / ring.erl
Created July 21, 2012 23:38
Ring Benchmark in Erlang
-module(ring).
-export([run/2]).
run(N, M) ->
register(home, self()),
io:format("Starting ring processes: "),
statistics(wall_clock),
L = for(1, N, fun() -> spawn(fun() -> loop() end) end),
lists:foreach(fun(I) -> init(L, I, M) end, lists:seq(1, N)),
@jbcrail
jbcrail / triangle.pde
Created August 22, 2012 21:28
Flexible Triangle
PVector[] v = new PVector[3];
int HOVER_DIAMETER = 15;
int ARC_DIAMETER = 20;
int selectedVertex = -1;
boolean draggingVertex = false;
void setup() {
size(600, 600);
@jbcrail
jbcrail / starwarsdns.txt
Created February 9, 2013 19:49
traceroute 216.81.59.173 http://beaglenetworks.net/
$ traceroute 216.81.59.173
traceroute to 216.81.59.173 (216.81.59.173), 64 hops max, 52 byte packets
1 10.0.1.1 (10.0.1.1) 15.771 ms 0.899 ms 0.906 ms
2 * * *
[line 3-12 removed for security reasons]
13 episode.iv (206.214.251.1) 96.198 ms 89.103 ms 88.678 ms
14 a.new.hope (206.214.251.6) 104.822 ms 88.198 ms 96.391 ms
15 it.is.a.period.of.civil.war (206.214.251.9) 104.657 ms 91.137 ms 98.725 ms
16 rebel.spaceships (206.214.251.14) 96.970 ms 91.328 ms 95.296 ms
17 striking.from.a.hidden.base (206.214.251.17) 106.466 ms 98.808 ms 96.921 ms
@jbcrail
jbcrail / incognito.c
Last active December 17, 2015 02:39
A short program designed to demonstrate how to remove program arguments from process listing.
// Compile: gcc -o incognito incognito.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
// Removes all program arguments from process listing
if (argc > 1) {
joseph@ubuntu:~/Haywire$ valgrind --tool=memcheck --leak-check=full --show-reachable=yes ./builds/unix/debug/hello_world
==1441== Memcheck, a memory error detector
==1441== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==1441== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==1441== Command: ./builds/unix/debug/hello_world
==1441==
Added route /
Listening on 0.0.0.0:8000
read: connection reset by peer
read: connection reset by peer
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "haywire.h"
char *body = "hello world";
/*
#define CRLF "\r\n"
@jbcrail
jbcrail / euler.txt
Last active December 26, 2015 15:39
Performance benchmarks for my Project Euler implementations on 32-bit Linux
joseph@crail:~/projects/private/project-euler$ ./euler run | sort -n -k4
clojure 006 25164150 0.001s
erlang 002 4613732 0.001s
erlang 005 232792560 0.001s
erlang 006 25164150 0.001s
erlang 013 5537376230 0.001s
erlang 016 1366 0.001s
erlang 020 648 0.001s
erlang 028 669171001 0.001s
erlang 065 272 0.001s
@jbcrail
jbcrail / wii-plotter.py
Created January 3, 2014 04:41
Plot intensity of accelerometer values from Wii remote
#!/usr/bin/env python
import cwiid
import time
# Tutorials used for Wii plotting script:
# http://www.raspberrypi-spy.co.uk/2013/02/nintendo-wii-remote-python-and-the-raspberry-pi/
# http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/wiimote/
# http://convolutedlogic.com/projects/wiimote/
#
@jbcrail
jbcrail / README.md
Last active August 29, 2015 14:02
Louisville crimes by day/hour

Forked from tjdecke’s block #5558084.

Example data shows Louisville crimes between 2012 and 2014.