Skip to content

Instantly share code, notes, and snippets.


Michael Howell notriddle

View GitHub Profile
notriddle /
Last active Mar 5, 2020
Sorts out the unique non-robot IP addresses that requested style.css
# The first step is to get a list of robot IP addresses
# We stash it in a file for later
awk -F' ' '/robots.txt/ {print $1}' /var/log/nginx/access.log.1 | sort | uniq > robots-ips.txt
# Also add a few known bots that don't necessarily get robots.txt from the same IP
grep -iE '(bingbot|BingPreview|msnbot|adbeat|ArchiveBot|YandexBot|Googlebot|Pinterestbot|Spider)' /var/log/nginx/access.log.1 | awk -F' ' '{print $1}' | sort | uniq > robots-ips.txt # The second step is to get a list of non-robot IP addresses
# This one is comparatively complicated, so let's dissect my awk syntax
# NR==FNR -- FNR is the line number ("record number") in the current file, while NR is the line number processed in total. If these are equal, then we're on the current file. # {a[$1]=1;next} -- we want to load the robots-ips.txt file into an array, a
notriddle /
Last active Oct 31, 2019
@notriddle's Rust 2020 wishlist, or, Rust 2021: Integration

@notriddle's Rust 2020 wishlist

or, Rust 2021: Integration

This is just a brain dump. Doing all of this is not going to happen, but all of it is stuff I know of that impacts Rust's integration with the rest of the world and eventually becoming Too Big To Fail like C++ is.

Better resources outside the Rust core team's reach

  1. Improved support for vendored, external, and crates. Some of it is just a matter of documenting the workarounds to allow cargo to use local git repositories in place of networked ones. Some of it is providing official, documented registry software.
  2. Improved support for third-party discussion and documentation platforms. I love Users and Internals, and I can deal with Discord, but these are platforms specifically for discussing Rust. What we need is greater presence on platforms that are dedicated to problem domains: database courses
notriddle / latency.txt
Created Apr 26, 2019 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
View latency.txt
Latency Comparison Numbers (~2012)
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
notriddle /
Last active Dec 10, 2018
Tests the old vs the new Windows argument parser for Rust, to ensure identical behavior
use std::collections::VecDeque;
use std::ffi::OsString;
use std::os::windows::ffi::OsStringExt;
use std::slice;
use std::iter;
use std::ptr;
/// Implements the Windows command-line argument parsing algorithm, described at
/// <>.

This is the rough implementation plan:

pick 9ae5db20d2 introduce Universe struct

We want this. =)

pick 1da0b70c57 introduce UniverseIndex into ParamEnv

Instead of adding a universe to the ParamEnv, the plan is now to add this field to the InferenceCtxt. It represents the maxixum

use std::ffi::CStr;
use std::os::raw::{c_char, c_int};
use std::slice;
use lua_sys::lua_State;
unsafe extern "C" fn runargs(l: *mut lua_State, argv: *mut *mut c_char, n: c_int) -> c_int {
// slices can use normal [] access, while pointers have to use the .offset method
// so convert the pointer to a slice, because otherwise this'll be 99% .offset(i).deref().offset(0).deref()
let args = &slice::from_raw_parts(argv, n)[1..];
let mut iter = args.iter().cloned().map(CStr::from_ptr);
notriddle /
Last active Jun 28, 2017
The hub workflow

How to use hub's PAT for user accounts

$ git config --global hub.protocol https
$ cat ~/.config/hub
- user: notriddle
  oauth_token: [CENSORED]
  protocol: https
$ cat > ~/.netrc
notriddle /
Last active Apr 7, 2020
Language package managers: Elixir's mix and Rust's cargo
Action Mix Cargo
Create a project mix new [--app APP] PATH cargo new [--bin] PATH
Run your project iex -S mix / mix run --no-halt / mix phoenix.server cargo run
Get help mix help cmd cargo [cmd] --help
Build configuration mix.exs Cargo.toml
Project commands mix COMMAND N/A
Global add-on commands mix archive.install PACKAGE cargo install PACKAGE
Integrating with other languag
notriddle / glorw.txt
Last active Apr 5, 2017 — forked from saiqulhaq/glorw.txt
General list of reserved words
View glorw.txt
### General List of Reserved Words
### Stuart P. Bentley <>, June 4, 2013
### Michael Howell <>, April 5, 2017
## This is a general list of words you may want to consider reserving,
## in a system where users can pick any name, in a context where the
## system may use names as well. One prominent example of a system
## where this is the case would be a site that serves pages for users,
## at their username, from the site root, like
## . In this system, you would want to
notriddle / pimpl.ex
Created Feb 17, 2017
Implement :lists.prefix for any enumerable, in Elixir
View pimpl.ex
defmodule Enum2 do
@type t :: Enum.t
@doc """
If `enum` starts with `prefix`, return true. Otherwise, return false.
### Examples
iex> Enum.starts_with?([1, 2, 3], [1, 2])
You can’t perform that action at this time.