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 / gist:11287726
Created April 25, 2014 12:20
find-the-nth-largest-number-in-an-array
// http://xorswap.com/questions/167-find-the-nth-largest-number-in-an-array
function testData() {
return [10, 1001, 15, 7, 33, 1001, 2, 0, 99, 131];
};
function sortAsc(a, b) {
if(a < b) {
return -1;
}else if(a === b) {
drawable/app_background.xml:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/actual_pattern_image"
android:tileMode="repeat" />
values/styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
@Configuration
@EnableJpaRepositories(basePackages = "io.eddumelendez.springdatajpa.repository1")
public class FirstConfiguration {
@ConfigurationProperties(prefix = "datasource.postgres")
@Bean
@Primary
public DataSource postgresDataSource() {
return DataSourceBuilder.create().
build();
@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 / gist:3965949
Last active October 12, 2015 03:47
javascript scope
(function(msg) {
return {
"hot":function() {
console.log(msg);
}
};
})('doggy').hot();
@mhuckaby
mhuckaby / gist:04ea5eb7ce3b50f9e469
Last active October 25, 2015 19:15
virtual box guest additions on centos 7
####
# For Centos 7
# iso
# https://www.centos.org/download/mirrors/
sudo yum update
sudo yum -y install gcc make gcc-c++ kernel-devel-`uname -r` zlib-devel openssl-devel readline-devel sqlite-devel perl wget dkms nfs-utils bzip2
sudo mkdir /mnt/cdv2
sudo mount -r -t iso9660 /dev/sr1 /mnt/cdv2
cd /mnt/cdv2
@mhuckaby
mhuckaby / setenv.sh
Created November 13, 2015 18:21 — forked from terrancesnyder/setenv.sh
./setenv.sh - example setenv.sh with defaults set for minimal time spent in garbage collection
#! /bin/sh
# ==================================================================
# ______ __ _____
# /_ __/___ ____ ___ _________ _/ /_ /__ /
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / /
# / / / /_/ / / / / / / /__/ /_/ / /_ / /
#/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
@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