This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef USART_H | |
#define USART_H | |
#include <avr/io.h> | |
/** | |
* Initialize the USART registers for async operation with 8N1 data frames. | |
* | |
* Ref: 7810D–AVR–01/15, p. 159 - 165 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bitstream(x: int, length: int, block_size: int): | |
assert length > 0 and block_size > 0, "Unsupported parameters" | |
mask = int("1" * block_size, 2) | |
for i in range(length): | |
block = x & mask | |
x >>= block_size | |
yield block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Purpose: | |
Play PCM data. | |
API overview: | |
sound_init Initialize sound system. | |
sound_close Close sound system. | |
sound_play Play PCM data. | |
Dependencies: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
State transition table for scanning an unsigned int. | |
Source: p. 34, Engineering a Compiler, 3ed. | |
""" | |
S0 = 0 | |
S1 = 1 | |
S2 = 2 | |
SE = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import os | |
class SyntaxError(Exception): pass | |
class Parser: | |
""" | |
Translates infix expressions into postfix through a | |
syntax-directed, predictive "translator" (parser). | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: Enter the JS snippet below into the web console (opened with Ctrl+Shift+K). | |
// Source: https://connect.mozilla.org/t5/ideas/dark-mode-for-embedded-pdf-viewer/idi-p/4932#link_30 | |
window.PDFViewerApplication.pdfViewer.container.style.filter = "invert(1) grayscale(1)" |