Instantly share code, notes, and snippets.

View inspector-stylesheet.css
.blob-code span:before {
background: #fdfd9c;
color: #a2a2a2;
content: attr(class);
font-family: sans-serif;
font-size: 0.7em;
padding: 0 0.2em;
vertical-align: middle;
View look-ma-no-downcasts.cs
using System;
using Color = System.Drawing.Color;
namespace CsTest {
// Generic interfaces. // (1)
interface IEquatable<in T> {
bool Equals(T other);
interface ICloneable<out T> {
  • Invalid signature void main() (… I mean, seriously?!)
  • Missing namespace qualifiers throughout
  • Missing include for accumulate
  • Missing ) in accumulate call
  • Invalid arguments to accumulate call:
    • init missing
    • op has wrong function type (expected (T, T) -> T; got (T) -> void)
    • — in fact, it seems they actually meant std::for_each.
  • … but using std::accumulate correctly would have been way easier, without a gratuitous lambda.
View summary-tibble.r
summary.tbl_df = function (object, ...) {
dots = rlang::quos(...)
stopifnot(length(dots) == 1)
name = rlang::quo_name(dots[[1]])
do(object, as_data_frame(as.list(summary(.[[name]]))))
View tmup
tmup() {
local IFS=$'\n'
for line in $(tmux showenv -t $(tmux display -p '#S')); do
case $line in
-*) unset ${line:1} ;;
*) export $line ;;
View group-table-cols.r
#' Apply a function over groups of columns.
grouped_columns_apply = function (data, width, fun) {
# Generate the group indices for the columns (see below).
group_indices = group_indices(ncol(data), width)
# For each group, apply `fun` to the columns of its indices.
results = lapply(group_indices, function (indices) fun(data[, indices, drop = FALSE]))
# If the number of columns is always evenly divisible by the width, the following
View # glibc - 2017-10-03_18-51-18.txt
Homebrew build logs for glibc on Ubuntu 12.04.5 LTS
Build date: 2017-10-03 18:51:18
View select-lines.cpp
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
auto main(int argc, char** argv) -> int {
if (argc < 2) {
View normalize_path.r
#' Replacement for \code{normalizePath} that works with non-existent paths on
#' Unix
#' @param path vector of paths to normalize.
#' @details
#' \code{normalize_path} works like \code{\link[base]{normalizePath}}, but also
#' works on non-existent paths. \code{\link[base]{normalizePath}} has an option
#' \code{mustWork = FALSE} for this; however, that option only works on Windows.
#' On Unix systems, it causes paths to be left untouched. However, and as a
#' consequence, \code{normalize_path} does \emph{not} resolve symlinks.
View test-interactive.r
context('Same as the basic tests, just in an interactive R shell')
play_back_results = function (record_events, onto) {
for (event in record_events) {
start_test = onto$start_test(event$context, event$test),
add_result = onto$add_result(event$context, event$test, event$result),
end_test = onto$end_test(event$context, event$test))