Skip to content

Instantly share code, notes, and snippets.

@kazuho
kazuho / timemachine.rb
Last active January 12, 2023 06:42
generational backup using rsync
#! /usr/bin/ruby
if ARGV.empty?
puts "Usage: #{$0} [rsync-options] <src-host:src-dir>"
exit 0
end
generations = Dir.glob("*").grep(/^[0-9]{8}-[0-9]{6}$/).sort
argv = ARGV
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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)
{
@kazuho
kazuho / git-blame-pr.pl
Last active June 28, 2022 07:15
git-blame by PR #
#! /usr/bin/perl
#
# Written in 2017 by Kazuho Oku
#
# To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
#
use strict;
use warnings;
@kazuho
kazuho / fusionbench.c
Last active May 10, 2022 14:27
Tiny benchmark program for picotls-fusion
/*
* Copyright (c) 2020 Fastly, 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:
*
@kazuho
kazuho / sockaddr_cmp.c
Last active April 9, 2022 18:05
compare sockaddr
/*
* As of May 25 2021, this code is provided as CC0 / public domain (Kazuho Oku)
*
* Copyright (c) 2014 Kazuho Oku
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,