This file contains 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 api | |
# Create test client | |
cl = Client() | |
# Hit all endpoints defined in api file | |
for _, obj in inspect.getmembers(api): | |
try: | |
test_url = '/api/v1/%s/' % obj.Meta.resource_name | |
response = cl.get(test_url, {'format': 'json'}) |
This file contains 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
""" | |
Specify this settings file to run nose tests format instead of the standard Django test runner. | |
Useful for getting coverage reports and for getting xunit compaible reports for use with a CI server. | |
To run all tests: | |
> python manage.py test --settings=settings_folder.nose_settings apps | |
To run tests only for a specific app: | |
> python manage.py test --settings=settings_folder.nose_settings apps.myapp.tests |
This file contains 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
for (var i; i<10; i++) { | |
var x = $("$a-thing"); | |
// ...more work here | |
} |
This file contains 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
for i in range(10): | |
x = 4 | |
print x |
This file contains 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
for(var i=1; i<10; i++){var x = 3;}; | |
x |
This file contains 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
#!/usr/bin/env python | |
import os | |
import subprocess | |
child = subprocess.Popen('service mysqld status', shell=True, stdout=subprocess.PIPE) | |
# Capture output string | |
outstr = '' | |
while True: |
This file contains 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
var MyApp = angular.module('MyApp'); | |
MyApp.factory('msgBus', ['$rootScope', function($rootScope) { | |
var msgBus = {}; | |
msgBus.emitMsg = function(msg, data) { | |
data = data || {}; | |
$rootScope.$emit(msg, data); | |
}; | |
msgBus.onMsg = function(msg, func, scope) { | |
var unbind = $rootScope.$on(msg, func); | |
if (scope) { |
This file contains 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
# Some tips: | |
# - tips on multiple versions: http://stackoverflow.com/questions/1553165/multiple-django-sites-with-apache-mod-wsgi | |
# - using the wsgi daemon mode allows better performance with multi-threading | |
WSGISocketPrefix /var/run/wsgi | |
Alias /err/ "/var/www/error/" | |
ErrorDocument 404 /err/HTTP_NOT_FOUND.html.var | |
# The default virtual host |
This file contains 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
WSGISocketPrefix /var/run/wsgi | |
WSGIDaemonProcess site-1 user=myapp group=myapp threads=20 | |
WSGIDaemonProcess site-alt user=myapp group=myapp threads=5 | |
LoadModule ssl_module modules/mod_ssl.so | |
# Get apache listening on another port | |
# The "Listen 80" directive is in httpd.conf | |
Listen 8080 |
This file contains 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
from django.conf import settings | |
class MultiPortMiddleware(object): | |
""" | |
Middleware changes the SESSION_COOKIE_NAME to use the current port in the name | |
""" | |
def process_request(self, request): | |
settings.SESSION_COOKIE_NAME = 'sessionid' + request.META['SERVER_PORT'] |
OlderNewer