Skip to content

Instantly share code, notes, and snippets.

View randomradio's full-sized avatar
🎯
Focusing

i.an randomradio

🎯
Focusing
View GitHub Profile
@randomradio
randomradio / gitignore
Created March 20, 2017 16:59
my gitignore for node/python/virtualenv/golang/osx
# Compiled Python files
*.pyc
# Folder view configuration files
.DS_Store
Desktop.ini
# Thumbnail cache files
._*
Thumbs.db
@randomradio
randomradio / karabiner xml
Last active March 20, 2017 16:59
my karabiner configuration, continue in progress
<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>VORTEX</vendorname>
<vendorid>0x04d9</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>POK3R</productname>
<productid>0x0141</productid>
@randomradio
randomradio / maps.utils.js
Last active June 27, 2017 20:15 — forked from joseadrian/maps.utils.js
Google Maps. Detect if one of the points on the polyline paths intersects a circle
(function(){
var polyline = new google.maps.Polyline();
google.maps.Polyline.prototype.closestDistanceToSegment = function(center, segment)
{
var firstPoint, lastPoint, A, B, C, D, E, distanceAB, t, projection = this.getMap().getProjection();
// The other extreme of the path
lastPoint = segment[0];
@GrahamDumpleton
GrahamDumpleton / gist:b380652b768e81a7f60c
Last active February 1, 2024 16:58
Setting environment variables for Apache/mod_wsgi hosted Python application.

Django documentation says to use:

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIPythonPath /path/to/mysite.com

<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Require all granted
@bmcbride
bmcbride / geojson-length.py
Created March 31, 2014 20:41
Calculate the length of a GeoJSON linestring using the Python GDAL/OGR API
from osgeo import ogr
from osgeo import osr
source = osr.SpatialReference()
source.ImportFromEPSG(4326)
target = osr.SpatialReference()
target.ImportFromEPSG(3857)
transform = osr.CoordinateTransformation(source, target)
@hest
hest / gist:8798884
Created February 4, 2014 06:08
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
@lucacioria
lucacioria / domains_api_tutorial.markdown
Last active December 21, 2015 10:29
Google+ Domains API with Service Accounts (Quick Start Tutorial in Python on App Engine)

Google+ Domains API - Quick Start

introduction

Google+ Domains API are meant to interact with your G+ accounts in the domain. With these APIs you can manage circles, read and write posts, shares, and comments etc.. more informations here

This tutorial is for creating an application that uses the Domains API, running on Google App Engine with python.

create GAE (Google App Engine) app

@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active May 7, 2024 01:27
A badass list of frontend development resources I collected over time.
@miohtama
miohtama / gist:5389146
Created April 15, 2013 15:56
Decoding emails in Python e.g. for GMail and imapclient lib
import email
def get_decoded_email_body(message_body):
""" Decode email body.
Detect character set if the header is not set.
We try to get text/plain, but if there is not one then fallback to text/html.
:param message_body: Raw 7-bit message body input e.g. from imaplib. Double encoded in quoted-printable and latin-1