Skip to content

Instantly share code, notes, and snippets.

View prasanthj's full-sized avatar

Prasanth Jayachandran prasanthj

View GitHub Profile
@prasanthj
prasanthj / chrome-ext-tab-url.js
Created December 15, 2014 20:00
Chrome extension get tab url
chrome.tabs.query({'active': true, 'lastFocusedWindow': true, 'currentWindow': true}, function (tabs) {
var url = tabs[0].url;
console.log(url);
});
@prasanthj
prasanthj / gist:081aa7a680ba1184dfe7
Created September 10, 2015 20:39
Diff between directories with exclusion filter
diff -r -U3 -I "String to exclude" <directory-1> <directory-2>
@prasanthj
prasanthj / gist:af9e289fe4dedb06ab77
Created September 30, 2015 21:43
Mac OS Terminal - Linux screen scrollback
After ssh into linux box from Mac OS X terminal. Add the following lines to .screenrc
defscrollback 5000
termcapinfo xterm* ti@:te@
@prasanthj
prasanthj / gist:10cf6ebe17494061e64d
Last active March 9, 2016 04:21
Print Top-N java methods from java flame graph
#!/usr/bin/python
import sys,operator,getopt
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
@prasanthj
prasanthj / hive-log4j2.properties
Last active February 25, 2016 01:58
Apache Hive PerfLogger Log to Separate File
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@prasanthj
prasanthj / vpn-autoconnect
Created July 18, 2016 08:39
VPN auto-connect OS X El Capitan (Run this from Script Editor)
set vpn_name to "'VPN_NAME'"
tell application "System Events"
set rc to do shell script "scutil --nc status " & vpn_name
if rc starts with "Connected" then
do shell script "scutil --nc stop " & vpn_name
else
-- get current clipboard contents as a string
set CurrentClipboard to the clipboard as string
@prasanthj
prasanthj / init.lua
Last active April 8, 2024 21:14
Hammerspoon script for VPN auto-connect in OS X El Capitan
-- hot reload init.lua script
function reloadConfig(files)
doReload = false
for _,file in pairs(files) do
if file:sub(-4) == ".lua" then
doReload = true
end
end
if doReload then
hs.reload()
@prasanthj
prasanthj / native-mem-tracking.md
Last active June 5, 2024 12:48
Native memory tracking in JVM

Enable native memory tracking in JVM by specifying the following flag

-XX:NativeMemoryTracking=detail

Know the <PID> of the java process

jps

To print ps based RSS

ps -p <PID> -o pcpu,rss,size,vsize

To print native memory tracking summary

@prasanthj
prasanthj / debug-notes.txt
Last active November 17, 2021 10:47
Debugging hadoop/tez/llap shuffle issues
# PDSH Usage
export PDSH_SSH_ARGS_APPEND="-q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ~/.ssh/private.key"
pdsh -R ssh -w ^slaves.txt
# parallel-ssh Usage
parallel-ssh -x "-oStrictHostKeyChecking=no -i ~/.ssh/private.key" -i -h slaves.txt "sudo -u root jps | grep "LlapDaemon" | cut -f1 -d' '"
# remote heap-dump
# Add the following contents to jcmds.sh and use parallel-scp to copy the script to all hosts
#!/bin/bash
@prasanthj
prasanthj / leveldb-tuning.txt
Created June 28, 2017 08:52
configs to tune leveldb
These are tunings from https://github.com/basho/leveldb
Video: https://www.youtube.com/watch?v=vo88IdglU_8
https://github.com/google/leveldb/blob/master/include/leveldb/options.h#L83
- write buffer size - default 4MB (increase this for higher performance) (try 10x or 100x will get 72% performance)
https://github.com/google/leveldb/blob/master/db/skiplist.h#L98
- if increasing write buffer size, also increase skip list max height. Since skip list is probabilistic,
expected number of keys in write buffer has to specified ahead. (change it from 2^12 to 2^17, affects read and write performance)