Skip to content

Instantly share code, notes, and snippets.

View richardlehane's full-sized avatar
🦉
Wuz up

Richard Lehane richardlehane

🦉
Wuz up
View GitHub Profile
exe, _ := os.Executable()
sf, err := siegfried.Load(filepath.Join(filepath.Dir(exe), "pronom.sig"))
// Assumes that we only want to parse text strings that are simple signatures anchored at the beginning of the file (i.e. no signatures that have BOF and EOF bits)
func FormatStr(id, str string) (frames.Signature, error) {
sig, _, _, err := process(id, str, false)
if err != nil {
return err
}
sig[0] = frames.NewFrame(frames.BOF, seg[0].Pattern, seg[0].Min, seg[0].Max)
return sig, nil
}
@richardlehane
richardlehane / sorted.go
Last active June 8, 2020 07:50
sorted.go
import "sort"
// sorted sorts signatures by their index so that runs of signatures e.g. fmt/1, fmt/1, fmt/2, fmt/1
// can be propertly placed.
type sorted struct{ Parseable }
func (s sorted) Signatures() ([]frames.Signature, []string, error) {
sigs, ids, err := m.Parseable.Signatures()
if err != nil {
return sigs, ids, err
@richardlehane
richardlehane / keybase.md
Created August 20, 2019 18:40
keybase.md

Keybase proof

I hereby claim:

  • I am richardlehane on github.
  • I am richardlehane (https://keybase.io/richardlehane) on keybase.
  • I have a public key ASDrsoKqcrRAiDKfUKezmJIyhititBd4QLBegOycAIYpJAo

To claim this, I am signing this object:

@richardlehane
richardlehane / readmember.go
Last active August 30, 2018 05:52
example use of decompress package
package main
import (
"fmt"
"io"
"os"
"os/user"
"path/filepath"
"github.com/richardlehane/siegfried"
// parse FcCompressed (section 2.9.73)
func parseFcCompressed(fcData []byte) *fcCompressed {
fCompressed := fcData[3]&64 == 64 // check fcompressed value (second bit from lestmost of the last byte in fcdata)
fcData[3] = fcData[3] & 63 // clear the fcompressed value from data
fc := binary.LittleEndian.Uint32(fcData) // word doc generally uses little endian order (1.3.7)
return &fcCompressed{fc: int(fc), fCompressed: fCompressed}
}
@richardlehane
richardlehane / import.csv
Created June 13, 2017 11:21
ASA directory of Australian archives
We can't make this file beautiful and searchable because it's too large.
identifier,uploadLimit,authorizedFormOfName,contactPerson,streetAddress,telephone,email,fax,website,geoculturalContext,internalStructures,collectingPolicies,holdings,findingAids,openingTimes,accessConditions,disabledAccess,researchServices,reproductionServices,publicFacilities,maintenanceNote,descInstitutionIdentifier,descRevisionHistory,descSources,culture
archives/22,0,Abbotsleigh,Archivist,"1666 Pacific Highway, Wahroonga 2076
Postal address:
Locked Bag 1666, Wahroonga 2076",(02) 9473-7777,gleavesj@abbotsleigh.nsw.edu.au,(02) 9473-7680,http://www.abbotsleigh.nsw.edu.au/,,Officer in charge: Archivist,"Continuing acquisition of material relating to the School, its current and ex students and staff; with some material relating to the local areas of Wahroonga, Ku-Ring-Gai.","Secretary's Office: Student records 1913- (10m). Council: Minutes 1924 (3m).
Quantity: 50m (100% in-house).",,"Abbotsleigh Archives is open Monday to Thursday 8am-4pm throughout the year, including school holidays. General reference assi
[atom]
; The user running the application
user = www-data
group = www-data
; Use UNIX sockets if Nginx and PHP-FPM are running in the same machine
listen = /run/php7.0-fpm.atom.sock
listen.owner = www-data
listen.group = www-data
upstream atom {
server unix:/run/php7.0-fpm.atom.sock;
}
server {
listen 80;
root /usr/share/nginx/atom;
# http://wiki.nginx.org/HttpCoreModule#server_name