Skip to content

Instantly share code, notes, and snippets.

View jrockway's full-sized avatar
🌒
Eclipse viewing

Jonathan Rockway jrockway

🌒
Eclipse viewing
View GitHub Profile
@jrockway
jrockway / xorg.conf
Created December 5, 2013 10:11
xorg.conf for a custom EDID for my TV, making my card not send null audio over the DVI link. See also: http://analogbit.com/hdmi_dvi_audio
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" RightOf "Screen0"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
Option "Xinerama" "0"
EndSection
Section "Files"
@jrockway
jrockway / foo.pl
Created September 22, 2012 08:25
make a dot file out of lsmod's output
#!/usr/bin/perl -n
BEGIN { print "digraph modules {\n" }
if(/^([^[:space:]]+).*\s([^[:space:]]+)$/) {
print "# $1 -> $2\n";
for (split /,/,$2) {
print " $1 -> $_;\n";
}
}
END { print "}" }
@jrockway
jrockway / display.c
Created August 27, 2012 08:43
driver for adafruit led backpack
#include "display.h"
#include "third_party/i2cmaster.h"
static const uint8_t number_table[] = {
0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F, 0x77, 0x7C,
0x39, 0x5E, 0x79, 0x71 };
void init_display(int address) {
i2c_start_wait(address + I2C_WRITE);
i2c_write(0x21);
@jrockway
jrockway / play.pl
Created December 27, 2011 08:18
Sending a transcript to a SMTP server nicely
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':5.10';
use autodie qw/open/;
my $file = shift;
open my $fh, '<', $file;
@jrockway
jrockway / test.pl
Created December 13, 2011 16:05
xmms2 + powermate
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':5.10';
use Config;
my $event_size =
($Config{longsize} * 2) + # input_event.time (struct timeval)
($Config{i16size} * 2) + # input_event.type, input_event.code
has 'request_builder' => (
is => 'ro',
isa => 'CodeRef',
traits => ['Code'],
handles => { request => 'execute' },
default => sub {
my ($self) = @_;
weaken $self;
return sub {
my ($method, $uri, $headers, $cb) = @_;
@jrockway
jrockway / events.js
Created April 6, 2011 02:53
class as event handler in node?
function EventListener() {}
EventListener.prototype.listen_to = function (that) {
for (var key in this) {
var event;
if(event = /^handle_(.+)$/.exec(key)){
var method = [this, this[event[0]]];
that.on( event[1], function() {
method[1].apply(method[0], arguments);
});
@jrockway
jrockway / sock.c
Created April 4, 2011 23:13
perl vs. c for syslog protocol
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
use strict;
use 5.010;
{ package Class;
sub new { my $self = bless $_[1], $_[0]; warn $self; $self }
sub DESTROY { warn $_[0] }
}
# works
{
@jrockway
jrockway / get.pl
Created December 16, 2010 01:38
node.js proxy (with AnyEvent::HTTP test case)
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':5.10';
use AnyEvent::HTTP;
my $cv = AE::cv;
http_get 'http://www.google.com/', $cv;