Skip to content

Instantly share code, notes, and snippets.

View harkishen's full-sized avatar
🔬
Engineering @timescale's data ingest tools

Harkishen Singh harkishen

🔬
Engineering @timescale's data ingest tools
View GitHub Profile
@harkishen
harkishen / running promscale on docker.md
Created January 4, 2021 08:48
Prometheus with SQL (Postgres) using Promscale and running Promscale on docker

install timescaledb (includes promscale extension)

docker run --name promscale-extension-image -e POSTGRES_PASSWORD=secret -d -p 5431:5432 timescaledev/promscale-extension:latest-pg12 postgres -csynchronous_commit=off

get the IP address of the container running timescaledb

docker inspect {container-ID}

copy the above output

To show CPU frequency in linux,

cat /proc/cpuinfo | grep "cpu MHz"

limiting CPU throttling https://dunterov.github.io/cpu-freq/

set max CPU frequency: sudo cpupower --cpu all frequency-set --max 1500MHz

during go benchmarks, change this to sudo cpupower --cpu all frequency-set --max 300MHz

Fast way of getting count of all rows in a very long table: (https://stackoverflow.com/a/7945274)

SELECT reltuples::bigint AS estimate FROM pg_class where relname='mytable';

OR

SELECT reltuples::bigint AS estimate FROM pg_class WHERE oid = 'myschema.mytable'::regclass; (if there's a schema)

and fast way of getting count of rows across all partitions (https://stackoverflow.com/a/30594273):

All these v*.** got fixed by go get -d github.com//@master

@harkishen
harkishen / main.go
Created June 30, 2020 20:45 — forked from gouthamve/main.go
A complete runnable example
package main
import (
"fmt"
"io/ioutil"
"os"
"time"
"github.com/prometheus/tsdb"
"github.com/prometheus/tsdb/labels"
@harkishen
harkishen / memorySizeOfObject.js
Created April 4, 2020 19:34
calculate memory size of javascript object, it is not a accurate value!
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
@harkishen
harkishen / webdriver-hover.js
Created March 15, 2019 18:45 — forked from umaar/webdriver-hover.js
Hover over an element in WebDriverJS
/*
* Hover over an element on the page
*/
(function() {
"use strict";
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().usingServer().withCapabilities({'browserName': 'chrome' }).build();