most of these require logout/restart to take effect
# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false
# Set a shorter Delay until key repeat
from django import forms | |
class EmptyChoiceField(forms.ChoiceField): | |
def __init__(self, choices=(), empty_label=None, required=True, widget=None, label=None, | |
initial=None, help_text=None, *args, **kwargs): | |
# prepend an empty label if it exists (and field is not required!) | |
if not required and empty_label is not None: | |
choices = tuple([(u'', empty_label)] + list(choices)) |
import datetime | |
import time | |
import random | |
import logging | |
from minimongo.model import Model, MongoCollection | |
from pyramid.interfaces import ISession | |
from zope.interface import implements | |
from pyramid.response import Response |
# iOS builds for ARMv7 and simulator i386. | |
# Assumes any dependencies are in a local folder called libs and | |
# headers in a local folder called headers. | |
# Dependencies should already have been compiled for the target arch. | |
PROJ=untitled | |
ifeq ($(IOS), 1) | |
ARCH=armv7 | |
DEVICE=OS | |
CC_FLAGS=-arch $(ARCH) |
var mongo = require('mongodb'), | |
EventEmitter = require('events').EventEmitter; | |
function Connector(settings) { | |
settings.port = settings.port || mongo.Connection.DEFAULT_PORT; | |
this.settings = settings; | |
this.server = new mongo.Server(settings.host, settings.port); | |
this.db = new mongo.Db(settings.database, this.server, {native_parser: true}); | |
} |
update-rc.d logstash-shipper defaults | |
update-rc.d logstash-reader defaults |
var mongo = require('mongoskin'); | |
var db = mongo.db('127.0.0.1:27017/test'); | |
// create index: | |
// key, unique, callback | |
db.collection('user').ensureIndex([['name', 1]], true, function(err, replies){}); | |
// bind method: db.user ===> db.collection('user') | |
db.bind('user'); |
import unittest | |
from pyramid import testing | |
from paste.deploy.loadwsgi import appconfig | |
from webtest import TestApp | |
from mock import Mock | |
from sqlalchemy import engine_from_config | |
from sqlalchemy.orm import sessionmaker | |
from app.db import Session |
from pyramid.config import Configurator | |
from pyramid.view import view_config | |
import json | |
import logging | |
import datetime | |
log = logging.getLogger(__name__) | |
from webservice.model import Session, Machine, LogFile, LogMessage |
[tox] | |
envlist=py27,lint | |
[testenv] | |
downloadcache={homedir}/.pipcache | |
distribute=True | |
sitepackages=False | |
[testenv:py27] | |
deps=nose |