Skip to content

Instantly share code, notes, and snippets.

@pyrrho
pyrrho / foo.rs
Created April 1, 2024 19:29
syn type extraction
fn is_option(ty: &syn::Type) -> bool {
// TODO: static this (Arc<Mutex<...>>?)
let valid_option_idents: [&[syn::Ident]; 3] = [
&[syn::parse_quote!(Option)],
&[
syn::parse_quote!(std),
syn::parse_quote!(option),
syn::parse_quote!(Option),
],
@pyrrho
pyrrho / input
Last active August 18, 2019 12:41
Another Hugo partial for generating a Table of Contents
## Pangrams Are Fun!
### Pack My Box With Five Dozen Liquor Jugs
#### Pack My Box With Five Dozen Liquor Jugs
##### Pack My Box With Five Dozen Liquor Jugs
###### Pack My Box With Five Dozen Liquor Jugs
## We Can Drop And Raise Heading Levels By More Than One Step!
#### The First Was An H2
#### The Second Third And Fourth Are H4s
#### This Is The Fourth
@pyrrho
pyrrho / a.cpp
Last active May 16, 2017 20:37
C++14 inline Variable Hack
#include "a.h"
#include "shared.h"
namespace A {
int & getShared() { return shared_int; }
int * getSharedAddr() { return &shared_int; };
int & getMacro() { return macro_int; }
int * getMacroAddr() { return &macro_int; }
}
@pyrrho
pyrrho / test.cc
Last active May 15, 2017 04:45
Special Member Disabler Test
#include <cstdio>
#include <utility>
namespace n2_ {
template <bool EnableCopyCtor>
struct _EnableCopyCtor {
constexpr _EnableCopyCtor() noexcept = default;
constexpr _EnableCopyCtor(const _EnableCopyCtor&) noexcept = default;
_EnableCopyCtor& operator=(const _EnableCopyCtor&) noexcept = default;
@pyrrho
pyrrho / test.cpp
Last active May 9, 2017 20:28
Subordinate Type Ctor Trait Test
#include <type_traits>
#include <cstdint>
#include <cstdio>
#include <cassert>
// Compile with clang, I'd recommend
// /usr/bin/clang++ -fsanitize=address,undefined \
// -fno-omit-frame-pointer \
// -fno-optimize-sibling-calls \
// -O0 \
@pyrrho
pyrrho / gist:c528c3093a5b118510d5a78a050a9ed5
Created November 6, 2016 19:49 — forked from fcofdez/gist:04f0f9b01398a9910417
Distributed systems questions

Questions about Distributed systems by @tsantero.

  1. explain the life of an http request.
  2. what does the FLP result teach us?
  3. what is a byzantine failure?
  4. explain CRDTs
  5. explain linearizability.
  6. how does DNS work?
  7. crash-stop vs crash-recovery?
  8. difference between soft and hard real time
[user]
name = Put In Your Own
email = I.aint@tellin.you
[alias]
# Shortcuts, cuz' I'm lazy
ci = commit
br = branch -v
bra = branch -v -a
co = checkout
Shamelessly stolen from, but with great appreciation for,
https://www.w3.org/TR/html-aria/
<table>
<caption>
Rules of <abbr title="Accessible Rich Internet Applications">ARIA</abbr> attributes usage by HTML language feature
</caption>
<tbody>
<tr>
<th>HTML language feature </th>
@pyrrho
pyrrho / HelloWorldLayer.m
Created March 25, 2012 00:31
Modifies HelloWorldLayer.m for Cocos2D that demonstrates isAnchorRelative behavior
//
// HelloWorldLayer.m
// relativeAnchorPointTest
//
// Created by Drew P-B on 3/24/12.
// Copyright __MyCompanyName__ 2012. All rights reserved.
//
// Import the interfaces