Skip to content

Instantly share code, notes, and snippets.

@lpar
lpar / freshdesk-html-edit.js
Created August 22, 2024 15:31
Re-enable HTML edit in Freshdesk rich text editor
// ==UserScript==
// @name Freshdesk HTML edit reenable
// @namespace http://tampermonkey.net/
// @version 2024-08-22
// @description Re-enables the HTML edit option in the Freshdesk reply editor
// @author [email protected]
// @match https://*.freshdesk.com/a/tickets/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=freshdesk.com
// @grant none
// ==/UserScript==
@lpar
lpar / README.md
Last active August 14, 2024 02:53
Rules for Bouncer app to block SMS spam from Democratic campaigns

I got tired of SMS spam from political campaigns. I found an app called Bouncer for iOS which lets you create your own filtering rules to move SMS into a junk folder, but that seemed like hard work.

So I tried various paid services that claimed they could stop SMS spam, some of which claimed they used AI. None of them worked as well as Bouncer plus a few rules I wrote myself. In addition, Bouncer runs entirely on the device, unlike several of the commercial systems, so your messages aren't sent to some random server somewhere.

Happily Bouncer can import and export rules as JSON, so here are mine. It has been several weeks since spam texts made it to my message inbox; the rules caught four on Thursday.

As an aside, SMS spam is supposed to be illegal without consent, and I've been careful never to give my number to any political campaign. But political campaigns get around the law by having banks of humans copy and paste the spam and s

@lpar
lpar / petstore2.yaml
Created January 12, 2022 16:53
Modified petstore.yaml to demonstrate openapi-generator bug
openapi: 3.0.0
servers:
- url: 'http://petstore.swagger.io/v2'
info:
description: >-
This is a sample server Petstore server. For this sample, you can use the api key
`special-key` to test the authorization filters.
version: 1.0.0
title: OpenAPI Petstore
license:
@lpar
lpar / ec2tags.go
Created November 12, 2020 00:23
How to fetch the tags for the current EC2 instance, from Go, using only official AWS Go SDK calls.
package main
// An example of obtaining the tags for the current EC2 running instance,
// from a Go program running inside the instance, using the official AWS SDK (v1).
import (
"errors"
"fmt"
"github.com/aws/aws-sdk-go/aws"
@lpar
lpar / elephantoplasty.sh
Last active June 15, 2020 16:47
Change the name of your default Git branch to `trunk`.
#!/bin/sh -e
#
# This is a terrible hack of a Github script to change the name of your
# default or main branch from 'master' to 'trunk', both in your local
# repo and on Github. I don't usually write shell scripts, so if someone
# wants to clean it up and make it robust, that'd be great.
#
# As to why you might want to rename your default branch...
#
# Consider that the entire metaphor of source control is that of a
@lpar
lpar / ocrimg.rb
Created November 11, 2019 17:17
OCR random images using Google Cloud Vision and put the results in the Finder metadata for macOS Spotlight search
# 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 September 12, 2019 10:16
Example of a processing pipeline in Kotlin — once with threads and BlockingQueue, once with channels and suspend functions

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 June 16, 2023 22:24
A small C program to add the current moon phase to your prompt
#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 / config.go
Last active May 1, 2018 18:25
Very simple example of reading a config file into an object which provides an interface for fetching config values
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
type Config interface {
@lpar
lpar / noo.json
Last active April 26, 2018 20:41
Quick test of YAML parsing in Go
[{"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"