Don’t create generators with side effects:
import contextlib
@contextlib.contextmanager
def my_nice_context():
try:
A tree can be produced by counting the number of trailing zeros from an input integer index.
This count ('c') of trailing zeros (or position of the lowest bit) comes back every 2^c sample, i.e. corresponds to a frequency of 2^-c
Furthermore every sample corresponds with one and only one octave.
;; Simulates Acme by creating clickable regexp links in the buffer. | |
;; | |
;; You can use it for instance to create an index: | |
;; | |
;; :/uu-re-link-mode/ : entry point. | |
;; | |
(defcustom uu-re-link-re ":/\\(.+\\)/" "Regular expression for regular expression links.") | |
(defcustom uu-re-link-re-initial "[[:space:]]:/" nil) | |
(defcustom uu-re-link-isearch t "Use isearch to find the expression interactively.") |
If you develop drivers (Software) for USB peripherals then you may only need to read chapters, 4 - Architectural Overview 5 - USB Data Flow Model 9 - USB Device Frame Work, and 10 - USB Host Hardware and Software.
You probably also need to know xHCI. The host-side USB spec.
The IOKit
framework is Apple’s base framework to interact with devices.
This is your go to when for instance working with USB devices.
There is a way in IOKit to register notifications to discover devices as they are plugged by our users. The API seems easy enough (see IOKitLib header)
However I was puzzled for quite long why my notifications were not processed.
It turns out you have to process the iterator immediately after calling
IOServiceAddMatchingNotification
, otherwise notifications won’t be
// -*- mode: c ; c-file-style: "k&r" -*- | |
// x86 boot sector. | |
// | |
// Once you execute this program you will get a series of disk images, which you can try in qemu: | |
// qemu -drive file=boot.img,format=raw | |
// | |
// and burn to a usb stick using something like rufus or dd | |
#include <assert.h> | |
#include <stdlib.h> |
(require 'cl) | |
(defstruct wm-window buffer (point 0) (start 0) (hscroll 0) dedicated) | |
(defvar wm-windows) | |
(defvar wm-windows-alist) | |
(defvar wm-focus) | |
(defvar wm-workspace 0) | |
(defvar wm-workspaces nil) | |
(defvar wm-layout 0) |
Sophistication in programming languages has diminishing returns.
I treat programming language features like I treat drugs. They come with side-effects, which I want to be aware off before even thinking of putting them into use. And if in doubt, I’d rather not use them.
For an alternative take, legions of programmers write online about the features they want to have in their language. Is it based on actual experience rather than wishful thinking? Is it based on their own introspection of what’s producing defects or harming progress?
#include <stdio.h> | |
// Shows how to iterate backwards in C. (Counter version) | |
int main(int argc, char** argv) | |
{ | |
{ int c = argc; while (c--) { | |
printf("%s%s", argv[c], c == 0 ? "\n" : ", "); | |
} } | |
} |