Skip to content

Instantly share code, notes, and snippets.

View yeoupooh's full-sized avatar

Thomas Jinwoo Min yeoupooh

View GitHub Profile
@yeoupooh
yeoupooh / ExampleStaticHandler.java
Last active August 28, 2018 06:26
Avoiding "This Handler class should be static or leaks might occur".
// This is OLD way of usnig Handler which shows an warning.
private Handler oldHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
// Handle a message as you want.
}
}
@yeoupooh
yeoupooh / CurrentWorkingDirectory.java
Created May 6, 2013 08:57
Getting currently working directory.
String currentDir = MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath());
String currentDir = new java.io.File( "." ).getCanonicalPath();
String currentDir = System.getProperty("user.dir");
@yeoupooh
yeoupooh / InputStreamToString.java
Created July 19, 2013 00:23
Convert InputStream to String.
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class InputStreamToString {
private static final String DEFAULT_CHARSET = "utf-8";
private static final int BUFFER_LEN = 1024 * 8;
@yeoupooh
yeoupooh / NetUtils.java
Last active December 19, 2015 23:19
Get external IP address.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
public class NetUtils {
public static String getExternalIpAddress() throws IOException {
URL whatismyip = new URL("http://checkip.amazonaws.com/");
BufferedReader in = new BufferedReader(new InputStreamReader(
@yeoupooh
yeoupooh / QRImage.java
Created July 19, 2013 01:00
Get QR code from Google chart.
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLEncoder;
public class QRImage {
public static InputStream getInputStream(String host, int port)
throws IOException {

Mac OSX Tips

Run Chrome Browser with TLS1

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --ssl-version-max=tls1

Tools