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 / index.md
Last active May 21, 2019 21:43
[索引] #SQL

聚集索引 : clustered index

  • 把这种正文内容本身就是一种按照一定规则排列的目录称为“聚集索引”。如:汉语字典本身按照a-z排序,认识拼音的字,可以直接翻到字典到特定区间查,所有读音类似的字都在一起,如 ”术“,”书“
  • 每个table只能有一个聚集索引
  • 最大好处就是能够根据查询要求,迅速缩小查询范围,避免全表扫描

非聚集索引 : nonclustered index

  • 把这种目录纯粹是目录,正文纯粹是正文的排序方式称为“非聚集索引”。如:不认识的字,必须先按偏旁查找目录,然后再翻到指定页数;注意,偏旁一样的字分散在不同的地方,如 "认",“读”

误区:

@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");
@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 / 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 / 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 / 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 / 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 / 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 / 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
);