Skip to content

Instantly share code, notes, and snippets.

@daz
daz / gist:477190328f5f20121c26c42ef8fbedbc
Created Sep 23, 2022
Upgrading postgresql 12 to 14 homebrew with postgis
View gist:477190328f5f20121c26c42ef8fbedbc
brew install postgresql
brew services stop postgresql
pg_upgrade --old-bindir=/opt/homebrew/opt/postgresql@12/bin \
--new-bindir=/opt/homebrew/opt/postgresql@14/bin \
--old-datadir=/opt/homebrew/var/postgresql@12 \
--new-datadir=/opt/homebrew/var/postgres \
--check
# If you're getting non-empty database errors for the new database, rename the directory to a backup and init a new db:
@daz
daz / organize-h20t.rb
Last active Sep 2, 2022
Organize DJI H20T images into folders
View organize-h20t.rb
#!/usr/bin/env ruby
# organize-h20t.rb [files]
# https://gist.github.com/daz/9c214125341ce7a3dc3909a1126297c8
# Organize H20T images, videos, and captions into folders by camera types, i.e. S, T, W, Z
# Creates a folder for each camera type, and moves the files into their respective folder
# Usage:
# cd DJI_202208071450_002
# ./organize-h20t.rb DJI_20220807145439_0001_S.MP4 DJI_20220807145439_0001_T.MP4 DJI_20220807145439_0001_W.MP4 DJI_20220807145439_0001_Z.MP4
@daz
daz / 360-photo-facebook.sh
Created Apr 12, 2022
Prepare 360 photo for Facebook with max resolution
View 360-photo-facebook.sh
#!/bin/sh
# Resizes any equirectangular image down to the max resolution and file size
# that Facebook will allow and adds 360 metadata. Saves copy with _fb appended
# to file name.
#
# Usage:
# ./360-photo-facebook.sh equirectangular_360_image.jpg
# Max settings, working April 2022
@daz
daz / is-inside.js
Created Mar 8, 2022
Check if images are inside a polygon
View is-inside.js
#!/usr/bin/env node
// Example usage:
//
// ./is-inside.js base/path/to/images -21,149 -21.1,152 -24,152.2 -24.1,148.9
import glob from "glob";
import * as fs from "fs";
import * as path from "path";
import * as turf from "@turf/turf";
@daz
daz / setup-unifi-macos.sh
Created Oct 29, 2021 — forked from mkormendy/setup-unifi-macos.sh
UniFi Network Controller Setup for MacOS with Homebrew
View setup-unifi-macos.sh
#!/bin/sh
brew tap homebrew/cask-drivers
brew install --cask homebrew/cask-versions/adoptopenjdk8
brew install --cask ubiquiti-unifi-controller
@daz
daz / hikvision-anpr.sh
Created Mar 12, 2021
Hikvision ANPR ISAPI list with curl
View hikvision-anpr.sh
curl --digest -u username:password \
-X POST http://192.168.1.4/ISAPI/Traffic/channels/1/vehicleDetect/plates \
-d '<AfterTime><picTime>2020-03-07T21:00:00Z</picTime></AfterTime>'
@daz
daz / airdata-flights.js
Created Oct 23, 2020
Download all Airdata flights
View airdata-flights.js
// Get a list of all Airdata flight download URLs in KML, GPX, CSV, original format.
// Go to https://app.airdata.com/flight/last and paste this into the console
let urlList = $("#item_list_dt")
.DataTable()
.tables()
.context[0].aoData.map(a => {
return a._aData.h;
})
.slice(1, -1)
@daz
daz / RightClick.applescript
Created Aug 23, 2020 — forked from vitorgalvao/Right-Click.applescript
Make right-clicking on OSX accessible via a keyboard shortcut.
View RightClick.applescript
(*
Even though a [native solution][1] exists, it still suffers from a big flaw: it right-clicks the place you cursor is, not what you’re selecting. This addresses that limitation.
You can install this as a [Finder Service, and later asign it a keyboard shortcut][2].
[1]: http://stackoverflow.com/questions/9171613/right-click-shortcut-for-mac-lion-os
[2]: http://www.macosxautomation.com/services/learn/tut01/index.html
*)
@daz
daz / gulpfile.js
Last active Feb 7, 2022
Gulpfile to minify single HTML, CSS, JS file, make it a C++ string, and inject it into a C++ file. Handy for Arduino/ESP projects
View gulpfile.js
const gulp = require("gulp");
const gutil = require("gulp-util");
const inject = require("gulp-inject");
const htmlMin = require("gulp-htmlmin");
const cssMinifyOptions = true;
const jsMinifyOptions = {
mangle: {
toplevel: true
},
@daz
daz / reduce_faces.py
Created Oct 31, 2019 — forked from tylerlindell/reduce_faces.py
script for reducing faces programmatically with Meshlab's api
View reduce_faces.py
#!/usr/bin/env python
import sys
import os
import subprocess
# Script taken from doing the needed operation
# (Filters > Remeshing, Simplification and Reconstruction >
# Quadric Edge Collapse Decimation, with parameters:
# 0.9 percentage reduction (10%), 0.3 Quality threshold (70%)