Skip to content

Instantly share code, notes, and snippets.

@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"
@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 / 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
// 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
}
exe, _ := os.Executable()
sf, err := siegfried.Load(filepath.Join(filepath.Dir(exe), "pronom.sig"))