Skip to content

Instantly share code, notes, and snippets.

View mniehe's full-sized avatar

Mark Niehe mniehe

View GitHub Profile
@mniehe
mniehe / posts.js
Created May 21, 2016 19:07
Comments and votes per post
function(doc) {
if (doc.type == 'post') {
emit([doc._id, 0]);
} else if (doc.type == 'comment' || doc.type == 'vote') {
emit([doc.postId, 1, doc.type]);
}
}
function processData(rawInput) {
var input = rawInput.split("\n").map(line => line.split(" ").map(value => parseInt(value)))
var [ counts, buffer, ...questions ] = input;
var [ n, k, q ] = counts;
var result = Array.from({length: buffer.length});
questions = questions.reduce((last, current) => last.concat(current))
buffer.forEach((value, oldPosition) => {
var newPosition = (k + oldPosition) % n;
@mniehe
mniehe / rabbitmq_consumer.js
Last active April 24, 2017 18:41
Consumer class for rabbit mq
class Consumer {
constructor(channel, queueName, name, interval = 1000, maxQueue = 5) {
this.queueName = queueName;
this.queue = [];
this.channel = channel;
this.maxQueue = maxQueue;
this._interval = interval;
this._consumerTag = `${name}:${uuidV4()}`;
this._processInterval = null;
this._processFunc = null;

Keybase proof

I hereby claim:

  • I am mniehe on github.
  • I am mniehehc (https://keybase.io/mniehehc) on keybase.
  • I have a public key whose fingerprint is 59FE A0D8 87CB 2959 1185 896E 9072 95EA A1D7 B20C

To claim this, I am signing this object:

@mniehe
mniehe / hosts.txt
Created October 28, 2021 21:52 — forked from Luro02/hosts.txt
A blocklist for the Amazon Fire devices, that should block (some) telemetry...
# Amazon Fire (HD 8) Blocklist (V.1.0)
#
# Constribute:
# please make a comment under this gist and I'll add it after checking to this list.
#
# Constributions by:
# Luro02
#
# Credits:
# https://forum.xda-developers.com/amazon-fire/general/how-to-block-updates-via-router-t3640267
#!/bin/bash
# This script backs up files using restic and sends emails on success or errors.
#
# Files that the script expects:
# /usr/local/etc/restic/repo.env: shell variables that define the restic repository
# /usr/local/etc/restic/include.txt: paths to back up
# /usr/local/etc/restic/exclude.txt: paths to not include in the backup, even if they are in include.txt
#
# Inspired by https://gist.github.com/perfecto25/18abbd6cfbaa4e9eb30251470e9b7504
@mniehe
mniehe / dt_raw_autoexport.sh
Created June 19, 2022 03:36 — forked from crapp/dt_raw_autoexport.sh
Darktable cli convert all files in provided locations
#!/usr/bin/env bash
# Simple bash script to automate raw conversion using darktable cli
# Copyright © 2021 C. Rapp
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.