Skip to content

Instantly share code, notes, and snippets.

View manfre's full-sized avatar

Michael Manfre manfre

View GitHub Profile

Keybase proof

I hereby claim:

  • I am manfre on github.
  • I am manfre (https://keybase.io/manfre) on keybase.
  • I have a public key whose fingerprint is 50A3 DAC5 25A5 7C63 27EB 1E3E 74DE D158 BAD0 EDF8

To claim this, I am signing this object:

@manfre
manfre / check_for_updates.py
Created November 14, 2011 16:21 — forked from zyegfryed/check_for_updates.py
Check locally installed packages against one or more package indexes for updates and list them. Using subprocess instead of stdout (wasn't working on my MacPython 2.6.1). Removed curses dependency to allow it to work on windows.
#!/usr/bin/env python
"""
Use pip to get a list of local packages to check against one or more package
indexes for updated versions.
"""
import sys
import xmlrpclib
import subprocess
from distutils.version import StrictVersion, LooseVersion
@manfre
manfre / gist:1443360
Created December 7, 2011 16:07
Waffle flag view decorator
from django.http import HttpResponse
from django.template import RequestContext
from django.template.loader import render_to_string
from django.utils.decorators import available_attrs
import waffle
def waffled_view(function=None, flag=None, template='503-waffled.html', **kwargs):
"""
Check the decorated view to see if the flag is enabled for the current
request. Any kwargs will be made available to the template.
@manfre
manfre / manfre-pycarolinas-django-on-windows.rst
Created July 31, 2012 14:38
PyCarolinas Proposal - Django on Windows

PyCarolinas Talk Proposal: Django on Windows

Presented by Michael Manfre

Overview

www.src.org, a case study of running Django in a Windows environment. This talk will describe the Semiconductor Research Corporation's (SRC) website,

@manfre
manfre / gist:4502333
Last active December 10, 2015 22:28 — forked from Pharylon/gist:4502183
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
class SQLCompiler(compiler.SQLCompiler):
def resolve_columns(self, row, fields=()):
# If the results are sliced, the resultset will have an initial
# "row number" column. Remove this column before the ORM sees it.
if getattr(self, '_using_row_number', False):
row = row[1:]
values = []
index_extra_select = len(self.query.extra_select.keys())
for value, field in map(None, row[index_extra_select:], fields):
@manfre
manfre / gist:6691126
Created September 24, 2013 20:57
Django test suite run with sqlite on Python 2.7.5
======================================================================
FAIL: test_templates (template_tests.tests.TemplateTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\projects\django\django\tests\template_tests\tests.py", line 621, in test_templates
('-'*70, ("\n%s\n" % ('-'*70)).join(failures)))
AssertionError: Tests failed:
----------------------------------------------------------------------
Template test (Cached='False', TEMPLATE_STRING_IF_INVALID='', TEMPLATE_DEBUG=False): filter-timeuntil10 -- FAILED. Expected u'0\xa0minutes', got u'59\xa0minutes'
----------------------------------------------------------------------
@manfre
manfre / subquerytests.py
Created September 25, 2013 21:12
Improved SubqueryTests to cover some potential problem areas for database backends that must do some trickery for slicing
class SubqueryTests(TestCase):
def setUp(self):
DumbCategory.objects.create(id=1)
DumbCategory.objects.create(id=2)
DumbCategory.objects.create(id=3)
DumbCategory.objects.create(id=4)
def test_ordered_subselect(self):
"Subselects honor any manual ordering"
try:
class ItemGroup(models.Model):
name = models.CharField(max_length=10)
group_type = models.CharField(max_length=10, default='test')
class Item(models.Model):
group = models.ForeignKey(ItemGroup,
related_name='items',
limit_choices_to={
'group_type__in': ('test'),