Skip to content

Instantly share code, notes, and snippets.

View ariesmcrae's full-sized avatar
💭
typescript, node.js, aws, java, go (golang)

A. M. ariesmcrae

💭
typescript, node.js, aws, java, go (golang)
View GitHub Profile
@ariesmcrae
ariesmcrae / genesis.json
Last active August 27, 2017 23:40
genesis.json
{
"difficulty":"0x400",
"extraData":"",
"gasLimit":"0x8000000",
"nonce":"0x0000000000000042",
"mixhash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp":"0x0",
"alloc":{
@ariesmcrae
ariesmcrae / CsvError.java
Created September 10, 2017 09:03
Java POJO to JSON
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
@Getter
public class CsvError {
private String filename;
@ariesmcrae
ariesmcrae / CsvValidator.java
Last active April 20, 2018 12:16
Validates the number expected commas in a CSV
/**
* Validate row of csv to see if it has the correct number of commas.
* @param input The csv row to be evaluated.
* @param expectedNumberOfCommas The expected number of commas in the csv row.
*/
public static void validateLine(String input, int expectedNumberOfCommas) {
// Example input: [email protected],Male,21
// Check that there are 2 commas in the input:
// regex = ^([^,]*,){2}[^,]*$
@ariesmcrae
ariesmcrae / .gitignore
Last active October 7, 2017 09:00
.gitignore
# Compiled source #
######################
*.class
# Packages #
######################
*.jar
@ariesmcrae
ariesmcrae / MainBuldingStreams.java
Last active February 22, 2019 02:21
Arrays.asList vs Stream.Of
package com.ariesmcrae.streams;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
public class MainBuldingStreams {
public static void main(String[] args) {
// first way
Dockerfile
.dockerignore
.gitignore
README.md
.git/
# Compiled source #
######################
*.class
@ariesmcrae
ariesmcrae / Dockerfile
Last active October 29, 2017 23:09
Dockerfile sample for React and yarn. Modifying a React file from your laptop would sync them into the running container.
FROM node:8.8.1-alpine
# Make less message noise during docker build
#ENV NPM_CONFIG_LOGLEVEL warn
ARG app_env
ENV APP_ENV $app_env
# All subsequent commands will now be run from inside of this folder
RUN mkdir -p /usr/app/src
@ariesmcrae
ariesmcrae / CombinedStreams.java
Last active February 22, 2019 01:51
Combine list and array into a comma separated value to produce a regex pattern
Stream<String> states = Stream.of("NSW", "VIC", "SA", "WA", "ACT", "QLD", "TAS", "NT");
Stream<String> additionalStates = {"AUCKLAND", "CHRISTCHURCH"};
List<String> combinedStates = Stream.concat(states, additionalStates).collect(Collectors.toList());
String regexPattern = "\\A(" + StringUtils.join(combinedStates, "|") + ")\\z";
// \A(NSW|VIC|SA|WA|ACT|QLD|TAS|NT|SPACE)\z
@ariesmcrae
ariesmcrae / Main.java
Created January 27, 2018 12:21
Java: Return sensible default and avoid NullPointerException in deep hierarchical object tree
import java.util.Optional;
public class Main {
public static void main (String[] args) {
Apple apple = new Apple();
Banana banana = new Banana();
apple.setBanana(banana);
Coconut coconut = new Coconut();
@ariesmcrae
ariesmcrae / Main.java
Last active March 28, 2019 05:37
Optional nullable
package com.ariesmcrae.combination.service;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class Main {