Note: These snippets are tested with Python 3, which has better
datetime
object support than Python 2.
from datetime import datetime
# example Twitter "created_at" field time format
# Please make this file available to others | |
# by sending it to <[email protected]> | |
# | |
# this config file was automatically generated | |
# using lirc-0.9.0(default) on Sun Feb 21 02:54:40 2016 | |
# | |
# contributed by http://github.com/hhromic | |
# | |
# brand: Dell | |
# model no. of remote control: Dell Travel Remote NU-851 |
setup.py
or setup.cfg
git commit -a
git tag X.Y.Z
git push --tags
python setup.py sdist bdist_wheel
twine upload dist/*
import sys | |
import multiprocessing | |
import tqdm | |
import snap | |
# the graph needs to be global so workers can access it after forking | |
GRAPH = None | |
# task: compute eccentricy of a node | |
def compute_ecc(node_id): |
Notes for slimming down a fresh installation of Raspbian Stretch Lite. This guide does not strip Raspbian of basic functionality such as Bluetooth and mDNS.
Install a fresh Raspbian Stretch Lite image into the SD card ([source][1]).
$ unzip -p 2018-04-18-raspbian-stretch-lite.zip | dd bs=4M of=/dev/sdX conv=fsync
From https://tex.stackexchange.com/a/16956:
\textwidth is generally the global width of the text area, while \columnwidth is the width of a column of text (it will be different from \textwidth when typesetting in two or more columns). However, inside a minipage, \textwidth will be set to the given argument along with \hsize, \columnwidth, and \linewidth (they will revert to the previous values at the end of the minipage because it forms a group). Note that \parbox doesn't reset \textwidth; the size is available as \linewidth.
The parameter \linewidth contains the line length inside a list (or derived) environment and it may change in a nested list (while \hsize, \textwidth and \columnwidth don't change). >
import msgpack | |
def _encode_ext_type(obj): | |
if isinstance(obj, set): # encode 'set' with typecode 10 | |
return msgpack.ExtType(10, packb(tuple(obj))) | |
raise TypeError("unknown extended type for %r" % type(obj)) | |
def _decode_ext_type(typecode, data): | |
if typecode == 10: # decode a 'set' type | |
return set(unpackb(data)) |
#!/usr/bin/env bash | |
# Show the current capacity of all managed batteries | |
# script by github.com/hhromic | |
POWER_SUPPLY_DIR=/sys/class/power_supply | |
mapfile -t CAPACITIES < <(compgen -G "$POWER_SUPPLY_DIR"/'*'/capacity) | |
for capacity in "${CAPACITIES[@]}"; do | |
battery="${capacity%/*}" | |
battery="${battery##*/}" |
Ref: https://www.linuxquestions.org/questions/linux-general-1/how-to-mount-img-file-882386/#post4365399
To list the partitions of a disk image:
$ fdisk -l mydisk.img
Disk mydisk.img: 15 GiB, 16088301568 bytes, 31422464 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes