Skip to content

Instantly share code, notes, and snippets.

View fnl's full-sized avatar

Florian Leitner fnl

View GitHub Profile
@fnl
fnl / keybase.md
Created February 8, 2017 22:36
Keybase proof

Keybase proof

I hereby claim:

  • I am fnl on github.
  • I am fnl (https://keybase.io/fnl) on keybase.
  • I have a public key ASAtviduoVKtS7prYUGXxnvmv4gd-WpeiGq50miTcprB_go

To claim this, I am signing this object:

@fnl
fnl / test.java
Created February 24, 2016 19:01
Comparing Java HashSet, TreeSet, and LinkedHashSet performance.
import java.util.*;
public class test{
// Conclusion
// use HashSet...
// ...unless you have few accesses and mostly only build them, in which case LinkedHashSet is faster
// ...and only use TreeSet when you need the order
final static int size = 500;
final static int accesses = 10;
package spark.example
import org.apache.spark.SparkContext
import org.apache.spark.SparkConf
object SparkGrep {
def main(args: Array[String]) {
if (args.length < 3) {
System.err.println("Usage: SparkGrep <host> <input_file> <match_term>")
System.exit(1)
@fnl
fnl / skript.py
Created June 28, 2015 12:16
Python 3 script/command-line skeleton
#!/usr/bin/env python3
"""
Description
"""
from argparse import ArgumentParser
import logging
import os
import sys
from somewhere import main
@fnl
fnl / pos.py
Created September 25, 2014 10:03
A simpler feature extractor for PoS tagging with CRFsuite. Input now only needs to be 'w y', meaning the word itself and the PoS tag, separated by a space.
#!/usr/bin/env python
"""
An example for part-of-speech tagging.
Copyright 2010,2011 Naoaki Okazaki.
"""
import crfutils
# Separator of field values.
@fnl
fnl / annotation_quote.js
Created May 22, 2013 10:02
A quick-and-dirty hack to have the Annotator (https://github.com/okfn/annotator) popup show the actually annotated text (!called "annotation.quote") in addition to the comment (!called "annotation.text").
var data = $(element).data('annotator');
// expand the viewer to show the annotated text (quote)
data.viewer.fields[0].load = function (field, annotation) {
return annotation.text
? $(field).html(annotation.quote + "<br/><i>" + escape(annotation.text) + "</i>")
: $(field).html(annotation.quote),
data.publish("annotationViewerTextField", [field, annotation]);
}
@fnl
fnl / sync_hfs_with_fat32.sh
Created January 29, 2013 10:16
backup/restore files to [a USB dongle] FAT32 drive on OSX/HFS using rsync. Updates and deletes changed files recursively starting in some root directory "dir". Note that the terminal slashes present in the paths are required for rsync to work correctly.
# backup from HFS drive to FAT32 (NB: file owner and extended metadata are not synced):
time rsync --recursive --update --delete --links --hard-links --safe-links --perms --times --modify-window=1 --stats --exclude '.DS_Store' --exclude '._*' ~/dir/ /Volumes/FAT32
# restore from FAT32 to HFS (NB: "--delete" removes files in "dir" not in "FAT32"):
time rsync --recursive --update --delete --links --hard-links --safe-links --perms --times --modify-window=1 --stats --exclude '.DS_Store' --exclude '.Spotlight-V100' --exclude '.fseventsd' --exclude '.Trashes' /Volumes/FAT32/ ~/dir