Skip to content

Instantly share code, notes, and snippets.

@mrry
mrry / tensorflow_self_check.py
Last active Jun 29, 2021
[DEPRECATED] TensorFlow on Windows self-check
View tensorflow_self_check.py
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@Andrew-Reid
Andrew-Reid / cairo.json
Last active Feb 14, 2018
Autoscale and center topojson d3v3
View cairo.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jebeck
jebeck / README.md
Last active May 15, 2018
SVG foreignObject tooltips in D3
View README.md

SVG foreignObject tooltips in D3

Just a little proof-of-concept here - using an SVG <foreignObject> element as a container for a tooltip that can involve handy HTML features like text-wrapping and (semi-)dynamic sizing.

Gotchas so far:

  • Like an <svg> element, a <foreignObject> element needs a width and a height in order to be rendered.

  • However, specifying width and/or height can be delayed. Here I specify a width (foWidth) of 300px, then find the height of the contained <div> using getBoundingClientRect() and use that to specify the height of the containing <foreignObject>.

@pdc
pdc / testy.py
Created Sep 2, 2011
Mocking time to do time-sensitive unit tests in Python
View testy.py
import unittest
from mock import *
from datetime import datetime, timedelta
import time # so we can override time.time
mock_time = Mock()
mock_time.return_value = time.mktime(datetime(2011, 6, 21).timetuple())
class TestCrawlerChecksDates(unittest.TestCase):
@patch('time.time', mock_time)