Skip to content

Instantly share code, notes, and snippets.

@aaronzirbes
aaronzirbes / add-host-to-ubuntu-keystore.sh
Created February 3, 2012 10:15
This will add a web server's SSL certificate to your Ubuntu System-wide keystore
#!/bin/bash
host=$1
port=$2
# Make sure we got the host name
if (( ${#host} == 0 )); then
echo "usage: $0 <hostname> [port]"
exit 1
elif (( ${#port} == 0 )); then
@aaronzirbes
aaronzirbes / filesystem-as-gremlin-graph.groovy
Last active November 8, 2016 19:03
Want to view your filesystem as a Gremlin graph?
/**
* Run this on your DSE graph instance via DSE studio to see some pretty graphs.
* Feel free to change folderDepth or rootPath.
*
* Note, this only works in DSE if development mode is on, and vertex scanning is enabled.
*/
// schema.config().option("graph.allow_scan").set(true)
// schema.config().option("graph.schema_mode").set("Development")
@aaronzirbes
aaronzirbes / make-time-machine-work.sh
Last active August 25, 2016 19:45
Script to setup SMB share for time machine backup
#!/bin/bash
###
### This is the script I use to setup time machine to work with my LinkSys attched NAS (USB 3.0 Hard Drive)
###
#### Configurable Parameters #########
SIZE=300g
NAME="Z.org Time Machine Backup"
@Grapes([
@Grab(group='com.squareup.retrofit', module='retrofit', version='1.9.0')
])
import retrofit.http.*
import retrofit.RestAdapter
import java.time.ZoneOffset
import java.time.LocalDateTime
import java.text.NumberFormat
@aaronzirbes
aaronzirbes / jira
Created April 6, 2016 15:30
Jira Script to open JIRA
#!/bin/bash
JIRA_HOST="https://jira.atlassian.com"
ISSUE=""
DEFAULT_PROJECT=PCDR
if [ "$1" == "" ]; then
current_branch=`git rev-parse --abbrev-ref HEAD`
if [ $? == 0 ] && [[ "${current_branch}" =~ [A-Za-z]-[0-9] ]]; then
echo "Using git branch name as JIRA issue"
#!/bin/bash
devices=`mount |grep -E '^/dev/' | cut -d ' ' -f 1`
warn_threshold="85"
fail_threshold="90"
status="OK"
for device in ${devices}; do
diskfree=`df -h ${device} |grep ${device}`
percent=`echo ${diskfree} |awk '{print $5}' |sed -e 's/%//'`
@aaronzirbes
aaronzirbes / GrailsEnum.groovy
Last active December 18, 2015 03:29
Trying to write an AST transformer to make it easier to add a @GrailsEnum annotation
class GrailsEnumType {
String name
}
@interface GrailsEnumHolder {
String value() default 'default value'
}
@interface Parameter {
String name() default 'default name'
@aaronzirbes
aaronzirbes / hammer_grails_console.js
Last active December 15, 2015 04:29
This will hammer the Grails /console to try to get it to fail when it drops the POST data
for (var wat = 0; wat < 1000; wat++) {
var url = '/console/execute';
var data = { code: "println 'too big to fail'\n" };
$.post(url, data, function(data, textStatus) {
console.log(textStatus);
if (data.exception) {
console.log("Found Error!");
console.log(data.exception);
}
@aaronzirbes
aaronzirbes / find-missing-specs.sh
Created February 20, 2013 19:30
Find groovy classes that don't have Spock tests written for them yet.
#!/bin/bash
groovy_src=src/main/groovy
spec_src=src/test/groovy
groovy_classes='_groovy_classes.txt'
specs='_spock_specs.txt'
find ${groovy_src} -name *.groovy \
| sed -e 's#.*/##' -e 's/\.groovy$//' \
| sort -u \
@aaronzirbes
aaronzirbes / gist:4773776
Created February 12, 2013 21:52
Ensure encryption algos encrypt to the same field length
@Grapes([
@Grab(group='org.bouncycastle', module='bcprov-jdk15on', version='1.47'),
@Grab(group='org.jasypt', module='jasypt', version='1.9.0')
])
import java.security.Provider
import java.security.Security
import java.security.NoSuchAlgorithmException
import org.jasypt.exceptions.EncryptionInitializationException
import org.bouncycastle.jce.provider.BouncyCastleProvider