Skip to content

Instantly share code, notes, and snippets.

@d
d / config.fish
Last active March 3, 2021 07:42
fish_prompt with git branch
set -x GIT_EDITOR "mvim -f"
# until fish 2.2, we'll have to do this
set PATH (brew --prefix)/bin $PATH
complete -f -c git -n '__fish_git_using_command pull' -l ff-only -d 'Refuse to merge unless fast-forward possible'
complete -f -c git -n '__fish_git_using_command pull' -l rebase -d 'Rebase instead of merge'
complete -c git -n '__fish_git_using_command commit' -s v -l verbose -d 'Show diff in commit message template'
complete -c git -n '__fish_git_using_command commit' -s a -l all -d 'Commit all changed files'
@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 / uber_headers.txt
Last active August 20, 2020 04:25
include what you use
Jesses-MacBook-Air ~/s/p/gporca (master=)> git describe --tags
7.0.0-alpha.0-7231-g32446a321d49
Jesses-MacBook-Air ~/s/p/gporca (master=)> ninja -C cmake-build-debug-clang-12 -t deps | grep -F ../ | grep -v -F libgpos | sort | uniq -c | sort -nr
944 ../libnaucrates/include/naucrates/dxl/gpdb_types.h
942 ../libnaucrates/include/naucrates/md/IMDId.h
928 ../libnaucrates/include/naucrates/dxl/operators/CDXLDatum.h
923 ../libnaucrates/include/naucrates/md/CDXLStatsDerivedRelation.h
923 ../libnaucrates/include/naucrates/md/CDXLStatsDerivedColumn.h
923 ../libnaucrates/include/naucrates/md/CDXLBucket.h
918 ../libnaucrates/include/naucrates/dxl/operators/CDXLOperator.h
@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?