Skip to content

Instantly share code, notes, and snippets.

@unasuke
unasuke / Gemfile
Last active May 13, 2023 00:36
Verify DoH certificates for RubyKaigi 2023's network DNS
source 'https://rubygems.org'
gem 'net-http'
gem 'base64'
gem 'addressable'
gem 'resolv', git: 'https://github.com/hanazuki/ruby-resolv', branch: 'svcb-dns'
def sliced_buffer(start, ends)
buf = IO::Buffer.for("thisisteststring")
buf.slice(start, ends-start).get_string
end
loop do
10.times do |i|
sliced_buffer(i, 11)
end
end
@unasuke
unasuke / Dockerfile
Last active July 16, 2022 01:28
mini_paperclip with S3 compatible object storage
FROM ruby:2.7
WORKDIR /app
COPY Gemfile Gemfile.lock /app/
RUN bundle install
COPY . .
CMD bundle exec ruby script.rb
@unasuke
unasuke / Dockerfile
Created April 24, 2022 18:10
msh3app build
FROM ubuntu:22.04
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y git build-essential pkg-config cmake
WORKDIR /root
RUN git clone --depth 1 --recursive https://github.com/nibanks/msh3
RUN mkdir msh3/build
WORKDIR /root/msh3/build
RUN cmake -G 'Unix Makefiles' -DMSH3_TOOL=on ..
RUN cmake --build .
RUN cmake --install .
CMD /usr/local/lib/msh3app www.google.com
@unasuke
unasuke / Dockerfile
Created April 23, 2022 17:57
curl HTTP/3 msh3 (msquic) version build failed
FROM ubuntu:22.04
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y git build-essential pkg-config autoconf cmake libtool
WORKDIR /root
RUN git clone -b v0.1.0 --single-branch --recursive https://github.com/nibanks/msh3
RUN mkdir msh3/build
WORKDIR /root/msh3/build
RUN cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
RUN cmake --build .
RUN cmake --install .
@unasuke
unasuke / openssl.diff
Created September 11, 2021 06:55
Make OpenSSL::Cipher Ractor-safe
diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c
index 28f5c1b..3e76bed 100644
--- a/ext/openssl/ossl_cipher.c
+++ b/ext/openssl/ossl_cipher.c
@@ -8,6 +8,7 @@
* (See the file 'LICENCE'.)
*/
#include "ossl.h"
+#include <ruby/ractor.h>
@unasuke
unasuke / decode_tls_clienthello_in_quic_initial_packet.rb
Created August 18, 2021 15:39
Parse TLS 1.3 ClientHello in QUIC Initial packet by Ruby
# This software is released under the MIT License.
# Copyright 2021 Yusuke Nakamura
# Copyright 2021 Nao Yonashiro
# https://opensource.org/licenses/MIT
require "bundler/inline"
require "socket"
gemfile do
source "https://rubygems.org"
@unasuke
unasuke / quic_initial_packet.rb
Last active September 26, 2023 09:58
Parse QUIC Initial Packet by Ruby
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
require 'bundler/inline'
gemfile do
source "https://rubygems.org"
gem "bindata"
end
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
@unasuke
unasuke / rails.patch
Created November 29, 2018 17:19
rails test suite on local docker compose
diff --git a/actioncable/test/subscription_adapter/redis_test.rb b/actioncable/test/subscription_adapter/redis_test.rb
index ac2d8ef724..ca91a19567 100644
--- a/actioncable/test/subscription_adapter/redis_test.rb
+++ b/actioncable/test/subscription_adapter/redis_test.rb
@@ -25,7 +25,8 @@ class RedisAdapterTest::AlternateConfiguration < RedisAdapterTest
def cable_config
alt_cable_config = super.dup
alt_cable_config.delete(:url)
- alt_cable_config.merge(host: "127.0.0.1", port: 6379, db: 12)
+ #alt_cable_config.merge(host: "127.0.0.1", port: 6379, db: 12)