Skip to content

Instantly share code, notes, and snippets.

View vnnvanhuong's full-sized avatar

Huong Nguyen vnnvanhuong

View GitHub Profile
abstract class AbstractDocumentGenerator{
//THIS IS TEMPLATE METHOD
public final File generate() {
Document defaultDocument = prepareDocumentByDefault();
Document refinedDocument = redefineDocument(defaultDocument);
String templatePath = getTemplatePath();
String outputName = getOutputName();
return DocFactory.generate(refinedDocument, templatePath, outputName);
}
//Which the same way to solve a problem
//Template Method uses Inheritance
//Strategy uses Composition/Delegation
abstract class TemplateMethod{
public final void execute() {
doFirstThing();
doSecondthing();
}
//modifier can be public, private, protected
package vn.nvanhuong.java_lab;
//Inheritance from defined default methods
interface Foo{
default void method() {
System.out.println("Foo");
};
}
interface Bar{
package vn.nvanhuong.coding.exercise;
import java.util.Scanner;
/**
* All squares (original & sub-squares) has these following characteristics:
* [1]. sorted entries
* + right entry - left entry = 1
* + below entry - above entry = dimension
* [2]. if we know smallest entry (T), dimension (N) & orientation -> we can know the rest entries
package vn.nvanhuong.hellojava.java8inaction;
import java.util.stream.IntStream;
public class MyMathUtils {
public static void main(String[] args) {
primes(numbers());
}
@vnnvanhuong
vnnvanhuong / pipelines-axonivy-pom.xml
Created October 29, 2017 10:03
pipelines-axonivy-pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>vn.nvanhuong</groupId>
<artifactId>pipelines-axonivy</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>iar</packaging>
<properties>
@vnnvanhuong
vnnvanhuong / bitbucket-pipelines-axonivy.yml
Created October 29, 2017 10:06
bitbucket-pipelines-axonivy.yml
# This is a sample build configuration for Java (Maven).
# Check our guides at https://confluence.atlassian.com/x/zd-5Mw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: vnnvanhuong/axonivy-engine:7.0.1
pipelines:
default:
- step:
@vnnvanhuong
vnnvanhuong / axonivy-engine.Dockerfile
Last active October 29, 2017 10:43
axonivy-engine-dockerfile
FROM vnnvanhuong/maven-oracle-jdk:8
MAINTAINER Huong Nguyen vnnvanhuong@gmail.com
# Install wget, unzip
RUN apt-get update && \
apt-get install -y --no-install-recommends \
wget \
unzip
# Download and extract Axon.ivy Engine
// DDP Server
// Use an implementation of WebSocket Server such as SockJS
ddpServer.socket = WebSocketServer
ddpServer.socket.onData = (msg) => {
switch(msg):
case 'connect':
check whether WebSocket connection
socket.send({msg: 'connected', ...})
case 'method':
result = methodsMap.get(msg.methodID).invoke()
@vnnvanhuong
vnnvanhuong / maven-oracle-jdk.Dockerfile
Last active August 21, 2020 06:45
maven-oracle-jdk-dockerfile
## Install Oracle Java 8
FROM ubuntu:16.04
MAINTAINER Huong Nguyen vnnvanhuong@gmail.com
# Update the package repository
RUN echo "deb http://archive.ubuntu.com/ubuntu xenial main universe" > /etc/apt/sources.list
RUN apt-get -y update
# Install python-software-properties
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q python-software-properties software-properties-common