Skip to content

Instantly share code, notes, and snippets.

Cliff Wells cwells

Block or report user

Report or block cwells

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View geolocation.py
#!/usr/bin/env python3
import dbus
from dbus.mainloop.glib import DBusGMainLoop
from gi.repository import GLib
GEOCLUE = 'org.freedesktop.GeoClue2'
DBUS_PROPERTIES = 'org.freedesktop.DBus.Properties'
GCLUE_ACCURACY_LEVEL_COUNTRY = dbus.UInt32(1)
View location.py
#!/usr/bin/env python3
SKYHOOK_SDK_KEY = '<your skyhook sdk key>'
SKYHOOK_URL = 'https://global.skyhookwireless.com/wps2/location'
UUID = '<generate using uuidgen>'
import time
import webbrowser
import gi
gi.require_version('NM', '1.0')
View patch.py
import functools
def async_compat(func):
@functools.wraps(func)
def wrapper_decorator(*args, **kwargs):
version = sys.version_info[0] + sys.version_info[1] / 10.0
if version >= 3.7:
kwargs['is_async'] = kwargs.get('async', False)
del kwargs['async']
return func(*args, **kwargs)
@cwells
cwells / deep_fn_merge.py
Created Dec 7, 2018
deep merge two nested dictionaries, while applying a function to each item
View deep_fn_merge.py
import collections
def deep_fn_merge(fn, left, right):
for k, v in right.iteritems():
if k in left and isinstance(left[k], dict) and isinstance(right[k], collections.Mapping):
deep_fn_merge(fn, left[k], right[k])
else:
left[k] = fn(left, right, k)
def sum(left, right, key):
View main.jl
include("./strings.jl")
filename, stride, highest = ARGS
@time main(filename, parse(Int64, stride), parse(Int64, highest))
View aws-mfa.py
#!/bin/env python3
#
# Create ~/.aws/aws-mfa.yaml with the following content:
#
# ---
# default:
# account: 1234567890
# username: phil@veridiandynamics.com
# aws_profile: production
View dig.py
def dig(d, keys, *args):
"""Locate a value in a nested dictionary.
Args:
d (dict): the dictionary
keys (list): list of keys to index the dictionary with
default (value|callable): value or callable to return in case of missing key
Returns:
Value at `d[k0][k1][...]` if all keys are present
View proxy.py
#!/usr/bin/env python3
import sys
import os
import getpass
import socket
import select
import threading
import logging
import yaml
View snapshot.py
#!/usr/bin/python3
import os
import re
import logging
import boto3
from queue import Queue
from threading import Thread
from datetime import datetime, timedelta, timezone
@cwells
cwells / github.css
Last active Dec 16, 2017
Grey theme for FF 57+ / matching Stylish theme for slack.com, github.com
View github.css
body {
background-color: #eeeeee;
}
a {
color: #333333;
text-decoration: none;
}
.server-stats {
You can’t perform that action at this time.