Skip to content

Instantly share code, notes, and snippets.

What exactly is "iowait"?
To summarize it in one sentence, 'iowait' is the percentage
of time the CPU is idle AND there is at least one I/O
in progress.
Each CPU can be in one of four states: user, sys, idle, iowait.
Performance tools such as vmstat, iostat, sar, etc. print
out these four states as a percentage. The sar tool can
print out the states on a per CPU basis (-P flag) but most
@haridsv
haridsv / bookmarklet
Last active December 11, 2024 12:10
Paste Enabler, remove attributes from form text fields that restrict copy and paste operations. Tested to be working on many financial websites, though on some it causes duplication (workaround: undo).
javascript:s=document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='https://goo.gl/OrQlxL';void(0);
@haridsv
haridsv / ghPRExpandAll-bookmarklet
Last active October 29, 2024 06:44
Expand all pages ("Load more..." buttons) in a Github PR conversation view.
NOTE: Doesn't work because of github CSP meta tags.
javascript:s=document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='https://git.io/JJTwA';void(0);
@haridsv
haridsv / ghApprovePR.js
Last active June 12, 2024 15:14
Approve the PR with an LGTM comment.
document.getElementById("files_tab_counter").click();
setTimeout(function approvePR() {
var ele = document.querySelector(".js-review-changes");
if (! ele) {
setTimeout(approvePR, 300);
return;
}
ele.click();
document.getElementById("pull_request_review_body").value = "LGTM";
document.evaluate("//*/form/div[1]/fieldset/div/div[2]/span/label", document.querySelector("#review-changes-modal > div"), null, XPathResult.ANY_TYPE, null).iterateNext().click();
@haridsv
haridsv / GoogleBookmarks.py
Created July 2, 2023 13:16
Extracts entries that contain the specified keywords from the Google Bookmarks export HTML file.
import re
import click
from bs4 import BeautifulSoup
bookmarks = dict()
def add_bookmark(linknode, descnode):
link = linknode.get("href")
linktext = linknode.next.text.strip()
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
# create our directories
@haridsv
haridsv / ghPRExpandAllMyComments.js
Created July 21, 2020 07:38
Expand all the comments made by the current user (handles only those that are part of a review submission).
var currentUser = document.querySelector(".user-profile-link").href.replace(/.*\//, "")
document.querySelectorAll("div.js-comment.js-targetable-comment.js-updatable-content").forEach(function(n) {
var authorNode = n.parentNode.querySelector(".author");
if (authorNode && authorNode.textContent == currentUser) {
n.parentNode.querySelectorAll(".js-toggle-outdated-comments").forEach(n => n.click());
}
})
@haridsv
haridsv / note.md
Created June 6, 2016 13:15
Cause of "Failed to renew token: Kind: HDFS_DELEGATION_TOKEN"

One of the reasons that this failure occurs is because of the incorrect client setting of yarn.resourcemanager.cluster-id that ends up not matching the one in the cluster. This often results in a cryptic error that looks like this:

Failed to renew token: Kind: HDFS_DELEGATION_TOKEN, Service: ha-hdfs:test-local-EMPTY, Ident: (HDFS_DELEGATION_TOKEN token 40242 for hari)

Unfortunately, the original IOException seems to get completely lost, neither logged on the server nor gets seen on the client. When I put an extra trace log line to print the exception, I got this:

2016-06-06 12:57:57,394 ERROR [tionTokenRenewer #50] security.DelegationTokenRenewer - Failed to renew token: Kind: HDFS_DELEGATION_TOKEN, Service: ha-hdfs:test-local-EMPTY, Ident: (HDFS_DELEGATION_TOKEN token 40663 for sfdc)
java.io.IOException: Unable to map logical nameservice URI 'hdfs://test-local-EMPTY' to a NameNode. Local configuration does not have a failover proxy provider configured.
        at org.apache.hadoop.hdfs.DFSCl
@haridsv
haridsv / hbase_shell_snippets.md
Last active June 22, 2019 10:17
Decode byte strings from HBase shell, a collection of snippets
hbase(main):002:0> T = create 'emp',  {NAME => 'f', VERSIONS => 5}
0 row(s) in 1.1300 seconds

=> Hbase::Table - emp
hbase(main):003:0> T.put '001', 'f:name', 'Tom'
0 row(s) in 0.0890 seconds
hbase(main):003:0> T.put '001', 'f:name', 'Tom Too'
0 row(s) in 0.0890 seconds
@haridsv
haridsv / opencv_demo.py
Created October 7, 2011 00:16
Sample OpenCV 2.0 Python script to detect faces using a webcam
import sys
import cv
class FaceDetect():
def __init__(self):
cv.NamedWindow ("CamShiftDemo", 1)
device = 0
self.capture = cv.CaptureFromCAM(device)
capture_size = (320,200)
cv.SetCaptureProperty(self.capture, cv.CV_CAP_PROP_FRAME_WIDTH, capture_size[0])