Skip to content

Instantly share code, notes, and snippets.

View analytik's full-sized avatar
😐
b u r n o u t

Milan B analytik

😐
b u r n o u t
View GitHub Profile
r.db("rethinkdb").table("stats")
.hasFields('db', 'table')
.group('db', 'table')
.map(doc => doc('storage_engine')('disk')('space_usage')('data_bytes').default(0))
.sum()
.ungroup()
.map(doc => ({db: doc('group').nth(0), table: doc('group').nth(1), size: doc('reduction').div(1024).div(1024)}))
.orderBy(r.desc('size'));
r.db("rethinkdb").table("table_config")
.hasFields('db', 'name')
.concatMap(doc => [{
db: doc('db'),
table: doc('name'),
shards: doc('shards').count(),
replicas: doc('shards').nth(0)('replicas').count(),
}])
// this part is dumb - assuming you have 4 main servers,
// and that ONLY tables with 5 total replicas have 5 replicas
@analytik
analytik / rethinkdb total read and written bytes per table
Created January 1, 2017 14:14
Sum up reads and writes across the cluster, in bytes read/written to disk - does not include cache hits
r.db("rethinkdb").table("stats")
.hasFields('db', 'table')
.group('db', 'table')
.map(doc => ({
reads: doc('storage_engine')('disk')('read_bytes_total').default(0),
writes: doc('storage_engine')('disk')('written_bytes_total').default(0)
}))
.ungroup()
.map(doc => ({
db: doc('group').nth(0),
// By slack user ronz
query
.changes({includeInitial: true, includeStates: true, includeTypes: true})
.pluck('type', 'state')
.filter(row => row('type').ne('change'))
.fold(
0,
(acc, next) => r.branch(
r.or(next('type').eq('add'), next('type').eq('initial')),
acc.add(1),
@analytik
analytik / package.json
Created June 3, 2017 09:56
package.json that does not install correctly under npm 5.0.0-5.0.2
{
"name": "broken",
"private": true,
"version": "0.0.1",
"scripts": {
"test-football-formulas": "jasmine www/formulas/test/football_formulas_tests.js",
"dev-scripts": "npm run hgrc && npm run create-env",
"dev": "webpack-dev-server --config=webpack.config.js --progress --hot",
"preinstall": "npm prune",
"predevsilent": "npm run dev-scripts",
@analytik
analytik / run.js
Created July 23, 2017 10:06
Nodemon's lib/monitor/run.js 1.11.0 with my logging changes
var debug = require('debug')('nodemon');
var utils = require('../utils');
var bus = utils.bus;
var childProcess = require('child_process');
var spawn = childProcess.spawn;
var exec = childProcess.exec;
var watch = require('./watch').watch;
var config = require('../config');
var child = null; // the actual child process we spawn
var killedAfterChange = false;
@analytik
analytik / Dockerfile
Created July 26, 2017 06:45
Basic RethinkDB - official-build based docker image
FROM debian:jessie
ENV LC_ALL C.UTF-8
RUN apt-get update && apt-get install -y vim nano curl netcat less tcpdump
# Add the RethinkDB repository and public key
ENV RETHINKDB_PACKAGE_VERSION 2.3.6~0jessie
RUN curl -s https://download.rethinkdb.com/apt/pubkey.gpg | apt-key add -v - \
&& echo "deb http://download.rethinkdb.com/apt jessie main" > /etc/apt/sources.list.d/rethinkdb.list \
@analytik
analytik / npm-install-461.sh
Created December 21, 2017 12:24
npm-install.sh script with hardcoded version 4.6.1
#!/bin/sh
# A word about this shell script:
#
# It must work everywhere, including on systems that lack
# a /bin/bash, map 'sh' to ksh, ksh97, bash, ash, or zsh,
# and potentially have either a posix shell or bourne
# shell living at /bin/sh.
#
# See this helpful document on writing portable shell scripts:
@analytik
analytik / 2018-01-11T13_55_20_300Z-debug.log
Created January 11, 2018 14:06
node-rdkafka 2.2.1-master npm install log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node',
1 verbose cli '/usr/bin/npm',
1 verbose cli 'i',
1 verbose cli 'git+https://git@github.com/Blizzard/node-rdkafka.git' ]
2 info using npm@4.6.1
3 info using node@v8.9.1
4 silly install loadCurrentTree
5 silly install readLocalPackageData
6 silly fetchPackageMetaData git+https://git@github.com/Blizzard/node-rdkafka.git
@analytik
analytik / node-rdkafka@2.2.3 build log
Created March 16, 2018 07:43
node-rdkafka build 2.2.3/2.3.1 with debian 9.4 and node.js 9.8
> node-rdkafka@2.2.3 preinstall /usr/lib/node_modules/node-rdkafka
> node util/configure
checking for OS or distribution... ok (Linux)
checking for C compiler from CC env... failed
checking for gcc (by command)... ok
checking for C++ compiler from CXX env... failed
checking for C++ compiler (g++)... ok
checking executable ld... ok
checking executable nm... ok