Skip to content

Instantly share code, notes, and snippets.

@mrlannigan
mrlannigan / ListBucket.js
Created February 25, 2015 19:07
ListBucket
'use strict';
function ListBucket(size) {
this.array = [];
this.position = 0;
this.size = size;
this.length = 0;
}
ListBucket.prototype.toArray = function () {
(function (exports) {
var shortCodeRegex = /\{\{\s*(.+?)\}\}/g,
hasWhitespaceRegex = /\s+/;
/**
* @param {string} input - Parsed string
* @param {object} [context] - context object defining shortcodes
* @param {object} [callContext] - call context for any functions called within any shortcode replacement
*
* Supported Inputs:
@mrlannigan
mrlannigan / gist:4fe572754027bcad3110
Created June 10, 2015 19:36
example passthrough stream for testing
var PassThrough = require('stream').PassThrough;
var stream = new PassThrough();
stream.pipe(process.stdout);
stream.write('hello\nworld\n');
stream.end();
var BPromise = require('bluebird');
var prom = new BPromise(function (resolve, reject) {
console.log(1);
resolve(3);
console.log(2);
{
"version": "1.0.0"
}
var BPromise = require('bluebird'),
Hoek = require('hoek');
(function (exports) {
exports.shortCodeRegex = /\{\{\s*(.+?)\}\}/g;
exports.hasWhitespaceRegex = /\s+/;
/**
* @param {string} input - Parsed string
//////////////////////////////////////////////////
// mapping example
var x = {
validate: {
type: 'joi',
key: 'somekey'
}
}
// sidebar: the mapping example
0x5c033554fba443f04b40197b17d47c5279fce90f
@mrlannigan
mrlannigan / README.md
Last active February 23, 2018 17:08
2018-02-23 [Brown Bag] Node.js Debugging and Profiling

Debugging in Node.js

Preparing the process

First step is to always use at least the latest LTS version of Node (8.x).

Next get acquainted with how to run your process without npm or yarn, for you will need to be able to run it with node process flags. For example, for looking-glass we start our server using an index.js file in the root of the project. So instead of running yarn start, we would run node index.js.

Now by default node doesn't have the "inspector" on in the process. You have to turn it on and there are a couple ways to do that. First, and the most common, is to pass a flag to the command; node --inspect index.js or node --inspect-brk index.js. Next, you can activate it by sending a SIGUSR1 to the running process; kill -s SIGUSR1 <pid>

const list = document.getElementsByTagName('img')
for (let i = 0; i < list.length; i += 1) {
const img = list.item(i);
if (arraytomakered.includes(img.src)) {
img.style.border = '5px solid red';
}
}