Skip to content

Instantly share code, notes, and snippets.

View BillyDonahue's full-sized avatar
🎯
Focusing

Billy Donahue BillyDonahue

🎯
Focusing
  • MongoDB
  • New York
View GitHub Profile
// Processed by `../gfxfont_preview.py`
const uint8_t FreeMonoBoldOblique24pt7bBitmaps[] PROGMEM = {
// { 0x20 ' ' (0 x 0) @(0,0) +28 }
// [0 >]
0x00,0x01,0xE0,0x3F,0x07,0xF0,0xFF,0x0F,0xF0,0xFF,0x0F,0xE0,0xFE,0x0F,0xE0,0xFE,0x0F,0xC0,0xFC,0x1F,0xC1,0xF8,0x1F,0x81,0xF8,0x1F,0x81,0xF0,0x1F,0x01,0xF0,0x1E,0x00,0x80,0x00,0x00,0x00,0x00,0x03,0xC0,0x7E,0x0F,0xE0,0xFE,0x0F,0xC0,0x78,0x00,
@BillyDonahue
BillyDonahue / move_default_component_definition.py
Last active February 21, 2024 06:59
Move the LOGV2 default component #define down below the include blocks (SERVER-52604)
#!/usr/bin/python
# Perform a quick rewrite to move
#
# #define MONGO_LOGV2_DEFAULT_COMPONENT CCCC
#
# further down the file after all includes.
import sys
import re
@BillyDonahue
BillyDonahue / test.cpp
Last active October 31, 2020 21:11
msvc bug: expr sfinae on private
#include <type_traits>
template <typename T, typename=void> struct Direct : std::false_type {};
template <typename T> struct Direct<T, std::void_t<decltype(std::declval<T>().f())>> : std::true_type {};
template <typename T> using Op = decltype(std::declval<T>().f());
template <typename T, typename=void> struct ViaAlias : std::false_type {};
template <typename T> struct ViaAlias<T, std::void_t<Op<T>>> : std::true_type {};
#!/bin/bash
# $ sed_grep_results.sh cmd
#
# Apply the sed command `cmd` to every file:line: specified on stdin.
# Example:
#
# git grep -n '\<IsMasterOutcome\>' | sed_grep_results.sh 's/IsMasterOutcome/HelloOutcome/g'
#
@BillyDonahue
BillyDonahue / hits.out
Last active June 26, 2020 18:08
8-digit LOGV2 identifiers git grep -En 'LOGV2.*\(\s*[0-9]{8}' >hits.txt
[
{
"file": "src/mongo/db/auth/sasl_mechanism_registry.cpp",
"line": 192,
"data": " LOGV2_ERROR(47429001,",
"blame": "b'817a7f19511 (Mark Benvenuto 2020-04-20 14:34:56 -0400 192) LOGV2_ERROR(47429001,\\n'"
},
{
"file": "src/mongo/db/catalog/index_catalog_entry_impl.cpp",
"line": 356,
@BillyDonahue
BillyDonahue / vpn_evg.sh
Last active June 9, 2020 06:06
Create a route to an Evergreen workstation through the selected VPN interface
#!/bin/bash
set -e
host="${1:-$(<~/.local/etc/evghost)}"
vpn_name="${2:-"mongo vpn"}"
cat >&2 <<EOF
host: [$host]
vpn_name: [$vpn_name]
@BillyDonahue
BillyDonahue / hash_table_bm.out
Created May 27, 2020 07:16
string_data_comparator hash container speed results.
Running build/install/bin/hash_table_bm
Run on (40 X 3100 MHz CPU s)
CPU Caches:
L1 Data 32K (x20)
L1 Instruction 32K (x20)
L2 Unified 256K (x20)
L3 Unified 25600K (x2)
Load Average: 1.39, 1.37, 1.61
------------------------------------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations UserCounters...
@BillyDonahue
BillyDonahue / action_type.h
Created April 29, 2020 16:12
generated action_type.h
// AUTO-GENERATED FILE DO NOT EDIT
// See src/mongo/db/auth/generate_action_types.py
/**
* Copyright (C) 2018-present MongoDB, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
#include <cstdint>
#include <iostream>
#include <type_traits>
template <typename> const std::string tName{"???"};
template <> const std::string tName<char>{"char"};
template <> const std::string tName<signed char>{"signed char"};
template <> const std::string tName<unsigned char>{"unsigned char"};
template <> const std::string tName<short>{"short"};
template <> const std::string tName<unsigned short>{"unsigned short"};
+/**
+ * Test uniformity of nextInt32(max)
+ */
+TEST(RandomTest, NextInt32Uniformity) {
+ PseudoRandom prng(10);
+ /* Break the range into sections. */
+ /* Check that all sections get roughly equal # of hits */
+ constexpr int32_t kMax = (int32_t{3} << 29) - 1;
+ constexpr size_t kBuckets = 64;
+ constexpr size_t kNIter = 1'000'000;