Skip to content

Instantly share code, notes, and snippets.

View takluyver's full-sized avatar

Thomas Kluyver takluyver

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@takluyver
takluyver / make_sdist.py
Created February 4, 2016 18:26
flit sdist
import io
from pathlib import Path
from posixpath import join as pjoin
import tarfile
from flit import common, inifile
SETUP = """\
#!/usr/bin/env python
@takluyver
takluyver / asyncio_magic.py
Created January 25, 2016 11:53
Cell magic for 'await' expressions in IPython
# (c) Thomas Kluyver, 2016
# Use it under the MIT license
# This is fairly experimental. Use at your own risk.
import ast
from ast import Call, Attribute, Name, Load
import asyncio as asyncio_mod
#import astpp
from IPython.utils.text import indent
@takluyver
takluyver / flituptools.py
Created January 21, 2016 11:05
Flituptools
from pathlib import Path
import re
# This is a code smell all by itself
import setuptools
from flit import common, inifile
fields_same_name = [
'name',
@takluyver
takluyver / repeatable_iterator.py
Created January 14, 2016 22:12
Wrap a generator in a re-usable iterator
class CursorIterator(object):
def __init__(self, sequence, start=0):
self.sequence = sequence
self.position = start - 1
def __next__(self):
self.position += 1
return self.sequence[self.position]
class RepeatableIterable(object):
@takluyver
takluyver / 2to3_nb.py
Last active November 5, 2021 02:45
Run 2to3 on IPython notebooks
#!/usr/bin/env python3
"""
To run: python3 nb2to3.py notebook-or-directory
"""
# Authors: Thomas Kluyver, Fernando Perez
# See: https://gist.github.com/takluyver/c8839593c615bb2f6e80
import argparse
import pathlib
from nbformat import read, write
@takluyver
takluyver / backslash.md
Last active August 29, 2015 14:22
UK keyboard layout on US keyboard -add backslash

I set up US physical keyboards with a UK layout, because I can type without looking at the keys. But the key for backslash is missing. This is how I remap it to AltGr+Z.

Edit /usr/share/X11/xkb/symbols/gb. In the extd section, add this line:

    key <AB01>  { [  z,                  Z,       backslash,        bar ] };

Also, change dead_grave to grave near the top of this section to fix backticks. Save the file.

@takluyver
takluyver / ipy_jupyter_components.svg
Created April 22, 2015 19:09
Jupyter and IPython components
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@takluyver
takluyver / gist:26fb3b7e365dce527886
Created April 19, 2015 23:32
Pycon videos by views
Results of running this script: https://gist.github.com/jabbalaci/398429347c96e98aba88
Views Ups Downs Title (Speakers)
9,810 166 3 Keynote - Jacob Kaplan-Moss - Pycon 2015 (Jacob Kaplan-Moss)
7,044 64 0 Type Hints - Guido van Rossum - PyCon 2015 (Guido van Rossum)
4,742 121 0 David Beazley - Python Concurrency From the Ground Up: LIVE! - PyCon 2015 (David Beazley)
4,684 66 3 Keynote - Guido van Rossum - PyCon 2015 (Guido van Rossum)
4,272 78 1 Dan Callahan - My Python's a little Rust-y - PyCon 2015 (Dan Callahan)
2,694 34 0 How to build a brain with Python (Trevor Bekolay)
2,391 29 0 Andrew T. Baker - Demystifying Docker - PyCon 2015 (Andrew T. Baker)