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
int leds[] = {D4, D3, D2, D1, D0}; | |
int led_count = 5; | |
int timer = 15; | |
void setup() { | |
for (int i = 0; i < led_count; i++) { | |
pinMode(leds[i], OUTPUT); | |
} | |
} |
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
#include "RCSwitch/RCSwitch.h" | |
RCSwitch mySwitch = RCSwitch(); | |
int ledPin = D7; | |
int inputPin = D3; | |
int outputPin = D2; | |
int flagsCount = 6; | |
bool lightFlags[6]; | |
char* onCodes[] = { |
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
class OrderStatus(object): | |
NEW = 'new' | |
PAID = 'paid' | |
DELIVERED = 'delivered' | |
CANCELLED = 'cancelled' | |
COMPLETED_STATES = ( | |
DELIVERED, | |
CANCELLED, |
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
# project-repo/app/settings/.env-example | |
# | |
# DJANGO | |
# | |
SITE_HOST=localhost:8000 | |
USE_SSL=False | |
ALLOWED_HOSTS=localhost,127.0.0.1 | |
SECRET_KEY=asdasd | |
DEBUG=true # never on production, will cause settings including api keys to leak | |
DJANGO_LOG_LEVEL=DEBUG |
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 logging | |
logger = logging.getLogger('django_auth_ldap') | |
logger.addHandler(logging.StreamHandler()) | |
logger.setLevel(logging.DEBUG) |
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
class XMPPSettingsTestCase(SettingsTestCaseMixin, TestCase): | |
nested_setting = 'XMPP_SETTINGS' | |
SETTINGS = ( | |
('host', basestring), | |
('conference_host', basestring), | |
('endpoint', basestring), | |
('archive_timezone', (basestring, datetime.tzinfo)), | |
) |
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
/* Making jquery ajax POST requests work with django builtin csrf protection. | |
* Taken from: | |
* https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax | |
*/ | |
jQuery(document).ajaxSend(function(event, xhr, settings) { | |
function getCookie(name) { | |
var cookieValue = null; | |
if (document.cookie && document.cookie !== '') { | |
var cookies = document.cookie.split(';'); |
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.test import TestCase, Client | |
URLS = ( | |
{} | |
) | |
class MyTest(TestCase): | |
def create_test_client(self, urldata): |
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
def is_enumerable(collection): | |
"""Checks if the variable is not a basestring instance and can be | |
enumerated. | |
""" | |
try: | |
# strings can be iterated - that's not what we want | |
if isinstance(collection, basestring): | |
return False | |
# avoid opening a generator | |
if isinstance(collection, types.GeneratorType): |
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
def model_attrs_unicode(instance, attrs=None): | |
"""Helper for creating simple instance string descriptions. | |
Accepts a list of string attributes names or functions that can be given by | |
specifying attrs or defining __UNICODE__ATTRS on the model. | |
If a get_{fieldname}_display method exists, it will be used instead of | |
simple getattr. | |
Attrs can contain function that accept model instance and return | |
(attrname, val) pairs, both must be unicode strings. |
NewerOlder