Skip to content

Instantly share code, notes, and snippets.

View Harkishen-Singh's full-sized avatar

Harkishen Singh Harkishen-Singh

View GitHub Profile
@Harkishen-Singh
Harkishen-Singh / 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();
@Harkishen-Singh
Harkishen-Singh / 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-Singh
Harkishen-Singh / 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"

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

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):

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

@Harkishen-Singh
Harkishen-Singh / 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

this is a content

Integrating Gitter with Github using Webhooks manually

This gist discusses about integrating gitter community with Github webhooks so that updates in github can be shwon under activity place in gitter comunity room.

To do this, follow the steps:

  1. Click on settings
  2. Go to integrations
  3. Click on Github
  4. You will get a token there. Copy that and call it, say TOKEN.