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 / jersey_custom_object_injection.md
Last active March 18, 2022 12:17
[Jersey custom object injection using `@Context MyObj`] #Java #REST

Custom Factory

import org.glassfish.hk2.api.Factory;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.process.internal.RequestScoped;

import javax.inject.Inject;
import javax.ws.rs.container.ContainerRequestContext;
@vicly
vicly / a.file
Last active April 30, 2020 00:06
[Lepton Tags] Maintain Lepton Tags #AWS #Java #Gradle #Maven #Spring #SQL #Guava #JPA #Json #Jackson #Soap #Hibernate #REST #Tomcat #Git #CSharp #JavaLib #Shell #Test #DevOps #Docker #OAuth #Note #Handy #Frontend #Angular
Maintain the tags used in Lepton.
@vicly
vicly / aws_monitoring_metrics_logging.md
Last active September 15, 2017 02:50
[AWS Monitoring Metrics and Logging] #AWS

Check out the CloudWatch Metrics and Dimensions

Custom Metrics

By default Amazon Linux get CLI installed

# Send custom metrics to CloudWatch (without dimensions)
aws cloudwatch put-metric-data --metric-nname MyFreeMemGB --namespace MyLinux --value 5 --region eu-west-1
@vicly
vicly / simulate_cpu_work.md
Last active September 15, 2017 02:52
[Simulate CPU work using Stress] #Shell
sudo apt-get install stress

# run 8 processes, to get CPU load high
sudo stress --cpu 8
@vicly
vicly / gradle_install_to_local_maven_repo.md
Last active September 15, 2017 03:24
[Gradle intall to local maven repo] install jar to local maven cache #Gradle

In api/build.gradle

apply plugin: "maven"

group = "foo"
version = "1.0"
@vicly
vicly / AwsS3UserFolderPolicy.json
Last active June 19, 2019 09:48
[S3 - Grant access to user specific folder] #AWS
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowUserToSeeBucketListInTheConsole",
"Action": [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"Effect": "Allow",
@vicly
vicly / QueryParamOrMetrixParam.md
Created September 22, 2017 04:56
[Query or Metrix in URL] #REST
  • URL with ? are not cached in many cases
  • URL with matrix params are cached
  • Metrix param can appear everywhere in the path and are not limited to its end
  • Metrix param can have more than one value, e.g. paramA=val1,val2
  • Metrix param is used when it's hard to structure a hierarchy in URL

Example

@vicly
vicly / jersey_PATCH.md
Last active September 27, 2017 07:59
[Jersey note] #REST #Jersey

PATH: partical update

Create Annotation

@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@HttpMethod("PATCH")
@vicly
vicly / url_encoding.md
Created September 24, 2017 10:18
[URL fundamental] #Note #Fundamental
@vicly
vicly / time.md
Last active February 19, 2020 04:38
[Time] #Note #Fundamental #Time

TAI - International Atomic Time (Temps Atomique International = TAI)

部署在50多个国家的200多个原子时钟的平均值 TAI-UT1大约是1958年1月1日

UT - Universal Time 世界时

Defined by the Earth's rotation (GPS satellites used) UT0完全按照天体运行计算出来的时间 UT1在UT0上做了调整