Skip to content

Instantly share code, notes, and snippets.

View brettwooldridge's full-sized avatar

Brett Wooldridge brettwooldridge

  • LogicVein, Inc
  • Tokyo, Japan
View GitHub Profile
private String sql = "SELECT ZDeviceLite.device_id," +
" ZDeviceLite.ip_address," +
" ZDeviceLite.ip_high," +
" ZDeviceLite.ip_low," +
" ZDeviceLite.hostname," +
" ZDeviceLite.network," +
" ZDeviceLite.adapter_id," +
" ZDeviceLite.device_type," +
" ZDeviceLite.vendor_hw," +
" ZDeviceLite.model," +
var page = require('webpage').create();
page.open('http://store.apple.com/jp/browse/home/specialdeals/mac/imac/27', function(status) {
page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function(status) {
page.onConsoleMessage = function (msg) { console.log(msg); };
page.evaluate(function() {
$( "td.specs" ).each( function(index) {
var pattern = /(i5|i7)[\s\S]*(8GB|16GB|32GB)[\s\S]*(Fusion)/mi;
var m = $(this).text().match(pattern);
if (m != null && m.length > 0) {
var path = require('path')
var childProcess = require('child_process')
var phantomjs = require('phantomjs')
var nodemailer = require("nodemailer");
// create reusable transport method (opens pool of SMTP connections)
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "br****@gmail.com",
@brettwooldridge
brettwooldridge / gist:2572573e1c6955bd7b31
Created June 12, 2014 01:07
Japan/US collation comparison test over the ASCII space
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import org.junit.Assert;
import org.junit.Test;
import static java.lang.System.currentTimeMillis;
import java.sql.Connection;
public class HikariTest
{
private static String db1 = "test1";
private static String db2 = "test2";
private static int RUNS = 5000;
@brettwooldridge
brettwooldridge / gist:a451da5db02039b47de6
Created October 10, 2014 03:28
HikariCP test for issue #159
/*
* Copyright (C) 2013, 2014 Brett Wooldridge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@brettwooldridge
brettwooldridge / HikariJmxElf
Created December 5, 2014 01:35
HikariCP JMX Access
package com.zaxxer.hikari;
import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
public class HikariJmxElf
{
@brettwooldridge
brettwooldridge / gist:dfd21934416fc2a3c865
Created April 11, 2015 07:37
Intercepting DataSource
public abstract class InterceptorDataSource {
private final InvocationHandler handler;
protected InterceptorDataSource(final DataSource delegate) {
this.handler = new InvocationHandler() {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return (method.getName().equals("getConnection")) ? getConnection(delegate) : method.invoke(delegate, args);
}
};
}
@brettwooldridge
brettwooldridge / MyHikariDataSource.java
Created August 21, 2015 14:38
DataSource/abandoned connection killer
public class MyHikariDataSource extends HikariDataSource{
private final Timer killer = new Timer();
public Connection getConnection() throws SQLException {
final Connection c = super.getConnection();
return (Connection) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { Connection.class }, new MyHandler(c)));
}
private class MyHandler implements InvocationHandler {
private Connection conn;
public class InterceptorDataSource implements InvocationHandler {
private final DataSource delegate;
private InterceptorDataSource(final DataSource delegate) {
this.delegate = delegate;
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return (method.getName().equals("getConnection")) ? getConnection() : method.invoke(delegate, args);
}