Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pathlib | |
def likely_python_module(filename): | |
''' | |
Given a filename or Path, return the "likely" python module name. That is, iterate the | |
parent directories until it doesn't contain an __init__.py file. | |
Python 3.4+ only (uses pathlib), but then again, it's only Python 3 where | |
no relative imports causes this problem! | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ThingsToCal -- Copyright (c) 2016 Michael Scott Cuthbert | |
* Released under a BSD License | |
* | |
*/ | |
ObjC.import("stdlib"); | |
class ThingsOrganizer { | |
constructor() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://fivethirtyeight.com/features/how-badly-can-a-car-salesman-swindle-you/ | |
# Michael Scott Cuthbert ([email protected]) -- CC-BY 2015 | |
from __future__ import print_function, division | |
import itertools | |
from collections import OrderedDict | |
from pprint import pprint | |
inf = float('inf') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Allow sphinx rst references in markdown cells | |
// TODO: Markdown cells will only be reevaluated when a notebook is dirty | |
// (i.e. you have made changes). If you save it before reevaluating MD cells, | |
// they will show the old value. | |
define([ | |
'base/js/namespace', | |
'jquery', | |
'notebook/js/cell', | |
'base/js/security', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class X(object): | |
__slots__ = ('hi',) | |
class Y(X): | |
__slots__ = ('bye',) | |
x = X() | |
print(x.__slots__) | |
# ('hi',) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fractions import Fraction | |
DENOM_LIMIT = 65535 | |
def _preFracLimitDenominator(n, d): | |
''' | |
copied from fractions.limit_denominator. Their method | |
requires creating three new Fraction instances to get one back. this doesn't create any | |
call before Fraction... | |
DENOM_LIMIT is hardcoded to defaults.limitOffsetDenominator for speed... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mainTest(*testClasses, **kwargs): | |
''' | |
Takes as its arguments modules (or a string 'noDocTest' or 'verbose') | |
and runs all of these modules through a unittest suite | |
Unless 'noDocTest' is passed as a module, a docTest | |
is also performed on `__main__`, hence the name "mainTest". | |
If 'moduleRelative' (a string) is passed as a module, then | |
global variables are preserved. |