Skip to content

Instantly share code, notes, and snippets.

View czpython's full-sized avatar

Paulo Alvarado czpython

View GitHub Profile
@Daenyth
Daenyth / debug_requests.py
Created August 27, 2015 14:35
Enable debug logging for python requests
import requests
import logging
import httplib
# Debug logging
httplib.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
req_log = logging.getLogger('requests.packages.urllib3')
req_log.setLevel(logging.DEBUG)
@brianburridge
brianburridge / gist:11298396
Last active October 8, 2023 12:49
How to load MySQL time zone tables from Mac OS time zone files

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
@kyhau
kyhau / devpiNotes.md
Last active October 2, 2023 21:01
devpi Quick Start Guide

devpi Quick Start Guide

For details see Quickstart: uploading, testing, pushing releases

How to add the devpi index to your pip configuration file

Update C:\Users\username\pip\pip.ini on Windows 8/10, or ~/.config/pip/pip.conf on Linux

[global]
@amites
amites / center_geo.py
Last active October 15, 2021 23:14
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
henriquemoody / sublime-text-2.sh
Last active July 8, 2021 09:54
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.
#
# OPTIONS
#
# -h, --help Displays this help message.
#
@blueyed
blueyed / test_django_data_migration.py
Last active December 9, 2020 16:20
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):
@jessfraz
jessfraz / proposal.md
Last active September 15, 2017 02:59

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.

@lucasallan
lucasallan / install_postgis_osx.sh
Created September 6, 2011 21:03 — forked from klebervirgilio/install_postgis_osx.sh
Installing PostGIS on Mac OS X and Ubuntu
# 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
@chronossc
chronossc / get_tmpdir.py
Created May 25, 2012 11:11
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/tempfile.py
dirlist = []
# First, try the environment.