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 / AWSPingTest.js
Created May 14, 2017 07:59
Find your closest AWS region
'use strict';
(function() {
// inspired by cloudping.info
var regions = {
'us-east-1': 'US-East (Virginia)',
'us-east-2': 'US East (Ohio)',
'us-west-1': 'US-West (California)',
'us-west-2': 'US-West (Oregon)',
'ca-central-1': 'Canada (Central)',
'eu-west-1': 'Europe (Ireland)',
@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();
})
@numtel
numtel / example.js
Last active August 4, 2023 09:07
Restart ZongJi gracefully on error
var ZongJi = require('zongji');
var RETRY_TIMEOUT = 4000;
function zongjiManager(dsn, options, onBinlog) {
var newInst = new ZongJi(dsn, options);
newInst.on('error', function(reason) {
newInst.removeListener('binlog', onBinlog);
setTimeout(function() {
// If multiple errors happened, a new instance may have already been created

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
@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];
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