Skip to content

Instantly share code, notes, and snippets.

View daniel-noland's full-sized avatar

Daniel Noland daniel-noland

  • Stateless
  • Boulder
View GitHub Profile
@daniel-noland
daniel-noland / easycap.sh
Last active May 5, 2024 18:15
Easier netlink captures
#!/usr/bin/env bash
set -euo pipefail
clean_up_strace_io() {
printf -- 'command: %s\n' "${*}"
printf -- 'messages:\n' "${*}"
declare line
declare strace_parse
declare label
@daniel-noland
daniel-noland / picky-zod.ts
Created March 8, 2024 18:56
Make zod do better static analysis on the input types
// Sketch library code:
import {z} from 'zod';
declare const _is_: unique symbol;
export type Tags = string | number | symbol;
export type Parsed<Tag extends Tags> = {
readonly [_is_]: {
readonly [key in Tag]: typeof _is_;
}
@daniel-noland
daniel-noland / expected.ts
Created March 8, 2024 04:42
Tricky typescript thought problem on how to improve error messages and better communicate with library users about types
// Sketch library code:
import {z} from 'zod';
declare const _is_: unique symbol;
export type Parsed<T extends string | number | symbol> = {
[_is_]: {
[key in T]: typeof _is_;
}
}
@daniel-noland
daniel-noland / json
Last active January 23, 2023 01:47
testCcsDeploy
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"variables": {
"actions": [
"Microsoft.Network/connections/delete",
"Microsoft.Network/connections/read",
"Microsoft.Network/connections/write",
"Microsoft.Network/expressRouteCircuits/delete",
"Microsoft.Network/expressRouteCircuits/nrpinternalupdate/action",
@daniel-noland
daniel-noland / alsoWorksOnGithub.md
Last active January 27, 2021 22:47
Welcome file

I think markdown is super easy to use. If you want to make a title you just write:

Markdown is super easy to use

There, I gave my page a title

You can learn to use markdown in 15 minutes

There, I gave my page a sub title

@daniel-noland
daniel-noland / alsoWorksOnGithub
Last active April 23, 2020 15:07
Welcome file
I think markdown is super easy to use. If you want to make a title you just write:
# Markdown is super easy to use
There, I gave my page a title
## You can learn to use markdown in 15 minutes
There, I gave my page a sub title
@daniel-noland
daniel-noland / ipaddress.c
Created April 16, 2020 16:29
IP address print logic
int print_linkinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE *)arg;
struct ifinfomsg *ifi = NLMSG_DATA(n);
struct rtattr *tb[IFLA_MAX+1];
int len = n->nlmsg_len;
const char *name;
unsigned int m_flag = 0;
SPRINT_BUF(b1);
hello world
@daniel-noland
daniel-noland / confusing_function.cpp
Last active October 11, 2016 20:48
A confusing function
std::unique_ptr<StoppointOptions::CommandData>
StoppointOptions::CommandData::CreateFromStructuredData(
const StructuredData::Dictionary &options_dict, Error &error) {
// Is it just me, or is "data_up" a not very good name? Could be anything.
// This is fine, but it is oldschool. In C++14 we gained std::make_unique
std::unique_ptr<CommandData> data_up(new CommandData());
// should be
// auto data_up = std::make_unique<CommandData>();
bool found_something = false;

Keybase proof

I hereby claim:

  • I am daniel-noland on github.
  • I am dnoland (https://keybase.io/dnoland) on keybase.
  • I have a public key whose fingerprint is 68D7 15BC 3E03 BEFB 3485 A81E B540 F2BB 1888 73FF

To claim this, I am signing this object: