Skip to content

Instantly share code, notes, and snippets.

Avatar

Carl Meyer carljm

View GitHub Profile
View postactivate
export GEM_HOME=$VIRTUAL_ENV/rubygems
export GEM_PATH=
export PATH=$VIRTUAL_ENV/rubygems/bin:$PATH
View gist:9086090
$ curl -s -XGET 'http://localhost:9200/_settings?pretty'
{
"jlor" : {
"settings" : {
"index.analysis.analyzer.default.filter.1" : "lowercase",
"index.analysis.analyzer.default.filter.0" : "standard",
"index.analysis.analyzer.default.tokenizer" : "standard",
"index.analysis.analyzer.default.type" : "custom",
"index.number_of_shards" : "5",
"index.number_of_replicas" : "1",
View keybase.md

Keybase proof

I hereby claim:

  • I am carljm on github.
  • I am carljm (https://keybase.io/carljm) on keybase.
  • I have a public key whose fingerprint is 3C32 FA99 DC96 932C 2204 6A41 2D1F B791 6A52 E121

To claim this, I am signing this object:

View tox.ini.diff
diff --git a/tox.ini b/tox.ini
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,9 @@
[tox]
envlist=
py26-1.3,py26-1.4,py26-1.5,py26-1.6,
- py27-1.3,py27-1.4,py27-1.5,py27-1.6,py27-1.7,py27-master
+ py27-1.3,py27-1.4,py27-1.5,py27-1.6,py27-1.7,py27-master,
+ py33-1.5,py33-1.6,py33-1.7,py33-master,
@carljm
carljm / greatest.py
Created Aug 21, 2014
GREATEST() of aggregates, in the Django ORM.
View greatest.py
class Greatest(object):
"""A pseudo- (or meta-) aggregate; returns highest of sub-aggregates.
This has to be inserted directly into the Query internals; it can't go
through the usual ``qs.annotate(...)`` or ``qs.aggregate(...)`` path
(because that leads to ``Query.add_aggregate(...)`` which makes assumptions
we can't meet).
To use, instantiate ``Greatest`` with one or more normal aggregates, and
call ``greatest_instance.add_to_qs(queryset, 'name')``
View gist:e4fbf46d51c311834926
$ ./tests/runtests.py migrations
Testing against Django installed in '/home/carljm/projects/django/django/django/django'
Creating test database for alias 'default'...
Creating test database for alias 'other'...
..................................................................................................................................s...............................EE.EE.E..........s.......................................
======================================================================
ERROR: test_squashmigrations_squashes (migrations.test_commands.SquashMigrationsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/carljm/projects/django/django/django/django/test/utils.py", line 187, in inner
@carljm
carljm / patch.diff
Created Feb 12, 2015
draft patch for --fake-initial doc updates
View patch.diff
diff --git a/docs/topics/migrations.txt b/docs/topics/migrations.txt
index a0dc365..fae87a0 100644
--- a/docs/topics/migrations.txt
+++ b/docs/topics/migrations.txt
@@ -148,6 +148,13 @@ developers (or your production servers) check out the code, they'll
get both the changes to your models and the accompanying migration at the
same time.
+.. versionadded:: 1.8
+
@carljm
carljm / test.py
Created Mar 24, 2015
playing with logging
View test.py
from logging.config import dictConfig
import logging
initial = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
@carljm
carljm / deploy.wsgi
Created Jan 27, 2011
A mod_wsgi deployment file for Django that handles a virtualenv, putting its paths in front
View deploy.wsgi
import os, sys, site
base = os.path.dirname(os.path.dirname(__file__))
project = os.path.join(base, 'project')
virtenv = os.path.join(base, 'env')
### virtual environment, with precedence over global env ###
# from http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
View Exception wrapping is dumb
def unwrap_template_syntax_error(function, *unwrap_exceptions):
"""
A decorator to catch TemplateSyntaxError and unwrap it, reraising the
wrapped exception.
If unwrap_exceptions are passed, the unwrapping will only occur if the
wrapped exception is one of those exception types.
"""
@wraps(function)
You can’t perform that action at this time.