Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am nicpottier on github.
  • I am nicpottier (https://keybase.io/nicpottier) on keybase.
  • I have a public key whose fingerprint is 85A0 51C6 259A BBD3 716C D714 CCED 409A F5EF D044

To claim this, I am signing this object:

explain analyze select count(*) from msgs_msg where org_id=2 and visibility='V' and direction='I' and msg_type='I';
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=315633.66..315633.67 rows=1 width=0) (actual time=34491.919..34491.920 rows=1 loops=1)
-> Index Only Scan using msg_visibility_direction_type_created_inbound on msgs_msg (cost=0.56..315328.62 rows=122015 width=0) (actual time=1.668..34384.518 rows=252775 loops=1)
Index Cond: ((org_id = 2) AND (visibility = 'V'::text) AND (direction = 'I'::text) AND (msg_type = 'I'::text))
Heap Fetches: 252775
Total runtime: 34491.989 ms
(5 rows)
explain analyze SELECT "flows_flowstep"."id", "flows_flowstep"."run_id", "flows_flowstep"."contact_id",
"flows_flowstep"."step_type", "flows_flowstep"."step_uuid", "flows_flowstep"."rule_uuid", "flows_flowstep"."rule_category",
"flows_flowstep"."rule_value", "flows_flowstep"."rule_decimal_value", "flows_flowstep"."next_uuid", "flows_flowstep"."arrived_on",
"flows_flowstep"."left_on" FROM "flows_flowstep"
WHERE ("flows_flowstep"."rule_uuid" IS NULL AND
"flows_flowstep"."step_uuid" = '76e71f2a-f15a-405d-b81f-36e847d3f09b' AND
"flows_flowstep"."next_uuid" = '9fca130c-eba5-4445-8ab9-88c60f55690b')
ORDER BY "flows_flowstep"."left_on" DESC LIMIT 15;
rapidsms=> \d flows_flowstep;
Table "public.flows_flowstep"
Column | Type | Modifiers
--------------------+--------------------------+-------------------------------------------------------------
id | integer | not null default nextval('flows_flowstep_id_seq'::regclass)
step_type | character varying(1) | not null
step_uuid | character varying(36) | not null
arrived_on | timestamp with time zone | not null
left_on | timestamp with time zone |
rule_uuid | character varying(36) |
@nicpottier
nicpottier / gist:086715b6e42cdd072a3d
Created May 20, 2014 16:20
Generating Documentation from UserVoice Knowledge Base Articles
def generate_docs(): # pragma: no cover
"""
Generates a single html file that contains all the knowledge base articles we have on
UserVoice, organized by topic.
"""
config = settings.USERVOICE_CONFIG
client = uservoice.Client(config['SUBDOMAIN_NAME'],
config['API_KEY'],
config['API_SECRET'])
### Keybase proof
I hereby claim:
* I am nicpottier on github.
* I am nicpottier (https://keybase.io/nicpottier) on keybase.
* I have a public key whose fingerprint is A8E9 24FC 6C4C C28B 30D1 0F9D 09C2 B99A 2245 296F
To claim this, I am signing this object:
@nicpottier
nicpottier / view_permission.py
Created March 22, 2011 07:43
Adds a view permission to all your models in Django
from django.db.models.signals import post_syncdb
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import Permission
def add_view_permissions(sender, **kwargs):
"""
This syncdb hooks takes care of adding a view permission too all our
content types.
"""
# for each of our content types
@nicpottier
nicpottier / readme.rst
Created July 29, 2010 13:28
Authenticating in MoinMoin using Apache2's HTTP Auth Digest

HTTP Auth Digest for MoinMoin

Tested on apache2 on ubuntu.

  1. Enable auth_digest:

    # ln -s /etc/apache2/mods-available/auth_digest.load /etc/apache2/mods-enabled
  2. Create your digest file:
@nicpottier
nicpottier / PageEditor.py
Created July 29, 2010 08:05
Restructured Text, Pygments, CodeMirror and Moin Moin, all playing together.
# -*- coding: iso-8859-1 -*-
"""
MoinMoin - PageEditor class
PageEditor is used for r/w access to a wiki page (edit, rename, delete operations).
TODO:
* See comments in Page.py, most apply here, too.
* The editor code should be modularized so we will be able to use it for any
text/* mimetype data with some special features enabled depending on the
@nicpottier
nicpottier / README
Created April 17, 2010 17:03
Simple Django template tag to get the image URL for a photologue photo by slug.
This gist is just a simple Django template tag that will output the display
URL for a photologue photo looked up by slug. This satisfies my need for using
Photologue simple as an admin interface to managing photos that I'm including
in flatpages.
Usage
=====
Just put photos.py in your templatetags directory. Make sure photologue
is installed, then create a new photo object.