Skip to content

Instantly share code, notes, and snippets.

View andrashann's full-sized avatar

andrashann

View GitHub Profile
@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)),
@pgiraud
pgiraud / index.html
Last active January 18, 2023 09:53
Elevation Profile d3js
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
@my8bit
my8bit / stream.py
Created January 21, 2014 16:57
How to save youtube live stream. Python script which allows to save video by sequences
#!/usr/bin/python
# # # # # # # # # # # # # # # # # # # #
# #
# Script was made by Dennis #
# http://stefansundin.com/blog/452 #
# http://pastebin.com/8cw9LHFg #
# #
# # # # # # # # # # # # # # # # # # # #

Falsehoods programmers believe about prices

  1. You can store a price in a floating point variable.
  2. All currencies are subdivided in 1/100th units (like US dollar/cents, euro/eurocents etc.).
  3. All currencies are subdivided in decimal units (like dinar/fils)
  4. All currencies currently in circulation are subdivided in decimal units. (to exclude shillings, pennies) (counter-example: MGA)
  5. All currencies are subdivided. (counter-examples: KRW, COP, JPY... Or subdivisions can be deprecated.)
  6. Prices can't have more precision than the smaller sub-unit of the currency. (e.g. gas prices)
  7. For any currency you can have a price of 1. (ZWL)
  8. Every country has its own currency. (EUR is the best example, but also Franc CFA, etc.)

Moved

Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.

Why it was moved

Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!

@neckro
neckro / zalgo.py
Last active July 4, 2016 20:49
H͙̻͍ḙ̰ c͟͡o͕̳̻ͅm͍͚͈e̅s
#!/usr/bin/env python
from random import randint
from fileinput import input
from argparse import ArgumentParser
from sys import stdout
# "data set of leet unicode chars" stolen from
# Tchouky's Zalgo Generator on eeemo.net
@minrk
minrk / nbstripout
Last active June 6, 2023 06:23
git pre-commit hook for stripping output from IPython notebooks
#!/usr/bin/env python
"""strip outputs from an IPython Notebook
Opens a notebook, strips its output, and writes the outputless version to the original file.
Useful mainly as a git filter or pre-commit hook for users who don't want to track output in VCS.
This does mostly the same thing as the `Clear All Output` command in the notebook UI.
LICENSE: Public Domain
@tebeka
tebeka / gist:5426211
Created April 20, 2013 14:43
Serving dynamic images with Pandas and matplotlib (using flask)
#!/usr/bin/env python2
'''Serving dynamic images with Pandas and matplotlib (using flask).'''
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from cStringIO import StringIO
@brentp
brentp / linear_model.py
Created April 10, 2013 15:57
calculate t statistics and p-values for coefficients in Linear Model in python, using scikit-learn framework.
from sklearn import linear_model
from scipy import stats
import numpy as np
class LinearRegression(linear_model.LinearRegression):
"""
LinearRegression class after sklearn's, but calculate t-statistics
and p-values for model coefficients (betas).
Additional attributes available after .fit()
@urschrei
urschrei / extract_from_gpx.py
Last active February 23, 2023 22:38
Extract basic GPS data (lat, lon, elevation, timestamp) from GPX, and dump it into a CSV file. Requires the gpxpy library.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Output Elevation, Lat, Long, and Timestamp series from GPX to CSV
Requires gpxpy
This script expects your input GPX to be located in a subdir named 'data'
"""
import os