Skip to content

Instantly share code, notes, and snippets.

haridsv / ghApprovePR.js
Created March 11, 2024 11:27
Approve the PR with an LGTM comment.
setTimeout(function() {
document.getElementById("pull_request_review_body").value = "LGTM";
document.evaluate("//*/form/div[1]/div[2]/label/input", document.querySelector("#review-changes-modal > div"), null, XPathResult.ANY_TYPE, null).iterateNext().click();
document.evaluate("//*/form/div[2]/button//*[contains(text(), 'Submit review')]", document.querySelector("#review-changes-modal > div"), null, XPathResult.ANY_TYPE, null).iterateNext().click()
}, 300);
haridsv /
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 =
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 =>;
haridsv / ghPRExpandAll-bookmarklet
Last active July 3, 2020 08:56
Expand all pages ("Load more..." buttons) in a Github PR conversation view.
NOTE: Doesn't work because of github CSP meta tags.
haridsv / bookmarklet
Last active November 4, 2016 13:10
Open Citibank India login dialog and set it right.
haridsv / bookmarklet
Last active November 2, 2016 18:56
Copy all members of a chatter group. Click "Show All" and run the bookmarklet. See the member names in the console log.
haridsv /
Last active August 12, 2016 16:39
Improved the script from to work with more scenarios. Save this file in the same directory as nsenter ( and chmod +x it. This allows you to mount a host path on a running container. You may have to adjust the ownership of the mounted directory…
#!/bin/bash -e
# Based on
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
[[ $# -eq 3 ]] || {
echo "Usage: $0 <container_name_or_id> <host_path> <container_path>" 1>&2
exit 1
haridsv /
Last active July 15, 2016 17:53 — forked from konradkonrad/
restore yank-last-arg and yank-nth-arg in ipython 5
# ~/.ipython/profile_default/startup/
from IPython import get_ipython
from prompt_toolkit.enums import DEFAULT_BUFFER
from prompt_toolkit.keys import Keys
from prompt_toolkit.filters import HasFocus, HasSelection, ViInsertMode, EmacsInsertMode
ip = get_ipython()
insert_mode = ViInsertMode() | EmacsInsertMode()
haridsv /
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) 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 /
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