Skip to content

Instantly share code, notes, and snippets.

View tlhunter's full-sized avatar
📷
Taking Photos

Thomas Hunter II tlhunter

📷
Taking Photos
View GitHub Profile
#!/usr/bin/env node
// this script looks through chase credit card transactions looking for repeat description/amount combinations
// login to Chase, click credit card, set a time range, click download account activity (down arrow), choose CSV
// usage: node ./chase-subscription-finder.js Chase*Activity*.CSV
const fs = require('fs');
const BLACKLIST = [
'PEETZ', // coffee
@tlhunter
tlhunter / delete-raw-files.mjs
Created January 21, 2024 22:21
Script to help delete unwanted RAW files with a Darktable workflow
#!/usr/bin/env zx
/**
* `npm install -g zx`
*
* I take photos on a Sony camera in RAW+JPG mode.
* I then scroll through all the photos in Darktable usually at least once.
* When I really like a photo I export it as DSC001.export.jpg or DSC001.insta.jpg.
* Sometimes I rate photos in Darktable but not always.
*
@tlhunter
tlhunter / distance-geolocation.js
Created May 18, 2017 00:07
Get the distance between two points in meters
function getDistance(p1, p2) {
var radlat1 = Math.PI * p1.lat/180;
var radlat2 = Math.PI * p2.lat/180;
var theta = p1.lng - p2.lng;
var radtheta = Math.PI * theta/180;
var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
dist = Math.acos(dist);
dist = dist * 180 / Math.PI;
dist = dist * 60 * 1.1515 * 1.609344 * 1000;
return dist;
@tlhunter
tlhunter / average-geolocation.js
Created May 17, 2017 18:00
Calculate the center/average of multiple GeoLocation coordinates
/**
* Calculate the center/average of multiple GeoLocation coordinates
* Expects an array of objects with .latitude and .longitude properties
*
* @url http://stackoverflow.com/a/14231286/538646
*/
function averageGeolocation(coords) {
if (coords.length === 1) {
return coords[0];
}
@tlhunter
tlhunter / gist:3740676
Created September 18, 2012 01:05
PHP localhost dashboard
<?php
session_start();
?>
<html>
<head>
<title><?php echo $_SERVER['SERVER_NAME']; ?></title>
<style>
body {
background-color: #000;
margin: 10px; padding: 0px;
@tlhunter
tlhunter / rmq-pub.js
Created June 4, 2014 22:01
Node.js ampqlib pubsub example, works with RabbitMQ, run several instances of each script
#!/usr/bin/env node
var amqp = require('amqplib');
var exchange_name = 'pubsub';
amqp.connect('amqp://localhost').then(function(conn) {
process.once('SIGINT', function() { conn.close(); });
return conn.createChannel().then(function(channel) {
#EXTM3U
#EXTINF:-1,Groove Salad: a nicely chilled plate of ambient beats and grooves. [SomaFM]
http://uwstream1.somafm.com:80
#EXTINF:-1,Dub Step Beyond: Dubstep, Dub and Deep Bass. May damage speakers at high volume. [SomaFM]
http://somafm.com/dubstep.pls
#EXTINF:-1,Def Con Radio: SomaFM's special mix for Def Con [SomaFM]
http://somafm.com/defcon.pls
#EXTINF:-1,The Trip: Progressive house / trance. Tip top tunes. (Formerly Tag's Trance Trip) [SomaFM]
http://somafm.com/thetrip.pls
#EXTINF:-1,Suburbs of Goa [SomaFM]
@tlhunter
tlhunter / crawler.php
Created September 18, 2012 01:28
PHP Eve Online Killmail Scraper
<?php
include("mysql.ssi.php");
#Naming conventions: http://support.eve-online.com/Pages/KB/Article.aspx?id=37
#Sample page format: http://www.example.com/?a=kill_detail&kll_id=1000000
# This is a script I wrote a few years ago to scrape Eve Online kill mails. I ran it on a single
# core 2.4 Ghz with 2GB of RAM for a week and it scraped a couple million kills. It stores data
# in a relational format, but I've since lost the schema file. It can be easily reverse
# engineered from this file though. It would scrape sequentially, it should have run multiple
# requests in parallel for better efficiency.
@tlhunter
tlhunter / traveling-salesman.php
Created September 18, 2012 01:11
PHP Traveling Salesman Genetic Algorithm
<?php
ini_set("error_reporting", E_ALL & ~E_NOTICE);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Genetic Algorithm : TSP : PHP Implementation by Thomas Hunter</title>
<style>
body {
@tlhunter
tlhunter / node-cluster.js
Created July 19, 2019 23:36
Just the basic node cluster example
const cluster = require('cluster');
const http = require('http');
const numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
console.log(`Master ${process.pid} is running`);
// Fork workers.
for (let i = 0; i < numCPUs; i++) {
cluster.fork();