Skip to content

Instantly share code, notes, and snippets.

@lpar
lpar / Evernote filing droplet.dmg
Last active August 27, 2021 22:40
AppleScript droplet to file documents into specific Evernote notebooks
@lpar
lpar / ssh-agent.fish
Created November 14, 2017 19:05
Fish shell script to run ssh-agent correctly, i.e. only start a new one when necessary
#!/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 July 22, 2019 16:24
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:

@lpar
lpar / README.md
Last active January 29, 2023 14:09
How to make Hugo (0.20+) generate an Atom feed instead of RSS

The Hugo static site generator sadly still uses the obsolete and badly standardized RSS format.

Here's how to set it up to generate an Atom feed instead. Pretty much all feed readers which understand RSS also understand Atom, except iTunes, and Atom is a better format.

  1. Define an appropriate media type and corresponding output format in config.toml:
@lpar
lpar / combos
Last active July 13, 2016 14:17
Go programming exercise: generating all combinations of an alphabet of symbols
See https://forum.golangbridge.org/t/generation-of-strings-generation/2968/2
@lpar
lpar / reflection.go
Created April 20, 2016 18:08
A detailed example of reflection in Go, interrogating and modifying field values in a struct
package main
import (
"fmt"
"reflect"
)
// A detailed example of examining a struct value in Go via reflection,
// and changing field values (if possible).
//
-- This is the script piece of an Automator workflow, it won't work without the rest of the workflow.
on run {input, parameters}
set maxDaysOld to 14 -- This is the number of days of stuff to keep
set oldFiles to {}
set oldFilesRef to a reference to oldFiles
repeat with n from 1 to length of input
set thing to item n of input
set dateAddedString to (do shell script "mdls -name kMDItemDateAdded -raw " & quoted form of POSIX path of thing)
set dateadded to the (date dateAddedString)
set daysold to ((current date) - dateadded) / 86400
@lpar
lpar / DirectoryNamePicker.java
Created January 5, 2016 22:55
Domino XPages directory name picker using standard Directory API, compatible with Directory Assistance Raw
/*
* © Copyright IBM Corp. 2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@lpar
lpar / bom.c
Created December 1, 2015 23:08
Somebody set us up the BOM!
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
FILE *ifp, *ofp;
ofp = fopen("test.txt", "wb");
@lpar
lpar / java-install
Last active October 29, 2015 14:39
Set up Java on Linux
#!/usr/bin/env ruby
# encoding: UTF-8
# Programs to install from the Java runtimes
PROGS = ['java', 'javac', 'javaws', 'jar', 'keytool']
# Plugins for browsers, original lib name then the name to use in the
# alternatives system
PLUGINS = {
'libnpjp2.so' => 'libjavaplugin.so'