Skip to content

Instantly share code, notes, and snippets.

@jkeyes
jkeyes / gist:2057216
Created March 17, 2012 09:54
python-intercom blurb
from intercom import Intercom
from intercom import User
...
Intercom.api_key = 'xxx'
Intercom.api_id = 'yyy'
...
user = User.find_by_email('[email protected]')
user.custom_data['age'] = 42 user.save()
...
user.created_at # datetime object
@jkeyes
jkeyes / gist:3830479
Created October 3, 2012 23:10
Standalone functions to disable and restore Django transaction support
from django.db import connections
from django.db import transaction
def disable_transaction_methods():
from django.test.testcases import disable_transaction_methods
for db in connections:
transaction.enter_transaction_management(using=db)
transaction.managed(True, using=db)
@jkeyes
jkeyes / gist:3830501
Created October 3, 2012 23:16
Disabling and restoring Django transaction support in a TestCase
# See https://gist.github.com/3830479 for disable_ and restore_ functions
from unittest import TestCase
class Test(TestCase):
@classmethod
def class_setup(cls):
disable_transaction_methods()
# ... import test fixtures
@jkeyes
jkeyes / mongo.py
Created November 21, 2012 13:11 — forked from kennethreitz/mongo.py
MongoHQ w/ pymongo on Heroku
import os
import pymongo
from urlparse import urlparse
MONGO_URL = os.environ.get('MONGOHQ_URL')
if MONGO_URL:
# Get a connection
conn = pymongo.Connection(MONGO_URL)
@jkeyes
jkeyes / acme.rst
Created November 28, 2012 10:21
ReST Hyperlink with Unicode

The following ReST:

|Acme(TM)|_

.. |Acme(TM)| unicode:: Acme U+2122
.. _Acme(TM): http://example.com

produces this HTML:

|Acme(TM)|_

@jkeyes
jkeyes / index.coffee
Last active December 10, 2015 06:18
Updated sample code for the "Stitch It Up" example from "The Little Book of CoffeeScript".
"use strict"
require("coffee-script")
stitch = require("stitch")
express = require("express")
argv = process.argv.slice(2)
pkg = stitch.createPackage(
# Specify the paths you want Stitch to automatically bundle up
paths: [ __dirname + "/app"],
@jkeyes
jkeyes / 1-pre.md
Last active December 14, 2015 17:39
A tagged pre block extension (1-pre.md). The `prettypre` extension inserts 'prettyprint' into the class attribute of the `pre` and if there is an additional token it inserts a language class on the `code` element (a child of `pre`) (2-pre.html). And the result after prettifying (3-pretty-pre.html).
@prettyprint python
class PrettyPreExtension (markdown.Extension):

    def extendMarkdown(self, md, md_globals):
        md.registerExtension(self)
        self.processor = PreTreeprocessor()
        self.processor.md = md
        self.processor.config = self.getConfigs()
@jkeyes
jkeyes / wercker.yml
Last active December 18, 2015 13:09
Install lessc on wercker
box: wercker/python
build:
steps:
- script:
name: "install lessc with sudo"
code: |-
curl https://npmjs.org/install.sh | sudo bash
sudo npm install less -g
- script:
name: "install lessc locally"
@jkeyes
jkeyes / async.py
Created August 21, 2013 21:00
Docraptor async example
import time
from docraptor import DocRaptor
docraptor = DocRaptor()
print "Create PDF"
# resp = docraptor.create({
# 'document_content': '<h1>python-docraptor</h1><p>Async Test</p>',
# 'test': True,
# 'async': True
@jkeyes
jkeyes / wercker.yml
Created September 2, 2013 13:48
Heroku Deploy on Wercker
deploy:
steps:
- heroku-deploy
- script:
name: install heroku-exit-status plugin
code: heroku plugins:install https://github.com/glenngillen/heroku-exit-status.git
- script:
name: migrate with south
code: heroku run "python manage.py migrate" -a $HEROKU_APP_NAME