Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am acgourley on github.
  • I am acgourley (https://keybase.io/acgourley) on keybase.
  • I have a public key ASBp8VNw2WUPCS8hP-n6Nzogdbfk7eBM6uD1KQBlrxD7ZAo

To claim this, I am signing this object:

@acgourley
acgourley / animate.sh
Created September 22, 2016 19:08
This script will use the https://github.com/fogleman/primitive library to create an abstract one second animation of the input image.
#!/bin/sh
palette="/tmp/palette.png"
fps=8
filters="fps="$fps",scale=600:-2:flags=lanczos"
for i in `seq 1 $fps`;
do
echo starting image $i
sem --id prim$1 -j+0 ~/go/bin/primitive -i $1 -o $1.0$i.png -n $2 -m $3
@acgourley
acgourley / gist:9a11ffedd44c414fb4b8
Last active January 21, 2022 06:37
Knex / MySQL Timeout Issue Postmortem

For several weeks our production deployment (Express, Bookshelf/Knex -> MySQL) was randomly having queries fail resulting in 500 errors and server crashes.

The first issue is that the Knex library was using Pool2 slightly incorrectly, and when a ETIMEDOUT error occurred, it tried to release the pooled connection twice. This would create an exception which would crash express (unless you have a top level error handler defined in your express setup)

In this issue (myndzi/pool2#12 (comment)) filed on pool2 by the author of knex (tgriesser) the author of pool2 (myndzi) points out the error handling issue and created a fork of knex with the fix git+https://github.com/myndzi/knex#double-release

After installing the fix on my server, whenever ETIMEDOUT occured an error would be generated in the expected part of the code so that I could decide to retry the query or fail gracefully. Removing the ETIMEDOUT entirely would be

@acgourley
acgourley / FBO Copy Method
Created December 4, 2013 07:27
A gist to show off my problematic FBO copy code. The copy method creates a dynamic texture and then tries to copy it to the destination texture. The result is always that the destination becomes entirely filled with whatever pixel is at texture coordinate (0, 0) on the input texture. This code runs fine without GL errors of any kind on a Galaxy …
public void UpdateTexture(float value) {
checkGlError("pre-UpdateTexture");
// Save the current state
IntBuffer previousFBO = IntBuffer.allocate(1);
IntBuffer previousRenderBuffer = IntBuffer.allocate(1);
IntBuffer previous_program = IntBuffer.allocate(1);
GLES20.glGetIntegerv(GLES20.GL_FRAMEBUFFER_BINDING, previousFBO);
GLES20.glGetIntegerv(GLES20.GL_RENDERBUFFER_BINDING,
previousRenderBuffer);