Skip to content

Instantly share code, notes, and snippets.

View incoming_cpu.c
#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>
View areas.c
#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)
{
View injectaddr.so.c
/*
* 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/
*
View runall.pl
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,
View rpick.pl
#! perl
use strict;
use warnings;
my $lines_to_pick = 5; # 何行選ぶか
my $lines_total = 0;
my @picked;
@kazuho
kazuho / cloexec-posix-spawn.c
Created Nov 16, 2021
Command hangs on macOS 11.5 if O_CLOEXEC is used
View cloexec-posix-spawn.c
#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
View delivery_rate.h
/*
* 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:
*
@kazuho
kazuho / main.cpp
Last active Aug 8, 2021
micro:bit v2 controller for RIGID Micro DC Aircon https://www.rigidhvac.com/micro-dc-aircon-12v
View main.cpp
#include <algorithm>
#include <cstdio>
#include "MicroBit.h"
static MicroBit uBit;
static int targetTemp = 35;
static int showCount;
static void setPower(int newPeriod, NRF52Pin &pin)
{
View gist:fa5a95e0aa2c44b552a78ba5ea0b5cdc
commit 2340bc1ef749df3494ed8897e438fd747e978b67 (origin/kazuho/travis-test, kazuho/travis-test)
Author: Kazuho Oku <kazuhooku@gmail.com>
Date: Mon Mar 22 20:41:34 2021 +0900
add assertion
diff --git a/lib/common/http1client.c b/lib/common/http1client.c
index 25c580d97..221c4b38b 100644
--- a/lib/common/http1client.c
+++ b/lib/common/http1client.c
View iw10.log
{"type":"packet-sent", "conn":0, "time":1611735067804, "pn":0, "len":1280, "packet-type":0, "ack-only":0}
{"type":"packet-received", "conn":0, "time":1611735067806, "pn":0, "decrypted":"0x7ffeebbe60c5", "decrypted-len":99, "packet-type":0}
{"type":"packet-acked", "conn":0, "time":1611735067806, "pn":0, "is-late-ack":0}
{"type":"packet-received", "conn":0, "time":1611735067806, "pn":1, "decrypted":"0x7ffeebbe615c", "decrypted-len":1076, "packet-type":2}
{"type":"packet-received", "conn":0, "time":1611735067806, "pn":2, "decrypted":"0x7ffeebbe65c4", "decrypted-len":1228, "packet-type":2}
{"type":"packet-received", "conn":0, "time":1611735067806, "pn":3, "decrypted":"0x7ffeebbe6ac4", "decrypted-len":715, "packet-type":2}
{"type":"packet-received", "conn":0, "time":1611735067806, "pn":4, "decrypted":"0x7ffeebbe6daa", "decrypted-len":363, "packet-type":3}
{"type":"packet-sent", "conn":0, "time":1611735067806, "pn":1, "len":112, "packet-type":2, "ack-only":0}
{"type":"packet-sent", "conn":0, "time":1611735067806, "