Skip to content

Instantly share code, notes, and snippets.


Garrett T film42

Block or report user

Report or block film42

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
film42 /
Last active Jan 17, 2019
Simple example using foundationdb's Flow
#include <iostream>
#include <vector>
#include "flow/flow.h"
#include "flow/DeterministicRandom.h"
#include "flow/actorcompiler.h"
// Simple counting actor that:
// 1. Logs a tag on start and finish.
// 2. Waits for some time.
// 3. Returns the new number.
film42 / sketching_a_disk_backed_queue.rb
Last active Aug 27, 2017
Exploring different back pressure mechanism for active publisher
View sketching_a_disk_backed_queue.rb
require "pstore"
require "thread"
require "securerandom"
module ActivePublisher
module Async
module DiskBackedQueue
class Page
attr_reader :file_path
film42 / redirect.go
Created Aug 24, 2017
If you need to go from io.Reader to io.Reader but need to do a streaming io.Writer -> io.Reader before hand, this redirects the output
View redirect.go
type NoOpWriteCloser struct {
writer io.Writer
func (c *NoOpWriteCloser) Write(p []byte) (int, error) {
return c.writer.Write(p)
func (c *NoOpWriteCloser) Close() error {
return nil
film42 / tls_cert_key_and_ca_jruby.rb
Created Apr 9, 2017
Load a x509 cert + rsa key and x509 ca and create an sslcontext in java using jruby. This took me a few hours to figure out since I wasn't super familiar with java, but here you go! Btw, you'll notice I'm using bouncycastle which is fine because it's a dependency of jruby-openssl. So as long as you require "openssl" this should work out of the box.
View tls_cert_key_and_ca_jruby.rb
require "openssl"
def create_ssl_context(options)
# Create our certs and key converters to go from bouncycastle to java.
cert_converter =
key_converter =
# Load the certs and keys.
tls_ca_cert = cert_converter.getCertificate(read_pem_object_from_file(options[:tls_ca_cert]))
tls_client_cert = cert_converter.getCertificate(read_pem_object_from_file(options[:tls_client_cert]))
View pg.rb
require "socket"
class Client
def initialize(addr, port, user, db)
@user = user
@db = db
@socket =, port)
def login_packet
View single_producer_multi_consumer_pool.rb
module Protobuf
module Nats
class ThreadPool
def initialize(size, opts = {})
@queue =
@active_work = 0
# Callbacks
@error_cb = lambda {|_error|}
View arel-visitor-thread-safe-test.rb
# frozen_string_literal: true
module Arel
module Visitors
class Visitor
def initialize
@dispatch = get_dispatch_cache
@random = [0.1, 0.5, 1, 2, 4]
def accept object
film42 / disable-capslock-delay.c
Created Dec 8, 2016
Apple Aluminum Keyboard Caps Lock Delay Remover
View disable-capslock-delay.c
// FROM:
// FROM:
#include <linux/hidraw.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
film42 / fluxbox.conf
Created Nov 24, 2016
Fluxbox with mac keyboard
View fluxbox.conf
# super-tab
Mod4 Tab :NextWindow {groups} (workspace=[current])
Mod4 Shift Tab :PrevWindow {groups} (workspace=[current])
#1920 / 2 = 960
#1080 / 2 = 540
Control KP_0 :Minimize
Control KP_1 :MacroCmd {ResizeTo 958 540} {MoveTo 00 00 LowerLeft}
Control KP_2 :MacroCmd {ResizeTo 1920 540} {MoveTo 00 00 LowerLeft}
View proxy.go
package main
import (
You can’t perform that action at this time.