Skip to content

Instantly share code, notes, and snippets.

@franzwong
franzwong / Sample.elm
Created July 8, 2018 05:34
Send HTTP request with Elm
module Sample exposing (..)
import Html exposing (Html, input, button, div, text, program)
import Html.Events exposing (onInput, onClick)
import Http exposing (post, jsonBody)
import Json.Encode as Encode exposing (..)
import Json.Decode as Decode exposing (Decoder, int, string)
import Json.Decode.Pipeline exposing (decode, required)
import Debug exposing (log)
sudo openssl req -x509 -nodes \
-days 365 \
-newkey rsa:2048 \
-keyout /etc/ssl/mydomain_com.key \
-out /etc/ssl/mydomain_com.crt \
-subj '/CN=mydomain.com'
@franzwong
franzwong / main.md
Last active July 1, 2018 04:40
Interesting question
  • Joe Celko's SQL for Smarties, 5th Edition

    Chapter 32.1 - Finding Subregions of Size (n)

  • Finding the maximum contiguous sum in an array

alias j10="export JAVA_HOME=`/usr/libexec/java_home -v 10`; java -version"
alias j9="export JAVA_HOME=`/usr/libexec/java_home -v 9`; java -version"
alias j8="export JAVA_HOME=`/usr/libexec/java_home -v 1.8`; java -version"
alias j7="export JAVA_HOME=`/usr/libexec/java_home -v 1.7`; java -version"

Branches

Long life

  • master
  • dev

Short life

  • Release branch
@franzwong
franzwong / setup_local_dev_env_with_docker.md
Last active April 14, 2018 15:49
Setup local development environment with docker

Setup local development environment with docker

MySQL

Start MySQL docker

docker run --name local-mysql -d \
  -v <local data dir>:/var/lib/mysql \
 -e MYSQL_ROOT_PASSWORD= \
@franzwong
franzwong / coding_guideline.md
Last active April 11, 2018 00:52
Coding guideline

Coding guideline

Coding recommendation

  • Composition over inheritance
  • Extract code to separate method instead of putting code comment
  • Return early
  • Don't ignore exception
  • Avoid singleton pattern
@franzwong
franzwong / VertxApplication.kt
Created April 6, 2018 11:27
Simple Vert.x Webapp
import io.vertx.core.Vertx
import io.vertx.core.json.Json
import io.vertx.ext.web.Router
data class Person(
val name: String,
val nationality: String
) {
}
@franzwong
franzwong / BinaryTreeNode.java
Created December 3, 2017 09:36
BinaryTreeNode
public class BinaryTreeNode<T> {
private T value;
private BinaryTreeNode<T> leftChild;
private BinaryTreeNode<T> rightChild;
public T getValue() {
return value;
}
@franzwong
franzwong / app.go
Last active October 16, 2017 03:32
Quick sort implemented in Golang
package main
import (
"fmt"
"math/rand"
"time"
)
func Quicksort(elements []int, low int, high int) {
if (high > low) {