Skip to content

Instantly share code, notes, and snippets.

View andir's full-sized avatar

Andreas Rammhold andir

View GitHub Profile
@andir
andir / debian.nix
Last active May 2, 2020 14:19
debian stretch
{ pkgs ? import <nixpkgs> {}}:
let
lib = pkgs.lib;
makeImageFromDebDist =
{ name, fullName, size ? 4096, urlPrefix
, packagesList ? "", packagesLists ? [packagesList]
, packages, extraPackages ? [], postInstall ? ""
, extraDebs ? []
, QEMU_OPTS ? "", memSize ? 512
, createRootFS }:
@andir
andir / default.nix
Created September 12, 2018 11:41
nixos build virtualbox image for dummies
# This file describes how to build custom virtualbox instances. This examples ignores things like cross compiling etc..
# this defines the function signature of our expression, pkgs is defaulted to the systems packages,
# you could also overrides that if you need a specific release / channel.
{ pkgs ? import <nixpkgs> {}}:
# "let" expressions are just there to introduce scoped variables and functions,
# in this case it is declaring just a helper function
let
# this creates a helper function that abstracts a bit of the boilerplate away
# `mkVM` takes one argument, a list of `modules` to include in the image.
@andir
andir / enp0s31f6.network
Created October 9, 2016 13:12
enp0s31f6.network with vrf
[Match]
Name=enp0s31f6
[Network]
Address=192.168.0.1/24
VRF=vrf-customer1
@andir
andir / vrf-customer1.netdev
Created October 9, 2016 13:05
systemd networkd example
[NetDev]
Name=vrf-customer1
Kind=vrf
[VRF]
TableId=42
@andir
andir / tasks_to_ical.py
Created August 18, 2016 14:46
convert taskwarrior tasks to ical entries when they have a scheduled date
#!/usr/bin/env python3
import os.path
from ics import Calendar, Event
import subprocess
import json
def read_tasks():
output = subprocess.check_output(['task', 'export'])
for task in json.loads(output.decode('utf-8')):
if task['status'] == 'completed':
@andir
andir / postgresql-docker-container.service
Last active September 13, 2017 10:37
postgresql-tmpfs via socket activation
[Service]
ExecStartPre=-/usr/bin/docker rm psql-tmpfs
ExecStart=/usr/bin/docker run --rm --shm-size=2g --name psql-tmpfs -p 127.0.0.1:5434:5432 -t andir/postgresql-tmpfs
ExecStartPost=/bin/sleep 15
ExecStop=/usr/bin/docker stop psql-tmpfs
@andir
andir / parse_relayed_msg.pl
Last active March 2, 2016 00:26
patched parse_relayed_msg.pl to work for flexget with gitter
#
# Copyright (c) 2011-2013 by w8rabbit (w8rabbit[at]mail[dot]i2p)
# or from outside i2p: w8rabbit[at]i2pmail[dot]org
#
# Script is under GPL3.
#
# Script is inspired by NullPointerException's xchat script
#
# thanks to darrob for hard beta-testing
#
#!/bin/dash
###
# ABOUT : collectd monitoring script for smartmontools (using smartctl)
# AUTHOR : Samuel B. <samuel_._behan_(at)_dob_._sk> (c) 2012
# LICENSE: GNU GPL v3
# SOURCE: http://devel.dob.sk/collectd-scripts/
#
# This script monitors SMART pre-fail attributes of disk drives using smartmon tools.
# Generates output suitable for Exec plugin of collectd.
###
@andir
andir / gist:9570611
Last active August 29, 2015 13:57
nvidia enable SLI Mosaic
# python
Python 2.7.5 (default, Feb 19 2014, 13:47:28)
[GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('nvidia_drv.so', 'r+b') # version 330.4Xsomething...
>>> f.seek(0xb3e87)
>>> f.read(1)
'\x85'
>>> f.seek(0xb3e87)
>>> f.write('\x84')
@andir
andir / gist:8399048
Created January 13, 2014 11:53
flask-restless profile to_dict
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.restless.helpers import to_dict
from sqlalchemy.ext.hybrid import hybrid_property
import line_profiler
profile = line_profiler.LineProfiler()
profile.add_function(to_dict)
app = Flask(__name__)