Skip to content

Instantly share code, notes, and snippets.

@MrDOS
MrDOS / omlway2ll.sh
Created February 13, 2014 03:47
OML way to latitude/longitude pair conversion.
#! /bin/sh
# Convert an OSM way to a set of latitude/longitude pairs. Assumes only one way
# in input.
NODE_PATTERN='<nd ref="\([0-9]\+\)"\/>'
COORD_PATTERN='\-\?[0-9.]\+'
LAT_PATTERN='lat="'"$COORD_PATTERN"'"'
LON_PATTERN='lon="'"$COORD_PATTERN"'"'
@MrDOS
MrDOS / Eliminator.java
Created December 20, 2014 18:35
The Eliminator reads in two files, the first containing the set of “potential duplicates”, the second containing the “baseline” set, and outputs only those lines which exist in the first file but not the second.
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
public class Eliminator
{
@MrDOS
MrDOS / mc_ids.py
Created January 5, 2015 05:54
Minecraft block/item IDs
"""Provides a lookup table for Minecraft block and item IDs to names.
Exposes one dictionary, MC_IDS. Keys are IDs, values are names.
"""
__author__ = "Samuel Coleman"
__copyright__ = "Mojang AB, probably"
__credits__ = ["http://minecraft.gamepedia.com/Data_values"]
__license__ = "WTFPL"
@MrDOS
MrDOS / convert_stat_ids_to_names.py
Created January 5, 2015 05:59
Convert block and item IDs in Minecraft player stat files to names for 1.7 to 1.8 migrations.
#!/usr/bin/env python
from __future__ import print_function
"""Converts keys in Minecraft player stats files from ids (1.7) to names (1.8).
Workaround for SPIGOT-167.
Requires a table providing ID to name lookup. Mine is available at
[global]
# Windows networking workgroup and machine name.
workgroup = SEESIDE
netbios name = nancy
# Equivalent to the machine description on a Windows desktop.
server string = %h server
@MrDOS
MrDOS / StaticFieldCacheExample.cls
Created June 5, 2015 17:42
An example of how to cache a value in a static field.
public class StaticFieldCacheExample
{
/* Define a static field to hold the value. */
private static String cachedValue = null;
public static String getCachedValue()
{
/* If the value has been previously calculated, return it immediately
* instead of performing an expensive calculation. */
if (StaticFieldCacheExample.cachedValue != null)
@MrDOS
MrDOS / riptime.py
Created October 15, 2012 19:40
Determine the extraction speed of a disc drive based on an EAC log.
#! /usr/bin/python
import sys, re
DRIVE_PATTERN = "Used drive : (.+?) Adapter"
TRACK_PATTERN = "([0-9]+) +\| +([0-9]+):([0-5][0-9].[0-9]{2}) \| +([0-9]+):([0-5][0-9].[0-9]{2}) \| +([0-9]+) +\| +([0-9]+)"
SPEED_PATTERN = "Extraction speed ([0-9]+.[0-9]) X"
def parse(log):
if not log.startswith("Exact Audio Copy V"):
@MrDOS
MrDOS / grabber.py
Created October 16, 2012 20:08
Generate log file URLs for all torrents with logs recently uploaded to What.CD.
#! /usr/bin/python
"""Use values from one of your personal RSS feed URLs."""
USER=""
AUTH=""
PASSKEY=""
AUTHKEY=""
import urllib, re
try:
@MrDOS
MrDOS / grope.sh
Created November 14, 2012 22:10
Grope, a multipiece Amazon album art retrieval script
#! /bin/sh
# Grab multipiece album art from Amazon.
# Usage:
# ./grope.sh url output
# ...where URL is the URL of one piece of the album art, as shown by
# right-click -> Page Info after zooming in on the image, e.g.,
# http://z2-ec2.images-amazon.com/R/1/a=B0011Z1BII+c=A17SFUTIVB227Z+d=_SCR(3,2,0)_+o=01+s=RMTILE+va=MAIN+ve=391313817+e=.jpg
# (Yes, the whole thing.)
@MrDOS
MrDOS / checkalbums.sh
Created November 28, 2012 19:57
Check album art and ReplayGain tags of a hierarchical music library
#! /bin/sh
# Check through a hierarchical music library to verify that album art meets a
# minimum size or that music is ReplayGain-tagged.
# Usage:
# ./checkalbums.sh [-art] [-replaygain]
# If -art is given, verify album art size. If -replaygain is given, check for
# the existence of ReplayGain tags and add them if not present.
MINSIZE=600