Skip to content

Instantly share code, notes, and snippets.

View blackgis's full-sized avatar
🐍
Python everywhere

Richard Schoerghofer blackgis

🐍
Python everywhere
View GitHub Profile
# Import Tweepy, sleep, credentials.py
import tweepy
from time import sleep
from credentials import *
# Access and authorize our Twitter credentials from credentials.py
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
@RobertSudwarts
RobertSudwarts / deg_to_cardinal.py
Created June 7, 2015 16:18
[python] degrees to cardinal directions
def degrees_to_cardinal(d):
'''
note: this is highly approximate...
'''
dirs = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE",
"S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"]
ix = int((d + 11.25)/22.5)
return dirs[ix % 16]
@hannob
hannob / wordpress-4.2-xss-emergency-fix.diff
Created April 27, 2015 14:52
Wordpress 4.2 XSS emergency fix
--- wordpress/wp-comments-post.php 2015-01-08 08:05:25.000000000 +0100
+++ htdocs/wp-comments-post.php 2015-04-27 16:50:24.250000000 +0200
@@ -12,6 +12,12 @@
exit;
}
+$psize=0;
+foreach($_POST as $p) {
+ $psize += strlen($p);
+}
@dettmering
dettmering / gist:3767366
Created September 22, 2012 18:43
Python: Read CSV file into array
def readcsv(filename):
ifile = open(filename, "rU")
reader = csv.reader(ifile, delimiter=";")
rownum = 0
a = []
for row in reader:
a.append (row)
rownum += 1
@jeromer
jeromer / compassbearing.py
Last active February 21, 2024 13:31
compass bearing between two points in Python
# LICENSE: public domain
def calculate_initial_compass_bearing(pointA, pointB):
"""
Calculates the bearing between two points.
The formulae used is the following:
θ = atan2(sin(Δlong).cos(lat2),
cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong))