Skip to content

Instantly share code, notes, and snippets.

View zxdawn's full-sized avatar
🛰️
Operational

Xin Zhang zxdawn

🛰️
Operational
View GitHub Profile
@benhutchins
benhutchins / pyget2.py
Created June 3, 2010 16:14
A python download accelerator
#!/usr/bin/env python
#
# pyget2.py
# A python download accelerator
#
# This file uses multiprocessing along with
# chunked/parallel downloading to speed up
# the download of files (if possible).
#
# @author Benjamin Hutchins
@baijum
baijum / selenium_with_python.rst
Last active February 17, 2025 10:54
Selenium with Python
@rochacbruno
rochacbruno / haversine.py
Created June 6, 2012 17:43
Calculate distance between latitude longitude pairs with Python
#!/usr/bin/env python
# Haversine formula example in Python
# Author: Wayne Dyck
import math
def distance(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
@aeberspaecher
aeberspaecher / scatterPlot.py
Created August 7, 2012 10:12
Nice scatter plots with Matplotlib
#!/usr/bin/env python
#-*- coding:utf-8 -*-
"""Test different hollow Matplotlib markers for scatter plots.
Imitate Gnuplot a bit.
"""
#import matplotlib
#matplotlib.use("module://backend_pgf")
@JerryFleming
JerryFleming / this.py
Last active June 26, 2019 13:06
Zen of Python, Chinese Ultimate Final Version. The script features short (shortest?) and unreadable string. Beat me, break me!
#!/usr/bin/python
# Zen of Python, Chinese Ultimate Final Version
# by Jerry Fleming <[email protected]> at 2012-12-14
# No right reserved. Use at your own risk!
s = '''
x\x9cM\x90\xdbO\xc20\x18\xc5\xdf\xf9\xff\xff\x012%\x88K\x84\xb2\xb1Kwc\x9dv+\x17
g\xbb\x0b!\xd3\xe0D\xf0Ax\x00SHp\x89mb\xa2O\xcd\xef\xf4\x9c\xef\xebi\x8b\xdd\xa3
\x80\\\xb1\xe5\xf0\x18\xf6\xdaJ\x0b\x9d\xc6\x13\x89\xf0%Q\x05:\x07w%\xd1\xd42&P
\x1e\x12\xc7\x1f!\x15\xf8\xe0\x16\x03\x89x4-e\xb6r\xee$\xba_Z.\xd0OF\xe34\xb3
@jmnwong
jmnwong / ST2 Cycle Tabbing
Created June 28, 2013 15:24
Makes CTRL-Tab cycle tabs in order for Sublime Text.
Put in (Preferences -> Key Bindings - User):
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" }
@jackiekazil
jackiekazil / rounding_decimals.md
Last active January 17, 2024 12:29
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

@pelson
pelson / shapely.ipynb
Created March 26, 2014 15:10
Demonstration of the new shapely.vectorized functionality
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@graydon
graydon / country-bounding-boxes.py
Created April 23, 2014 00:03
country bounding boxes
# extracted from http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip
# under public domain terms
country_bounding_boxes = {
'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)),
'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)),
'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)),
'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)),
'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)),
'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)),
@pelson
pelson / us_coastal_states.ipynb
Last active July 6, 2021 12:42
Creating a shapefile representing the coastline segments of the US states.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.