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 / sql_example.sql
Created January 17, 2019 01:45
[SQL example] #SQL
CREATE TABLE product (
id UUID PRIMARY KEY,
name VARCHAR(64) NOT NULL,
-- max 999999.9999
price_amount NUMERIC(10, 4) NOT NULL CHECK (price_amount >= 0),
price_currency VARCHAR(10) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE NULL
);
@vicly
vicly / kubernetes_notes.md
Last active January 23, 2019 18:18
[Kubernetes tutorial notes] #K8S

https://kubernetes.io/docs/tutorials

K8S master node(single in the cluster) has three processes kube-apiserver, kube-controller-manager and kube-scheduler.

K8S non-master nodes have two processes kubelet(talks to master), kube-proxy(access cluster)

Basic Objects

@vicly
vicly / postgres_skip_locked.md
Created March 10, 2019 22:10
[Postgres SKIP LOCKED] #SQL #Postgres

DB Client 1

-- row 2 is locked
SELECT * FROM t_demo WHERE id=2 FOR UPDATE;

DB Client 2: BAD performace

@vicly
vicly / mockito_final_class.md
Created March 17, 2019 23:09
[Mockito mock final class/method] #Test

Use Mockito V2, V1 does not support mocking final/static.

<dependency>
  <groupId>org.mockito</groupId>
  <artifactId>mockito-core</artifactId>
  <version>2.25.1</version>
</dependency>
@vicly
vicly / put_patch.md
Created March 20, 2019 20:32
[PUT vs PATCH] #REST

Key:

  • Don't use PATCH OR use it the right way
  • PATCH is not to replace POST or PUT
  • PATCH applies a delta rather than replacing the entire resource
  • PATCH is of a different content-type
  • PUT's payload is considered to be a modified version of the resource stored on the origin server, so the client is to replace it
  • PATCH's payload contains a set of instructions about how to modify the resource on the origin server, so to produce a new version
  • You can use whatever format you want as “description of changes”
@vicly
vicly / network_basic.md
Created April 9, 2019 04:06
[Network basic] #Network #Handy

IP

  • 公网IP唯一
  • 内网IP不唯一,如公司A有192.168.0.1,公司B也有192.168.0.1

NAT

Network Address Translation

本地IP转为公网IP,便于内网机器使用有限公网IP访问互联网

@vicly
vicly / rdb_isolation_levels.md
Last active April 11, 2019 05:58
[Isolation Levels] #SQL #Handy

The phenomena which are prohibited at various levels are:

dirty read

A transaction reads data written by a concurrent uncommitted transaction.

nonrepeatable read

A transaction re-reads data it has previously read and finds that data has been modified by another transaction (that committed since the initial read).

phantom read

@vicly
vicly / soap_bind_endpoint.md
Last active December 16, 2019 21:49
[SOAP manually bind endpoint] #Java #Soap
BindingProvider bindingProvider = (BindingProvider) port;
    bindingProvider.getRequestContext().put(
          BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
          "https://blah/blah/blah");