Skip to content

Instantly share code, notes, and snippets.

View vicly's full-sized avatar

Vic vicly

  • Auckland, New Zealand
View GitHub Profile
@vicly
vicly / dropwizard_clientBuilder.md
Last active January 10, 2019 02:35
[Create WebTarget in Dropwizard] #Java #Dropwizard
	JerseyClientConfiguration clientConfig = ...;
    String clientName = "PaymentAPIClient";
    String baseUrl = "http://the-host/the-path";

    JerseyClientBuilder clientBuilder = new JerseyClientBuilder(environment)
        .using(clientConfig)
        .withProvider(new CorrelationIdClientRequestFilter())
        .withProvider(new LoggingFeature(
@vicly
vicly / custom_validation.md
Created January 10, 2019 01:25
[Custom bean validation] #Java

Custom constraint and group

@Documented
@ReportAsSingleViolation
@Constraint(validatedBy = { FirstName.Validator.class })
@Target({ ElementType.FIELD, ElementType.PARAMETER })
@Retention(RUNTIME)
@NotBlank
@vicly
vicly / custom_generated_type.md
Last active August 14, 2021 08:13
[WSDL java code gen] #Gradle

Generate java.time.OffsetDateTime for xs:dateTime

JXB file - MyService.jxb (see extraArgs in gradle file)

<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings version="2.1"
               xmlns:xs="http://www.w3.org/2001/XMLSchema"
 xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"&gt;
@vicly
vicly / checkstyle.md
Created December 20, 2018 21:01
[Gradle code check] #Gradle

$root/config

  • checkstyle.xml
  • suppression.ml
plugins {
@vicly
vicly / ecr.md
Created December 20, 2018 19:53
[AWS docker] #Docker #AWS

Assume role and pull/push image to ECR


export http_proxy=<PROXY>
export https_proxy=<PROXY>
export no_proxy=localhost,127.0.0.1
export AWS_DEFAULT_REGION=ap-southeast-2
@vicly
vicly / aws_cloudfront_s3.md
Created December 19, 2018 22:27
[CloudFront+S3+EdgeLambda] #AWS
@vicly
vicly / gitconfig.md
Created December 18, 2018 02:15
[git config file] #Git

~/.gitconfig

[alias]
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all

lg = !"git lg1"
@vicly
vicly / my_commands.sh
Created December 18, 2018 02:12
[custom shell command] #Bash
#!/bin/bash
CUSTOM_BASH_DIR=~/my_bash
function aws-encrypt() {
$CUSTOM_BASH_DIR/./aws-encrypt.sh "$@"
}
function aws-decrypt() {
$CUSTOM_BASH_DIR/./aws-decrypt.sh "$@"
@vicly
vicly / git-compeltion.sh
Created December 18, 2018 02:11
[git-completion] #Bash
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# *) local and remote tag names
@vicly
vicly / aws_ssh.md
Created December 14, 2018 03:13
[SSH & AWS] #AWS #Bash

AWS EC2 accpet

  • OpenSSH public key format (PEM)
  • Base64 encoded DER format
  • SSH public key file format, e.g. ~/.ssh/id_rsa.pub

On client node, generate a key pair: ~/.ssh/id_rsa.pub, id_rsa

ssh-keygen