Skip to content

Instantly share code, notes, and snippets.

@guymac
guymac / jp2_to_tiff.java
Last active July 24, 2022 00:12
Converting a Jpeg-2000 to TIFF
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
/**
* https://github.com/jai-imageio/jai-imageio-core
* https://github.com/jai-imageio/jai-imageio-jpeg2000
*
* Example of fetching dependencies, compiling, and running.
@guymac
guymac / SpotLister.java
Last active October 24, 2023 19:55
Given a Spotify playlist URL, prints out a track listing.
import java.io.*;
import java.net.*;
import java.net.http.*;
import java.nio.charset.*;
import java.util.*;
import javax.swing.text.html.parser.*;
import javax.swing.text.html.*;
import javax.swing.text.*;
/**
@guymac
guymac / fpc.groovy
Last active August 29, 2015 13:57
Script used to convert lat-lon footprints to map coordinates, reading them from one database and writing to another.
/**
Script to take footprint polygons from one database, perform a conversion on
them and write them to another database.
*/
MARS_RADIUS_METERS = 3394500 as double
MARS_CIRCUM_METERS = 2*Math.PI*MARS_RADIUS_METERS as double
// cutoff
EQ_POLAR_LAT_LIMIT = 65
@guymac
guymac / charts.groovy
Last active August 29, 2015 13:56
Groovy x-y charting function
import org.jfree.chart.ChartFactory
import org.jfree.chart.ChartPanel
import org.jfree.chart.plot.XYPlot
import org.jfree.chart.renderer.xy.XYDotRenderer
import org.jfree.data.time.TimeSeriesCollection
import org.jfree.data.xy.XYSeriesCollection
import groovy.swing.SwingBuilder
@guymac
guymac / HiRISE_Data_Location.groovy
Last active December 28, 2015 19:39
Line-for-line (or as close to it as possible) port of a Perl CLI utility to Groovy.
//#!/usr/bin/env groovy
CVS_ID = 'HiRISE_Data_Location $Revision: 1.1 $ $Date: 2013/11/01 19:47:41 $'
println CVS_ID
Command_Name = ('$RCSfile: HiRISE_Data_Location,v $' =~ /(\w+),v/)[0][1]
// Number of orbits per directory.
DEFAULT_ORBITS_PER_DIRECTORY = 100
@guymac
guymac / risk10hdl.groovy
Last active December 28, 2015 19:39
Groovy code used to analyze the risk formula used in the new cholesterol guidelines.
A = 0.91436
B = 61.1816
C = [ 12.344, 11.853, 2.664, 7.99, 1.769, 1.764 ]
TC = 180 // mg/dL
BPS = 120 // systolic
import static java.lang.Math.log // ln
import static java.lang.Math.exp // e^x
@guymac
guymac / setcover.cpp
Last active July 22, 2021 20:54
Embeds cover art in music files (MP3, M4A/AAC, Ogg/Vorbis)
/*
Command-line application for embedding JPEG cover art in MP3, MP4 and OGG audio files.
Based on taglib-1.7 (debian libtag1-dev)
and libb64 (http://libb64.sourceforge.net/) needed for OGG Vorbis embedded cover art
g++ -I/usr/local/include/taglib -L/usr/local/lib -ltag -lb64 setcover.cpp -o setcover
g++ -I/opt/homebrew/include/taglib -L/opt/homebrew/include/b64 -ltag -lb64 setcover.cpp -o setcover
*/
@guymac
guymac / mp3playlist
Last active June 23, 2023 11:28
Example of using HTML5 as a music playlist. This html would be put in a directory and all the mp3 files that it references in a subdirectory called mp3. The whole thing can be written to CD-R where this html serves as the music playing application (and MP3 CD-Rs will autoplay in most non-interactive devices).
<html>
<head>
<title>EDM Favorites Volume 4</title>
<script type="text/javascript">
//<![CDATA[
(function(){
// audioElement = HTML5 Audio
AudioHandler = function(audioElement)