The Albers equal-area conic projection is available as d3.geo.albers. See also the interactive version.
This file contains 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
module Rubinius | |
class CompiledCode | |
def _dump(depth) | |
Marshal.dump([@scope, Rubinius::ToolSets::Runtime::CompiledFile::Marshal.new.marshal(self)]) | |
end | |
def self._load(string) | |
scope, dump = Marshal.load(string) | |
cm = Rubinius::ToolSets::Runtime::CompiledFile::Marshal.new.unmarshal(dump) | |
cm.scope = scope |
This file contains 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
def primes(): | |
prime_multiple_factors = {} | |
def add_factor(composite, factor): | |
if composite not in prime_multiple_factors: | |
prime_multiple_factors[composite] = set([factor]) | |
else: | |
prime_multiple_factors[composite].add(factor) | |
x = 2 | |
while True: |
This file contains 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
# jslen -- find the JavaScript length of a string (Python 3) | |
# | |
# Note to Python developers: since you know it as of Python 3.3, it'd | |
# be nice to have a way to find out in O(1) if a string contains any | |
# wide characters. | |
# find the preferred (i.e. faster) byte order | |
if ''.encode('utf-16') == b'\xFE\xFF': | |
preferred_encoding = 'utf-16le' | |
else: |
This file contains 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
""" | |
McCarthy's amb operator (kind of) implemented in Python | |
ᚾᚪᚻᛏ᛫ᛁᛋ᛫ᚦᚱᚫᛞᛋᛁᚳᚩᚱ | |
very unoptimized, much slow, wow | |
""" | |
class amb: | |
def __init__(self, *values): | |
self.values = tuple(values) | |
if len(self.values) < 2: |
This file contains 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
tell application "System Events" to set _app to the name of the first process whose frontmost is true | |
tell application _app | |
quit | |
set _isRunning to true | |
repeat while (_isRunning) | |
delay 1 | |
tell application "System Events" | |
set _isRunning to ((name of processes) contains _app) | |
end tell | |
end repeat |
This file contains 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
if (('devicePixelRatio' in window && window.devicePixelRatio >= 1.5) || | |
('matchMedia' in window && window.matchMedia("(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)").matches)) | |
{ | |
document.addEventListener('DOMContentLoaded', function() { | |
var elements = document.getElementsByClassName('retina'); | |
for (var i = 0; i < elements.length; i++) { | |
var element = elements[i]; | |
if (element.tagName !== 'IMG') continue; | |
var match = element.src.match(/^(.+)\.(.+?)$/); |
This file contains 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
#!/usr/bin/perl -w | |
# A smarter string capitaliser. Everyone knows that in words that start with certain prefixes, | |
# the prefix should be left in lower- or mixed-case when the word is made 'all-caps.' | |
# For instance, MacDonald becomes MacDONALD rather than MACDONALD, iPod becomes | |
# iPOD instead of IPOD, etc. This script attempts to be vaguely clever about doing that while | |
# also avoiding doing the same with intercapsed or camelcased product names like QuarkXPress. | |
# The cut-off point was set at four characters because the longest surname prefix that ought | |
# to be left in mixed-case that I could think of was 'Fitz,' but this causes problems with some | |
# product names, and they can be listed in @exceptions. Included are MacBook, AirPort, WiFi, | |
# and PostScript. If you have any other word suggestions, mail them to me at the address on |
This file contains 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
// A javascript port of my Perl string capitaliser. Possibly someone who is better at | |
// DOM scripting than me could make a script that would automatically apply this to any | |
// element styled with text-transform: uppercase. | |
// Again, the algorithm is too simple to be worth insisting on attribution, but if you | |
// do use this script anywhere, please attribute it to me in a comment block somewhere. | |
// By David Kendal, http://dpk.org.uk/ | |
// see also the original perl version at http://gist.github.com/567255 | |
function is_exception (word, exceptions) { // possibly there's a routine built-in to JavaScript to do this | |
word = word.toLowerCase(); |
This file contains 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
#!/usr/bin/perl -w | |
use strict; | |
use LWP::UserAgent; | |
use JSON; | |
use Getopt::Long; | |
use URI::Escape qw( uri_escape_utf8 ); | |
# options | |
my $query; | |
my $titles; |
OlderNewer