Skip to content

Instantly share code, notes, and snippets.

View danielkza's full-sized avatar

Daniel Miranda danielkza

  • Vonage
  • London, United Kingdom
View GitHub Profile
@danielkza
danielkza / ipsec
Created November 29, 2016 13:54
Strongswan IPSec init script with UCI support
#!/bin/sh /etc/rc.common
START=90
STOP=10
NAME=ipsec-uci
USE_PROCD=1
IPSEC_BIN=/usr/sbin/ipsec
IPSEC_SECRETS=/var/run/ipsec/ipsec.secrets
@danielkza
danielkza / gzip-cont.sh
Last active November 11, 2022 13:54
Incrementally gzip a file (such as a log). Each call will append only new bytes from the input to the output.
#!/bin/bash
# Usage: gzip-cont {in_file} {out_file} {gzip_args...}
set -e -o pipefail
in="$1"
out="$2"
shift 2
@danielkza
danielkza / rsmith_save.c
Created December 24, 2012 18:49
Rocksmith save game transfer tool
// Author: pcsmith
// Modifications: danielkza (danielkza2@gmail.com)
// License: GPLv3 https://www.gnu.org/licenses/gpl.html
// More info: http://rsmods.oakey-dev.eu/index.php?title=Savegame_Transfer
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@danielkza
danielkza / Dockerfile
Created January 5, 2018 21:54
Bors-NG Docker setup
ARG ELIXIR_VERSION=1.4.5
FROM elixir:${ELIXIR_VERSION} as builder
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
RUN apt-get update -q && apt-get install -y build-essential libtool autoconf curl
RUN DEBIAN_CODENAME=$(sed -n 's/VERSION=.*(\(.*\)).*/\1/p' /etc/os-release) && \
curl -q https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
@danielkza
danielkza / zfs-root-fs-generator.sh
Last active August 20, 2017 10:30
ZFS root systemd generator
#!/bin/sh
generator_dir="$1"
list_datasets() {
/usr/sbin/zfs list -r -H -o name,canmount,mountpoint "$1"
}
get_root_zfs_dataset() {
while read mnt_dev mnt_path mnt_type rest; do
@danielkza
danielkza / fedora-bfq.py
Last active May 2, 2017 15:23
Script to build a BFQ-patched kernel from Fedora packages
#!/usr/bin/env python2.7
from __future__ import print_function
import sys
import os.path
import re
import shutil
from glob import glob
from HTMLParser import HTMLParser
from subprocess import check_output, check_call, Popen, CalledProcessError, PIPE

Keybase proof

I hereby claim:

  • I am danielkza on github.
  • I am danielkza (https://keybase.io/danielkza) on keybase.
  • I have a public key whose fingerprint is B797 986C 9753 D44F 0477 32D0 0790 9306 308D 7399

To claim this, I am signing this object:

@danielkza
danielkza / heartbeat.clj
Created March 15, 2017 17:44
Riemann heartbeat with continuous alerting (with exponential backoff time)
(defn- heartbeat-bounce
[alpha min-ttl max-ttl & children]
(fn [event]
(let [ttl (max min-ttl (:ttl event))
ttl (min max-ttl (* alpha ttl))]
(call-rescue (assoc event :ttl ttl :time (unix-time)) children))))
(defn- heartbeat-process
[svc desc index bounce & children]
(fn [event]
(require '[clojure.java.io :as io]
'[clojure.tools.logging :refer [infof]]
'[riemann.common :refer [encode decode-inputstream]]
'[riemann.config :refer [service!]]
'[riemann.service :refer [thread-service]]
'[riemann.time :refer [unix-time]])
(import '[java.io.File FileOutputStream])
(defn index-save
[file index]
@danielkza
danielkza / reddit-update-filters.py
Created December 3, 2016 19:18
Python3 script to synchronize Reddit /r/all filters from a list file
#!/bin/env python3
# Copyright (c) 2016, Daniel Miranda <danielkza2@gmail.com>
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.