Goal: Connect to MSSQL using FreeTDS / ODBC in Python.
Host: Ubuntu 11.10 x86_64
Install:
sudo apt-get install freetds-dev freetds-bin unixodbc-dev tdsodbc
pip install pyodbc sqlalchemy
In /etc/odbcinst.ini:
var path = require('path'); | |
var webpack = require('webpack'); | |
module.exports = { | |
entry: [ | |
'react-hot-loader/patch', | |
'webpack-dev-server/client?http://localhost:3000/', | |
'webpack/hot/only-dev-server', | |
path.resolve(__dirname, 'app/index') | |
], |
import {Injectable, EventEmitter} from 'angular2/core'; | |
@Injectable() | |
export class EmitterService { | |
private static _emitters: { [ID: string]: EventEmitter<any> } = {}; | |
static get(ID: string): EventEmitter<any> { | |
if (!this._emitters[ID]) | |
this._emitters[ID] = new EventEmitter(); | |
return this._emitters[ID]; |
DATABASE_URL=postgres://USERNAME:PASSWORD@127.0.0.1/DATABASE | |
MEMCACHE_SERVERS=127.0.0.1:11211 | |
DJANGO_SETTINGS_MODULE=settings.development.local |
class DynamicFieldsMixin(object): | |
""" | |
A serializer mixin that takes an additional `fields` argument that controls | |
which fields should be displayed. | |
Usage:: | |
class MySerializer(serializers.HyperlinkedModelSerializer, DynamicFieldsMixin): | |
class Meta: | |
model = MyModel |
from uuid import UUID | |
def validate_uuid4(uuid_string): | |
""" | |
Validate that a UUID string is in | |
fact a valid uuid4. | |
Happily, the uuid module does the actual | |
checking for us. |
Goal: Connect to MSSQL using FreeTDS / ODBC in Python.
Host: Ubuntu 11.10 x86_64
Install:
sudo apt-get install freetds-dev freetds-bin unixodbc-dev tdsodbc
pip install pyodbc sqlalchemy
In /etc/odbcinst.ini:
# replaces default django logging config | |
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': False, | |
'handlers': { | |
'mail_admins': { | |
'level': 'ERROR', | |
'class': 'django.utils.log.AdminEmailHandler' | |
}, | |
'null': { |
var oldSync = Backbone.sync; | |
Backbone.sync = function(method, model, options){ | |
options.beforeSend = function(xhr){ | |
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN); | |
}; | |
return oldSync(method, model, options); | |
}; |
def save_m2m(self, bundle): | |
""" | |
Handles the saving of related M2M data. | |
Due to the way Django works, the M2M data must be handled after the | |
main instance, which is why this isn't a part of the main ``save`` bits. | |
Currently slightly inefficient in that it will clear out the whole | |
relation and recreate the related data as needed. | |
""" |
from django.db import models | |
import uuid | |
class UUIDField(models.CharField): | |
""" | |
A field which stores a UUID value in hex format. This may also have | |
the Boolean attribute 'auto' which will set the value on initial save to a | |
new UUID value (calculated using the UUID1 method). Note that while all | |
UUIDs are expected to be unique we enforce this with a DB constraint. |