Skip to content

Instantly share code, notes, and snippets.

View ke4roh's full-sized avatar

Jim Scarborough ke4roh

View GitHub Profile
#!/bin/bash
set -e
[ -e /etc/profile.d/proxy.sh ] && source /etc/profile.d/proxy.sh
# Some defaults that may be overridden by command line
HEADLESS=false
CLEAN=false
# Execute getopt
@ke4roh
ke4roh / Gemfile
Last active April 2, 2023 10:56 — forked from binarydev/json_utilities.rb
declare module_function
source 'https://rubygems.org'
gem 'json'
group :test do
gem 'minitest'
gem 'test-unit'
end
@ke4roh
ke4roh / islocalhost
Created May 28, 2015 13:54
Determine if the given host is localhost
#!/bin/bash
set -e
function isLocalhost {
local TEST_IP=$(getent hosts $1 | cut -f1 -d\ | head -1)
local ALL_MY_IPS=$(ip addr | grep inet | grep -v link | cut -f2- -de | cut -f2 -d\ | cut -f1 -d/)
( echo $ALL_MY_IPS | grep -q $TEST_IP ) && return 0
return 1
}
@ke4roh
ke4roh / kcheck
Created June 24, 2015 14:43
perform kinit if there is no kerberos ticket
#!/bin/bash
while ! klist -s ; do
ERR=$( kinit 3>&2 2>&1 1>&3- )
EC=$?
if [ $EC -ne 0 ] ; then
echo $ERR
if ( echo $ERR | grep -q "Cannot contact any KDC" ) ; then
exit 2
fi
@ke4roh
ke4roh / whereIsFile.sh
Created August 5, 2015 15:03
Find out where the symbolic links bottom out
#!/bin/sh
FILE_PATH=$1;
while([ -h "${FILE_PATH}" ]) do cd -P $(dirname "${FILE_PATH}"); FILE_PATH=$(readlink "${FILE_PATH}"); done
cd -P $(dirname "${FILE_PATH}") > /dev/null
echo $(pwd);
@ke4roh
ke4roh / findJavaHome.sh
Created August 5, 2015 16:52
Where is JAVA_HOME?
#!/bin/bash
function whereIsFile() {
pushd . > /dev/null
FILE_PATH=$1;
while([ -h "${FILE_PATH}" ]) do cd -P $(dirname "${FILE_PATH}"); FILE_PATH=$(readlink "${FILE_PATH}"); done
cd -P $(dirname "${FILE_PATH}") > /dev/null
echo $(pwd)
popd >/dev/null
}
@ke4roh
ke4roh / lab1SchemaSetup.sh
Created October 13, 2015 15:50
Solr Under The Hood Getting Started field definition
#!/bin/bash
curl http://localhost:8983/solr/gettingstarted/schema -D - -X POST -H \
'Content-type:application/json' --data-binary '{
"add-field" : {
"name":"name",
"type":"text_general",
"stored":true
},
"add-field" : {
@ke4roh
ke4roh / git-show-big
Last active April 22, 2017 12:11
Show large objects in the git repo for cleaning cruft
$ cat git-show-big
#!/bin/bash
# Ref http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history
SHAS=$(git rev-list --objects --all | sort -k 2)
BIGOBJS=$(git gc && git verify-pack -v .git/objects/pack/pack-*.idx | egrep "^\w+ blob\W+[0-9]+ [0-9]+ [0-9]+$" | sort -k 3 -n -r)
join <(echo "$BIGOBJS" | sort ) <(echo "$SHAS" | sort ) | sort -k 3 -n -r | cut -f 1,3,6- -d\
@ke4roh
ke4roh / sslserver.py
Created February 10, 2017 15:06
Circuits Framework SSL web with redirector
#!/usr/bin/env python3
from circuits import Debugger, BaseComponent, handler
from circuits.web import Controller, Server
from circuits.web.errors import redirect
from urllib.parse import urlparse, urlunparse
class Root(Controller):
def index(self):
return "Hello World!"
@ke4roh
ke4roh / fetchertest.py
Created February 14, 2017 15:47
Circuits framework parallel fetching example - broken
#!/bin/env python3
from circuits.web.client import Client, request as request_event
from circuits.web import Server, Controller
from circuits import handler, Debugger
class Root(Controller):
channel = "web"
def __init__(self):