Skip to content

Instantly share code, notes, and snippets.

View mhuckaby's full-sized avatar
✌️
Ahoy hoy

Matthew Huckaby mhuckaby

✌️
Ahoy hoy
View GitHub Profile
@mhuckaby
mhuckaby / veep.js
Created August 24, 2012 16:51
nodejs - zenity popup when vpn fails silently
#!/usr/bin/node
var exec = require('child_process').exec;
var connect_status = 'ifconfig | grep tun0 > /dev/null 2>&1 && echo "Connected" || echo "Not connected"';
var show_no_veep = 'zenity --error --text "You are not connected to VPN"'
function checkVeep(){
exec(connect_status, function(error, stdout, stderr){
if(stdout.match(/Not/)){
exec(show_no_veep, function(){
setTimeout(checkVeep, 25000);
@mhuckaby
mhuckaby / zenity.sh
Created August 24, 2012 17:07
zenity popups via ssh to remote rendering display on :0
zenity --error --text "This is the contents of the alert" --display :0
response=`zenity --entry --text "Please enter your value" --display :0
@mhuckaby
mhuckaby / gist:3965949
Last active October 12, 2015 03:47
javascript scope
(function(msg) {
return {
"hot":function() {
console.log(msg);
}
};
})('doggy').hot();
@mhuckaby
mhuckaby / option.sh
Created April 23, 2013 16:02
Bash option idiom
while test $# -gt 0
do
case "$1" in
--opt1) echo "option 1"
;;
--opt2) echo "option 2"
;;
--*) echo "bad option $1"
;;
*) echo "argument $1"
@mhuckaby
mhuckaby / env_check.sh
Created April 23, 2013 16:08
Exit script if environment var is not set
if [ "$ENV" == "" ]
then
echo "ENV must be set"
exit
else
echo "ENV is $ENV"
fi
@mhuckaby
mhuckaby / branch_notes
Last active December 21, 2015 17:39
branch notes
# Clone project
git clone https://github.com/mhuckaby/retro-post.git rp-eh-1
# Track remote branch
git checkout --track origin/ehcache
# Branch the remote branch locally
git branch ehcache-1
# Push new local branch to remote
# This script compiles nginx + echo module on Ubuntu
# Tested on Ubuntu 10.04 LTS (Lucid Lynx), 32 bit
# Resources:
# - http://extralogical.net/articles/howto-compile-nginx-passenger.html
# - http://wiki.nginx.org/InstallOptions
# - http://wiki.nginx.org/CommandLine
# - http://superuser.com/questions/336275/find-out-if-user-name-exists - check if the user exists
# Tips:
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@mhuckaby
mhuckaby / java tmp file and default browser
Created October 18, 2013 20:35
temp file and default browser java code
public class Gist {
public static void main(String[] args) throws Exception {
final String tmpPath = System.getProperty("java.io.tmpdir");
System.out.println(tmpPath);
final java.io.File dir = new java.io.File(tmpPath);
@mhuckaby
mhuckaby / bash.pid.tomcat.sh
Created November 7, 2013 14:27
List PID(s) for Tomcats
ps -ef | grep org.apache.catalina.startup.Bootstrap | grep -v "grep" | awk '{print $2}'