Skip to content

Instantly share code, notes, and snippets.

Mark Birbeck markbirbeck

Block or report user

Report or block markbirbeck

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View es-writable-stream-6.js
const stream = require('stream')
class ElasticSearchWritableStream extends stream.Writable {
constructor(config, options) {
super(options)
this.config = config
/**
* Create the ElasticSearch client:
*/
View es-writable-stream-5.js
class ElasticSearchWritableStream extends stream.Writable {
constructor(config, options) {
super(options)
this.config = config
/**
* Create the ElasticSearch client:
*/
this.client = new elasticsearch.Client({
View es-writable-stream-4.js
class ElasticSearchWritableStream extends stream.Writable {
...
async _writev(chunks, next) {
const body = chunks
.map(chunk => chunk.chunk)
.reduce((arr, obj) => {
/**
* Each entry to the bulk API comprises an instruction (like 'index'
* or 'delete') and some data:
View es-writable-stream-3.js
class ElasticSearchWritableStream extends stream.Writable {
constructor(config) {
...
}
/**
* When writing a single record, we use the index() method of
* the ES API:
*/
View es-writable-stream-2.js
const stream = require('stream')
const elasticsearch = require('elasticsearch')
class ElasticSearchWritableStream extends stream.Writable {
constructor(config) {
super()
this.config = config
/**
* Create the ElasticSearch client:
View es-writable-stream-1.js
const stream = require('stream')
class ElasticSearchWritableStream extends stream.Writable {
}
module.exports = ElasticSearchWritableStream
@markbirbeck
markbirbeck / ubuntu-from-scratch.md
Last active Jun 29, 2019
Setting up a new Ubuntu Laptop
View ubuntu-from-scratch.md
# Update repos
#
sudo apt update
sudo apt install --only-upgrade -y \
  gcc-5-base \
  libstdc++6

# Tools
#
View memoryleak.js
var heapdump = require('heapdump');
function generateHeapDumpAndStats(){
//1. Force garbage collection every time this function is called
try {
global.gc();
} catch (e) {
console.log('You must run program with \'node --expose-gc index.js\'');
process.exit();
}
View gist:d196bb4ddea782ceedc5a90650f4f5d5
# Courtesy of:
#
# http://stackoverflow.com/questions/31990757/network-timed-out-while-trying-to-connect-to-https-index-docker-io
#
docker-machine restart default
eval $(docker-machine env default)
View mac-from-scratch.md

Admin Account

During installation, create a user called admin rather than one with your own name.

Apps for All Users

Then install Homebrew as per latest instructions (note that this will install the necessary CLI components for XCode):

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
You can’t perform that action at this time.