(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
#!/usr/bin/python | |
# | |
# git-slim | |
# | |
# Remove big files from git repo history. | |
# | |
# Requires GitPython (https://github.com/gitpython-developers/GitPython) | |
# | |
# References: | |
# - http://help.github.com/remove-sensitive-data/ |
#!/bin/bash | |
# | |
# Restart Bluetooth Module on Mac OS X | |
# | |
# Requires Blueutil to be installed: http://brewformulas.org/blueutil | |
BT="/usr/local/bin/blueutil" | |
log() { | |
echo "$@" |
import requests | |
import time | |
import json | |
token = '' | |
#Delete files older than this: | |
ts_to = int(time.time()) - 30 * 24 * 60 * 60 | |
def list_files(): |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
#!/usr/bin/env python | |
''' | |
This is a high level basic example of roles | |
''' | |
from fabric.api import * | |
@task | |
def load_hosts(region='region'): |
# Find the IAM username belonging to the TARGET_ACCESS_KEY | |
import boto3 | |
from botocore.exceptions import ClientError | |
iam = boto3.client('iam') | |
def find_user(key): | |
try: | |
key_info = iam.get_access_key_last_used(AccessKeyId=key) |
This gist contains lists of modules available in
in AWS Lambda.
It also contains the code to run in Lambda to generate these lists. In addition there
is a less_versbose
module in the code that you can call to get a list of the top
level modules installed and the version of those modules (if they contain a version
in the module)
def compress_utf8_file(fullpath, delete_original = True): | |
"""Compress a UTF-8 encoded file using GZIP compression named *.gz. If `delete_original` is `True` [default: True], | |
the original file specified by `delete_original` is removed after compression.""" | |
with codecs.open(fullpath, 'r', 'utf-8') as fin: | |
with gzip.open(fullpath + '.gz', 'wb') as fout: | |
for line in fin: | |
fout.write(unicode(line).encode('utf-8')) | |
if delete_original: | |
os.remove(fullpath) |
# requirements: python3, numba, dask | |
import random | |
import numba | |
import dask | |
@dask.delayed | |
@numba.jit(nopython=True, nogil=True) | |
def calc_pi(N): |
#!/usr/bin/env python | |
""" | |
Convert camel-case to snake-case in python. | |
e.g.: CamelCase -> snake_case | |
Relevant StackOverflow question: http://stackoverflow.com/a/1176023/293064 | |
""" |