Skip to content

Instantly share code, notes, and snippets.

@georgecao
georgecao / LocalStorage.java
Created March 14, 2020 02:46 — forked from roydekleijn/LocalStorage.java
Selenium WebDriver Javascript execution for localStorage
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
public class LocalStorage {
private JavascriptExecutor js;
public LocalStorage(WebDriver webDriver) {
this.js = (JavascriptExecutor) webDriver;
}
@georgecao
georgecao / test_ffi.lua
Created April 5, 2017 10:44
FFI and ngx.shared.DICT
local ffi = require 'ffi'
local C = ffi.C
local ffi_cast = ffi.cast
local ffi_str = ffi.string
local M = {}
ffi.cdef [[
size_t strlen(const char *str);
@georgecao
georgecao / ResolvedSocketAddress.java
Last active December 14, 2015 21:49
Creates a resolved {@link InetSocketAddress} when your hostname is actually an IP address.
/**
* Convert an IP in text format to its binary format.
*
* @param textIP literal IP
* @return byte array or null if failed.
*/
private byte[] getAddress(String textIP) {
if (IPAddressUtil.isIPv4LiteralAddress(textIP)) {
return IPAddressUtil.textToNumericFormatV4(textIP);
} else if (IPAddressUtil.isIPv6LiteralAddress(textIP)) {
@georgecao
georgecao / gist:4102883
Created November 18, 2012 02:11
Monitor the Http Transport on Linux Box.
sudo ngrep -d eth0 -q -W byline port 8080
@georgecao
georgecao / gist:4070786
Created November 14, 2012 07:19
Calculate AVG. using AWK
awk 'BEGIN{t=0}{t += $1}END{print "Sum: " t, "Lines:" NR,"Avg:" t/(NR)}'
@georgecao
georgecao / print_options.sh
Created March 20, 2012 16:09
Print all Oracle JVM options
#!/bin/sh
java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version