Skip to content

Instantly share code, notes, and snippets.

View numtel's full-sized avatar
🦓
Natural Ungulates Make Teeming Elephants Laugh

Ben Green numtel

🦓
Natural Ungulates Make Teeming Elephants Laugh
View GitHub Profile
@numtel
numtel / ec2-rai-node.md
Last active May 12, 2019 22:18
Install rai_node on EC2 Ubuntu instance

Follow these instructions to start an EC2 instance running Ubuntu that will run rai_node on startup

  1. Select Ubuntu Server 16.04 LTS (HVM), SSD Volume Type. A t2.small or larger instance type is recommended.

  2. Configure the security group to match the screenshot.

  3. Download install_rai_node.sh below, update the URLs with their latest versions.

    Get latest rai_node archive URL from https://github.com/clemahieu/raiblocks/releases.

    Get latest gdrive-linux-x64 version URL from https://github.com/prasmussen/gdrive#downloads

@numtel
numtel / binlog.js
Created December 18, 2014 09:13
Tail mysqlbinlog in row mode with Node JS
#!/usr/bin/env node
var determineDb = function(lines, startIndex){
// Look backward from statement at startIndex to find database name used
var result;
for(var i = startIndex; i >= 0; i--){
result = lines[i].match(/^use (`([^\.]+)`|[^\.\/]+)?/i);
if(result === null) continue;
if(result[2] === undefined){
return result[1];
function genPow(hash, timeout) {
timeout = timeout || 15000000;
const start = Date.now();
const hashBytes = hex_uint8(hash);
let i=0;
while(Date.now() - start < timeout) {
const workBytes = nacl.randomBytes(8);
for(let j=0;j<256;j++) {
workBytes[7] = j;
@numtel
numtel / index.js
Last active February 20, 2018 23:08
node-raiblocks-pow threaded implementation starting
// Change index.js to this contents
var cp = require('child_process');
var os = require('os');
var addon = require('bindings')('functions.node');
function zeroPad(num, size) {
// Max 32 digits
var s = "00000000000000000000000000000000" + num;
return s.substr(s.length-size);
};
@numtel
numtel / aws-lambda-fetch-npm.js
Created September 2, 2016 04:08
AWS Lambda example to fetch an NPM package inline, works only if the package has no dependencies
'use strict';
const asyncProgressPromise = fetchNPM('progress-promise', '0.0.5');
exports.handler = (event, context, callback) => {
asyncProgressPromise
.then(ProgressPromise => {
console.log(ProgressPromise);
callback();
})

From what I can tell, accomplishing a more automatic lazy-loading system would require the current file bundling scheme to be amended to support applications written with explicit source file dependency trees.

With the dependency tree, an intelligent lazy-loader could decide which files are necessary for which routes/templates.

In order to not break compatibility with existing applications, the directories used must become configurable.

The default configuration could be described in a file such as .meteor/dirmap.json:

{
@numtel
numtel / gist:c8f9b883b4bbbfab6abd
Created April 26, 2015 09:05
Javascript Async style memory usage

Async/await style (i.e. how most of this package's code is written)

module.exports = async function() {
  await delay(1)
}

function delay(duration) {
  return new Promise(resolve => setTimeout(resolve, duration))
}
@numtel
numtel / gist:1831ff7e468fad0e2d35
Last active August 29, 2015 14:14
Possible Join interface

For the given sample database, the following example illustrates a possible interface for joining SQL tables within Minimongo.

Sample Data

Table classes

id name teacher
1 algebra 1234
ben@x131e:~/meteor$ meteor create velocity-core-issue-114
velocity-core-issue-114: created.
To run your new app:
cd velocity-core-issue-114
meteor
ben@x131e:~/meteor$ cd velocity-core-issue-114/
ben@x131e:~/meteor/velocity-core-issue-114$ meteor add numtel:velocity-tinytest velocity:html-reporter
added velocity:html-reporter at version 0.2.4
added coffeescript at version 1.0.4