Skip to content

Instantly share code, notes, and snippets.

@johnnywey
johnnywey / History|-237ce9c|entries.json
Last active August 14, 2022 15:08
vs-code-settings
{"version":1,"resource":"vscode-remote://dev.johnnywey.com/Users/johnnywey/code/go/learning_go/grpc-go/internal/grpctest/example_test.go","entries":[{"id":"feZZ.go","timestamp":1656645683309},{"id":"rkLT.go","timestamp":1656646334568}]}
@johnnywey
johnnywey / keybase.md
Created September 23, 2014 14:44
keybase.md

Keybase proof

I hereby claim:

  • I am johnnywey on github.
  • I am johnnywey (https://keybase.io/johnnywey) on keybase.
  • I have a public key whose fingerprint is F1F1 66AF 72B7 35A9 9357 9D32 61EA A6B0 ECD0 4B0E

To claim this, I am signing this object:

@johnnywey
johnnywey / AddBackgroundToPdf
Created April 15, 2014 19:29
Add A White Background to a PDF File Using Groovy and iText
import com.itextpdf.text.*
import com.itextpdf.text.pdf.*
@Grab(group='com.itextpdf', module='itextpdf', version='5.5.0')
@Grab(group='org.bouncycastle', module='bcpkix-jdk15on', version='1.49')
class AddBackgroundColorToPdf {
static def createPdfFromImageFile(String fileName) {
def input = new FileInputStream(fileName)
@johnnywey
johnnywey / gist:3279736
Created August 6, 2012 23:56
Groovy JsonOutput failing example
// Groovy's JsonOutput is using a static SimpleDateFormat. This is not threadsafe.
import java.text.SimpleDateFormat
import java.util.concurrent.LinkedBlockingQueue
import java.util.concurrent.ThreadPoolExecutor
import java.util.concurrent.TimeUnit
ThreadPoolExecutor executor = new ThreadPoolExecutor(4, 4, 500, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(1000))
1000.times {executor.execute(new KillJsonOutput())}
while (true) {
@johnnywey
johnnywey / buster-server.sh
Created July 5, 2012 21:53 — forked from cjohansen/buster-server.sh
Run the Buster.JS server with a Phantom.JS client
#!/bin/bash
# Based on work by Tiago Rodrigues
# Here: http://trodrigues.net/presentations/buster-ci/#/24
# And here: https://gist.github.com/2630210
# Usage:
# env BUSTER_HOME=/where/you/installed/buster ./buster-server.sh start|stop
function buster_server_pid(){
echo `ps aux|grep buster-server|grep node|awk '{ print $2 }'`
@johnnywey
johnnywey / gist:2578109
Created May 2, 2012 16:46
Make HTTPBuilder Follow 302 Redirects Initiated by an HTTP POST
/*
* HTTPBuilder uses HttpClient and does not automatically follow HTTP 302 responses from a POST as per the HTTP spec. You can modify this
* behavior by overriding updating the default behavior to follow regardless of initiating method.
*/
def http = new HTTPBuilder("http://UrlThatExpectsAPostAndReturnsA302.com")
http.client.setRedirectStrategy(new DefaultRedirectStrategy() {
@Override
boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context) {
def redirected = super.isRedirected(request, response, context)