Skip to content

Instantly share code, notes, and snippets.

View dreamingbinary's full-sized avatar
💭
I love to build

Charles Le dreamingbinary

💭
I love to build
  • Los Angeles, Earth.
View GitHub Profile
#!/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/
@dreamingbinary
dreamingbinary / .wakeup
Created September 6, 2016 17:43 — forked from ralph089/.wakeup
Restarts Bluetooth Module on Mac OS X El Capitan. You can use the script as shortcut to restart Bluetooth on demand or you can use it with "SleepWatcher" to automatically restart Bluetooth on wakeup (See README.md). I created it, because my Logitech Bluetooth Mouse doesn't stay connected after sleep-mode, so i had to manually re-pair my mouse.
#!/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():
@dreamingbinary
dreamingbinary / introrx.md
Created April 19, 2018 22:31 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
#!/usr/bin/env python
'''
This is a high level basic example of roles
'''
from fabric.api import *
@task
def load_hosts(region='region'):
@dreamingbinary
dreamingbinary / find_user_from_access_key.py
Created September 9, 2018 21:08 — forked from andymotta/find_user_from_access_key.py
Find an AWS IAM user corresponding to an AWS Access Key (boto3)
# 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)
@dreamingbinary
dreamingbinary / all_aws_lambda_modules_python.md
Last active October 2, 2019 18:42 — forked from gene1wood/all_aws_lambda_modules_python.md
AWS Lambda function to list all available Python modules for Python 3.7

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)

@dreamingbinary
dreamingbinary / utf-8_gzip.py
Created November 6, 2019 21:34 — forked from dmdavis/utf-8_gzip.py
Python: Compress a UTF-8 file using GZIP compression
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)
@dreamingbinary
dreamingbinary / pi.py
Created January 24, 2020 17:20 — forked from jhidding/pi.py
Compute Pi using Numba and Dask
# requirements: python3, numba, dask
import random
import numba
import dask
@dask.delayed
@numba.jit(nopython=True, nogil=True)
def calc_pi(N):
@dreamingbinary
dreamingbinary / camel_case_to_snake_case.py
Created April 3, 2020 20:49 — forked from jaytaylor/camel_case_to_snake_case.py
Convert camel-case to snake-case in python.
#!/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
"""