Skip to content

Instantly share code, notes, and snippets.

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

downgoon downgoon

💭
I may be slow to respond.
View GitHub Profile
@downgoon
downgoon / JdbcTypeMapping.java
Last active April 19, 2017 07:34
jdbc sql column type mapping to java class
/**
* Translates a data type from an integer (java.sql.Types value) to a string
* that represents the corresponding class.
*
* REFER: https://www.cis.upenn.edu/~bcpierce/courses/629/jdkdocs/guide/jdbc/getstart/mapping.doc.html
*
* @param type
* The java.sql.Types value to convert to its corresponding class.
* @return The class that corresponds to the given java.sql.Types
* value, or Object.class if the type has no known mapping.
@downgoon
downgoon / JdbcTypeMapping.md
Created April 19, 2017 07:12
how to convert java.sql.Types into Java type

how to convert java.sql.Types into Java type

/**
     * Translates a data type from an integer (java.sql.Types value) to a string
     * that represents the corresponding class.
     * 
     * REFER: https://www.cis.upenn.edu/~bcpierce/courses/629/jdkdocs/guide/jdbc/getstart/mapping.doc.html
     * 
@downgoon
downgoon / HelloWorldGist.md
Last active April 19, 2017 08:43
how to use gist

基础

  • 匿名发布:发布gist,并不需要登陆。
  • 不限代码:可以发 xxx.c或xxx.java 等,但也可以发 xxx.md,实现富文本。
  • 版本管理:源代码管理出色的地方之一就是版本管理,用gist也有版本管理。
  • 任务列表:借助 xxx.md 的github拓展语法,可以做任务列表GTD工具。

程序员界的“轻博客”

@downgoon
downgoon / GithubBadge.md
Last active April 19, 2017 11:44
add Badges on your github project

Github 常见徽章

聊天群 Gitter:项目关联聊天群

你在 github 上发布了一个项目,如果网友有疑问,通常的做法是提一个 Issue,然后等我们有空时才能看见。 能不能弄一个 IM ,立马把Issue推送给作者呢?Gitter 就是这样的一个应用,使用步骤概述:

  • 有Github项目
@downgoon
downgoon / restapi.md
Last active April 20, 2017 01:43
deep thinking in RESTful API

对 API 的认识,要提升到“划时代”的高度。

  • API: 页面彻底分离。
  • 文档: 文档被提升到新的高度,否则API没有使用价值。如何提高API开发者和使用者之间的沟通效率。
  • 互联: OAuth2.0 不同所有权的站点开始互联。
  • 分层: API Gateway 可以完成很多API共同的东西,让API的开发者只专注业务。比如授权呀,监控呀。
  • 自动化: API 生成自动化。只要写数据库脚本,然后API就自动生成了,而且是运行时。

@downgoon
downgoon / trend-tips.md
Last active April 21, 2017 03:21
trend tips

编码风格流行趋势

取消 new

早前创建一个对象: Object obj = new Object();

如今: Vertx vertx = Vertx.vertx();, 再如 Router.router()Future.future()

原因: new Object() 硬编码了,Factory 模式就是解决这个硬编码产生的。但是Factory看着有点增加开发者负担。

@downgoon
downgoon / RestCrudHttpd.java
Created April 21, 2017 06:03
Simple RESTful API using vertx-web
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServer;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.Router;
public class RestCrudHttpd {
@downgoon
downgoon / DbapiAction.java
Created April 21, 2017 06:46
refactor RESTful API in vertx-web
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.RoutingContext;
public class DbapiAction implements Restlet {
@Override
public void index(RoutingContext routingContext) {
String dbname = routingContext.request().getParam("dbname");
JsonObject json = new JsonObject().put("action", "index").put("dbname", dbname);
@downgoon
downgoon / VertxConfusion.md
Last active June 16, 2017 09:48
vertx confusion

困惑列表

  • JSON
  • Router
  • 函数指针
  • 对象工厂
  • Router : Route = 1 : * , Route : Handler 是 1:1
@downgoon
downgoon / StringObject.java
Last active April 24, 2017 02:34
Java字符串文本反序列化成Java对象
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Java字符串文本反序列化成Java对象: Object有toString()方法,String得有个toObject方法。
* */
public class TypeDecoder {
/**
* convert filed value of pojo from String format to Object format