Skip to content

Instantly share code, notes, and snippets.

Mark Niehe mniehe

  • Vancouver, BC
Block or report user

Report or block mniehe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

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 / NewObject.js
Last active May 31, 2017
Example of an async factory method
View NewObject.js
class NewObject {
constructor(name) {
this.name = name;
}
addThis(func) {
this.that = func;
}
static async create(url) {
@mniehe
mniehe / livechat-user-data.js
Created May 4, 2017
LiveChat custom user data
View livechat-user-data.js
const LiveChatApi = require('livechatapi').LiveChatApi;
const api = new LiveChatApi(process.env.LIVE_CHAT_EMAIL, process.env.LIVE_CHAT_API_KEY);
async function addDetails(license, token, values) {
const fields = [];
for (const key of Object.keys(values)) {
fields.push({ name: key, value: values[key] });
}
@mniehe
mniehe / Dockerfile
Created May 3, 2017
Alpine dockerfile with build essentials
View Dockerfile
FROM node:7.8-alpine
LABEL maintainer "Mark Niehe<mark@niehe.ca>"
# Install all build dependencies
# Add bash for debugging purposes
RUN apk update \
&& apk add --virtual build-dependencies \
build-base \
gcc \
wget \
@mniehe
mniehe / rabbitmq_consumer.js
Last active Apr 24, 2017
Consumer class for rabbit mq
View rabbitmq_consumer.js
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;
@mniehe
mniehe / Dockerfile
Last active Apr 11, 2017
Alpine node docker basics
View Dockerfile
FROM node:7.8-alpine
LABEL maintainer "Mark Niehe<mark@niehe.ca>"
# Install all build dependencies
# Add bash for debugging purposes
RUN apk update \
&& apk add --virtual build-dependencies \
build-base \
gcc \
wget \
View circular-array-rotation.js
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 / posts.js
Created May 21, 2016
Comments and votes per post
View posts.js
function(doc) {
if (doc.type == 'post') {
emit([doc._id, 0]);
} else if (doc.type == 'comment' || doc.type == 'vote') {
emit([doc.postId, 1, doc.type]);
}
}
You can’t perform that action at this time.