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 spiDev = "/dev/spidev0.0"; | |
var cePin = 24; | |
var irqPin = 25; | |
var nrf = require('nrf'); | |
var radio = nrf.connect(spiDev, cePin, irqPin); // Connect to the radio | |
radio.channel(0x4c); // Set channel to 76 | |
radio.dataRate('1Mbps') // Set data rate to 1Mbps | |
radio.crcBytes(2) // Set the CRC to 2 | |
radio.autoRetransmit({ |
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 json | |
import tornado.web | |
class JsonHandler(BaseHandler): | |
"""Request handler where requests and responses speak JSON.""" | |
def prepare(self): | |
# Incorporate request JSON into arguments dictionary. | |
if self.request.body: | |
try: |
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
// file: app/models/user.js | |
// Get an instance of mongoose and mongoose Schema | |
var mongoose = require('mongoose'), | |
bcrypt = require('bcrypt'), | |
Schema = mongoose.Schema, | |
SALTINESS = 42; | |
// Create Schema | |
var UserSchema = new Schema({ |
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
# mdadm --create /dev/md0 --level=1 --raid-devices=(int multiple of 2) /dev/sd* /dev/sd** ... |
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
/* | |
IoT Manager mqtt device client https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager | |
Based on Basic MQTT example with Authentication | |
PubSubClient library v 1.91.1 https://github.com/Imroy/pubsubclient | |
- connects to an MQTT server, providing userdescr and password | |
- subscribes to the topic "/IoTmanager" (waiting "HELLO" messages from mobile device) | |
- publishes config to the topic "/IoTmanager/config/deviceID/" | |
Tested with Arduino IDE 1.6.7 + ESP8266 Community Edition v 2.1.0-rc2 | |
PubSubClient library v 1.91.1 https://github.com/Imroy/pubsubclient |
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
{ | |
"logging": { | |
"version": 1, | |
"disable_existing_loggers": true, | |
"formatters": { | |
"brief": { | |
"class": "logging.Formatter", | |
"datefmt": "%I:%M:%S", | |
"format": "%(levelname)-8s; %(name)-15s; %(message)s" | |
}, |
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 get_item_from_dict_list_by_key_value(list, key, value): | |
""" | |
Return an item from a list by key:value combination if possible | |
:param list list: | |
:param str key: | |
:param * value: | |
:return dict|None: | |
""" | |
for item in list: | |
if item[key] == value: |
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 promote_item_to_first_position(enumerator, key, value): | |
""" | |
Promotes an item to the first index of the list if it isn't already there. It moves the item from it's current | |
position and resets the list's indexes. Be careful to not use this on a giant list, because the operation could | |
be quite heavy. With small lists the impact is not noticeable. | |
:param enumerator: | |
:param key: | |
:param value: | |
:return: | |
""" |
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 get_value_by_multilevel_key(key, data): | |
""" | |
returns a value by a multilevel key reference e.g. 'object.foo.bar' as key returns the value 10 | |
(see below) | |
{ | |
object: { | |
foo: | |
bar: 10 | |
} | |
} |
OlderNewer