Skip to content

Instantly share code, notes, and snippets.

Paulo Alvarado czpython

Block or report user

Report or block czpython

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View proposal.md

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 https://github.com/jfrazelle/binctr, 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
blueyed / test_django_data_migration.py
Last active Mar 12, 2019
Test Django data migrations
View test_django_data_migration.py
"""
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
brianburridge / gist:11298396
Last active May 17, 2019
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
amites / center_geo.py
Last active Jul 20, 2019
Center Geolocations
View center_geo.py
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
henriquemoody / sublime-text-2.sh
Last active Jul 14, 2018
Install Sublime Text on Fedora.
View sublime-text-2.sh
#!/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.
#
# OPTIONS
#
# -h, --help Displays this help message.
#
@chronossc
chronossc / get_tmpdir.py
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.
View get_tmpdir.py
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/tempfile.py
dirlist = []
# First, try the environment.
@sh286
sh286 / install_postgis_osx.sh
Created Sep 6, 2011 — forked from klebervirgilio/install_postgis_osx.sh
Installing PostGIS on Mac OS X and Ubuntu
View install_postgis_osx.sh
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#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
You can’t perform that action at this time.