Skip to content

Instantly share code, notes, and snippets.

View Plutor's full-sized avatar
🗯️

Logan Ingalls Plutor

🗯️
View GitHub Profile
@Plutor
Plutor / A_star.html
Last active September 23, 2015 18:58
A little proof to myself that I understand A*.
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>A* demo</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<script type="text/javascript">
var size=81, fielddom, g, h;
var zeroes, walls, open, clos, camefrom, lastwalls, lastopen, lastclos;
var curx=Math.floor(size/2), cury=3;
var active = 1;
@Plutor
Plutor / Random draft order
Created March 21, 2011 18:47
Script for establishing a random draft order for Fantasy Baseball 2011
#!/usr/bin/perl
@t=("D.J. Vajazzle",
"Tu Madre",
"Royal Rooters",
"The Darkhorse",
"The Mighty Hamsters",
"Amish Rake Fight",
"PhineusGageHeadaches",
"Misfit Chinese Food",
@Plutor
Plutor / MLB-2011-schedule.csv
Created April 8, 2011 15:22
Full 2011 MLB schedule including lat/lon
DATE AWAY TEAM HOME TEAM LOCATION LATITUDE LONGITUDE
2011-03-31 Padres Cardinals Busch Stadium 38.62378 -90.19249
2011-03-31 Giants Dodgers Dodger Stadium 34.07388 -118.23996
2011-03-31 Braves Nationals Nationals Park 38.872778 -77.0075
2011-03-31 Brewers Reds Great American Ballpark 39.09714 -84.50707
2011-03-31 Angels Royals Kauffman Stadium 39.05158 -94.4801
2011-03-31 Tigers Yankees Yankee Stadium 40.829167 -73.926389
2011-04-01 Mariners Athletics Oakland Coliseum 37.75162 -122.20052
2011-04-01 Twins Blue Jays Rogers Centre 43.6414 -79.38917
2011-04-01 Pirates Cubs Wrigley Field 41.94822 -87.65536
@Plutor
Plutor / MLB-2012-schedule.csv
Created December 10, 2011 17:01
Shortest MLB roadtrip - depends on LimitedMinHeap from https://gist.github.com/1487321
DATE AWAY TEAM HOME TEAM STADIUM LAT LON
2012-03-28 Mariners Athletics Tokyo Dome 35.705658 139.751914
2012-03-29 Mariners Athletics Tokyo Dome 35.705658 139.751914
2012-04-04 Cardinals Marlins New Marlins Ballpark 25.778056 -80.219722
2012-04-05 Blue Jays Indians Progressive Field 41.49601 -81.68511
2012-04-05 Braves Mets Citi Field 40.756944 -73.845833
2012-04-05 Dodgers Padres PETCO Park 32.70724 -117.15708
2012-04-05 Marlins Reds Great American Ball Park 39.09714 -84.50707
2012-04-05 Nationals Cubs Wrigley Field 41.94822 -87.65536
2012-04-05 Phillies Pirates PNC Park 40.44684 -80.0056
@Plutor
Plutor / limitedminheap.php
Created December 16, 2011 18:37
A min-max heap and a limited-size min heap (in PHP)
<?php
include 'minmaxheap.php';
/* A min-heap that will restrict itself to a maximum of some number of values.
* Implemented internally as a min-max heap.
*
* Public API:
* - Contructor takes a number, used as the maximum number of values allowed on the heap
* - count() - returns the number of elements on the heap
@Plutor
Plutor / gist:2002457
Created March 8, 2012 18:15
Integer.bitCount()
// This is the source code for Integer.bitCount() for Java 1.5+
// <http://www.docjar.com/html/api/java/lang/Integer.java.html> line 1132
public static int bitCount(int i) {
i = i - ((i >>> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);
i = (i + (i >>> 4)) & 0x0f0f0f0f;
i = i + (i >>> 8);
i = i + (i >>> 16);
return i & 0x3f;
@Plutor
Plutor / fnBase36.sql
Created April 27, 2012 17:33
BIGINT to base 36 conversion in T-SQL
ALTER FUNCTION dbo.fnBase36
(
@Val BIGINT
)
RETURNS VARCHAR(9)
AS
BEGIN
DECLARE @Result VARCHAR(9) = ''
IF (@Val <= 0)
@Plutor
Plutor / mcf.user.js
Created August 29, 2012 18:05
Metafilter country flags
// ==UserScript==
// @name Metafilter country flags
// @namespace http://plutor.org/
// @description Add a flag next to users
// @include http://metafilter.com/*
// @include http://*.metafilter.com/*
// ==/UserScript==
/* -- Configuration variables, sort of --------------------------------- */
@Plutor
Plutor / sorts.py
Created August 31, 2012 13:00
A bunch of sort algorithms
from random import shuffle
import time
def generate_array(size):
result = [i for i in range(0, size)]
shuffle(result)
return result
def is_in_order(a, size):
if (len(a) != size):
@Plutor
Plutor / splaytree.py
Created September 4, 2012 00:48
Splay tree implementation in Python
"""Splay tree
Logan Ingalls <[email protected]>
Sept 3, 2012
Note that I only implemented insert and find. Delete is trivial,
and isn't the interesting part of splay trees. Some of these
algorithms would be simpler, but I chose to do this without parent
links from the tree nodes.
Example output on my desktop computer: