Skip to content

Instantly share code, notes, and snippets.

@thefloweringash
thefloweringash / fix-freebsd-update.sh
Created January 31, 2014 10:09
There I "fixed" freebsd-update.
#!/bin/sh
# freebsd-update makes assumptions that don't match the world I live
# in. My local mirror has a 20ms rtt, can probably saturate my 130mbps
# line speed and takes about 2 minutes to fetch all of FreeBSD 10's
# dists; freebsd-update's mirrors are at least 140ms away, and take
# about 4 hours to fetch the changes from 9.1-RELEASE-p10 to
# 10.0-RELEASE.
#
# freebsd-update is a clever script that downloads a lot of bsdiff
@thefloweringash
thefloweringash / gist:1511527c46d22730480c2f2e745ae7ad
Created October 24, 2018 05:13
What is `nix run`? How is it meant to work?
$ nix run nixpkgs.rubocop
error: attribute 'nixpkgs' in selection path 'nixpkgs.rubocop' not found
$ nix run -f '<nixpkgs>' rubocop
tourou:~ lorne$ which rubocop
/run/current-system/sw/bin/rubocop
tourou:~ lorne$ exit
$ nix run -f '<nixpkgs>' rubocop -c which rubocop
/nix/store/j7my41m8s9irhyczlscy6yd5lcgsclck-rubocop-0.59.1/bin/rubocop
@thefloweringash
thefloweringash / CMakeLists.txt
Last active October 9, 2018 17:53
accounts-service-consumer
cmake_minimum_required(VERSION 3.11)
project(accounts-service-consumer LANGUAGES C)
find_package(PkgConfig)
pkg_check_modules(Glib IMPORTED_TARGET REQUIRED glib-2.0)
pkg_check_modules(AccountsService IMPORTED_TARGET REQUIRED accountsservice)
add_executable(accounts-service-consumer main.c)
$ cat metrics.nix
with (import <nixpkgs> {});
runCommand "test-metrics" {} ''
performance-metrics() {
thingname=$1
shift
if [ -n "${enablePhaseMetrics:-}" ]; then
TIMEFORMAT="time.$thingname.user %U
time.$thingname.system %S
diff --git a/pkgs/tools/networking/whois/default.nix b/pkgs/tools/networking/whois/default.nix
index 6f37e88f4f6..abd358339b1 100644
--- a/pkgs/tools/networking/whois/default.nix
+++ b/pkgs/tools/networking/whois/default.nix
@@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
substituteInPlace $i --replace "prefix = /usr" "prefix = $out"
done
- substituteInPlace Makefile --replace "DEFS += HAVE_ICONV" "DEFS += HAVE_ICONV\nwhois_LDADD += -liconv"
+ substituteInPlace Makefile --replace "DEFS += -DHAVE_ICONV" "$(printf "%s\n%s" "DEFS += -DHAVE_ICONV" "whois_LDADD += -liconv")"
{
"name": "conshomebridge",
"scripts": {
"start": "nf start",
"start:mosca": "mosca --credentials mosca/credentials.json -v",
"start:homebridge": "homebridge -D -U $PWD/homebridge -P plugins"
},
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
#!/usr/bin/env ruby
require 'sqlite3'
db = SQLite3::Database.new(ARGV[0])
SEP = "\u001f"
# First field in deck is frame number from the v6 edition (well
# actually the id, but the id and frame number seem to match)
#
@thefloweringash
thefloweringash / portsnap
Last active January 4, 2016 02:49
Traceroutes for FreeBSD mirrors
lorne@northind$ traceroute ftp.nz.freebsd.org
traceroute to warnock.catalyst.net.nz (202.78.240.39), 64 hops max, 52 byte packets
1 routerboard (10.88.0.1) 0.367 ms 0.335 ms 0.233 ms
2 * * *
3 lo0.internet.ivpn.pe25.telstraclear.net (218.101.61.124) 42.577 ms 14.755 ms 8.580 ms
4 telstraclear3.wix.nzix.net (202.7.0.77) 10.100 ms 9.760 ms 9.917 ms
5 catalyst-it1.wix.nzix.net (202.7.0.145) 19.930 ms 19.580 ms 19.955 ms
6 warnock.catalyst.net.nz (202.78.240.39) 20.234 ms 19.625 ms 19.801 ms
lorne@northind$ traceroute update2.freebsd.org
@thefloweringash
thefloweringash / via-vodafone-proxy
Created December 10, 2013 05:03
Vodafone's "transparent" proxy is still extracting gzipped tars.
lorne@argon$ curl -vsL -o - http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz | file -
* Adding handle: conn: 0x7fd610803a00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fd610803a00) send_pipe: 1, recv_pipe: 0
* About to connect() to www.python.org port 80 (#0)
* Trying 82.94.164.162...
* Connected to www.python.org (82.94.164.162) port 80 (#0)
> GET /ftp/python/2.7.6/Python-2.7.6.tgz HTTP/1.1
@thefloweringash
thefloweringash / monad.clj
Created November 4, 2013 05:13
Why not Haskell syntax?
(ns gist.monad
(use [clojure.algo.monads :only [domonad]]))
(def <-)
(defn transform-monad-syntax [body last-was-assign]
(let [[v o e & r] body]
(cond (empty? body)
(if last-was-assign
(throw (IllegalArgumentException. "last value in m-do must be expression"))