Something something __Py_UnixMain
_main
python.o
:
$ brew uninstall binutils
Error is:
""" | |
Copyright 2016 David Antliff; this file is licensed under the terms of the Apache license version 2.0. For a full copy of the license, see https://www.apache.org/licenses/LICENSE-2.0 | |
Accept two styles of repeated options on the command line. | |
Style 1 - each instance repeats the option itself. E.g. | |
$ python prog --option A --option B | |
Style 2 - each instance occurs after a single instance of the option. E.g. |
import re | |
def partition(string, delimiters): | |
"""Split a string into a (head, sep, tail) tuple based on the | |
first occurrence of a delimiter in the string. | |
This is similar to str.partition() except it accepts a set of delimiters. | |
The set can be a list/tuple of characters, or a string.""" | |
seps = "".join(delimiters) | |
return re.match(r"([^{seps}]*)([{seps}]?)(.*)".format(seps=seps), string).groups() |
def coerce_iterable(scalar_or_sequence): | |
"""If scalar_or_sequence is not iterable, wrap it so that the return value is.""" | |
try: | |
_ = tuple(x for x in scalar_or_sequence) | |
result = scalar_or_sequence | |
except TypeError: | |
# The user has probably specified a single entity and forgotten to | |
# define it as a proper tuple, so be friendly and handle as a scalar instance: | |
result = (scalar_or_sequence,) | |
return result |
#!/bin/bash | |
# Note: this removes all uncommitted changes and untracked files! | |
git clean -xfd | |
git submodule foreach --recursive git clean -xfd | |
git reset --hard | |
git submodule foreach --recursive git reset --hard | |
git submodule update --init --recursive |
import logging | |
import sys | |
def init_logging(name, log_level): | |
# install handlers for stdout (DEBUG, INFO) and stderr (WARNING, ERROR) | |
# http://stackoverflow.com/a/16066513/143397 | |
logger = logging.getLogger(name) | |
logger.setLevel(log_level) |
# Assumes in_txt was generated by `xxd -g1 in.bin > in.txt` | |
import csv | |
with open(in_txt) as fin, open(out_csv, 'w') as fout: | |
o=csv.writer(fout, quotechar='"', quoting=csv.QUOTE_ALL) | |
for line in fin: | |
row = line.rstrip('\n').split(sep=' ', maxsplit=17) | |
# remove one leading space from last item | |
row[-1] = row[-1][1:] |
#!/usr/bin/env python | |
# Python 3.x | |
import random | |
rolls = 5000 # the more results the better | |
scaling = 10 # scale the histogram to fit the screen | |
dice = (20,) # a single d20 | |
#dice = (6, 6) # two d6s |
#!/usr/bin/env python | |
""" | |
Deactivate ACPI devices that may cause hibernation to fail | |
""" | |
from dataclasses import dataclass | |
import subprocess | |
@dataclass |
#include <iostream> | |
#include <thread> | |
#include <chrono> | |
#include <boost/asio.hpp> | |
#include <mqtt_client_cpp.hpp> | |
struct App { | |
boost::asio::io_context ioc {}; | |
using client_t = decltype(MQTT_NS::make_sync_client(std::declval<boost::asio::io_context &>(), "", 0)); |