Skip to content

Instantly share code, notes, and snippets.

@hatt
hatt / logstash-elasticache.pp
Last active Mar 13, 2017
Dynamically scoping Redis with AWS Elasticache to use the local availability zone. Batch writing is used for the shipper to reduce usage costs.
View logstash-elasticache.pp
$redis_host = $::ec2_placement_availability_zone ? {
'us-west-1a' => 'logging-redis-a.<redacted>.0001.usw1.cache.amazonaws.com',
'us-west-1b' => 'logging-redis-b.<redacted>.0001.usw1.cache.amazonaws.com'
}
logstash::output::redis { 'redis-shipper':
batch => true,
host => $redis_host,
key => 'logstash',
data_type => 'list'
@hatt
hatt / gcj-a.c
Created Apr 14, 2013
Google Code Jam 2013 Qualifying Round A
View gcj-a.c
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
int cmp( char a, char b);
int check_corners( uint8_t cur, char board[4][4]);
int check_stripes( uint8_t cur, char board[4][4]);
int check_ongoing( uint8_t cur, char board[4][4]);
@hatt
hatt / planeswap.cpp
Created Jul 29, 2012
AVISynth planeswap.cpp
View planeswap.cpp
const int pitch = dst->GetPitch(PLANAR_U)/4;
const int myx = (dst->GetRowSize(PLANAR_U)+3)/4;
const int myy = dst->GetHeight(PLANAR_U);
int *srcpUV = (int*)dst->GetWritePtr(PLANAR_U);
for (int y=0; y<myy; y++) {
for (int x=0; x<myx; x++) {
srcpUV[x] = 0x80808080; // mod 8
}
srcpUV += pitch;
@hatt
hatt / chromaswap.avs
Created Jul 29, 2012
Plane-Swapped Chroma Supersampling
View chromaswap.avs
loadplugin("dither.dll")
loadplugin("debilinear.dll")
dither_convert_8_to_16()
ly = debilinear(1280, 720, lsb_inout=true)
lc = dither_resize16(1280*2, 720*2, src_left=0.25, kernel="blackman")
lu = lc.utoy()
lv = lc.vtoy()
ytouv(lu,lv,ly)