Skip to content

Instantly share code, notes, and snippets.


Paulo Alvarado czpython

View GitHub Profile

Self isolating binaries

This is a play proposal for a new wrapper around go build that would build your binary but wrap it in code that would prepare isolation around your binary on run.

A concept of this is in, in that it takes a docker image and embeds the contents into a final binary so you have a self-contained binary.

The binctr example is unnessesarily heavy for go binaries because all you need is a completely static binary.

blueyed /
Last active Dec 9, 2020
Test Django data migrations
Test (data) migrations in Django.
This uses py.test/pytest-django (the `transactional_db` fixture comes from there),
but could be easily adopted for Django's testrunner:
from django.test.testcases import TransactionTestCase
class FooTestcase(TransactionTestCase):
def test_with_django(self):
brianburridge / gist:11298396
Last active Mar 24, 2021
How to load MySQL time zone tables from Mac OS time zone files
View gist:11298396

The easiest way to load the Mysql Time Zone tables from your Mac OS time zone fields is via this command:

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

However, on many systems like mine that will fail because some of the time zone information is incompatible with the database schema for the time zone tables.

Therefore, you'll want to load the time zone information into a text file and edit it to only include the time zones you need. (Or, attempt to find the data breaking the import.)

mysql_tzinfo_to_sql /usr/share/zoneinfo > zone_import.sql
amites /
Last active Apr 25, 2021
Center Geolocations
from math import cos, sin, atan2, sqrt
def center_geolocation(geolocations):
Provide a relatively accurate center lat, lon returned as a list pair, given
a list of list pairs.
ex: in: geolocations = ((lat1,lon1), (lat2,lon2),)
out: (center_lat, center_lon)
x = 0
henriquemoody /
Last active May 20, 2021
Install Sublime Text on Fedora.
#!/usr/bin/env bash
# Usage: {script} [ OPTIONS ] TARGET VERSION
# TARGET Default target is "/usr/local".
# VERSION If not defined tries to get the build into the Sublime Text 2 website.
# -h, --help Displays this help message.
chronossc /
Created May 25, 2012
A method to get first tmp dir in list and set it to environ so tempfile.mkstemp can use anywhere and you too at any place since it cache on os.environ.
def get_tmpdir(tmpdirs=tuple()):
# use a kind of cache
if not tmpdirs and os.environ.get('SET_TMPDIR_CHOICE',False):
return os.environ['SET_TMPDIR_CHOICE']
# starting here is a snipped copyed from /usr/lib/python2.7/
dirlist = []
# First, try the environment.
lucasallan /
Created Sep 6, 2011 — forked from klebervirgilio/
Installing PostGIS on Mac OS X and Ubuntu
# Some good references are:
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start