Skip to content

Instantly share code, notes, and snippets.

🐌
I'll be slow to respond - I operate a notification pull (not push) policy

Phil Elson pelson

🐌
I'll be slow to respond - I operate a notification pull (not push) policy
Block or report user

Report or block pelson

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
@phizaz
phizaz / async.py
Last active Nov 8, 2019
Python turn sync functions to async (and async to sync)
View async.py
import functools
def force_async(fn):
'''
turns a sync function to async function using threads
'''
from concurrent.futures import ThreadPoolExecutor
import asyncio
pool = ThreadPoolExecutor()
@ericdill
ericdill / render_env.py
Last active Sep 16, 2019
Render the dependency graph for your conda environment (needs graphviz!)
View render_env.py
import json
import glob
from os.path import join, basename
# install this with "conda install -c conda-forge python-graphviz"
import graphviz as gv
# path to your conda environment
path = '/tmp/foo'
dg = gv.Digraph(filename='env-%s' % basename(path), format='svg')
@mrocklin
mrocklin / trace.py
Created Jul 11, 2016 — forked from jcrist/trace.py
Dask Execution Tracer
View trace.py
import os
from dask.callbacks import Callback
from dask.dot import dot_graph
class Track(Callback):
def __init__(self, path='dasks'):
self.path = path
self.n = 0
@jcrist
jcrist / trace.py
Last active Dec 15, 2017
Dask Execution Tracer
View trace.py
import os
from dask.callbacks import Callback
from dask.dot import dot_graph
class Track(Callback):
def __init__(self, path='dasks', save_every=1):
self.path = path
self.save_every = save_every
@bastman
bastman / docker-cleanup-resources.md
Created Mar 31, 2016
docker cleanup guide: containers, images, volumes, networks
View docker-cleanup-resources.md

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
@HeinrichHartmann
HeinrichHartmann / RPi_ADC8032.py
Created Dec 14, 2014
Raspbery Pi Analog Input with ADC0832
View RPi_ADC8032.py
#!/usr/bin/env python
#
# Analog Input with ADC0832 chip
#
# Datasheet: http://www.ti.com/lit/ds/symlink/adc0838-n.pdf
# Part of SunFounder LCD StarterKit
# http://www.sunfounder.com/index.php?c=show&id=21&model=LCD%20Starter%20Kit
#
import time
@psmay
psmay / svg-to-fontforge-python.md
Created Dec 2, 2014
Notes on mass-importing SVG outlines into FontForge via Python
View svg-to-fontforge-python.md

Notes on dumping SVG outlines into a FontForge file

Sources I've looked at:

I have a hunch that createMappedChar() doesn't work unless you've done loadNameList('glyphlist.txt') or loadNameList('aglfn.txt') (BSD-licensed Adobe glyph lists). An alternative seems to be to go by codepoint with createChar().

@drgarcia1986
drgarcia1986 / __main__.py
Last active Nov 7, 2019
Example of OAuth2 autentication server with Client Credentials grant (using python-oauth2 and tornado)
View __main__.py
# !/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Diego Garcia'
import tornado.web
import tornado.ioloop
import oauth2.tokengenerator
import oauth2.grant
import oauth2.store.redisdb
import oauth2.store.mongodb
@ozh
ozh / xkcd.css
Created Mar 12, 2014
XKCD font
View xkcd.css
/* font from https://github.com/ipython/xkcd-font
* converted to web font in base64 with
* http://www.fontsquirrel.com
*/
@font-face {
font-family: 'xkcdregular';
src: url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAFUEABMAAAAAmIwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABqAAAABwAAAAcZzPs3EdERUYAAAHEAAAAHQAAACAAqwAER1BPUwAAAeQAAAUsAAAI6KIfuCpHU1VCAAAHEAAAACwAAAAwuP+4/k9TLzIAAAc8AAAARwAAAGB0yJOSY21hcAAAB4QAAAEcAAAB6qFMdl1jdnQgAAAIoAAAAEgAAABIE5kZd2ZwZ20AAAjoAAABsQAAAmVTtC+nZ2FzcAAACpwAAAAIAAAACAAAABBnbHlmAAAKpAAARK4AAH+Mp+zsDGhlYWQAAE9UAAAALwAAADYD5y0taGhlYQAAT4QAAAAeAAAAJA4xBqpobXR4AABPpAAAAU0AAAH48WoV22xvY2EAAFD0AAAA7AAAAP7KyqwybWF4cAAAUeAAAAAfAAAAIAGbAvduYW1lAABSAAAAAQ4AAAKyORJbEXBvc3QAAFMQAAABIwAAAcgo6S23cHJlcAAAVDQAAADFAAABdD4epAl3ZWJmAABU/AAAAAYAAAAGwE1THwAAAAEAAAAAzD2izwAAAADLsNlAAAAAAM9FcMx42mNgZGBg4ANiCQYQYGJgBMJaIGYB8xgACakAsAAAAHjaVZbfa5tVGMefNOkPejG0v9ReDJXSH/nRNI1tmqZppJSXEkIo4SWU8BJiqCVE29K1Yw6VoTJkypDhnYiUUYoXu5Aio4wxmLPUGTcpMnbjjVf+Fcvx855zlErIkpP3fT/ne77P93lWCYhIr0zJonQsO
@lrhache
lrhache / python-selenium-open-tab.md
Last active Nov 13, 2019
Python Selenium - Open new tab / focus tab / close tab
View python-selenium-open-tab.md

On a recent project, I ran into an issue with Python Selenium webdriver. There's no easy way to open a new tab, grab whatever you need and return to original window opener.

Here's a couple people who ran into the same complication:

So, after many minutes (read about an hour) of searching, I decided to do find a quick solution to this problem.

You can’t perform that action at this time.