Skip to content

Instantly share code, notes, and snippets.

View peterwallhead's full-sized avatar
👨‍💻
Currently focusing on ROS 2 & SLAM.

Peter Wallhead peterwallhead

👨‍💻
Currently focusing on ROS 2 & SLAM.
View GitHub Profile
@oodavid
oodavid / README.md
Last active April 8, 2026 18:20 — forked from aronwoost/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@jeromer
jeromer / compassbearing.py
Last active June 2, 2026 19:01
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))
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@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
@bcarl
bcarl / backends.py
Created July 6, 2012 06:08
Django Email as Username Authentication Backend
from django.contrib.auth.models import User, check_password
class LoginUsingEmailAsUsernameBackend(object):
"""
Custom Authentication backend that supports using an e-mail address
to login instead of a username.
See: http://blog.cingusoft.org/custom-django-authentication-backend
"""
supports_object_permissions = False
@imkevinxu
imkevinxu / template.html
Created August 16, 2012 02:11
Django code to read uploaded CSV file
<form action="{% url %}" method="post" enctype="multipart/form-data">{% csrf_token %}
<input type="file" name="csv_file" />
<input type="submit" value="Upload" />
</form>
@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007
@iso100
iso100 / ga-link-tracking.js
Created October 7, 2012 13:03
jQuery for Tracking Outbound Links in GA
@lucasvo
lucasvo / test_helpers.py
Created October 26, 2012 22:01
Flask Unit Test Helpers
import json as jsonlib
def response_success(response, code=200):
if 200 <= code < 300:
assert 200 <= response.status_code < 300
assert code == response.status_code
def response_error(response, code=400):
if 400 <= code < 500:
assert 400 <= response.status_code < 500
@NickJosevski
NickJosevski / guids.md
Last active September 18, 2017 00:35
Used Guids, share the love.

Used Guid Reporting

Ever wondered if that that GUID you're about to use has already been consumed?

No.

Well you should. Check the twitter feed - twitter.com/UsedGuid, and start reporting your usage of GUIDs. It's the right thing to do.

Throw away those old paper based systems.