Skip to content

Instantly share code, notes, and snippets.

View bhavanki's full-sized avatar
💭
Flossing

Bill Havanki bhavanki

💭
Flossing
View GitHub Profile
@bhavanki
bhavanki / freeport.go
Created June 17, 2022 13:09
A small Go program to find a free / unused TCP port
package main
import (
"fmt"
"net"
"os"
)
func main() {
ln, err := net.Listen("tcp", "")
@bhavanki
bhavanki / xb_colima.sh
Created February 4, 2022 18:21
An xbar / swiftbar script for simple status and control of Colima.
#!/usr/bin/env bash
PATH=/usr/local/bin:$PATH
# https://en.wikipedia.org/wiki/Magdalena_rat
RAT_ICON=iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAYAAAAehFoBAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAlmVYSWZNTQAqAAAACAAFARIAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSATEAAgAAABEAAABah2kABAAAAAEAAABsAAAAAAAAAJAAAAABAAAAkAAAAAF3d3cuaW5rc2NhcGUub3JnAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAALKADAAQAAAABAAAALAAAAABAa5naAAAACXBIWXMAABYlAAAWJQFJUiTwAAADCGlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICAgICAgICAgIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWURpbWVuc2lvbj4yODg8L2V4aWY6UGl4ZWxZRGltZW5za
@bhavanki
bhavanki / Bash.markdown
Created November 4, 2021 21:33
My cheat sheet for helpful Bashisms

Read the lines output from a command into an array variable

readarray -t var < <(command)
var=()
while IFS= read -r line; do
  var+=( "$line" )
{
"basics": {
"name": "William A. Havanki, Jr.",
"label": "",
"picture": "",
"email": "test@example.com",
"website": "http://havanki.us/",
"summary": "",
"location": {
"address": "1234 Test St.",
@bhavanki
bhavanki / director_install.sh
Last active September 25, 2017 17:39
A bash script for installing Cloudera Director. If you are feeling adventurous, use curl to pipe it into bash. Otherwise, download and run.
#!/usr/bin/env bash
# Copyright 2017 William A. Havanki, Jr.
# Licensed 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
#
@bhavanki
bhavanki / master-protect-pre-push
Created March 10, 2015 21:09
Protects origin/master from your screwed-up pushes
#!/bin/bash
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
remote_name=$1
if [[ $remote_name != "origin" ]]; then
exit 0
fi
@bhavanki
bhavanki / gist:e6e21ea15cf5670ba534
Created May 27, 2014 22:18
Out-of-memory stack traces when writing and scanning Accumulo rows of 100 cells with 100 MB values in each cell
Observed in monitor:
Unexpected throwable while invoking!
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2786)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
at org.apache.thrift.transport.TFramedTransport.write(TFramedTransport.java:146)
at org.apache.thrift.protocol.TCompactProtocol.writeBinary(TCompactProtocol.java:342)
at org.apache.thrift.protocol.TCompactProtocol.writeBinary(TCompactProtocol.java:337)
at org.apache.accumulo.core.data.thrift.TKeyValue$TKeyValueStandardScheme.write(TKeyValue.java:465)
@bhavanki
bhavanki / MetadataTableUtilTesting.java
Created March 20, 2014 15:32
An example of using a factory class to improve testability over a static method call.
/*
* Current getMetadataTable() method. This is hard to test because it requires a real HdfsZooInstance object.
*/
public synchronized static Writer getMetadataTable(Credentials credentials) {
Writer metadataTable = metadata_tables.get(credentials);
if (metadataTable == null) {
metadataTable = new Writer(HdfsZooInstance.getInstance(), credentials, MetadataTable.ID);
metadata_tables.put(credentials, metadataTable);
}
return metadataTable;
@bhavanki
bhavanki / makeapp.sh
Last active January 2, 2016 14:29 — forked from demonbane/makeapp.sh
Chrome SSB generation script. Modifications since forking: - support for spaces in app name
#!/bin/sh
echo "What should the Application be called (e.g. GCal)?"
read inputline
name="$inputline"
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url="$inputline"
@bhavanki
bhavanki / gitprompt.sh
Last active December 21, 2015 23:29
.bashrc snippet to include the current Git branch in the prompt
parse_git_branch() {
git branch --no-color 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1 /'
}
gitps1() {
local GREEN="\[\033[0;32m\]"
local DEFAULT="\[\033[0m\]"
PS1="[\u@\h \W]$GREEN\$(parse_git_branch)$DEFAULT\$ "
}
gitps1