Skip to content

Instantly share code, notes, and snippets.

View lingz's full-sized avatar

Ling Zhang lingz

  • London
View GitHub Profile

Keybase proof

I hereby claim:

  • I am lingz on github.
  • I am lingz (https://keybase.io/lingz) on keybase.
  • I have a public key whose fingerprint is 3251 207D 8C86 37FA FE2B 1417 839B 60DA D77F 4BD7

To claim this, I am signing this object:

@lingz
lingz / HostAvailable.java
Last active February 26, 2016 10:11
Java + Android - Check if host is available
public boolean hostAvailable(String host, int port) {
try (Socket socket = new Socket()) {
socket.connect(new InetSocketAddress(host, port), 2000);
return true;
} catch (IOException e) {
// Either we have a timeout or unreachable host or failed DNS lookup
System.out.println(e);
return false;
}
}
@lingz
lingz / webpack.config.js
Created January 30, 2016 16:01
Excluding node_modules from webpack build
var Fs = require('fs')
var nodeModules = {}
Fs.readdirSync('node_modules').forEach(function (module) {
if (module !== '.bin') {
nodeModules[module] = true
}
})
var nodeModulesTransform = function(context, request, callback) {
// search for a '/' indicating a nested module
var slashIndex = request.indexOf("/");