Skip to content

Instantly share code, notes, and snippets.

View gfx's full-sized avatar

FUJI Goro gfx

View GitHub Profile
#include <stdio.h>
#include <time.h>
#include <stdint.h>
#define NUM_ITERATIONS 1000000
uint64_t timespec_to_ns(struct timespec ts) {
return (uint64_t)ts.tv_sec * 1000000000 + ts.tv_nsec;
}
@gfx
gfx / Dockerfile
Created May 17, 2022 02:05
Enabling HTTP/3 in cURL with quiche + boringSSL
# 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 March 16, 2022 05:28
MiniThreadPool - A minimum viable thread pool implementation for Ruby
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 December 1, 2021 04:39
curl -sSfL https://cpanmin.us | perl - -f --verbose --notest App::cpanminus 2>&1 | pbcopy
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 January 28, 2024 23:55
Wi-Fiルーターおすすめ by 妻

概要

  • ネットーワーク機器のマーケ担当をしてる妻から聞いた、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)です

追記(2022/05/24):

  • TP-Linkはちょいちょいやらかしがあります
@gfx
gfx / 000-request-rejection.md
Last active July 24, 2021 01:30
Explain why 001-CVE-2021-23410 is invalid

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 November 22, 2020 12:32
Type-Function to Parse JSON into TypeScript types
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
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);
#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 April 6, 2020 02:50
`fread(3)` returns 0 for success. why?
#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());