Skip to content

Instantly share code, notes, and snippets.

View AnthonyClink's full-sized avatar

Anthony J Clink AnthonyClink

  • Clinkworks
  • Beaverton, Oregon
View GitHub Profile
My Hero Pool: Ranged Assasin(Chromie, Hanzo, Ming) Brawler (Arthas, Chen, Blaze) Healer(Uther, Deckard, Rehgar, Stukov, brightwing, lili), Specalist(Medivh, The Lost Vikings, Murky, Abathur)
find . -name '*\$*' -print
@AnthonyClink
AnthonyClink / random-commands.txt
Last active July 25, 2016 19:25
Random Commands
kibana stack
bin/logstash -ftest-conf.conf -w1 > "../stack-logs/logstash.log" 2>&1 &
bin/kibana > "../stack-logs/kibana.log" 2>&1 &
bin/elasticsearch -d -p pid
sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" xmlns="http://www.w3schools.com">
<Appenders>
<!-- TODO: parameterize the pattern and the log level -->
<Console name="SysOut" target="SYSTEM_OUT">
<PatternLayout
pattern="%d{yyyy-MM-dd HH:mm:ss:sss} %-5p %c{1}:%L - %m%n" />
<Filters>
<ThresholdFilter level="warn" onMatch="DENY"
@AnthonyClink
AnthonyClink / FixUrlUnitTest.java
Last active June 7, 2016 21:08
fix multiple slashes in urls generated from user input
public class CleanUserInputUnitTests{
private static final Pattern HAS_MORE_THAN_SINGLE_SLAHES_PATTERN = Pattern.compile("([^:])\\/+");
@Test
public void regexPatternForRemovingSlashesFromBadUrlsWorksCorrectly() {
String input = "https://www.google.com//we////super///love/slashes//////in//generated/urls";
String expectedOutput = "https://www.google.com/we/super/love/slashes/in/generated/urls";
Assert.assertEquals(Pattern.compile(HAS_MORE_THAN_SINGLE_SLAHES_PATTERN).matcher(input).replaceAll("$1/"), expectedOutput);
# Directories #
/build/
/bin/
target/
test-output/
tmp/
screenshots/
# OS Files #
.DS_Store
@Test
public void showJSON(){
String json = "{\"innerObject\":{\"myObjectProp1\":\"prop1\"}, \"myArray\" : [\"one\", \"two\", 1]}";
JsonElement jsonElement = new JsonParser().parse(json);
assertTrue(jsonElement.getAsJsonObject().get("innerObject").isJsonObject());
assertTrue(jsonElement.getAsJsonObject().get("myArray").isJsonArray());
assertEquals("one", jsonElement.getAsJsonObject().get("myArray").getAsJsonArray().get(0).getAsString());
assertEquals("two", jsonElement.getAsJsonObject().get("myArray").getAsJsonArray().get(1).getAsString());
assertEquals(1, jsonElement.getAsJsonObject().get("myArray").getAsJsonArray().get(2).getAsInt());
If this is expected to be a non trivial application I would probably use the strategy pattern.
public class CommandLineCalculator{
public static void main(String[] args){
CommandLineCalculator commandLineCalculator = new CommandLineCalculator();
int total = 0;
int lastValue = 0;
@AnthonyClink
AnthonyClink / DataRegistry.java
Created April 25, 2014 02:03
A usage of the data library
package com.clinkworks.neptical;
import java.io.File;
import java.util.Map;
import com.clinkworks.neptical.data.file.FileData;
import com.clinkworks.neptical.data.loaders.json.JsonDataLoader;
import com.clinkworks.neptical.util.PathUtil;
import com.google.common.collect.Maps;
@AnthonyClink
AnthonyClink / DataMojo.java
Created April 25, 2014 01:48
My hello maven using a custom library.
package com.clinkworks.neptical.maven;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import com.clinkworks.neptical.Data;
import com.clinkworks.neptical.DataRegistry;