Skip to content

Instantly share code, notes, and snippets.

View carljm's full-sized avatar

Carl Meyer carljm

View GitHub Profile
@carljm
carljm / test_ws.py
Last active November 10, 2022 20:05
Establishing a websocket connection to SocketIO 1.x from Python
import json
import requests
from websocket import create_connection
BASE = 'localhost:3000/socket.io/?EIO=3'
# First establish a polling-transport HTTP connection to get a session ID
url = 'http://%s&transport=polling' % BASE
$ ./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 / greatest.py
Created August 21, 2014 20:46
GREATEST() of aggregates, in the Django ORM.
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')``
@carljm
carljm / db.py
Last active May 1, 2023 00:54
SQLAlchemy and Postgres autocommit
"""
SQLAlchemy, PostgreSQL (psycopg2), and autocommit
See blog post: http://oddbird.net/2014/06/14/sqlalchemy-postgres-autocommit/
"""
from contextlib import contextmanager
from sqlalchemy import create_engine, event
from sqlalchemy.orm import sessionmaker, Session as BaseSession
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,

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:

$ 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",
export GEM_HOME=$VIRTUAL_ENV/rubygems
export GEM_PATH=
export PATH=$VIRTUAL_ENV/rubygems/bin:$PATH
diff --git a/docs/ref/forms/models.txt b/docs/ref/forms/models.txt
index 46f7df1..dd0a422 100644
--- a/docs/ref/forms/models.txt
+++ b/docs/ref/forms/models.txt
@@ -33,8 +33,8 @@ Model Form Functions
``formfield_callback`` and ``widgets`` are all passed through to
:func:`~django.forms.models.modelform_factory`.
- Arguments ``formset``, ``extra``, ``max_num``, ``can_order``, and
- ``can_delete`` are passed through to
It seems to me that there's a remarkable level of consensus developing
here (though it may not look like it), and a small set of remaining open
questions.
The consensus (as I see it):
- Migrate away from scraping external HTML pages, with package owners in
control of the migration but a deadline for a forced switch, as outlined
in Holger's PEP (with all appropriate caution and testing).