Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/perl
#
# Eric Jiang
# http://notes.ericjiang.com/posts/54
# This software is public domain.
#
# NOTE: This code is not maintained!
# There is a newer version written in C:
# https://github.com/erjiang/usbscale
#
@erjiang
erjiang / minke_aire.txt
Last active October 6, 2021 05:21
Minke Aire remote command codes
01010 - toggle light
10010 - toggle light 2
01000 - speed 2
00100 - speed 1
10100 - stop
10000 - speed 3
00010 - reverse
ALL CODES:
import secrets
import string
from typing import Sequence
"""
This is a set of functions for demonstrating one-time pad
encryption using a twenty-six letter alphabet.
This code is a companion to the article at
https://notes.ericjiang.com/posts/1051
#!/bin/bash
# This command can fix timezone offsets for Nikon D850 RAW photos.
# Other vendors may have different date/time metadata.
# the hours offset should be the difference in hours to add to the camera's time
HOURS_OFFSET=20:00:00
# this should be the location's actual TZ offset
NEW_OFFSET=+13:00
exiftool -ModifyDate+=$HOURS_OFFSET -CreateDate+=$HOURS_OFFSET -OffsetTime=$NEW_OFFSET -OffsetTimeOriginal=$NEW_OFFSET -OffsetTimeDigitized=$NEW_OFFSET -TimeZone=$NEW_OFFSET -DateTimeOriginal+=$HOURS_OFFSET -overwrite_original *.NEF
#!/bin/bash
# Given image files, check the file to see if it has an embedded rating. If it
# does, write it to a RawTherapee sidecar file (.pp3), unless there already is
# a sidecar file.
for FILE in $*
do
RATING=`exiftool -p '$Rating' $FILE`
if [ "$RATING" -ne "0" -a ! -z "$RATING" ]
@erjiang
erjiang / php_get_class.php
Created January 9, 2014 17:03
PHP inheritance and get_class
<?php
class BigClass {
function whatIsThis() {
echo __METHOD__ . ": " . get_class() . "\n";
}
function whatIsThisNow() {
echo __METHOD__ . ": " . get_class($this) . "\n";
}
@erjiang
erjiang / .hgrc
Created May 21, 2013 20:24
My .hgrc
[ui]
username = Eric Jiang <eric@doublemap.com>
editor = vim
merge = vimdiff
[extensions]
hgext.graphlog =
pager =
rebase =
color =
transplant =
@erjiang
erjiang / dp.py
Created April 22, 2013 03:32 — forked from xarg/dp.py
# pure-Python Douglas-Peucker line simplification/generalization
#
# this code was written by Schuyler Erle <schuyler@nocat.net> and is
# made available in the public domain.
#
# the code was ported from a freely-licensed example at
# http://www.3dsoftware.com/Cartography/Programming/PolyLineReduction/
#
# the original page is no longer available, but is mirrored at
# http://www.mappinghacks.com/code/PolyLineReduction/
#!/bin/bash
# copied from https://github.com/exogen/dotfiles/blob/730fb8e2b72b2fc3aa3d90b889874bb5195e1d07/.profile#L65
# Skip DASH manifest for speed purposes. This might actually disable
# being able to specify things like 'bestaudio' as the requested format,
# but try anyway.
# Get the best audio that isn't WebM, because afplay doesn't support it.
# Use "$*" so that quoting the requested song isn't necessary.
@erjiang
erjiang / merge-building-addrs.py
Last active October 15, 2015 21:44 — forked from balrog-kun/merge-building-addrs.py
Merge two .osm files, one with building footprints, one with address nodes. Write output.osm.
#! /usr/bin/python2
# vim: fileencoding=utf-8 encoding=utf-8 et sw=4
import sys
import os
import xml.etree.cElementTree as ElementTree
import string
outroot = ElementTree.Element("osm", { "version": "0.6" })
bldgroot = ElementTree.parse(sys.argv[1]).getroot()