Skip to content

Instantly share code, notes, and snippets.

View adamghill's full-sized avatar

Adam Hill adamghill

View GitHub Profile
@adamghill
adamghill / logging.py
Created November 29, 2013 14:57
Django logging configuration (with Sentry)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'root': {
'level': 'DEBUG',
'handlers': ['console', 'sentry'],
},
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
@adamghill
adamghill / logging.py
Created December 9, 2013 15:20
Django logging configuration
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'root': {
'level': 'DEBUG',
'handlers': ['console', ],
},
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
@adamghill
adamghill / up.sh
Last active October 19, 2018 19:23
Shell script to start up a Django project using pipenv
#!/bin/sh
set -e
PIPENV_VENV_IN_PROJECT=1 pipenv --version
if [ $? -eq 0 ]; then
if [ "$1" == "--install" ]; then
PIPENV_VENV_IN_PROJECT=1 pipenv install --dev
fi
@adamghill
adamghill / parse_available_io_domains.py
Last active December 31, 2015 00:09
Validate that an .io TLD is available to purchase. Uses https://gist.github.com/isaacbw/6831088#file-available-txt as the initial seed of domains to check. Props to http://whomsy.com/ for not blocking me.
import requests
gist_url = 'https://gist.github.com/isaacbw/6831088/raw/33b0072c6160f0fe304e998fa04715117456414d/available.txt'
gist_response = requests.get(gist_url)
if gist_response.ok:
with open('available.txt', 'w') as file:
lines = gist_response.content.split('\n')
available_count = 0
abaci.io
aback.io
abaft.io
abase.io
abash.io
abate.io
abbe.io
abbess.io
abbey.io
abbot.io
@adamghill
adamghill / python_sql_server.md
Last active January 2, 2016 03:49
Access Sql Server from Python on OSX
  1. brew install freetds
  2. pip install pymssql==2.0.1
  3. vim ~/.odbc.ini
[dsn]
Driver = FreeTDS
Server = SERVER
Database = DATABASE
Port = 1604
@adamghill
adamghill / messages_and_errors_django_template.html
Created January 3, 2014 21:20
Show messages and errors in Django templates. Useful to just throw in a base template.
{% if messages %}
{% for message in messages %}
<div class="alert {% if message.tags %} alert-{{ message.tags }}{% endif %}">{{ message|safe }}</div>
{% endfor %}
{% endif %}
{% if form.errors %}
<div class="alert alert-error">
<h4>Please fix the following errors</h4>
<ul>
@adamghill
adamghill / handle_stupid_python_on_snow_leopard.txt
Created January 4, 2014 16:13
How to handle invalid mach-o architecture error for Python on Snow Leopard OS X. From http://api.mongodb.org/python/current/installation.html#osx.env.
env ARCHFLAGS='-arch i386 -arch x86_64' pip install {PACKAGE_NAME}
e.g. env ARCHFLAGS='-arch i386 -arch x86_64' pip install psycopg2
@adamghill
adamghill / views.js
Last active March 15, 2024 22:00
Django AJAX forms. Uses a bunch of requirements installed in https://github.com/adamghill/django-template.
(function() {
$('a.button').click(function(e) {
var $form = $("#form");
$('#error').hide();
$('input').removeClass('error');
var handleError = function() {
$('#error').show();
}