Skip to content

Instantly share code, notes, and snippets.

View matiskay's full-sized avatar

Edgar Marca matiskay

View GitHub Profile
javascript:( function() {
console.group( 'Performance Information for all entries of ' + window.location.href );
console.log( '\n-> Duration is displayed in ms\n ' )
var entries = window.performance.getEntries();
entries = entries.sort( function( a, b ) {
return b.duration - a.duration;
} );
@matiskay
matiskay / svmflag.py
Created August 28, 2014 03:15 — forked from glamp/svmflag.py
import numpy as np
import pylab as pl
import pandas as pd
from sklearn import svm
from sklearn import linear_model
from sklearn import tree
from sklearn.metrics import confusion_matrix
@matiskay
matiskay / svm.py
Created August 28, 2014 03:12 — forked from mblondel/svm.py
# Mathieu Blondel, September 2010
# License: BSD 3 clause
import numpy as np
from numpy import linalg
import cvxopt
import cvxopt.solvers
def linear_kernel(x1, x2):
return np.dot(x1, x2)
import json
import geojson
from shapely.geometry import shape
o = {
"coordinates": [[[23.314208, 37.768469], [24.039306, 37.768469], [24.039306, 38.214372], [23.314208, 38.214372], [23.314208, 37.768469]]],
"type": "Polygon"
}
s = json.dumps(o)
@matiskay
matiskay / xyz_vs_tms.md
Last active August 29, 2015 14:07 — forked from tmcw/xyz_vs_tms.md

The difference between XYZ and TMS tiles and how to convert between them

Lots of tile-based maps use either the XYZ or TMS scheme. These are the maps that have tiles ending in /0/0/0.png or something. Sometimes if it's a script, it'll look like &z=0&y=0&x=0 instead. Anyway, these are usually maps in Spherical Mercator.

Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps.

Most of those are in XYZ. The best documentation for that is slippy map tilenames on the OSM Wiki, and Klokan's Tiles a la Google.

When there are so many other projections to chose from, why is it that today the Mercator projection is still such a widely recognized image used to represent the globe? The answer may be simply convention or habit. The inertia of habit is a powerful force.

^Alberto Rios

The main reason Mercator's projection became so popular was because of its navigational usefulness; in his map, straight lines represent lines of constant compass bearing. However, in manipulating the map to ensure this feature, the sizes of countries become hugely distorted. In particular, the southern hemisphere appears much smaller than it is in reality.

^The Guardian

Map projections have become a popular new-journalism meme. With a quick article, you can recap centuries of cartographic history and open peoples eyes to a variety of unusual ways to shape the world. The

@matiskay
matiskay / README.md
Last active August 29, 2015 14:07 — forked from tyrasd/README.md

Plotting Node Density

  1. download the source data

     wget http://fred.dev.openstreetmap.org/density/tiles.13
     wget http://fred.dev.openstreetmap.org/density/tiles.16
    
  2. convert to simple, gnuplot-readable text format

sed 's/([0-9]) z=([0-9]) x=([0-9]) y=([0-9])/\3 \4 \1/' < tiles.13 > tiles.13.txt

#!/usr/bin/env python
###############################################################################
# $Id$
#
# Project: GDAL2Tiles, Google Summer of Code 2007 & 2008
# Global Map Tiles Classes
# Purpose: Convert a raster into TMS tiles, create KML SuperOverlay EPSG:4326,
# generate a simple HTML viewers based on Google Maps and OpenLayers
# Author: Klokan Petr Pridal, klokan at klokan dot cz
# Web: http://www.klokan.cz/projects/gdal2tiles/

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
L2 cache reference ........................... 7 ns                     14x L1 cache
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns                     20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs 4X memory

from dictalchemy import make_class_dictable
from flask import Flask, request, jsonify, json
from flask_sqlalchemy import SQLAlchemy
from jsonpatch import JsonPatch, JsonPatchException
app = Flask(__name__)
app.debug = True
db = SQLAlchemy(app)
make_class_dictable(db.Model)