The Psychology of Persuasion.
Spring Data - powerful and succinct abstraction
Database tier definition
Database tables, indexes and foreign keys defined in Liquibase configuration:
1 | databaseChangeLog: |
DAO definition
- Draft Order
1 |
|
- Draft Order Combined
1 |
|
- An middle Aggregation Object
1 | public class CombinedIdSourceTimeInMs { |
CRUD Repository definition
- DraftOrderRepository
1 | public interface DraftOrderRepository extends CrudRepository<DraftOrder, Integer> { |
- DraftOrderCombinedRepository
1 | public interface DraftOrderCombinedRepository extends CrudRepository<DraftOrderCombined, Integer> { |
References
- Spring Data JPA Reference Documentation, https://docs.spring.io/spring-data/jpa/docs/current/reference/html/
SQL script generates random data and insert into MySQL database
1 | DROP PROCEDURE InsertRandomRecords; |
1 | DELIMITER $$ |
To generate 1,000,000 draft orders:
1 | CALL InsertRandomRecords(1000000); |
Set up and run AWS Lambda 'hello' function with serverless
serverless
With latest Node.js 6.x.x installed, then install serverless globally:
1 | $ npm install serverless -g |
AWS Lambda
Create a AWS Lambda skeleton project with serverless:
1 | $ mkdir serverless-example && cd $_ |
- Policies set up for Lambda function
For AWS user “ec2-user”, now need to have some policies with permissions to let “serverless” create role, Lambda function and deployment it …
- Roles for Lambda function
Lambda function role created after Lambda function added and deployed into AWS.
Deployment
Make sure AWS environment has been set up, including access key, user, group, policies …
Pack and deploy Lambda example into AWS:
1 | $ sls deploy -r ap-southeast-2 -s dev |
- Lambda “hello” function
A “hello” Lambda function has been created in Lambda after it’s deployed into AWS by “serverless”.
- Events generated during Lambda function deployment
Deployment events generated during Lambda “hello” function deployed into AWS.
- Add Lambda Trigger on AWS API Gateway
Manually create a Lambda Trigger. This time we use AWS API Gateway to trigger / invoke Lambda “hello” function.
- Exposed Lambda API Gateway
After Lambda Trigger created, an exposed RESTful interface for Lambda “hello” function.
Say “hello”
Set up AWS API Gateway trigger for Lambda “hello” function. Go to url, e.g.:
Function “hello” log:
1 | { |
References
- serverless framework, https://serverless.com/
- Example source code and artefact, https://github.com/TerrenceMiao/AWS/tree/master/serverless-example
Factorial function implementation in Java 8
Implementation
1 | package org.paradise.function; |
Unit test
1 | package org.paradise.function; |
Fibonacci function implementation in Java 8
Implementation
1 | package org.paradise.function; |
Unit test
1 | package org.paradise.function; |
Remote debugging Java applications run on Tomcat
Enable JVM option to attach a remote debugger:
1 | $ export JAVA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 |
“suspend” set to “y” is to let remote debugger start loading the application.
Now, start running Tomcat. JVM debugging port is bound on port 5005i on the machine runs on Tomcat.
Next, set up SSH tunnel mirror remotei host (ip-10-213-79-77.ap-southeast-2.compute.internal) 5005 port to localhost on port 5005. For example:
1 | $ ssh -L 5005:ip-10-213-79-77.ap-southeast-2.compute.internal:5005 -l ec2-user ip-10-213-79-77.ap-southeast-2.compute.internal |
You can start remote debugging in IDE like IntelliJ and debug the code since.
Web Components are coming
AngularJS is going to continue to succeed for some time. But change is inevitable.
Web Components are coming.
WebComponents create the ability to do all the sorts of markup-driven programming like AngularJS, ReactJS, but less ecosystem dependent. Because DOM is integration point for all the kinds of JavaScript frameworks. Web Components make it MUCH easier to interoperate between components.
The future isn’t here yet, but it will change fundamental assumptions about how a JavaScript framework should act and what it should be responsible for. Those shifts in assumptions frequently cause frameworks will drop out of the ecosystem quickly than expected.
Perfection
Il semble que la perfection soit atteinte non quand il n’y a plus rien à ajouter, mais quand il n’y a plus rien à retrancher.
1 | - Antoine de saint Exupery |
It seems that perfection is attained not when there is nothing more to add, but when there is nothing more to remove.