Skip to content

Instantly share code, notes, and snippets.

@willglynn
willglynn / Gemfile
Created April 23, 2014 16:48
Using a vendored zbar binary in Rails
source 'https://rubygems.org'
# ...
# zbar needs an environment variable, so don't require it automatically
gem 'zbar', require: false
--- a/zbar/jpeg.c
+++ b/zbar/jpeg.c
@@ -79,8 +79,15 @@
void skip_input_data (j_decompress_ptr cinfo,
long num_bytes)
{
- cinfo->src->next_input_byte = NULL;
- cinfo->src->bytes_in_buffer = 0;
+ if(num_bytes > 0) {
+ if (num_bytes < cinfo->src->bytes_in_buffer) {
@willglynn
willglynn / -- results.txt
Last active December 10, 2015 22:08
Experiments with Jux stylesheets
# I split up jux.desktop-c2366d6aa995c5fe80506debabee8ee2.css into parts:
# - one file for .theme-day
# - one file for .theme-dusk
# - one file for everything else
#
# My thought was that Jux.com could load the relevant theme CSS, and unload
# the unused theme(s). This would result in significantly fewer active CSS
# rules and some savings of data transfer without requiring much in terms of
# code changes.
#
@willglynn
willglynn / Makefile
Created November 30, 2012 03:13
Ragel for classifying log lines
line_classifier: line_classifier.o
%.c: %.rl
ragel -G2 $^ -o $@
@willglynn
willglynn / gist:4090893
Created November 16, 2012 21:04
Window functions for row pairs
-- PostgreSQL current
SELECT
round,
first_value(time) OVER pair AS first_time,
last_value(time) OVER pair AS last_time,
first_value(groundstatsid IS NULL) OVER pair AS first_is_standing,
last_value(groundstatsid IS NULL) OVER pair AS last_is_standing
FROM matchstats
WINDOW pair AS (PARTITION BY round ORDER BY time ROWS 1 PRECEDING);
@willglynn
willglynn / gist:4072470
Created November 14, 2012 14:35
curl from S3 HTTPS
$ curl -O -v https://s3.amazonaws.com/willglynn/physfs-2.1.0-pre20121013.tgz
* About to connect() to s3.amazonaws.com port 443 (#0)
* Trying 207.171.163.13...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* connected
* Connected to s3.amazonaws.com (207.171.163.13) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
} [data not shown]
* SSLv3, TLS handshake, Server hello (2):
@willglynn
willglynn / mission_planning.png
Created November 9, 2012 03:26
Race Into Space palettes
Race Into Space uses different palettes in different screens.
@willglynn
willglynn / packing.c
Created November 8, 2012 17:10
Neither #pragma pack() nor declaration order affects linker placement of globals
$ make packing
cc packing.c -o packing
$ nm packing | sort
U dyld_stub_binder
0000000100000000 T __mh_execute_header
0000000100000f50 T _main
0000000100001000 S _bar
0000000100001010 S _foo
0000000100001074 S _packed_bar
0000000100001080 S _packed_foo
@willglynn
willglynn / gist:3903510
Created October 17, 2012 03:14
Nesting modules within a class
class SomeClass; end
module SomeClass::NestedModule; end
puts SomeClass.class
puts SomeClass::NestedModule.class
# prints:
# Class
# Module
@willglynn
willglynn / gist:3841654
Created October 5, 2012 18:50
Negative array indices
#include <stdio.h>
int main() {
struct {
int scalar;
int array[5];
} some_struct;
some_struct.scalar = 5;