Skip to content

Instantly share code, notes, and snippets.

View HariSekhon's full-sized avatar
🏠
100% Remote - Digital Nomad

Hari Sekhon HariSekhon

🏠
100% Remote - Digital Nomad
View GitHub Profile
#Install R and then following packages
#repr failed to create
yum install R-*
install.packages("evaluate", dependencies = TRUE)
install.packages("base64enc", dependencies = TRUE)
install.packages("devtools", dependencies = TRUE)
install_github('IRkernel/repr')
install.packages("dplyr", dependencies = TRUE)
install.packages("caret", dependencies = TRUE)
install.packages("repr", dependencies = TRUE)
/* Expected exposure is the expected (average) credit exposure conditional on positive market values */
def expectedExposure(marketValues: Seq[Double]): Double = {
val exposures = marketValues.filter(_ > 0f)
if (exposures.size == 0) 0.0
else exposures.sum / exposures.size
}
/* A high percentile (95%) of the distribution of exposures at any particular future date. Also called Peak Exposure (PE) */
def potentialFutureExposure(marketValues: Seq[Double], confidenceLevel: Double): Double = {
val exposures = marketValues.filter(_ > 0)
@HariSekhon
HariSekhon / opentsdb_delete_old_data.sh
Created July 11, 2018 15:56 — forked from d10v/opentsdb_delete_old_data.sh
Delete old data from OpenTSDB using `scan --delete`
#!/bin/bash
set -o nounset
set -o errexit
set -o pipefail
TSDB_CMD=$( /usr/bin/which tsdb )
START_TIME="1y-ago"
END_TIME="21d-ago"
SLEEP=10
@HariSekhon
HariSekhon / tsdb_delete_old.sh
Created October 15, 2018 09:01 — forked from d10v/tsdb_delete_old.sh
opentsdb delete old data
#!/bin/bash
set -o nounset
set -o errexit
set -o pipefail
EXTRA_TAGS=${1}
TSDB_CMD=$( /usr/bin/which tsdb )
START_TIME="1y-ago"
END_TIME="45d-ago"
@HariSekhon
HariSekhon / check_hbase_onlineregions.sh
Created December 24, 2018 10:57 — forked from ashrithr/check_hbase_onlineregions.sh
nagios plugin for hbase to check how many regions a region server is serving and throw critical if regions > 90
#!/usr/bin/env bash
#Author: Ashrith
#Arrays to store hosts and their regionsOnLine respectively
declare -a HOSTS_ARRAY
declare -a REGIONS_ARRAY
message=""
EXIT_STATUS=0
@HariSekhon
HariSekhon / compare_buckets.py
Created October 18, 2019 14:36 — forked from tomkinsc/compare_buckets.py
This is a quick and dirty script to compare two different s3-compatible buckets, just dorp in the bucket name and credentials, and optionally change the endpoint host
#!/usr/bin/python
import boto, json
from boto.s3.connection import S3Connection
from boto.gs.connection import GSConnection
def compare_buckets(bucket_one_bucket_name,
bucket_two_bucket_name,
bucket_one_access_key_id,
--get running applications
http://seregion02.cloud.hortonworks.com:8088/ws/v1/cluster/apps?states=accepted,running
--get dag id for counters and callerId (hive session) for hive details
http://seregion02.cloud.hortonworks.com:8188/ws/v1/timeline/TEZ_DAG_ID?limit=1000&primaryFilter=applicationId%3Aapplication_1458195563211_0034
--get counters on the fly
http://seregion02.cloud.hortonworks.com:8088/proxy/application_1458195563211_0034/ws/v2/tez/verticesInfo?dagID=2&counters=org.apache.tez.common.counters.FileSystemCounter%2FHDFS_BYTES_WRITTEN%2CHDFS_BYTES_READ%3Borg.apache.tez.common.counters.TaskCounter%2FNUM_SPECULATIONS%2CREDUCE_INPUT_GROUPS
http://seregion02.cloud.hortonworks.com:8088/proxy/application_1458195563211_0034/ws/v2/tez/verticesInfo?dagID=3&counters=*
@HariSekhon
HariSekhon / tmux-cheatsheet.markdown
Created November 20, 2019 11:31 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@HariSekhon
HariSekhon / apt_wait.sh
Created June 7, 2020 14:14 — forked from tedivm/apt_wait.sh
A BASH function to wait for `apt` to finish and release all locks.
#!/usr/bin/env bash
apt_wait () {
while sudo fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
sleep 1
done
while sudo fuser /var/lib/apt/lists/lock >/dev/null 2>&1 ; do
sleep 1
done
if [ -f /var/log/unattended-upgrades/unattended-upgrades.log ]; then
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1