Skip to content

Instantly share code, notes, and snippets.

View hyleung's full-sized avatar

Ho Yan Leung hyleung

View GitHub Profile
@hyleung
hyleung / resume.json
Last active September 21, 2022 21:30
JSON Resume
{
"meta": {
"theme": "elegant"
},
"basics": {
"profiles": [
{
"url": "https://github.com/hyleung",
"username": "hyleung",
"network": "GitHub"
@hyleung
hyleung / api-format-examples.md
Last active September 13, 2019 17:24
API format examples

JSON-LD

    {
      "@context": "https://schema.org",
      "@type": "Person",
      "address": {
        "@type": "PostalAddress",
        "addressLocality": "Colorado Springs",
        "addressRegion": "CO",
        "postalCode": "80840",
@hyleung
hyleung / http-xml.clj
Last active May 5, 2018 03:54
clj-http coerce to xml/xml-zipper
(require '[clj-http.client :as http]
'[clj-http.util :as http.util]
'[clojure.data.xml :as xml]
'[clojure.zip :as zip]
'[clojure.data.zip.xml :as xml-zip])
(defmethod http/coerce-response-body :xml
[_ {:keys [body] :as resp}]
(assoc resp :body
@hyleung
hyleung / Ratpack.xml
Last active April 7, 2016 16:46
IntelliJ code formatting for RatPack work
<code_scheme name="Ratpack">
<option name="GENERATE_FINAL_PARAMETERS" value="true" />
<codeStyleSettings language="JAVA">
<option name="RIGHT_MARGIN" value="100" />
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
<option name="WRAP_FIRST_METHOD_IN_CALL_CHAIN" value="true" />
<option name="WRAP_LONG_LINES" value="true" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
quicksort :: Ord a => [a] -> [a]
quicksort [] = []
quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater)
where
lesser = filter (< p) xs
greater = filter (>= p) xs
@hyleung
hyleung / groupMaps.scala
Last active August 29, 2015 14:23
Map transformation - combine two maps
def groupMaps[A,B,C](m:(A,Map[B,C]))(n:(A,Map[B,C])):Map[B,Map[A,C]] = {
(m,n) match {
case ((a,mm),(b,nn)) if mm.nonEmpty && nn.nonEmpty =>
Map(mm.head._1 -> Map(a -> mm.head._2, b -> nn.head._2)) ++ groupMaps((a, mm.tail))((b, nn.tail))
case ((a,_),(b,_)) => Map.empty[B,Map[A,C]]
}
}
val hostA = ("hostA", Map("/oauth2/token" -> "1", "/carts/default" -> "2"))
val hostB = ("hostB", Map("/oauth2/token" -> "3", "/carts/default" -> "4"))
### Keybase proof
I hereby claim:
* I am hyleung on github.
* I am hyleung (https://keybase.io/hyleung) on keybase.
* I have a public key whose fingerprint is F5D2 A8A3 5DB4 6804 FD4A CEC2 D7F6 BE67 6D90 93EF
To claim this, I am signing this object:
@hyleung
hyleung / gist:e7d4740b3904b526e1ec
Created March 3, 2015 23:38
Clone and build with Maven
#!/bin/bash
echo "Cloning '$1' into 'workspace'..."
git clone "$1" workspace
shift
echo "Changing directory to 'workspace/$1'"
cd workspace/"$1"
shift
echo "Running 'mvn $@'"
mvn "$@"
@hyleung
hyleung / logstash.conf
Last active November 22, 2021 09:41
logstash for AEm
input {
file {
type => "syslog"
path => ["/var/logs/*"]
}
file {
type => "java"
path => ["/var/logs/java/*"]
codec => multiline {
pattern => "%{JAVA_MULTILINE_STACKTRACE}"
@hyleung
hyleung / logtash.conf
Last active August 29, 2015 14:13
Logstash conf for java stacktraces
input {
file {
type => "tomcat"
path => ["/var/logs/*"]
codec => multiline {
pattern => "(^.+Exception: .+)|(^\s+at .+)|(^\s+... \d+ more)|(^\s*Caused by:.+)|(^\s+...\s[\d]+[\s\w]+$)"
what => "previous"
}
}
}