Skip to content

Instantly share code, notes, and snippets.

Avatar

Robert Kreuzer rkrzr

View GitHub Profile
@rkrzr
rkrzr / shell.nix
Last active Apr 13, 2020
Reproducible jupyter lab notebook using the Nix package manager (including working plots)
View shell.nix
# Run this file with with 'nix-shell --command "jupyter lab"'
#
# This file uses jupyterWith from https://github.com/tweag/jupyterWith which
# implements reproducible Jupyter lab notebooks. The killer feature of jupyterWith
# is that it allows you to get plots working with e.g. matplotlib or seaborn,
# which did not work for me with the regular 'jupyterlab' derivation in nixpkgs.
#
# Enable plots with the `%matplotlib inline` magic command at the top of the notebook.
# Alternatively, you can do the same thing with `matplotlib.pyplot.ion()`.
#
@rkrzr
rkrzr / auto_tags.py
Last active May 19, 2021
Automatically generate ansible tags of the same name for each role in a playbook
View auto_tags.py
"""
This module implements an Ansible plugin that is triggered at the start of a playbook.
The plugin dynamically generates a tag for each role. Each tag has the same name as its role.
The advantage of this is that it saves you some boilerplate, because you don't have to wrap
all tasks of a role in an additional block and assign a tag to that.
Additionally, it works automatically when you add new roles to your playbook.
Usage is exactly the same as without this plugin:
View keybase.md

Keybase proof

I hereby claim:

  • I am rkrzr on github.
  • I am rkrzr (https://keybase.io/rkrzr) on keybase.
  • I have a public key ASDyfgTXDRLIuf01btMy3HxQeEQC5ejGFQWMkHY1G25vsAo

To claim this, I am signing this object:

View gzipRequestTest.js
var request = require('request'),
zlib = require('zlib');
var headers = {
"accept-charset" : "ISO-8859-1,utf-8;q=0.7,*;q=0.3",
"accept-language" : "en-US,en;q=0.8",
"accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"user-agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
"accept-encoding" : "gzip,deflate",
};
@rkrzr
rkrzr / UpperStream.js
Last active Dec 20, 2015
An example of how to use streams in Node.js. It gets a page via http, transforms the data to uppercase and prints it to stdout.
View UpperStream.js
var request = require('request');
var url = 'http://www.site2mobile.com';
// Set both readable and writable in constructor.
var UpperStream = function () {
this.readable = true;
this.writable = true;
};
// Inherit from base stream class.