Skip to content

Instantly share code, notes, and snippets.


Farid Zakaria fzakaria

View GitHub Profile
fzakaria / jruby.nix
Created Jun 15, 2021
Build any JRuby commit easily
View jruby.nix
# This derivation is meant to be used in the overlay or can be built
# by itself to test which is why you see all the defaults being set.
# Please consult
# for additional information.
{ sources ? import ./sources.nix, pkgs ? import sources.nixpkgs { }
, lib ? pkgs.lib, stdenv ? pkgs.stdenv, callPackage ? pkgs.callPackage
, fetchFromGitHub ? pkgs.fetchFromGitHub, makeWrapper ? pkgs.makeWrapper
, jre ? pkgs.jre, maven ? pkgs.maven, ant ? pkgs.ant }:
fzakaria / benchmark
Created Apr 29, 2021
Simple CephFS FUSE benchmark
View benchmark
#! /usr/bin/env ruby
require 'fileutils'
require 'thread'
lock =
# tear down any old directories
Errno::EAGAIN: Resource temporarily unavailable - Resource temporarily unavailable
getStackTrace at java/lang/
getBacktraceData at org/jruby/runtime/backtrace/
getBacktrace at org/jruby/runtime/backtrace/
captureBacktrace at org/jruby/
preRaise at org/jruby/exceptions/
<init> at org/jruby/exceptions/
<init> at org/jruby/exceptions/
<init> at org/jruby/exceptions/
<init> at org/jruby/exceptions/
View gist:b09b124359583a98c50eb5aa01d93d45
class RequestFilter
def initialize(app, tracer)
@app = app
@tracer = tracer

Keybase proof

I hereby claim:

  • I am fzakaria on github.
  • I am fzakaria ( on keybase.
  • I have a public key whose fingerprint is 0D68 D1FD E13D EBD6 95B9 19B2 81FB F501 D1B2 32E7

To claim this, I am signing this object:

View Virtual Block Instance Methods
class TestTable < Sequel::Model(:test_table)
def is_something?
self[:x] == 123
TestTable.where{ is_something? }
fzakaria /
Created Dec 28, 2018
Decrypt by hand TLS payload
public class Test {
public void testExtractMasterkeyWorksCorrectly() throws Exception {
SelfSignedCertificate cert = new SelfSignedCertificate();
SslContext serverContext = SslContextBuilder.forServer(cert.key(), cert.cert())
final OpenSslEngine serverEngine =
(OpenSslEngine) serverContext.newEngine(UnpooledByteBufAllocator.DEFAULT);
fzakaria /
Last active Mar 1, 2021
How to properly use an http client with a self signed certificate
* Too many examples on the internet demonstrate using self-signed certificates by disabling hostname verification
or providing a weak TrustManager (i.e. SelfSignedTrustManager).
This example shows how to properly start a server & client in the same JVM where the client knows about the
generated self-signed certificate.
Also it's all done programmatically! Avoid using keytool and pulling in heavy dependencies like BouncyCastle!~
public class SecureServerTest {
fzakaria /
Created Jan 2, 2018
Jaeger reading / writing thrift from a file
import com.uber.jaeger.Span;
import com.uber.jaeger.Tracer;
import com.uber.jaeger.exceptions.SenderException;
import com.uber.jaeger.reporters.Reporter;
import com.uber.jaeger.samplers.ConstSampler;
import com.uber.jaeger.samplers.Sampler;
import com.uber.jaeger.senders.ThriftSender;
import com.uber.jaeger.thriftjava.Process;
import org.apache.thrift.TBase;
import org.apache.thrift.TException;
* A very simple {@link Injector} and {@link Extractor} that use a {@link StringBuffer} as the transmission.
* This class <b>will only</b> transmit the {@link io.opentracing.SpanContext} without any baggage
* (that's why its simple).
public class SimpleStringCodec implements Injector<StringBuffer> , Extractor<StringBuffer> {
public void inject(SpanContext spanContext, StringBuffer carrier) {