Skip to content

Instantly share code, notes, and snippets.

View hyleung's full-sized avatar

Ho Yan Leung hyleung

View GitHub Profile
@hyleung
hyleung / v1.1.3 implementation
Created August 20, 2012 19:52
FS Tracker CPP configuration (Android)
//Unfortunately, the callbacks that are in 2.1 don't exist in v.1.1.3 so you'll need to update the CPP
//whenever the user lands on a "page"
SurveyUrlBuilder
.instance()
.addCustomCpp("pageName","some page name");
#!/bin/bash
entry=$1
if grep -Fxq "$entry" hosts
then
echo "Hosts file already contains $entry"
else
echo "$entry" >> hosts
fi
@hyleung
hyleung / pom.xml
Created June 11, 2013 18:32
Monitor pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.fsr.mobilemonitor</groupId>
<artifactId>MobileMonitor.App</artifactId>
<version>1.0.3-SNAPSHOT</version>
<packaging>apk</packaging>
<name>FSR Mobile Monitor Android app</name>
@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"
}
}
}
@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 / 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 "$@"
### 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 / 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"))
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 / 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" />