Skip to content

Instantly share code, notes, and snippets.

View ioquatix's full-sized avatar
⚖️
Let's make it scalable!

Samuel Williams ioquatix

⚖️
Let's make it scalable!
View GitHub Profile
#
# This file is part of the "Teapot" project, and is released under the MIT license.
#
teapot_version "2.3"
# Project Metadata
define_project "time" do |project|
@ioquatix
ioquatix / O(N) memory allocations.txt
Created April 27, 2019 22:22
10k WebSockets with Falcon
[
[WebSocket::Driver::OpenEvent, 10000],
[WebSocket::Extensions, 10001],
[WebSocket::Driver::Headers, 10001],
[WebSocket::Driver::StreamReader, 10001],
[WebSocket::Driver::Hybi, 10001],
[Async::WebSocket::Server, 10001],
[Addrinfo, 10001],
[Async::HTTP::Protocol::HTTP1::Server, 10001],
[HTTP::Protocol::Headers, 10001],
#!/usr/bin/env ruby
require 'csv'
require 'logger'
logger = Logger.new($stdout)
CSV do |csv|
5.times do
logger.info "Generating row..."
@ioquatix
ioquatix / make check
Created September 8, 2019 05:33
scotch 6.0.8 makepkg output
../../bin/atst ../../tgt/t4x4x4.tgt
A Terminals nbr=64
A Distance min=-1 max=6 avg=3.04762 dlt=1.83825
../../bin/gbase 1 data/m4x4.grf /tmp/m4x4_b1.grf
diff -q "data/m4x4_b1.grf" "/tmp/m4x4_b1.grf"
../../bin/gbase 1 data/m4x4_b1.grf /tmp/m4x4_b1.grf
diff -q "data/m4x4_b1.grf" "/tmp/m4x4_b1.grf"
../../bin/gbase 0 data/m4x4_b1.grf /tmp/m4x4.grf
diff -q "data/m4x4.grf" "/tmp/m4x4.grf"
../../bin/gmap data/bump.grf ../../tgt/h3.tgt /tmp/bump_h3.map -vmt
#!/usr/bin/env ruby
spread = {}
class ShiftRandom
def initialize(seed = 1)
@seed = seed
@accumulator = seed
end
@ioquatix
ioquatix / fizzbuzz.s
Created December 5, 2019 14:14
Fizz Buzz X86-64 (amd64) assembly (works on Linux)
.text
.global main
main:
# Save the non-volatile registers:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
@ioquatix
ioquatix / async-logging.rb
Created December 28, 2019 21:38
Async nested logging
#!/usr/bin/env RBENV_VERSION=2.7.0 ruby
gem 'async'
require 'async'
Async do |task|
Async.logger.info("Incoming request...")
Async(logger: task.logger.with(name: "request-id-1234")) do
Async.logger.info("Database Query")
@ioquatix
ioquatix / memory.rb
Created December 29, 2019 20:52
smaps pss memory usage
#!/usr/bin/env ruby
require 'process/pipeline'
def process_group_pids(pids)
pids.flat_map do |pid|
buffer = Process::Pipeline.("pstree -p #{pid}").read
buffer.scan(/(?<=\()\d+(?=\))/)
end.sort.uniq
#!/usr/bin/env ruby
require 'async'
require 'async/http/internet'
Async do |task|
internet = Async::HTTP::Internet.new
# Effectively a connection timeout:
response = task.with_timeout(10) do
@ioquatix
ioquatix / monads.rb
Created April 2, 2020 10:39
Compare Monads with Pure Ruby
require 'benchmark/ips'
require 'dry/monads/result'
extend Dry::Monads::Result::Mixin
def pure_square(x)
value = x ** 2
if value > 50