Skip to content

Instantly share code, notes, and snippets.

@jcfrank
jcfrank / angularjs-sample.md
Last active August 29, 2015 14:13
a basic angular rest client app.

Simple Angularjs app

This is a basic rest client app, very useful for creating demo page.

Backend

First, set up node.js as interface backend.
Dependencies:

  "dependencies": {
@jcfrank
jcfrank / hk2-sample.md
Last active August 29, 2015 14:13
HK2 is a dependency injection framework used in Jersey 2. This pice of code demonstrate how to add custom bindings.

HK2

Jersey 2 uses HK2 as dependency injection framework.
Although there are modules for integrating with Guice or Spring.
We can still just use HK2 to avoid using two frameworks for the same purposes.
Following snippets are two very basic sample for using HK2.

Sample

@jcfrank
jcfrank / decorator.md
Last active August 29, 2015 14:03
Python decorator pattern

Desc

Unlike java, python uses nested functions to implement decorators.

This could be tricky when we first try to understand.

A few features of python are applied:

  1. python functions are objects.
@jcfrank
jcfrank / visitor.md
Last active August 29, 2015 14:03
Visitor pattern -- my understanding

Roles

  • Visitor interface

    Defines visit methods for all types that could be visited.

  • Visitor implementations

    Defines visit behavior for different types.