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
function diameterToZoom (diameter) { | |
var zoom = Math.floor(19 - Math.log(diameter / 1000) / Math.LN2); | |
return zoom < 0 ? 0 : zoom > 20 ? 20 : zoom; | |
} | |
// tested with these values: | |
// diameter = zoom | |
// 758 = 19 | |
// 1515 = 18 | |
// 3031 = 17 |
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
class ConstStruct | |
def self.derive(name) | |
cls = Class.new(ConstStruct) | |
cls.instance_variable_set :@name, name | |
def cls.name; @name end | |
def cls.inspect; @name end | |
def cls.to_s; @name end | |
cls | |
end |
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
// "License": Public Domain | |
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like. | |
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to | |
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it | |
// an example on how to get the endian conversion functions on different platforms. | |
#ifndef PORTABLE_ENDIAN_H__ | |
#define PORTABLE_ENDIAN_H__ | |
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__) |
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
#!/bin/bash | |
do_printf=off | |
incs="" | |
flags="$CFLAGS" | |
only_preproc=off | |
no_asm=off | |
if [ "$CC" = "" ]; then | |
CC=gcc |
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
#!/bin/bash | |
incs="" | |
flags="$CXXFLAGS" | |
only_preproc=off | |
no_asm=off | |
no_space=off | |
if [ "$CXX" = "" ]; then | |
CXX=g++ |
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
#include <stdio.h> | |
#include <complex.h> | |
#define dc double complex | |
dc | |
Y(dc | |
V, | |
dc B,dc c){ | |
return | |
(cabs (V)<6)?(c?Y(V *V+ | |
B,B,c-1):c):(2+c-4*cpow |
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
CPP = g++ | |
LIB = `Magick++-config --cppflags --cxxflags --ldflags --libs` -lboost_thread-mt | |
CPPFLAGS = -Wall -O3 `Magick++-config --cppflags --cxxflags` | |
LDFLAGS = $(LIB) -Wall -O3 | |
BIN = visprim | |
.PHONY: all zip clean | |
all: $(BIN) |
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/env python | |
import sys | |
import Image | |
from itertools import islice | |
def primes(): | |
yield False # 0 | |
yield False # 1 | |
yield True # 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
Create a new bookmark and set it's URL to this: | |
javascript:(function(xs)%7Bfor(var%20i%3D0%3Bi%3Cxs.length%3B%2B%2Bi)%7Bif(xs%5Bi%5D.currentSrc)%7Breturn%20window.open(xs%5Bi%5D.currentSrc)%3B%7D%7D%7D)(document.querySelectorAll('audio%2Cvideo'))%3B | |
When media is playing using HTML5 audio/video you can click this bookmark to open a new tab/window with the media. Then to download it use the context menu action "Save As..." (right mouse button -> Save As...). | |
If you use Chrome/Safari/recent Opera (WebKit/Blink) you can do better(!) and immediately download the file using this bookmarklet instead: | |
javascript:(function(xs)%7Bfor(var%20i%3D0%3Bi%3Cxs.length%3B%2B%2Bi)%7Bif(xs%5Bi%5D.currentSrc)%7Bvar%20a%3Ddocument.createElement('a')%3Ba.target%3D'_blank'%3Ba.download%3D''%3Ba.href%3Dxs%5Bi%5D.currentSrc%3Ba.click()%3Breturn%3B%7D%7D%7D)(document.querySelectorAll('audio%2Cvideo'))%3B |
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/env python | |
import os | |
import re | |
import sys | |
import argparse | |
from os.path import abspath, join as pathjoin, splitext | |
from stat import S_ISREG, S_ISDIR |