Skip to content

Instantly share code, notes, and snippets.

@haakonn
haakonn / s3fs-delcache.sh
Created January 27, 2019 20:27
Script to expire files from s3fs-fuse's cache, with support for spaces in file names
#!/bin/bash
# Modified version of https://github.com/s3fs-fuse/s3fs-fuse/blob/master/test/sample_delcache.sh
# to support spaces in filenames (trade-off: filenames cannot contain "¼", which should be OK for most).
#
# This is unsupport sample deleting cache files script.
# So s3fs's local cache files(stats and objects) grow up,
# you need to delete these.
# This script deletes these files with total size limit
# by sorted atime of files.
@haakonn
haakonn / btno-nopaywall.user.js
Created December 4, 2016 12:51
btno-nopaywall.user.js - bt.no uten betalingsmurinnhold
// ==UserScript==
// @name btno-nopaywall
// @namespace haakonnilsen.com
// @include http://www.bt.no/*
// @version 1
// @grant none
// ==/UserScript==
function remAll(xpath) {
var els = document.evaluate(xpath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
@haakonn
haakonn / sportsfri-aftenposten.user.js
Created January 23, 2016 17:14
Sportsfri Aftenposten
// ==UserScript==
// @name Sportsfri Aftenposten
// @namespace http://haakonnilsen.com
// @description Aftenposten uten sport
// @include http://www.aftenposten.no/*
// @include https://www.aftenposten.no/*
// @include http://www.ba.no/
// @include http://www.bt.no/*
// @include https://www.vg.no/
// @grant none
@haakonn
haakonn / sportsfri-bt.user.js
Created January 23, 2016 17:13
Sportsfri Bergens Tidende
// ==UserScript==
// @name Sportsfri Bergens Tidende
// @namespace http://haakonnilsen.com
// @description Bergens Tidende uten sport
// @include http://www.bt.no/*
// @grant none
// ==/UserScript==
var boring = "sport|fotball|live|sprek";
var filterRE = new RegExp(boring);
@haakonn
haakonn / bt-abonnent.user.js
Last active December 14, 2016 13:48
Les abonnent-innhold på bt.no med Greasemonkey
// ==UserScript==
// @name bt-abonnent
// @namespace haakonnilsen.com
// @include http://www.bt.no/*
// @version 2
// @grant none
// ==/UserScript==
// Only works with JavaScript disabled. You can use YesScript for this.
@haakonn
haakonn / repeat.scala
Created April 21, 2015 20:38
Implementing the repeat loop in Scala
/*
Enables loops such as this:
var i = 10
repeat {
print(s"i is $i\n")
i = i - 1
} until (i == 0)
*/
Rank Who Followers Following Ratio
1 BTCFoundation 35407 224 158.06697
2 learnemacs 4834 414 11.676329
3 B1TCOIN 21869 9725 2.2487404
4 BitcoinPRBuzz 13507 6483 2.0834491
5 magistratic 58 28 2.0714285
6 EVRY_ASA 657 364 1.8049451
7 erikfossen 1483 868 1.7085253
8 klingsen 386 258 1.496124
Verifying myself: My Bitcoin username is +haakon. https://onename.io/haakon
@haakonn
haakonn / Logfile to CSV in Scala
Created October 7, 2013 19:00
Just a quick Scala script to convert a certain logfile into CSV. Instead of instinctively going to bash or python for these things, why not Scala? Just run with 'scala makecsv.scala', starts and finishes quickly. No build step or bytecode or support files, just a script.
println("date,msisdn,message")
scala.io.Source.fromFile("problem.log").getLines().foreach { line =>
val m = "^(.{19}).*msisdn='(.{10}).*msg='(.*)', status.*".r.findFirstMatchIn(line).get
println(s"""${m.group(1)},${m.group(2)},"${m.group(3)}"""")
}