Skip to content

Instantly share code, notes, and snippets.

View prasanthj's full-sized avatar

Prasanth Jayachandran prasanthj

View GitHub Profile
@prasanthj
prasanthj / ec2-nvme-count.txt
Created January 18, 2019 08:08
Mount NVMe SSDs in AWS EC2 instances
Mount Separately
----------------
# mount nvme SSDs to /dataN when available for specific instance types
# There are only 4 nvme slots in r5 instances. /dev/nvme0n1 is root EBS volume.
for i in $(seq 1 4); do
if [ -e "/dev/nvme${i}n1" ]
then
echo "Mounting /dev/nvme${i}n1 to /data${i}"
sudo mkfs.ext4 -E nodiscard /dev/nvme${i}n1
sudo mkdir -p /data${i}
@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 March 2, 2024 15:00
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 / lirc-pi3.txt
Last active January 5, 2023 01:35
Getting lirc to work with Raspberry Pi 3 (Raspbian Stretch)
Notes to make IR shield (made by LinkSprite) work in Raspberry Pi 3 (bought from Amazon [1]).
The vendor has some documentation [2] but that is not complete and sufficient for Raspbian Stretch.
Following are the changes that I made to make it work.
$ sudo apt-get update
$ sudo apt-get install lirc
# Add the following lines to /etc/modules file
lirc_dev
lirc_rpi gpio_in_pin=18 gpio_out_pin=17
@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
{{ $all := . }}
{{ $servers := .Servers }}
{{ $cfg := .Cfg }}
{{ $IsIPV6Enabled := .IsIPV6Enabled }}
{{ $healthzURI := .HealthzURI }}
{{ $backends := .Backends }}
{{ $proxyHeaders := .ProxySetHeaders }}
{{ $addHeaders := .AddHeaders }}
# Configuration checksum: {{ $all.Cfg.Checksum }}
@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);
});
apt-get update
apt-get install -y python curl vim
curl -O https://bootstrap.pypa.io/get-pip.py
export PATH=~/.local/bin:$PATH
python get-pip.py --user
pip install awscli --upgrade --user
mkdir -p ~/.aws
vim ~/.aws/config
[default]
@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 / eclipse-mat-offline.txt
Last active February 2, 2020 02:47
Eclipse MAT offline analysis
Download Eclipse MAT from https://www.eclipse.org/mat/
Change Xmx depending on heap dump size being analyzed in ini file. If GC errors are observed then add -XX:-UseGCOverheadLimit option too
vim ~/home/pkgs/mat/MemoryAnalyzer.ini
~/home/pkgs/mat/ParseHeapDump.sh heapdump.hprof