This file contains hidden or 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
# check if a proposed addition (prepend) to your $PATH will shadow anything | |
# outputs the absolute paths to the executable to be shadowed, below a heading of the new path entry that will shadow it | |
# e.g. NEW_PATH_ELEMENTS="/home/me/git/suspicious_package/bin:/home/me/git/iffy_repo/bin" | |
for f in $(echo "$NEW_PATH_ELEMENTS" | tr : ' '); do | |
echo "== $f =="; find -L $f -maxdepth 1 -type f -executable | xargs -I{} basename {} | sort | xargs -I{} which {} | |
done |
This file contains hidden or 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
#!/usr/bin/env python3 | |
""" | |
A very basic CLI remote control for a Roku device | |
Requires: | |
ssdp | |
requests | |
Written with Python 3.7 | |
""" |
This file contains hidden or 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
// Convert an A1 Notation column to a zero-based index | |
// A -> 0, Z -> 25, AA -> 26, AZ -> 51, ZZ -> 701, AAA -> 702, ... | |
var alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
function a1ColIndex(colString) { | |
var index = 0; | |
var len = colString.length; | |
var colLetter, numval; | |
for (var i = 0; i < len-1; i++) { |
This file contains hidden or 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 sys | |
import locale | |
from datetime import datetime, timedelta | |
locale.setlocale(locale.LC_ALL, 'en_US.utf-8') | |
def _thou_sep(num): | |
return locale.format('%d', int(num), grouping=True) | |
def _plural(num, word): |
This file contains hidden or 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
## get info about the other end of a unix socket! | |
# shown at PyCon 2016 Talk "File descriptors, Unix sockets and other POSIX wizardry" | |
# by Christian Heimes | |
# condensed by me | |
import socket, struct | |
# this is not defined in any python version I have readily at hand | |
# taken from /usr/include/asm-generic/socket.h on debian 7.9 |
This file contains hidden or 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 subprocess | |
import shlex | |
str_types = [str, unicode] | |
def runCmd(cmd, *args, **kwargs): | |
kwargs['stdout'] = kwargs.get('stdout', subprocess.PIPE) | |
kwargs['stderr'] = kwargs.get('stderr', subprocess.PIPE) | |
stdin = '' | |
if 'stdin' in kwargs and type(kwargs['stdin']) in str_types: |
This file contains hidden or 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
#!/usr/bin/perl -w | |
# USAGE: | |
# | |
# /RSAY <text> | |
# - same as /say, but outputs a coloured text | |
# | |
# /RME <text> | |
# - same as /me, but outputs a coloured text | |
# |
This file contains hidden or 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
#!/usr/bin/perl -w | |
# USAGE: | |
# | |
# /RSAY <text> | |
# - same as /say, but outputs a coloured text | |
# | |
# /RME <text> | |
# - same as /me, but outputs a coloured text | |
# |
NewerOlder