Skip to content

Instantly share code, notes, and snippets.

View hoangong's full-sized avatar
🏠
Working from home

Hoang Ong hoangong

🏠
Working from home
View GitHub Profile
# Change annotation location to Download folder
defaults write com.apple.screencapture location ~/Downloads/
killall SystemUIServer
# Disable blocking unidentified developer
sudo spctl --master-disable
[
{ "keys": ["shift+enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line.sublime-macro"} },
{ "keys": ["super+y"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["ctrl+shift+w"], "command": "toggle_setting", "args": {"setting": "word_wrap"}},
{ "keys": ["super+d"], "command": "duplicate_line" },
{ "keys": ["super+e"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} }
]
@hoangong
hoangong / Akka Http 2.4 custom unmarshalling
Last active January 6, 2019 00:35
akka http custom serialisation #akka #scala
import akka.http.scaladsl.model.HttpRequest
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.unmarshalling.FromRequestUnmarshaller
import akka.stream.Materializer
import com.fasterxml.jackson.databind.ObjectMapper
import com.voi.dto.response.HealthCheck
import com.voi.micro.services.ImplicitPojoMarshaller
import scala.concurrent.duration._
import scala.concurrent.{ExecutionContext, Future}
@hoangong
hoangong / HealthCheckEndpoint.scala
Last active December 31, 2018 11:09
Generic pojo marshaller for akka http 2.4 #pojo #marsheller #akka-http
import akka.http.scaladsl.marshalling.{Marshaller, ToEntityMarshaller}
import akka.http.scaladsl.model.{ContentTypes, HttpEntity}
import akka.http.scaladsl.server.Directives._
import com.fasterxml.jackson.databind.ObjectMapper
import com.voi.dto.response.HealthCheck
trait HealthCheckEndpoint {
val mapper = new ObjectMapper()
@hoangong
hoangong / git tool setup
Last active January 7, 2019 01:16
git tool setup #git
git config --global merge.tool kdiff3
git config --global mergetool.kdiff3.path /Applications/kdiff3.app/Contents/MacOS/kdiff3
git config --global core.editor "atom --wait"
or
git config --global core.editor nano
git config --global push.default simple
@hoangong
hoangong / idea
Created April 18, 2016 23:29 — forked from chrisdarroch/idea
Open a project in IntelliJ IDEA from your command line!
#!/bin/sh
# check for where the latest version of IDEA is installed
IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1`
wd=`pwd`
# were we given a directory?
if [ -d "$1" ]; then
# echo "checking for things in the working dir given"
wd=`ls -1d "$1" | head -n1`
@hoangong
hoangong / JsonEPSerializer.scala
Last active December 31, 2018 11:10
Play2 Json object serialization #play #scala #serialisation
val accessTokenReads = (
(__ \ "token").read[String] and
(__ \ "createdDate").read[LocalDateTime] and
(__ \ "expiredDate").read[LocalDateTime] and
(__ \ "expired").read[Boolean]
) (AccessToken.apply _)
val accessTokenWrites = (
(__ \ "token").write[String] and
(__ \ "createdDate").write[LocalDateTime] and
@hoangong
hoangong / JsonEPSerializerCommon.scala
Created February 16, 2016 06:05
Play2 Json custom datatype serialization
val uuidReads = Reads[UUID](i => i match {
case s: JsString => {
JsSuccess(UUID.fromString(s.value))
}
case _ => {
JsError("error")
}
})
val uuidWrites = Writes[UUID](i => JsString(i.toString))
implicit val uuidFormat: Format[UUID] = Format(uuidReads, uuidWrites)
@hoangong
hoangong / LongestPalindrome.java
Last active January 10, 2016 03:19
Find the longest palindrome
package com.ho.lp;
import java.util.Scanner;
/**
* Created by hoangong on 24/12/2015.
*/
public class Main {
private String input;
@hoangong
hoangong / LinkedList.java
Last active January 7, 2019 01:33
Linked List implementation #linkedlist #java
/**
* Created by hoangong on 23/12/2015.
*/
public class LinkedList {
private Node head;
private Node tail;
private int count;
public Node getHead() {