Skip to content

Instantly share code, notes, and snippets.

View joshourisman's full-sized avatar

Josh Ourisman joshourisman

View GitHub Profile
@classmethod
def import_events_to_django(klas, events):
num_created = 0
num_updated = 0
num_skipped = 0
events_dict = {int(event['id']): event for event in events}
existing_django_events = klas.objects.in_bulk(events_dict.keys())
for key in existing_django_events:
(virtualenv)project :: (±branch) » ./manage.py shell ~/Projects/project
Python 2.7.3 (default, Aug 11 2012, 18:22:59)
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.60))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from exceptions import UnicodeEncodeError
>>> from app.module import RECORD_TYPES
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/josho/Projects/project/app/module.py", line 2, in <module>
import sys
def equal(triplet):
return len(set(triplet)) == 1
def finished(world):
for i in range(len(world)):
if len(world[i:]) < 3:
for Model, relations in RELATIONSHIPS.items():
fields = [relations[relation]['field'] \
for relation in relations \
if relations[relation]['model'] is Constituent]
relationship_fields = {field: '{}_constituent_id'.format(field) \
for field in fields}
or_filters = [Q(**{'{}__isnull'.format(field): True}) \
for field in fields]
null_relations = reduce(lambda x, y: x | y, or_filters)
filters = null_relations
try:
django_obj = self.django_model.objects.get(my_field=value)
except self.django_model.DoesNotExist:
try:
django_obj = self.django_model.objects.get(**{
'other_field1': other_value1,
'other_field2': other_value2,
'other_field3': other_value3,
'other_field4': other_value4,
})
#
# Cookbook Name:: solr
# Recipe:: default
#
# Copyright 2012, Example Com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
class AsyncRegistrationTestCase(ResourceTestCase):
def setUp(self):
super(AsyncRegistrationTestCase, self).setUp()
self.resource = RegistrationResource()
self.resource.get_resource_uri()
def test_resource_uri(self):
self.assertNotEqual('', self.resource.get_resource_uri())
def test_resource_uri_2(self):
~ » brew doctor ~
Warning: Experimental support for using Xcode without the "Command Line Tools".
You have only installed Xcode. If stuff is not building, try installing the
"Command Line Tools for Xcode" package provided by Apple.
Warning: You are using Mac OS X 10.9.
We do not yet provide support for this (unreleased) version.
~ » brew --config ~ 1 ↵
HOMEBREW_VERSION: 0.9.4
ORIGIN: https://github.com/mxcl/homebrew
Уважаемые Граждане Еврейской Национальности!
В связи с тем, что лидеры еврейской общины Украины поддержали бандеровскую хунту в Киеве и враждебно
настроены в отношений православной Донецкой республики и её граждан, Главный Штаб Донецкой народной
республики постановил следующее:
Всем гражданам еврейской национальности старше 16 лет, проживающим на территории суверенной Донецкой
республики, необходимо в срок до 03 мая 2014г. явиться к и.о. комиссара по делам национальностей в здание
Донецкой ОДА каб. 514 для регистрации составляет 50 долларов США.
from django.conf import settings
from django.db import models
class Project(models.Model):
editors = models.ManyToManyField(
settings.AUTH_USER_MODEL, through='EditorMap', related_name='editable')
viewers = models.ManyToManyField(
settings.AUTH_USER_MODEL, through='ViewerMap', related_name='viewable')