Skip to content

Instantly share code, notes, and snippets.

View mikeywaites's full-sized avatar

Mike Waites mikeywaites

View GitHub Profile
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();
});
});
define(
[
'backbone',
'routers/router',
'store'
//request
{
'method': 'post',
'data': {
'some_key': 'some_val'
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
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)
class CustomQuerySet(QuerySet):
def latest(self):
return self.filter(foo=bar)
class Manager(models.Manager):
def get_query_set(self):
# coding: UTF-8
import sys
import logging
from django.core.management.base import BaseCommand
logger = logging.getLogger('command_mail')
from maps.models import Charity
"""
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()
@mikeywaites
mikeywaites / gist:5772578
Last active December 18, 2015 10:59
load django fixture sets on a test by test basis
"""
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):
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))