Skip to content

Instantly share code, notes, and snippets.

Avatar

FUJI Goro gfx

View GitHub Profile
@gfx
gfx / Dockerfile
Created May 17, 2022
Enabling HTTP/3 in cURL with quiche + boringSSL
View Dockerfile
# curl with http2 and http3 support
# https://curl.se/docs/http3.html
RUN wget --https-only --no-verbose -O - https://sh.rustup.rs | sh -s -- \
-y \
--profile minimal \
--default-toolchain 1.59.0 \
&& git clone --recursive --branch 0.12.0 --depth 1 https://github.com/cloudflare/quiche \
&& (cd quiche \
&& $HOME/.cargo/bin/cargo build --package quiche --release --features ffi,pkg-config-meta,qlog \
&& mkdir quiche/deps/boringssl/src/lib \
@gfx
gfx / mini-thread-pool.rb
Last active Mar 16, 2022
MiniThreadPool - A minimum viable thread pool implementation for Ruby
View mini-thread-pool.rb
class MiniThreadPool
def initialize(size: 8, abort_on_exception: true)
@queue = Queue.new
@join_all = false
@threads = []
size.times do
thr = Thread.new do
loop do
break if @join_all && @queue.empty?
begin
@gfx
gfx / log.txt
Created Dec 1, 2021
curl -sSfL https://cpanmin.us | perl - -f --verbose --notest App::cpanminus 2>&1 | pbcopy
View log.txt
cpanm (App::cpanminus) 1.7044 on perl 5.034000 built for darwin-thread-multi-2level
Work directory is /Users/goro-fuji/.cpanm/work/1638333555.20362
You have make /usr/bin/make
You have /opt/chef-workstation/embedded/bin/curl
You have /usr/bin/tar: bsdtar 3.3.2 - libarchive 3.3.2 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.6
You have /usr/bin/unzip
Searching App::cpanminus () on cpanmetadb ...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
@gfx
gfx / 001-wifi-routers-v2.md
Last active Feb 22, 2022
Wi-Fiルーターおすすめ by 妻
View 001-wifi-routers-v2.md

概要

  • ネットーワーク機器のマーケ担当をしてる妻から聞いた、Wi-Fiルータのオススメ(「同僚のメーカー担当ごとに己の”最強”を選んでもらった」とのこと)です
  • 「ルーターにはWi-Fiルータだけじゃなく他にもいろいろあるんだよ!これはWi-Fiルータのことね」と言われたのでタイトルを変えました
  • 「AXほにゃらら」は規格(AX = Wi-Fi 6)+速度の参考値とのことです
  • もともとの文脈: 家庭内の雑談をツイートしたところ( https://twitter.com/__gfx__/status/1464084908091920387 )知人が反応したので妻に「ルータのおすすめ教えてと知人がいってるのでなんか教えて」といって教えてもらったのが元です
  • 下にあるv1.md が最初のやつ(2021/11/26)で、このv2.md がホッテントリ入りしたあとの改訂版(2021/11/27)です

Buffalo

@gfx
gfx / 000-request-rejection.md
Last active Jul 24, 2021
Explain why 001-CVE-2021-23410 is invalid
View 000-request-rejection.md

CVE-2021-23410 is invalid because the PoC has nothing to do with the msgpack module and any other serializers.

The PoC is something like this:

var assert = require('assert');
var msgpack = require('msgpack');
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
@gfx
gfx / type-from-json.ts
Last active Nov 22, 2020
Type-Function to Parse JSON into TypeScript types
View type-from-json.ts
type Whitespace = " " | "\n" | "\r" | "\t";
type TrimStart<T extends string> = T extends `${Whitespace}${infer R}` ? TrimStart<R> : T;
type TrimEnd<T extends string> = T extends `${infer R}${Whitespace}` ? TrimEnd<R> : T;
type Trim<T extends string> = TrimStart<TrimEnd<T>>;
type BoolLiteral = "true" | "false";
type Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
type InferJsonScalarType<T extends string> = Trim<T> extends `"${infer _}"` ? string
: Trim<T> extends `${BoolLiteral}` ? boolean
View generator.ts
function* iterateParams() {
for (const x of ["a", "b", "c"]) {
for (const i of [1, 2, 3]) {
yield { x, i };
}
}
}
for (const p of iterateParams()) {
console.log(p);
View hires-time.c
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
int main() {
printf("gettmeofday:\n");
for (int i = 0; i < 10; i++) {
struct timeval tv1, tv2;
gettimeofday(&tv1, NULL);
gettimeofday(&tv2, NULL);
@gfx
gfx / prog.c
Created Apr 6, 2020
`fread(3)` returns 0 for success. why?
View prog.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
int main() {
char cmdline[256];
char proc_file[256];
snprintf(proc_file, sizeof(proc_file), "/proc/%d/cmdline", getpid());
@gfx
gfx / asroot.pm
Last active Sep 4, 2019
perl -Masroot foo.pl # run it as root
View asroot.pm
# usage: use asroot; # run it as root
package asroot;
use strict;
use warnings;
# TODO: inherits @INC
exec "sudo", $^X, $0, @ARGV if $< != 0;
1;