Skip to content

Instantly share code, notes, and snippets.

@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
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 July 22, 2019 16:24
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:

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

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
View combos
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
View reflection.go
package main
import (
"fmt"
"reflect"
)
// A detailed example of examining a struct value in Go via reflection,
// and changing field values (if possible).
//
View Clean up download files.applescript
-- 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
View DirectoryNamePicker.java
/*
* © 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!
View bom.c
#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
View java-install
#!/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'
@lpar
lpar / 10-mail.conf
Created May 15, 2015 14:13
Main Dovecot configuration file /etc/dovecot/conf.d/10-mail.conf
View 10-mail.conf
##
## Mailbox locations and namespaces
##
# Location for users' mailboxes. The default is empty, which means that Dovecot
# tries to find the mailboxes automatically. This won't work if the user
# doesn't yet have any mail, so you should explicitly tell Dovecot the full
# location.
#
# If you're using mbox, giving a path to the INBOX file (eg. /var/mail/%u)