Skip to content

Instantly share code, notes, and snippets.

@nicholashagen
nicholashagen / README.md
Created September 24, 2022 19:48
Five Star Architecture

Five Star Architecture

Being apart of several different architecture teams throughout my career, I have learned alot about data organization from the core data to the frontend interfaces to everything in-between. Generally, every single architecture survives off what I am coining as the Five Star Architecture (FSA). The FSA essentially encompasses five different tiers, each with their specific resposibilities and methodologies.

The following is a high-level diagram of the tiers including the communication protocol(s):

@nicholashagen
nicholashagen / 0_reuse_code.js
Created October 28, 2015 21:30
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@nicholashagen
nicholashagen / README.md
Created October 29, 2013 20:37
Metrics library rundown and overview

Metrics Library

About

  • Originally developed at Yammer by Coda Hale
  • Released as an open source metrics library implementation under Coda Hale
  • Considered one of the more prominent instrumentation libraries
  • Composed of core metrics library and set of growing plugins
  • Core library supports variety of metric gathering tools and health checks
  • Plugins support exposing core metrics (jmx, graphite, etc)
@nicholashagen
nicholashagen / README.md
Created October 24, 2013 03:40
HD HomeRun on Raspberry Pi

Download Source

#> wget http://download.silicondust.com/hdhomerun/libhdhomerun_20130117.tgz
#> tar zxvf libhdhomerun_20130117.tgz 

Install Tools

@nicholashagen
nicholashagen / StreamingExamples.java
Created October 23, 2013 20:31
The following demonstrates various examples of the new Streaming API in Java 8
package com.devchat.lambdas.examples;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
@nicholashagen
nicholashagen / README.md
Created September 24, 2013 03:18
Thoughts on merging JAXB annotations and JSON binding annotations

Currently, there are several implementations that provide JSON to object binding in Java. Several actually use the existing JAXB annotations that are XML driven. This results in oddities that you are exposing JSON binding rules with annotations that target XML (ie: @XmlType, @XmlValue, etc). As a result, there is a future spec coming for an official JSON bindings recommendation. This will most likely result in a new set of annotations (ie: @JsonType, @JsonValue). This will end up requiring double annotations leading to metadata bloat. The problem is that despite the two being very closely tied together, there are several differences. One could argue that JSON is a subset of XML, although that is not entirely accurate.

I would propose that indeed we have two separate annotations and two separate specifications that are aligned as consistently as possible (similar named annotations for common use cases such as @XmlValue and @JsonValue). I would propose a third joint effort spec that creates an aggregat

@nicholashagen
nicholashagen / Api.groovy
Created August 13, 2013 16:08
API example
@Path('/:sport/:league/events')
class EventResource {
String sport
String league
@Path('/:year/:month/:day')
EventResponse getEventsForDate(Integer year, Integer month, Integer day) { ... }
@Path('/today')
EventResponse getTodaysEvents() { ... }
@nicholashagen
nicholashagen / GrailsMongoDBTest.groovy
Created May 28, 2013 18:33
MongoDB plugin in Grails and Criteria queries
/* ASSUME FOLLOWING OBJECT MODEL
class Address {
String street
String city
}
class Role {
boolean admin
String type
@nicholashagen
nicholashagen / HTTPBuilderGitHubFailure.groovy
Created May 23, 2013 14:26
Groovy HTTPBuilder fails with GitHub
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.6' )
import groovyx.net.http.*
import groovyx.net.http.RESTClient
import static groovyx.net.http.ContentType.URLENC
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
// this fails
try {
@nicholashagen
nicholashagen / LoadTest.java
Last active December 17, 2015 10:59
Faster Synchronization Through Hash Maps
public class LoadTest {
public static void main(String[] args) {
// int count = 5000;
int count = 25000;
// int count = 100000;
// int count = 250000;
long s = System.nanoTime();
for (int i = 0; i < 1000; i++) {