Given the following proto file:
enum Key {
Unknown = 0;
KeyOne = 1;
KeyTwo = 2;
}
message KeyValue {
#! /usr/bin/env python3 | |
''' | |
Making SVGs by hand is a pain. This is a better way: | |
It's functional, rather than using the XML "markup language" directly. | |
No closing tags, just balanced parentheses! | |
#xml #svg #python #python3 #graphicsprogramming | |
https://twitter.com/halcanary/status/1458802118136111107 | |
Updated to use `xml.dom.minidom` instead of `lxml`. |
#include <cstdio> | |
using Bar = int; | |
class Foo { | |
public: | |
struct Iter { | |
Iter& operator++() { ++ptr; return *this; } | |
bool operator!=(Iter const& other) const { return ptr != other.ptr; } | |
Bar& operator*() { return *ptr; } |
#!/bin/sh | |
INFO="$(diskutil ap list disk1)" | |
printf 'size: %14d\n' "$(printf %s "$INFO" | sed -n 's/ *Size (Capacity Ceiling): *\([0-9]*\).*/\1/p')" | |
printf 'use: %14d\n' "$(printf %s "$INFO" | sed -n 's/ *Capacity In Use By Volumes: *\([0-9]*\).*/\1/p')" |
#include <errno.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <sys/sysctl.h> | |
int main() { | |
static const char* NAMES[3] = { | |
"hw.cpufrequency", |
from __future__ import division | |
def division(n, d): | |
''' | |
find integers q, r such that | |
d * q + r = n | |
0 <= r < d | |
''' | |
assert n >= 0 | |
assert d > 0 | |
q, r = 0, n |
Local:
download Xcode_XX.XX.XX.xip
from https://developer.apple.com/download/all/.
scp "$(ls -t ~/Downloads/Xcode_*.xip | head -1)" USER@REMOTE:
ssh USER@REMOTE
#! /usr/bin/env osascript | |
## Vertically maximize all open windows. | |
tell application "Finder" to set BNDS to (bounds of window of desktop) | |
set DESKTOP_HEIGHT to item 4 of BNDS | |
tell application "System Events" to repeat with P in application processes whose background only is false | |
tell application "System Events" to tell P | |
repeat with WIN in windows of P |
#ifndef DO_OR_FAIL_H | |
#define DO_OR_FAIL_H | |
extern void fail_now(const char* file, int line, const char* msg, int err); | |
#define DO_OR_FAIL(SUCCESS, MSG) \ | |
do { if (!(SUCCESS)) { fail_now(__FILE__, __LINE__, (MSG), errno); } } while (false) | |
#endif // DO_OR_FAIL_H |
%!PS | |
% wide ruled letter paper | |
/inch { 72 mul } def | |
/page_width 8.5 inch def | |
/page_height 11 inch def | |
/line_space 0.34375 inch def | |
/margin 1.25 inch def | |
<< /PageSize [page_width page_height] >> setpagedevice |