GET [service_api_root]/status
No authentication or custom accept header required.
import math | |
from shapely.geometry import LineString | |
def get_angle(line: LineString) -> float: | |
'Returns the angle (in radians) of a given line in relation with the X axis.' | |
start, end = line.boundary | |
if end.y - start.y == 0: # Avoids dividing by zero. | |
return math.acos(0) | |
return -math.atan((end.x - start.x) / (end.y - start.y)) |
import threading | |
import time | |
import random | |
class MyThread(threading.Thread): | |
def __init__(self, num): | |
self.num = num | |
threading.Thread.__init__(self) |
I hereby claim:
To claim this, I am signing this object:
import json | |
from collections import OrderedDict | |
def serialize_with(collection_type): | |
complex_object = collection_type() | |
complex_object['z'] = collection_type() | |
complex_object['z']['c'] = 30 | |
complex_object['z']['b'] = 20 | |
complex_object['z']['a'] = 10 |
# Handshake: (resolve the addressbook_path in order to cache it) | |
# Step 1: get [principal_path] from [server_root]: | |
$ curl -X PROPFIND --user [user]:[password] -H "Depth: 1" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><A:propfind xmlns:A=\"DAV:\"><A:prop><A:current-user-principal/></A:prop></A:propfind>" [server_root] | xpath "/d:multistatus/d:response[1]/d:propstat/d:prop/d:current-user-principal/d:href/text()" | |
# Step 2: get [addressbook_list_path] from [principal_path]: | |
$ curl -X PROPFIND --user [user]:[password] -H "Depth: 1" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><A:propfind xmlns:A=\"DAV:\"><A:prop><B:addressbook-home-set xmlns:B=\"urn:ietf:params:xml:ns:carddav\"/></A:prop></A:propfind>" [server_root][principal_path] | xpath "/d:multistatus/d:response[1]/d:propstat/d:prop/card:addressbook-home-set/d:href/text()" | |
# Step 3: get [addressbook_path] from [addressbook_list_path]: | |
$ curl -X PROPFIND --user [user]:[password] -H "Depth: 1" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><A:propfind xml |
# Download this example file first: | |
# http://podcast.cbc.ca/mp3/podcasts/spark_20130623_97794.mp3 | |
import cStringIO as StringIO | |
from PIL import Image | |
import eyed3 | |
audiofile = eyed3.load("spark_20130623_97794.mp3") | |
if len(audiofile.tag.images) > 0: |
# $ pip install pygeoip | |
# $ pip install requests | |
# $ wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz | |
# $ gunzip GeoIP.dat.gz | |
import pygeoip | |
import requests # Just for hiting httplib. | |
# Example or supported countries: | |
COUNTRIES = ('br', 'mx', 'cl', 'ar') |