Skip to content

Instantly share code, notes, and snippets.

View hrchu's full-sized avatar
:octocat:
Have an Octotastic day!

petertc hrchu

:octocat:
Have an Octotastic day!
View GitHub Profile
@hrchu
hrchu / log event example
Last active July 19, 2018 08:55
logstash grok filter pattern to extract (root) "Caused by:" from java stack trace
com.xx.Exception: java.io.FileNotFoundException
at org.apache.cxf.jaxrs.JAXRSInvoker.handleFault(JAXRSInvoker.java:324)
...
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:200)
... 46 more
Caused by: com.xx.WrongSizeException: blahblah
... 64 more
@hrchu
hrchu / 99-network-tuning.conf
Last active December 11, 2023 23:05 — forked from kgriffs/sysctl.conf
Linux Web Server Kernel Tuning
# Configuration file for runtime kernel parameters.
# See sysctl.conf(5) for more information.
# See also http://www.nateware.com/linux-network-tuning-for-2013.html for
# an explanation about some of these parameters, and instructions for
# a few other tweaks outside this file.
# See evil packets in your logs.
net.ipv4.conf.all.log_martians = 1
@hrchu
hrchu / mogstat.py
Created March 14, 2016 08:14
The mogstat collector of python-diamond collects utilization info from the mogilefs storage system.
import diamond.collector
import telnetlib
import time
class MogstatsCollector(diamond.collector.Collector):
def get_default_config_help(self):
config_help = super(MogstatsCollector, self).get_default_config_help()
config_help.update({
})
@hrchu
hrchu / V2sign.java
Created May 10, 2016 02:44
aws java sdk force v2 signing for s3 compatible storage
public static void main(String[] args) {
ClientConfiguration clientConf = new ClientConfiguration();
clientConf.withSignerOverride("S3SignerType");
AWSCredentials myCredentials = new BasicAWSCredentials("XX", "DD");
client = new AmazonS3Client(myCredentials, clientConf);
client.setEndpoint("http://s3.com");
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentType("application/octet-stream");
@hrchu
hrchu / pom.xml
Created July 28, 2016 09:07
Maven build config to generate single executable jar
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
// import org.apache.commons.io.output.CountingOutputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Arrays;
import java.util.UUID;
@hrchu
hrchu / checkedFunctionWrapper.java
Last active October 11, 2016 06:15
Wrap lambda which throws checked exception
private <T, R> Function<T, R> wrapFunction(ThrowableFunction<T, R, Throwable> function) {
try {
return function.apply(arg);
} catch (Throwable e) {
throw new RuntimeException(e);
}
};
}
@FunctionalInterface
@hrchu
hrchu / subuser (swift)
Last active December 30, 2016 02:48
coidc rgw install log
{
"user_id": "testuser",
"display_name": "First User",
"email": "",
"suspended": 0,
"max_buckets": 1000,
"auid": 0,
"subusers": [
{
"id": "testuser:swift",
@hrchu
hrchu / nginxSsl.md
Created May 2, 2017 11:02
SSL offload with Nginx and ubuntu 16.04 for radosgw
  • $ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt
  • $ apt install nginx
  • $ vim /etc/nginx/sites-available/default
upstream backends {
    server 10.144.225.175:8080;
}

server {
 listen 443 ssl;
@hrchu
hrchu / ckshBBS.sh
Created May 23, 2017 06:30
Emulate cksh.twbbs.org
#!/bin/bash
echo -e "\033[H\033[mbbs.cksh.tp.edu.tw ⊙ 濟城歲月 ⊙ 203.64.138.4 [CKSHBBS Ver.1225]"
echo -e "\033[65D歡迎光臨【\033[1;33;46m 濟城歲月 \033[m】。系統負載:0.00 0.01 0.00 [負載正常]"
echo -e "\033[60D"
echo -e "\033[8D\033[1;34m └──┘ ─ │ ├── ┌──────┐\033[m"
echo -e "\033[77D\033[1;34m └─┘└─┬─┬─┘ ┌──┼─┐ ─┴─┴─── │ │\033[m"
echo -e "\033[77D\033[1;36m └┐└┬┘┌┘ │ │ │ ┌───┼─┼┐ │ │\033[m"
echo -e "\033[79D\033[1m └─┘┌┴┐│┌┴┐ └┼┘├─┐└┐ │└┬┘│ ├──────┤\033[m"
echo -e "\033[85D\033[1m │ │││ │ │ │ │ │┐ │┌│┌└─┐ │ │\033[m"
echo -e "\033[86D\033[1;36m ├────┤ │ │ │┌┼┘ ││││ │┐ ├──────┤\033[m"