Skip to content

Instantly share code, notes, and snippets.

Avatar

Mikael Berg mikberg

View GitHub Profile
@mikberg
mikberg / Client.java
Created Mar 6, 2018
Deadly Dungeon Java Snippet
View Client.java
/*
* 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 Jan 23, 2016
Report Nightwatch results to SauceLabs
View sauce.js
/* 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 Jan 19, 2016
Relay mock module
View mockRelay.js
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 Jul 30, 2020
MongoDB connection with async/await
View connection.js
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.`);
}
You can’t perform that action at this time.