Skip to content

Instantly share code, notes, and snippets.

View BurntSushi's full-sized avatar
🤯
working on revamping globset

Andrew Gallant BurntSushi

🤯
working on revamping globset
View GitHub Profile
@BurntSushi
BurntSushi / 01-possible-generic-map.go
Last active May 14, 2019 16:49
Code from my blog post "Writing type parametric functions in Go."
// This is *not* valid Go!
func Map(f func(A) B, xs []A) []B {
ys := make([]B, len(xs))
for i, x := range xs {
ys[i] = f(x)
}
return ys
}
Map(func(x int) int { return x * x }, []int{1, 2, 3})
// works as of 2019-03-02
(function() {
// This function forces rustdoc to collapse documentation for all items,
// except for the methods defined in an impl block and the primary type's
// declaration. This is the most natural view IMO, since it provides the
// primary type along with an easy to scan overview of available methods.
//
// rustdoc does seemingly have user settings that purport to make this the
// default, but I could never cause them to work in a reliably consistent
// way. This is especially useful when writing documents, where you commonly
"""
A small API to read and analyze CSV files by inferring types for
each column of data.
Currently, only int, float and string types are supported.
from collections import namedtuple
"""
from __future__ import absolute_import, division, print_function
from collections import namedtuple
import csv
@BurntSushi
BurntSushi / keybase.md
Created November 16, 2019 13:36
keybase proof

Keybase proof

I hereby claim:

  • I am burntsushi on github.
  • I am burntsushi (https://keybase.io/burntsushi) on keybase.
  • I have a public key ASCuYAG9GLe7P0uomyj2f5-C82uGTD9NwBZGivEXj_7pfQo

To claim this, I am signing this object:

#!/bin/bash
# Recommended steps:
#
# bootstrap before entering chroot
# copy this script into INSTALL_DIR
# rootinit after entering chroot
# x (if installing graphics)
# pkgs
# xpkgs (if installing graphics)
@BurntSushi
BurntSushi / x11-gnome-do.py
Created April 22, 2020 11:40
Hacky Python script to switch focus between monitors in GNOME while respecting window stacking order.
#!/usr/bin/env python3
# This script serves as duct tape to make the multiple monitor experience
# on GNOME 3 just a little bit better. Currently, the only functionality of
# this script is to switch focus from one monitor to the next, while respecting
# the stacking order of windows inside each individual monitor. However, the
# script is designed to make it easy to add more functionality later. Namely,
# when the script is run, it reads the current monitor, desktop and window
# configuration into a convenient in-memory data structure.
#