Skip to content

Instantly share code, notes, and snippets.

View gerrard00's full-sized avatar

Gerrard Lindsay gerrard00

  • NYC
View GitHub Profile
@gerrard00
gerrard00 / install-vim-and-tmux.sh
Created May 27, 2017 15:22
Install newer Vim and Tmux on CentOs
# vim
yum group install "Development Tools" -y
yum install ncurses-devel -y
yum install unzip -y
yum install wget -y
yum install make -y
# prereqs copied from YouCompleteMe repo, probably overkill
yum install -y python python-devel
# yum install -y python3 python3-devel
wget -O vim-master.zip https://github.com/vim/vim/archive/master.zip
@gerrard00
gerrard00 / loadxml.cs
Created September 13, 2017 05:57
Xml Compression tests
using System;
using System.Diagnostics;
using System.IO;
using System.Xml;
namespace Test
{
class Test
{
static void Main()
// const limit = 1000000;
// const limit = Number.MAX_SAFE_INTEGER;
const limit = 1000000000;
let lastBarLength = 0;
let lastBar = '';
console.log('start');
for(let i = 0; i < limit; i++) {
@gerrard00
gerrard00 / regexmatchesgenerator.js
Created July 11, 2018 18:12
JavaScript Generator Function for RegEx Capture Groups
function* getMatches(regex, text) {
let match;
while((match = regex.exec(text)) != null) {
yield match.slice(1);
}
}
const assignmentRegEx = /^(.*)\s+=\s+(.*)\.$/gm;
@gerrard00
gerrard00 / pwdx_and_portpwdx_for_mac.bash
Last active November 1, 2018 10:11 — forked from tobym/pwdx_for_mac.bash
pwdx for mac. Usage: pwx pid also portpwdx that finds the pwd for the process that owns a port. Usage: portpwdx port
function pwdx {
# note: NF is the number of columns, so $NF gives us the last column
lsof -a -p $1 -d cwd -n | tail -1 | awk '{print $1, "\t", $NF}'
}
function portpwdx {
# pid=$(lsof -i :5858 | tail -1 | perl -pe 's/[^\s]+\s+([^\s]+)\s.*/$1/')
pid=$(lsof -i :$1 | tail -1 | perl -pe 's/[^\s]+\s+([^\s]+)\s.*/$1/')
if [[ ! -z $pid ]]; then
echo $pid
@gerrard00
gerrard00 / neptune-concurrency-2.js
Created November 13, 2018 17:56
Neptune Concurrency 2
const gremlin = require('gremlin');
const uuidv4 = require('uuid/v4');
const { t: { id }, cardinality } = gremlin.process;
const __ = gremlin.process.statics;
const hostname = process.env.NEPTUNE_HOST;
const testToRun = process.argv[2];
const threadsRequested = process.argv[3] ? Number(process.argv[3], 10) : 5;
@gerrard00
gerrard00 / json-to-node-module.js
Created November 26, 2018 20:32
Convert a json object to a node module...don't ask
'use strict';
const fs = require('fs');
const util = require('util');
const contents = fs.readFileSync(0, 'utf8');
const jsonObject = JSON.parse(contents);
const javascriptString = util.inspect(jsonObject, { depth: null });
@gerrard00
gerrard00 / standardize-dots.js
Created December 13, 2018 19:37
Standardizes stuff with leading or trailing dots.
const fs = require('fs');
const program = require('commander');
function makeTrailingDots(gremlin) {
const lines = gremlin
.split('\n')
.filter(line => line.length);
const lastLineIndex = lines.length - 1;
@gerrard00
gerrard00 / better-console-log.js
Created February 4, 2019 18:09
My version of code to include line numbers in console logs for node js
// https://stackoverflow.com/questions/45395369/how-to-get-console-log-line-numbers-shown-in-nodejs
['log','warn','error'].forEach((methodName) => {
const originalMethod = console[methodName];
console[methodName] = (...args) => {
const error = new Error();
originalMethod.apply(
console,
[
(
error
@gerrard00
gerrard00 / sleep.js
Created February 21, 2019 19:05
Stupid sleep function for node js
const sleep = (ms) =>
new Promise(resolve =>
setTimeout(() => resolve(), ms));