Skip to content

Instantly share code, notes, and snippets.

@ato
ato / debug.clj
Created December 9, 2009 11:42
Simpler debug-repl that works with unmodified Clojure
;; Inspired by George Jahad's version: http://georgejahad.com/clojure/debug-repl.html
(defmacro local-bindings
"Produces a map of the names of local bindings to their values."
[]
(let [symbols (map key @clojure.lang.Compiler/LOCAL_ENV)]
(zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols)))
(declare *locals*)
(defn eval-with-locals
@ato
ato / ucurl.c
Created April 25, 2014 07:07
LD_PRELOAD wrapper which tricks curl (or anything else) into connecting to a unix domain socket
/*
* LD_PRELOAD wrapper which tricks curl (or anything else) into connecting to a unix domain socket
*
* Compile: gcc -o ucurl.so -shared ucurl.c -ldl -fPIC
* Usage: LD_PRELOAD=/path/to/ucurl.so SOCKET=/path/to/socket curl http://0.0.0.0/
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
@ato
ato / TempoDirectory.java
Created October 1, 2013 05:55
TempDirectory java temporary directory delete on exit
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
class TempDirectory {
final Path path;
@ato
ato / warc-conversion-software-fields.md
Last active March 5, 2019 13:06
WARC conversion software fields draft

WARC conversion software fields (draft)

When converting content in an archive it is useful for diagnostic purposes to record the versions of major software components used and important conversion options. Another common use case is to identify records that later need to be reconverted with newer software in order to improve conversion quality or fix records misconverted due to a bug or incorrect option.

WARC-Conversion-Software

The WARC-Conversion-Software field indicates the version of software components used in the

@ato
ato / ReplayProxy.java
Last active November 28, 2018 23:12
OutbackProxy?
package outbackproxy;
import io.undertow.Undertow;
import io.undertow.connector.ByteBufferPool;
import io.undertow.server.DefaultByteBufferPool;
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.handlers.BlockingHandler;
import io.undertow.util.HeaderMap;
import io.undertow.util.HttpString;
https://nlaaus-my.sharepoint.com/:p:/g/personal/aosborne_nla_gov_au/ETBiJ45EopxHurgUNogz2NwBSuY5zG8uvQub-bccPj-GYw?e=FryT8V
@ato
ato / ssurt.py
Last active November 5, 2017 05:38
#!/usr/bin/python3
# coding=utf-8
import re
SSURT_RE = r"""
\A
(?P<scheme> [a-zA-Z] [a-zA-Z0-9+.-]* : )?
(?P<authority>
(?P<slashes> /* )
@ato
ato / ItemNodesController.java
Last active October 19, 2016 03:12
On the fly unzipping for dl-repo
import de.schlichtherle.truezip.rof.AbstractReadOnlyFile;
import de.schlichtherle.truezip.zip.ZipEntry;
import de.schlichtherle.truezip.zip.ZipFile;
// ...
@RequestMapping(value = "/Repository/unzip/copy/{copyId:nla\\.obj-[^/]+}/{path:.+}", method = {RequestMethod.GET})
@ResponseBody
public void unzipCopy(@PathVariable String copyId,
@PathVariable String path,
@ato
ato / README.md
Last active September 29, 2016 20:24
tinycdxserver example

I just tried my example from the tinycdxserver README and realised that curl is messing up the line-endings due to some conversion it does by default. I haven't checked yet exactly what curl is doing but tinycdxserver is interpreting it as if all the lines in the file have been concatenated together (you can see that by running tinycdxserver in verbose mode with the -v option).

Using curl's --data-binary option instead of --data fixes that and I've updated the README correspondingly.

That could be what's tripping you up. Here's a more complete example that I just tested. You should get an "Added N records" response back if it worked properly, where N is the line count of the cdx.

@ato
ato / ERB.java
Last active February 3, 2016 09:28
JRuby
package pavo;
import java.io.*;
import java.util.*;
import javax.script.*;
public class ERB {
static ScriptEngine jruby = initializeJRuby();