| const hoverTime = 400 | |
| const fetchers = {} | |
| const doc = document.implementation.createHTMLDocument('prefetch') | |
| function fetchPage (url, success) { | |
| const xhr = new XMLHttpRequest() | |
| xhr.open('GET', url) | |
| xhr.setRequestHeader('VND.PREFETCH', 'true') | |
| xhr.setRequestHeader('Accept', 'text/html') | |
| xhr.onreadystatechange = () => { |
One of the many reasons I love working with Ruby is it has a rich vocabulary that allows you to accomplish your goals with a minimal amount of code. If there isn't a method that does exactly what you want, it's usually possible to build an elegant solution yourself.
Let's take the example of simulating the rolling of a die.
We can represent a die as an array of its faces.
die = [*?⚀..?⚅]
# => ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]| import numbers | |
| import six | |
| import numpy | |
| import matplotlib.collections | |
| from matplotlib import pyplot | |
| # using example from | |
| # http://nbviewer.ipython.org/github/dpsanders/matplotlib-examples/blob/master/colorline.ipynb |
| /* | |
| * System Versioning Preprocessor Macros | |
| */ | |
| #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) | |
| #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) | |
| #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) | |
| #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) | |
| #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) |