Skip to content

Instantly share code, notes, and snippets.

diff --git a/reflector.rb b/reflector.rb
index c47370b..39e4115 100644
--- a/reflector.rb
+++ b/reflector.rb
@@ -4,12 +4,17 @@
# sudo ip link set tap-e up
# sudo ip route add 10.1.2.0/24 via 10.1.2.3
+require "fiber_scheduler"
require "./tun"
require 'rack'
counter = 0
Thread.new do
loop do
puts "hello, #{counter}"
counter += 1
sleep 1
end
n = 200
m = 63
q = 16
c = 0
1_000_000.times do
buckets = Array.new(m, 0)
n.times do
slot = rand(m)
buckets[slot] += 1
#define _GNU_SOURCE
#include <assert.h>
#include <limits.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
@kazuho
kazuho / areas.c
Created September 21, 2022 12:51
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define WIDTH (99 * 40)
#define HEIGHT (99 * 25)
static double timespec2d(struct timespec *ts)
{
/*
* NAME: injectaddr.so
*
* SYSOPSIS:
* % gcc -shared -fPIC injectaddr.c -ldl -o injectaddr.so
*
* -- inject 1s delay, then connect to 127.0.0.1:8888
* % LD_PRELOAD=injectaddr.so \
* curl http://d1000.p8888.4127-0-0-1.inject.example.com/
*
use strict;
use warnings;
use File::Temp qw(tempdir);
use Getopt::Long;
use POSIX qw(:sys_wait_h);
my $jobs = 1;
GetOptions(
"jobs=i" => \$jobs,
#! perl
use strict;
use warnings;
my $lines_to_pick = 5; # 何行選ぶか
my $lines_total = 0;
my @picked;
@kazuho
kazuho / cloexec-posix-spawn.c
Created November 16, 2021 08:33
Command hangs on macOS 11.5 if O_CLOEXEC is used
#include <errno.h>
#include <fcntl.h>
#include <spawn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define USE_O_CLOEXEC 1
/*
* Copyright (c) 2021 Fastly, Inc., Kazuho Oku
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*