Skip to content

Instantly share code, notes, and snippets.

👾
Invading

Santiago Espinosa Saigesp

👾
Invading
Block or report user

Report or block Saigesp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SVG_font_to_SVG_icons.py
import sys
with open('svg-font.svg', 'r') as r:
lines = r.read().split('\n')
glyphs = [x for x in lines if '<glyph' in x]
# for every glyph element in the file
for i in range(0, len(glyphs)):
with open(str(i + 1).rjust(3, '0') + '.svg', 'w') as w:
w.write('<?xml version="1.0" standalone="no"?>\n')
w.write('<svg width="1500px" height="1500px" version="1.1" xmlns="http://www.w3.org/2000/svg">\n')
View airbnb_guest_procedence.py
# -*- coding: UTF-8 -*-
import csv, urllib2, time
from bs4 import BeautifulSoup
# python -c "from airbnb_guest_procedence import *; crawler()"
def read_external_csv(url, delimiter=','):
data = []
for row in csv.DictReader(urllib2.urlopen(url), delimiter=delimiter):
View airbnb_geoscrapping.py
# -*- coding: UTF-8 -*-
import time, json, urllib, math
from pymongo import MongoClient
# python -c "from crawler2 import *; iterar_sobre_area(44.00766,-1.083201,40.544736,-1.75312)"
def deg_to_rad(deg):
return deg * (math.pi/180)
def get_distance_from_latlon_km(lat1,lon1,lat2,lon2):
@Saigesp
Saigesp / copyfiles.py
Created Sep 14, 2017
Copy files recursively with python
View copyfiles.py
# -*- coding: utf-8 -*-
import os, shutil
def copyfiles(src, dst_dir, symlinks=False, ignore=None):
for src_dir, dirs, files in os.walk(src):
folder = src_dir.replace(src, '')
folders = folder[1:].split('\\')
@Saigesp
Saigesp / ESP_MAD_adm5.json
Last active Oct 6, 2017
Madrid neighborhoods
View ESP_MAD_adm5.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Saigesp
Saigesp / ESP_VAL_adm5.json
Last active Oct 6, 2017
Valencia neighborhoods
View ESP_VAL_adm5.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View fix_geojson.py
# -*- coding: UTF-8 -*-
import os, json, time
from area import area
from termcolor import colored
# python3 -c "from fix_geojson import *; fix_geojson('ESP_MAD_adm6.json')"
def fix_geojson(filename):
try:
@Saigesp
Saigesp / GoogleMapsAPI_get_region_name.py
Created Oct 8, 2017
Function to retrieve region name based on administrative level and coordinates.
View GoogleMapsAPI_get_region_name.py
import os, json, time
import requests
from urllib.request import Request, urlopen
from termcolor import colored
debug_msg = True
def get_region_name(lat,lng,region_type):
def adm_parser(regtype):
tr = {
@Saigesp
Saigesp / catcsv.py
Created Sep 23, 2018
Para recortar archivos CSV desde la linea de comandos
View catcsv.py
# -*- coding: utf-8 -*-
import sys
import csv
from collections import deque
from itertools import islice
def skip_last_n(iterator, n=1):
it = iter(iterator)
prev = deque(islice(it, n), n)
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Premier</title>
</head>
<style>
body {
position: relative;
width: 100%;
You can’t perform that action at this time.