Skip to content

Instantly share code, notes, and snippets.

Avatar

Farid Zakaria fzakaria

View GitHub Profile
@fzakaria
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 https://github.com/looker/helltool/blob/master/docs/jruby.md
# 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
fzakaria / benchmark
Created Apr 29, 2021
Simple CephFS FUSE benchmark
View benchmark
#! /usr/bin/env ruby
require 'fileutils'
require 'thread'
lock = Mutex.new
NUMBER_OF_CLIENTS = 10
# tear down any old directories
View EAGAIN JRuby
Errno::EAGAIN: Resource temporarily unavailable - Resource temporarily unavailable
getStackTrace at java/lang/Thread.java:1607
getBacktraceData at org/jruby/runtime/backtrace/TraceType.java:242
getBacktrace at org/jruby/runtime/backtrace/TraceType.java:53
captureBacktrace at org/jruby/RubyException.java:371
preRaise at org/jruby/exceptions/RaiseException.java:115
<init> at org/jruby/exceptions/RaiseException.java:65
<init> at org/jruby/exceptions/Exception.java:38
<init> at org/jruby/exceptions/StandardError.java:38
<init> at org/jruby/exceptions/SystemCallError.java:38
View gist:b09b124359583a98c50eb5aa01d93d45
class RequestFilter
def initialize(app, tracer)
@app = app
@tracer = tracer
end
EXCLUDED_PATH_PREFIXES = %w[
...
].freeze
View keybase.md

Keybase proof

I hereby claim:

  • I am fzakaria on github.
  • I am fzakaria (https://keybase.io/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
end
end
TestTable.where{ is_something? }
@fzakaria
fzakaria / netty_tls_raw.java
Created Dec 28, 2018
Decrypt by hand TLS payload
View netty_tls_raw.java
public class Test {
@Test
public void testExtractMasterkeyWorksCorrectly() throws Exception {
SelfSignedCertificate cert = new SelfSignedCertificate();
SslContext serverContext = SslContextBuilder.forServer(cert.key(), cert.cert())
.sslProvider(SslProvider.OPENSSL).build();
final OpenSslEngine serverEngine =
(OpenSslEngine) serverContext.newEngine(UnpooledByteBufAllocator.DEFAULT);
@fzakaria
fzakaria / https.java
Last active Mar 1, 2021
How to properly use an http client with a self signed certificate
View https.java
/**
* 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
fzakaria / jaeger_thrift.java
Created Jan 2, 2018
Jaeger reading / writing thrift from a file
View jaeger_thrift.java
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;
View SimpleStringCodec.java
/**
* 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> {
@Override
public void inject(SpanContext spanContext, StringBuffer carrier) {
carrier.append(spanContext.contextAsString());