Skip to content

Instantly share code, notes, and snippets.

@d
d / when-was-it-dead
Last active February 21, 2021 19:23
when did this function become dead?
#!/bin/bash
set -e -u -o pipefail
pretty_log() {
git --no-pager log --color --abbrev=16 --abbrev-commit --topo-order -n8 -S "${func_name}" -- '*.cpp' '*.h' '*.inl'
}
count_occurrences() {
git --no-pager log --abbrev=16 --pretty=tformat:%h -n8 -S "${func_name}" -- '*.cpp' '*.h' '*.inl' | parallel -qj1 --load 125% -X git grep -cwF "${func_name}" {} -- '*.cpp' '*.h' '*.inl'
@d
d / ban.sql
Created March 28, 2020 04:50
big-ass number
CREATE TYPE ban;
CREATE FUNCTION banin(cstring, oid, int) RETURNS ban
IMMUTABLE STRICT LANGUAGE internal
AS 'bpcharin';
CREATE FUNCTION banout(ban) RETURNS cstring
IMMUTABLE STRICT LANGUAGE internal
AS 'bpcharout';

Keybase proof

I hereby claim:

  • I am d on github.
  • I am jesusabs (https://keybase.io/jesusabs) on keybase.
  • I have a public key ASBsm4kYFjoCW6q2eUZvc53l0EH0J8ENP6r1aIn9p2H0iAo

To claim this, I am signing this object:

@d
d / owning-pointer.md
Created May 21, 2019 22:01
object life time

Object life time: the implicit contract between functions and objects

An example of non-owning pointers

What expectations does F have about its parameter E?

void F(CExpression *E) {
  do_something_with_E(...);
@d
d / scratch.md
Created February 20, 2019 20:16

Our tests for pg_upgrade is its own travesty:

  1. It takes no control over its input: let's upgrade whatever is left in the cluster. That means we really don't know how or what we are testing.
  2. It relies on comparing two dumps (one before upgrade, one after upgrade) and asserting that they are verbatim identical. Philosophically speaking, this is sufficient not necessary. Practically, this is wrong.
@d
d / sort-warnings.rb
Created December 4, 2018 21:26
Sort Clang / GCC warnings
#!/usr/bin/env ruby
require 'forwardable'
FLIP_PATTERN = /^(?:(?<file>\w+\.c(?:pp)?):\d+:\d+: warning: )|(?:In file included from (?<file>\w+\.c(?:pp)?):\d+:)/
FLOP_PATTERN = /^\d+ warnings? generated\.$/
class Warnings
include Enumerable
n\time (ms) \branch 5X moving avg backport patch
16384 53.453 1694.091
32768 95.186 6640.734
65536 187.03 28848.276
131072 398.689 113056.203
262144 809.299 459619.552
524288 1813.492 1876957.178
1048576 4751.661 7464597.714
@d
d / dell.bash
Last active August 6, 2018 23:46
New Dell Ubuntu
# TODO: clang apt source
# TODO: docker apt source
sudo aptitude install -y vim-gnome fish cmake ninja-build g++ ccache libxerces-c-dev- git parallel clang-tidy-6.0 clang-format-6.0 pigz p7zip-full p7zip-rar rename git-cvs patchelf shellcheck- clang-6.0 lld-6.0 direnv
# TODO: extract shellcheck probably from Docker Hub?
@d
d / iterate.fish
Last active June 28, 2018 06:58
When did we fuck up bool?
xargs --verbose --no-run-if-empty -n1 --arg-file ~/src/d/naughty-booleans-sources.txt clang-query-6.0 -f (egrep -v '^//' ~/src/d/naughty-booleans-clang-query.txt | psub)
parallel --no-run-if-empty --keep-order -n1 --arg-file ~/src/d/naughty-booleans-sources.txt clang-query-6.0 --extra-arg="-fcolor-diagnostics" -f (egrep -v '^//' ~/src/d/naughty-booleans-clang-query.txt | psub)
@d
d / generate_reflow_diff.bash
Last active March 14, 2018 01:44
Which comments need more work for clang-format?
#!/bin/bash
set -e -u
_main() {
cat > .clang-format <<YAML
---
Language: Cpp
BasedOnStyle: Google
AllowShortFunctionsOnASingleLine: None