Skip to content

Instantly share code, notes, and snippets.

View simonwoo's full-sized avatar
💭
I may be slow to respond.

Chong WU simonwoo

💭
I may be slow to respond.
View GitHub Profile

Steps:

  • design API(RAML or Swagger)
  • using ApiSpark platform to generate Java code and angularJs code
  • add your logic
<!DOCTYPE html>
<html ng-app="myapp">
<head>
<title>AngularJS: UI-Router Quick Start</title>
<!-- Bootstrap CSS -->
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="container">
@simonwoo
simonwoo / cassandra keys.md
Last active February 13, 2024 16:59
describe the differences between partition key, composite key and clustering key

1.The primary key is a general concept to indicate one or more columns used to retrieve data from a Table.

  • the primary key may be SIMPLE
create table stackoverflow (
      key text PRIMARY KEY,
      data text      
  );
@simonwoo
simonwoo / mvn.md
Last active December 26, 2015 19:57
generate a project in maven

generate a project

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

@simonwoo
simonwoo / Patch and Put.md
Last active January 4, 2016 14:09
the difference between method patch and put

The HTTP methods PATCH can be used to update partial resources. For instance, when you only need to update one field of the resource, PUTting a complete resource representation might be cumbersome and utilizes more bandwidth

PATCH /user/jthijssen HTTP/1.1
<user>
    <firstname>Joshua</firstname>
</user>

Also, the PUT method is idempotent. PUTting the same data multiple times to the same resource, should not result in different resources, while POSTing to the same resource can result in the creation of multiple resources.

背景

------------------------
|       computer       |
| -------------------- |
| |     soundcard    | |
| | ---------------- | |
| | |     USB      | | |
| | | ------------ | | |
| | | | version  | | | |

介绍

Hamcrest是一个开源的库,07年被引入到Junit4。assertThat()是其中最常用的一个方法,位于org.junit.Assert包中, 方法签名如下:static <T> void assertThat(T actual, org.hamcrest.Matcher<T> matcher)

使用方法

package com.edgibbs.junit.example;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.StringDescription;
private static byte[] loadImage() {
        URL url = Thread.currentThread().getContextClassLoader().getResource("photo.png");

        try {
            return Files.readAllBytes(Paths.get(url.toURI()));
        } catch (Exception e) {
            throw new RuntimeException("Can not load the image");
        }
 }

Java NIO2

目标

  • 能批量获取文件属性的文件系统接口,去掉和特定文件系统相关的API。
  • 提供一个套接字和文件都能进行异步I/O操作的API。
  • 通道功能。

Path

path代表文件系统的位置。JVM会把Path绑定到运行的物理位置上。 NIO2把位置的概念和物理文件系统的处理分的很开。物理文件系统的处理通常是由Files辅助类完成的。

the principle of a program reading data from a source and writing it to some destination: Source -> Program -> Destination

The most typical sources and destinations of data are these:

  • Files
  • Pipes
  • Network Connections
  • In-memory Buffers (e.g. arrays)
  • System.in, System.out, System.error