Skip to content

Instantly share code, notes, and snippets.

@mikberg
mikberg / main.go
Created December 22, 2022 12:58
Promscale metric data retention job
package main
import (
"context"
"errors"
"fmt"
"math/rand"
"os"
"os/signal"
"sync"
@mikberg
mikberg / Client.java
Created March 6, 2018 09:54
Deadly Dungeon Java Snippet
/*
* Copyright (c) 2017, Just AS. All rights reserved.
*/
package com.gojust.deadlydungeon.client;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
@mikberg
mikberg / sauce.js
Created January 23, 2016 17:26
Report Nightwatch results to SauceLabs
/* eslint no-console:0 */
const https = require('https');
module.exports = function sauce(callback) {
const currentTest = this.client.currentTest;
const username = this.client.options.username;
const sessionId = this.client.capabilities['webdriver.remote.sessionid'];
const accessKey = this.client.options.accessKey;
if (!this.client.launch_url.match(/saucelabs/)) {
@mikberg
mikberg / mockRelay.js
Created January 19, 2016 22:28
Relay mock module
import Relay from 'real-react-relay';
export class Mutation extends Relay.Mutation {
_resolveProps(props) {
this.props = props;
}
}
export class MockStore {
reset() {
@mikberg
mikberg / connection.js
Last active December 29, 2021 16:57
MongoDB connection with async/await
import { MongoClient } from 'mongodb';
import promisify from 'es6-promisify';
let _connection;
const connect = () => {
if (!process.env.MONGO_CONNECTION_STRING) {
throw new Error(`Environment variable MONGO_CONNECTION_STRING must be set to use API.`);
}