This file contains hidden or 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://stackoverflow.com/questions/4640348/why-do-scrollbars-appear-when-using-a-svg-element-inside-a-div/4642713#4642713 | |
| svg { | |
| display:block; | |
| } |
This file contains hidden or 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
| I found this: http://bl.ocks.org/mbostock/1129492 | |
| But it doesn't work when you want the svg to be responsive to the browser window size: | |
| svg = d3.select("#network").append("svg") | |
| .attr("viewBox", "0 0 " + width + " " + height) | |
| .attr("preserveAspectRatio", "xMidYMid meet"); | |
| Since the height and width are the units of the svg now, we need to account for when the height and width aren't the same as when initialized. Note that for this example, height = width = 800. This example needs to be alters if height != width. | |
| var currentWidth = $("svg").width(); |
This file contains hidden or 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
| I was having an issue that a function in another file wasn't seeing a variable in another file: | |
| http://stackoverflow.com/questions/22545559/javascript-design-patterns-with-meteor/22546366 | |
| file scope | |
| var x = 10; | |
| meteor global scope | |
| x = 10; |
This file contains hidden or 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
| I spent way too long trying to get this to work. | |
| Template.search.events({ | |
| 'keyup input#search': function(e, t) { | |
| if (e.keyCode == 13) { | |
| // if the user presses enter to select a typeahead | |
| var node = Nodes.findOne({ | |
| title: e.target.value | |
| }); |
This file contains hidden or 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 MyException(Exception): | |
| def __init__(self, msg): | |
| Exception.__init__(self, msg) | |
| if True: | |
| raise MyException("fucked up") |
This file contains hidden or 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 pkg_resources | |
| def version(packageName): | |
| return pkg_resources.get_distribution(packageName).version | |
| package = "matplotlib" | |
| print package + ": " + version(package) |
This file contains hidden or 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 pylab import * | |
| # Some Log rules: | |
| # a*b = log(a) + log(b) | |
| # a/b = log(a) - log(b) | |
| # a**b = b*log(a) | |
| # exp(log(x)) = log(exp(x)) = x | |
| # | |
| # The Trick: | |
| # log(a + b) = log(a + b) - log(c) + log(c) |
This file contains hidden or 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 collections | |
| import functools | |
| memoized = [] | |
| def clearAllMemoized(): | |
| [m.reset() for m in memoized] | |
This file contains hidden or 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
| function randomInRange(min,max) { | |
| var random = Math.floor(Math.random() * (max - min + 1)) + min; | |
| return random; | |
| } |
This file contains hidden or 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
| randomInRange = function(min, max) { | |
| var random = Math.floor(Math.random() * (max - min + 1)) + min; | |
| return random; | |
| } | |
| randomFromCollection = function(C) { | |
| return function() { | |
| c = C.find().fetch(); | |
| i = randomInRange(0, c.count()) |
OlderNewer