This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.configure(function(){ | |
app.use(function(req, res, next){ | |
if ( "GET" == req.method && "/" != req.url[ req.url.length - 1 ] ) { | |
req.url += "/"; | |
res.redirect(req.url) | |
return; | |
} | |
next(); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define( | |
[ | |
'backbone', | |
'routers/router', | |
'store' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//request | |
{ | |
'method': 'post', | |
'data': { | |
'some_key': 'some_val' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A socket connected! | |
debug - client authorized | |
info - handshake authorized oNc4ETtFzpu1xfAnncyr | |
debug - setting request GET /socket.io/1/websocket/oNc4ETtFzpu1xfAnncyr | |
debug - set heartbeat interval for client oNc4ETtFzpu1xfAnncyr | |
debug - websocket writing 7:::1+0 | |
warn - client not handshaken client should reconnect | |
info - transport end (error) | |
debug - set close timeout for client oNc4ETtFzpu1xfAnncyr | |
debug - cleared close timeout for client oNc4ETtFzpu1xfAnncyr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_latest_comments(self, event_ids, limit=3, *args, **kwargs): | |
"""Get the last 3 comments added and re-orders them into ASC | |
order | |
:param event_ids: a list of ints | |
:returns: RawQuerySet | |
""" | |
SQL = """ | |
SELECT * FROM ( | |
SELECT ROW_NUMBER() OVER (PARTITION BY event_id ORDER BY created DESC) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomQuerySet(QuerySet): | |
def latest(self): | |
return self.filter(foo=bar) | |
class Manager(models.Manager): | |
def get_query_set(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: UTF-8 | |
import sys | |
import logging | |
from django.core.management.base import BaseCommand | |
logger = logging.getLogger('command_mail') | |
from maps.models import Charity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
anything used in all tests in seUpClass | |
meaning it's only run once | |
""" | |
@classmethod | |
def setUpClass(cls): | |
cls.user = factories.UserFactory() | |
cls.fundraiser_1 = factories.SoloFundraiserFactory() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Decorate a method inside of a django TestCase test runner instance to allow you to load fixtures on a per test basis | |
Useage:: | |
from tests.decorators import load_fixtures | |
MyTestCase(TestCase): | |
@load_fixtures(['fixtures.json']) | |
def test_load_fixtures(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
UDP_IP = "127.0.0.1" | |
UDP_PORT = 9999 | |
sock = socket.socket(socket.AF_INET, | |
socket.SOCK_DGRAM) | |
#this works | |
sock.sendto("{'ref': 'new ref'}", (UDP_IP, UDP_PORT)) |