Skip to content

Instantly share code, notes, and snippets.

@aaronzirbes
aaronzirbes / funWithRegexGroupNames.groovy
Created December 13, 2018 19:10
Fun with regex group names
import java.util.regex.Matcher
import java.util.regex.Pattern
Map splitLabel(String label) {
Pattern labelPattern = Pattern.compile('(?<column>^[A-Za-z]+)(?<side>\\d)(?<row>\\d+$)')
Matcher labelMatcher = labelPattern.matcher(label)
labelMatcher.find()
String columnLabel = labelMatcher.group("column")
Integer sideLabel = Integer.parseInt(labelMatcher.group("side"))
@aaronzirbes
aaronzirbes / java-to-json.sh
Created March 9, 2018 18:30
Turn Java Properties in to JSON
sed -E 's/(String|Integer|UUID|Instant|Boolean) ([a-zA-Z0-9]+;)/"\2": "\11",/' *.json
@aaronzirbes
aaronzirbes / ElasticTests.groovy
Created July 13, 2017 10:05
Testing Retrofit API for Elasticsearch
@Grapes([
@Grab(group='com.squareup.retrofit', module='retrofit', version='1.9.0')
])
import retrofit.http.*
import retrofit.RestAdapter
class ElasticTests {
static final String INDEX = 'zirbes'
@aaronzirbes
aaronzirbes / tail-pods
Created May 18, 2017 17:53
Tails multiple k8s pods
#!/bin/bash
default_filter="(event.*|container-container.*|dci-osn-bridge.*)"
filter="${1}"
color=32
if [ "$filter" == "" ]; then
filter="${default_filter}"
fi
HttpServer server = HttpServer.create(new InetSocketAddress(config.healthCheckServerPort), 0)
server.createContext("/health", new HealthCheckHttpHandler(healthCheckRegistry))
server.setExecutor(null)
server.start()
@aaronzirbes
aaronzirbes / MockTcpServer.groovy
Created April 28, 2017 20:57
Basic Netty TCP server
package org.zirbes.sandbox
import groovy.util.logging.Slf4j
import io.netty.bootstrap.ServerBootstrap
import io.netty.channel.ChannelFuture
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.ChannelInboundHandlerAdapter
import io.netty.channel.ChannelInitializer
import io.netty.channel.ChannelOption
import io.netty.channel.EventLoopGroup
@aaronzirbes
aaronzirbes / New MacBook Setup
Last active August 11, 2021 19:29
Steps I use to setup a new MacBook
# New MacBook Setup
This is how I setup a new MacBook
* brew install
* https://brew.sh/
* List: https://github.com/aaronzirbes/dot-files/blob/master/homebrew-list.txt
* `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
* brew cask install
* https://caskroom.github.io/
@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 / Codenarc.groovy
Last active July 16, 2018 11:37
Example Codenarc.groovy
/*
* Copyright 2014 the original author or authors.
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
@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