Skip to content

Instantly share code, notes, and snippets.

View vrootic's full-sized avatar
🏠
Working from home

Vic vrootic

🏠
Working from home
View GitHub Profile
from urllib.request import urlopen
# Original class
class UrlTemplate:
def __init__(self, template):
self.template = template
def open(self, **kwargs):
return urlopen(self.template.format_map(kwargs))
def print_msg(msg):
def printer():
print(msg)
printer()
print_msg("hello") # hello
def print_msg(msg):
def printer():
# Suppose I have a list of points, I want to order this list by calculating distance for specific points.
from functools import partial
import math
points = [(1, 2), (3, 4), (5, 6), (7, 8)]
def distance(p1, p2):
x1, x2 = p1
y1, y2 = p2
return math.hypot(x2 - x1, y2 - y1)
x = 10
a = lambda y: x + y
x = 20
b = lambda y: x + y
a(10) # 30
b(10) # 30
x = 15
a(10) # 25
def spam(a, b=42):
print(a, b)
spam(1) # a=1, b=42
spam(1, 2) # a=1, b=2
def spam(a, b=None):
if b is None:
b = []
def add(x: int, y: int) -> int:
return x + y
import time
import sys
import json
from threading import Thread
from collections import OrderedDict
from tweepy.streaming import StreamListener
from tweepy.api import API
from tweepy import OAuthHandler
from tweepy import Stream
import matplotlib.pyplot as plt
import cv2
fig = plt.figure("fig_1")
ax = fig.add_subplot(1, 1, 1)
image = cv2.imread("xxx.jpg")
ax.imshow(image)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
#%matplotlib inline
X = np.linspace(0, 10, 256)
plt.plot(X)
OSRM build on Linux Ubuntu 14.04LTS
1.
sudo apt-get install build-essential git cmake pkg-config \
libbz2-dev libstxxl-dev libstxxl-doc libstxxl1 libxml2-dev \
libzip-dev libboost-all-dev lua5.1 liblua5.1-0-dev libluabind-dev libtbb-dev
2.
git clone https://github.com/Project-OSRM/osrm-backend.git
cd osrm-backend