Skip to content

Instantly share code, notes, and snippets.

View r1cebank's full-sized avatar
🎯
Focusing on rust

Siyuan Gao r1cebank

🎯
Focusing on rust
View GitHub Profile
return new Promise((resolve, reject) => {
// Wait for connection and resolve this promise
// Create connection with mongoose
sharedInstance.mongodb = Mongodb.MongoClient.connect(sharedInstance.config.mongodb, function(err, db) {
if(err) reject(err);
else {
sharedInstance.L.info(TAG, 'connected to mongodb');
sharedInstance.db = db;
@r1cebank
r1cebank / tiny Promise.js
Created February 29, 2016 18:22 — forked from unscriptable/tiny Promise.js
A minimalist implementation of a javascript promise
// (c) copyright unscriptable.com / John Hann
// License MIT
// For more robust promises, see https://github.com/briancavalier/when.js.
function Promise () {
this._thens = [];
}
Promise.prototype = {
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
@r1cebank
r1cebank / uninstall_node.sh
Last active July 15, 2016 12:49
uninstall_node
#!/usr/bin/env bash
brew uninstall node;
brew prune;
rm -f /usr/local/bin/npm;
rm -f /usr/local/lib/dtrace/node.d;
rm -rf ~/.npm;

Keybase proof

I hereby claim:

  • I am r1cebank on github.
  • I am r1cebank (https://keybase.io/r1cebank) on keybase.
  • I have a public key whose fingerprint is 97CC 0F2C EB94 CCA1 0D94 E039 A212 AE09 5E1E 47E5

To claim this, I am signing this object:

const fs = require('fs');
fs.writeFileSync('./env.json', JSON.stringify(process.env, null, 4));
#!/usr/bin/env python3
# Python 3 code that will read, decompress, and then recompress the UE4 game
# save file that Astroneer uses.
#
# Though I wrote this for tinkering with Astroneer games saves, it's probably
# generic to the Unreal Engine 4 compressed saved game format.
import zlib
import sys
@r1cebank
r1cebank / custom-error.js
Created February 9, 2017 23:11 — forked from justmoon/custom-error.js
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
@r1cebank
r1cebank / siege
Created March 13, 2017 18:30 — forked from MikeNGarrett/siege
Siege with JSON POST data
siege -c50 -t60S -H 'Content-Type: application/json' 'http://domain.com/path/to/json.php POST {"ids": ["1","2","3"]}'
@r1cebank
r1cebank / element.js
Last active August 14, 2017 17:28
chanable js - input validator
import isEmpty from 'lodash/isEmpty';
import validators from '../validators';
import noop from '../utils/noop.js';
function addProperty (context, name, getter) {
if (typeof getter !== 'function') { getter = function() { }; }
Object.defineProperty(context, name, {
get() {
const result = getter.call(this);