Skip to content

Instantly share code, notes, and snippets.

mathew lpar

Block or report user

Report or block lpar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lpar
lpar / ocrimg.rb
Created Nov 11, 2019
OCR random images using Google Cloud Vision and put the results in the Finder metadata for macOS Spotlight search
View ocrimg.rb
# Ruby script to OCR random JPEG and PNG files using Google Cloud Vision,
# then add the results to the macOS Finder metadata for Spotlight search purposes.
# Before you can use this you need to set up billing for Google Cloud Vision, and
# download the public/private key credentials as a JSON file. See:
# https://cloud.google.com/vision/docs/setup
ENV["GOOGLE_APPLICATION_CREDENTIALS"] = "path-to-google-cloud-vision-credentials-file.json"
require "shellwords"
@lpar
lpar / KotlinPipeline.md
Last active Sep 12, 2019
Example of a processing pipeline in Kotlin — once with threads and BlockingQueue, once with channels and suspend functions
View KotlinPipeline.md

Kotlin pipeline example

Example of a processing pipeline in Kotlin, implemented two different ways:

  1. Using JVM threads and BlockingQueue (package threads)
  2. Using Kotlin coroutines and channels (package coroutines)

The pipeline in both cases goes Source -> Filter -> Output, with all three stages containing blocking code.

@lpar
lpar / moon.c
Last active Apr 17, 2019
A small C program to add the current moon phase to your prompt
View moon.c
#include <stdio.h>
#include <string.h>
#include <time.h>
/**
* Output the current moon phase as an emoji for your prompt.
*
* Build:
*
* gcc -o moon moon.c
@lpar
lpar / scurl.js
Created Mar 18, 2019
scurl.js: fetch web pages, process them with Mozilla Firefox Readability, write the results as html files to squirrel away
View scurl.js
const request = require("request");
const Readability = require("readability");
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const fs = require("fs");
function makeCallback(url) {
return function callback(error, response, body) {
if (error || response.statusCode != 200) {
return
@lpar
lpar / config.go
Last active May 1, 2018
Very simple example of reading a config file into an object which provides an interface for fetching config values
View config.go
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
type Config interface {
@lpar
lpar / noo.json
Last active Apr 26, 2018
Quick test of YAML parsing in Go
View noo.json
[{"designation":"419880 (2011 AH37)","discovery_date":"2011-01-07T00:00:00.000","h_mag":"19.7","i_deg":"9.65","moid_au":"0.035","orbit_class":"Apollo","period_yr":"4.06","pha":"Y","q_au_1":"0.84","q_au_2":"4.26"}
,{"designation":"419624 (2010 SO16)","discovery_date":"2010-09-17T00:00:00.000","h_mag":"20.5","i_deg":"14.52","moid_au":"0.028","orbit_class":"Apollo","period_yr":"1","pha":"Y","q_au_1":"0.93","q_au_2":"1.08"}
,{"designation":"414772 (2010 OC103)","discovery_date":"2010-07-28T00:00:00.000","h_mag":"19","i_deg":"23.11","moid_au":"0.333","orbit_class":"Apollo","period_yr":"1.31","pha":"N","q_au_1":"0.39","q_au_2":"2"}
,{"designation":"414746 (2010 EH20)","discovery_date":"2010-03-06T00:00:00.000","h_mag":"18","i_deg":"23.89","moid_au":"0.268","orbit_class":"Amor","period_yr":"4.24","pha":"N","q_au_1":"1.25","q_au_2":"3.99"}
,{"designation":"407324 (2010 OB101)","discovery_date":"2010-07-18T00:00:00.000","h_mag":"20.7","i_deg":"9.12","moid_au":"0.111","orbit_class":"Apollo","period_yr":"2.06","pha":"N"
@lpar
lpar / mviplayer.go
Last active Mar 3, 2018
Rename radio shows downloaded from BBC iPlayer with get_iplayer to have human-friendly filenames
View mviplayer.go
package main
// This is a quick Go program to rename radio shows downloaded from BBC iPlayer
// by removing the program IDs and _original from the end of the filename
// and converting underscores to spaces.
// Copyright status: WTFPL http://www.wtfpl.net
import (
"fmt"
@lpar
lpar / Evernote filing droplet.dmg
Last active Feb 10, 2018
AppleScript droplet to file documents into specific Evernote notebooks
@lpar
lpar / ssh-agent.fish
Created Nov 14, 2017
Fish shell script to run ssh-agent correctly, i.e. only start a new one when necessary
View ssh-agent.fish
#!/usr/bin/fish
#
# Fish script to run ssh-agent correctly, i.e. only start a new one when
# necessary. Drop it into ~/.config/fish/conf.d and forget about it.
#
# Uses ps and kill, everything else is done inside fish.
#
# Requires fish 2.3 for the string manipulation.
#
# Works with Fedora 26 and CentOS 7, for CentOS 6 you'll need a third party
@lpar
lpar / keybase.md
Last active Jul 22, 2019
keybase.md
View keybase.md

Keybase proof

I hereby claim:

  • I am lpar on github.
  • I am meta23 (https://keybase.io/meta23) on keybase.
  • I have a public key ASA7PxMoCOU9rSoehhs8ukKvGYk1ioM4GLQ-OTQslBIV3wo

To claim this, I am signing this object:

You can’t perform that action at this time.