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
// Python comprehension proc macro that handles multiple nested for-if-clauses, flattening nested structure. | |
// Example: | |
// | |
// let vec_of_vecs = vec![vec![1, 2, 3], vec![4, 5, 6]]; | |
// | |
// let result = comp![x for vec in vec_of_vecs for x in vec].collect::<Vec<_>>(); | |
// assert_eq!(result, [1, 2, 3, 4, 5, 6]); | |
// | |
use proc_macro2::TokenStream as TokenStream2; |
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
! model | |
pc101 Generic 101-key PC | |
pc102 Generic 102-key (Intl) PC | |
pc104 Generic 104-key PC | |
pc105 Generic 105-key (Intl) PC | |
dell101 Dell 101-key PC | |
latitude Dell Latitude series laptop | |
dellm65 Dell Precision M65 | |
everex Everex STEPnote | |
flexpro Keytronic FlexPro |
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 sys | |
from django.core.management import BaseCommand | |
from django.urls import resolvers | |
def collect_urls(urls=None, namespace=None, prefix=None): | |
if urls is None: | |
urls = resolvers.get_resolver() | |
prefix = prefix or [] | |
if isinstance(urls, resolvers.URLResolver): |
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 contextlib | |
import OpenSSL.crypto | |
import os | |
import requests | |
import ssl | |
import tempfile | |
@contextlib.contextmanager | |
def pfx_to_pem(pfx_path, pfx_password): | |
''' Decrypts the .pfx file to be used with requests. ''' |
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
{ | |
id: 'gruvbox-dark', | |
name: 'Gruvbox (Dark)', | |
highlights: { | |
background: '#282828', | |
text: '#ebdbb2', | |
variable: '#83a598', | |
attribute: '#8ec07c', | |
definition: '#fabd2f', | |
keyword: '#fb4934', |
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
# Pass the env-vars to MYCOMMAND | |
eval $(egrep -v '^#' .env | xargs) MYCOMMAND | |
# … or ... | |
# Export the vars in .env into your shell: | |
export $(egrep -v '^#' .env | xargs) | |
# set variables from .compose.env but don't override existing exported vars | |
eval "$(grep -v '^#' .compose.env | sed -E 's|^(.+)=(.*)$|export \1=${\1:-\2}|g' | xargs -L 1)" | |
# Load up .env |
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
define PRINT_HELP_PYSCRIPT | |
import re, sys | |
for line in sys.stdin: | |
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) | |
if match: | |
target, help = match.groups() | |
print("%-30s %s" % (target, help)) | |
endef | |
export PRINT_HELP_PYSCRIPT |
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
pulp_default_admin_password: password | |
pulp_install_source: pip | |
pulp_settings: | |
secret_key: secret | |
content_origin: "https://{{ inventory_hostname }}" | |
x_pulp_api_host: 127.0.0.1 | |
x_pulp_api_port: 24817 | |
x_pulp_api_user: "admin" | |
x_pulp_api_password: "{{ pulp_default_admin_password }}" | |
x_pulp_api_prefix: "pulp_ansible/galaxy/automation-hub/api" |
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
#!/usr/bin/env python | |
""" | |
Very simple HTTP server in python (Updated for Python 3.7) | |
Usage: | |
./dummy-web-server.py -h | |
./dummy-web-server.py -l localhost -p 8000 | |
Send a GET request: |
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
#!/usr/bin/env sh | |
file=/tmp/cmus_playing.txt | |
while true | |
do | |
music="" | |
if cmus-remote -C status | grep -q playing; then | |
music=$(cmus-remote -Q | grep -e "tag title" -e "tag artist" | sed "s/^tag\s\w*\s//g" | sed "N;s/\n/ - /g") | |
if (( ${#music} > 0 )); then | |
music="Now playing: $music" | |
fi |
NewerOlder