Skip to content

Instantly share code, notes, and snippets.

View gx0r's full-sized avatar

Grant Miner gx0r

  • Datasite
  • Minneapolis, MN
  • LinkedIn in/gx0r
View GitHub Profile
@gx0r
gx0r / pmon.js
Created January 17, 2021 18:41
Talking process monitorr
var net = require('net');
var chalk = require('chalk');
var lh = 'localhost';
var EventEmitter = require('events').EventEmitter;
//var exec = require('child_process').exec;
var execSync = require('child_process').execSync;
var warn = console.log
var ee = new EventEmitter();
ee.on('down', function(serviceName, had_error) {
@gx0r
gx0r / oracle-query-string.js
Created January 17, 2021 18:40
Oracle query string example
var oracle = require('strong-oracle')();
// Or use the other Oracle driver
// var oracle = require('oracle');
var OracleQueryStream = require('oracle-query-stream');
var JSONStream = require('JSONStream');
var db = require('./db');
@gx0r
gx0r / cookiemeter.js
Created May 17, 2019 20:14
Cookie Size Meter
// Cookie size meter
(function () {
var div = document.createElement('div');
div.style.position = 'absolute';
div.style.top = '10px';
div.style.left = '10px';
div.style.border = '1px dashed black';
div.style.cursor = 'crosshair';
div.style.padding = '2px';
div.style.zIndex = 10000;
@gx0r
gx0r / gist:a04bdaf553663e611c3ed8cd6b109383
Created September 15, 2017 16:49
gem install json -v '1.8.3'
➜ manager git:(master) gem install json -v '1.8.3'
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
/usr/local/opt/ruby/bin/ruby -r ./siteconf20170915-30761-ln2kx2.rb extconf.rb
creating Makefile
current directory: /usr/local/lib/ruby/gems/2.4.0/gems/json-1.8.3/ext/json/ext/generator
@gx0r
gx0r / Bluebird Benchmark Node 8 vs Node 7.txt
Last active May 30, 2017 22:23
Bluebird Benchmark Node 8 vs Node 7
** Node 8 **
results for 10000 parallel executions, 1 ms per I/O op
file time(ms) memory(MB)
callbacks-baseline.js 156 31.35
callbacks-suguru03-neo-async-waterfall.js 189 39.54
promises-bluebird-generator.js 246 41.37
promises-bluebird.js 322 48.27
promises-cujojs-when.js 393 61.61
promises-tildeio-rsvp.js 503 78.96
@gx0r
gx0r / qsparser.js
Last active March 26, 2019 20:51
One line QueryString parser - handles repeated parameters, initial question-mark is optional, handles null parameters, handles + in parameters, and decodes URI Components.
'use strict';
/**
"One line" QueryString parser
Initial question-mark optional
Handles repeated parameters (turns into array)
Handles null parameters
Handles + sign in parameters
@gx0r
gx0r / jqVsDOMContentLoaded.html
Last active February 28, 2017 16:49
DOMContentLoaded vs jQuery
<html>
<head>
<title>DOMContentLoaded vs jQuery</title>
</head>
<body>
<h1>
With jQuery (2.1.4) if a function throws in a $(document).ready listener, it will prevent subsequent
$(document).ready listeners from executing. This demonstrates that it does not happen with jQuery 3.1.1 or document.addEventListener.
</h1>
@gx0r
gx0r / gist:46f574412a7f5bc0790f
Created February 28, 2016 15:18
Routing with Mithril and Redux
var store = redux.createStore(function(state, action) {
var defaultState = {
view: LOGIN,
subview: '',
}
if (!state) {
return defaultState;
}
switch(action.type) {
@gx0r
gx0r / gist:7b414a2377bb7e804d7d
Created January 20, 2016 16:20
Koa rendering template
const jade = require('jade')
app.use((req, res) => {
const locals = req.locals // get your template locals from where ever
locals.cache = process.env.NODE_ENV === 'production' // set the template cache
const html = jade.renderFile('templates/home.jade', locals) // render the template
res.setHeader('Content-Length', Buffer.byteLength(html))
res.setHeader('Content-Type', 'text/html; charset=utf-8') // set the content type header
res.end(html) // send the response
})
@gx0r
gx0r / gist:73484233e4f33e1f24e6
Last active January 9, 2016 00:29
v8 vs bluebird
------
built in rejection:
Promise.reject(new Error('ether'))
(no error console output with V8 promise rejection, nothing shown on screen, no non-zero exit code on process, etc.)
--------
Promise = require('bluebird')