Skip to content

Instantly share code, notes, and snippets.

@mrry
mrry / tensorflow_self_check.py
Last active August 24, 2023 17:13
[DEPRECATED] TensorFlow on Windows self-check
# 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 February 14, 2018 08:09
Autoscale and center topojson d3v3
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 30, 2023 05:03
SVG foreignObject tooltips in D3

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 September 2, 2011 14:23
Mocking time to do time-sensitive unit tests in Python
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)