Original link: http://www.concentric.net/~Ttwang/tech/inthash.htm
Taken from: http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
Reformatted using pandoc
Thomas Wang, Jan 1997
last update Mar 2007
| /* | |
| You'll need something like this in your HTML: | |
| <script src="http://d3js.org/topojson.v1.min.js"></script> | |
| */ | |
| L.TopoJSON = L.GeoJSON.extend({ | |
| addData: function(jsonData) { | |
| if (jsonData.type === "Topology") { | |
| for (key in jsonData.objects) { | |
| geojson = topojson.feature(jsonData, jsonData.objects[key]); |
Original link: http://www.concentric.net/~Ttwang/tech/inthash.htm
Taken from: http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
Reformatted using pandoc
Thomas Wang, Jan 1997
last update Mar 2007
| # to generate your dhparam.pem file, run in the terminal | |
| openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
| # Note (November 2016): | |
| # This config is rather outdated and left here for historical reasons, please refer to prerender.io for the latest setup information | |
| # Serving static html to Googlebot is now considered bad practice as you should be using the escaped fragment crawling protocol | |
| server { | |
| listen 80; | |
| listen [::]:80; | |
| server_name yourserver.com; | |
| root /path/to/your/htdocs; |
Say you have a package with this layout:
my_project/
my_app/
files/
im_a_file.txt
__init__.py
run_my_app.py
| var svg = document.querySelector( "svg" ); | |
| var svgData = new XMLSerializer().serializeToString( svg ); | |
| var canvas = document.createElement( "canvas" ); | |
| var ctx = canvas.getContext( "2d" ); | |
| var img = document.createElement( "img" ); | |
| img.setAttribute( "src", "data:image/svg+xml;base64," + btoa( svgData ) ); | |
| img.onload = function() { |
tl;dr: Avoid Box<T> in general.
Actually, this rule is so important that the Rust Pointer Guide explicitly says the same. Therefore without a further ado, you should avoid Box<T> except for these three cases:
When you absolutely need a trait object (Box<Trait>). But review carefully to see if it is indeed absolutely needed; you may try to generalize things too far, for example.
When you have a recursive data structure. This may be mandatory when you have an inherently recursive data (e.g. scene graph), but it may also be a sign of the premature optimization. Again, review carefully to see if you need to write a separate data structure yourself, and use the collection crate if possible.
| from itertools import chain, starmap | |
| def remove_spans(s, spans): | |
| to_drop = set(chain(*starmap(range, spans))) | |
| return ''.join(c for (i, c) in enumerate(s) if i not in to_drop) |
| def memoize_to_file(func=None, **options): | |
| """Wraps a function definition so that if the function is ever | |
| called with the same arguments twice, the results are pulled from | |
| a cache stored in a file. The filename is specified when decorating | |
| the memoized function. Iterable objects like dicts, lists or | |
| pandas DataFrames are cast to a tuple before being hashed, and | |
| everything else uses the object's __repr__ definition. | |
| Usage: |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)