Skip to content

Instantly share code, notes, and snippets.

View thomasvnl's full-sized avatar

Thomas V. thomasvnl

  • Dordrecht, The Netherlands
View GitHub Profile
@thomasvnl
thomasvnl / user.js
Last active July 8, 2017 06:42
NodeJS Mongoose User Schema to be used within a default NodeJS application structure
// 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({
@thomasvnl
thomasvnl / jsonhandler.py
Created February 1, 2016 10:05 — forked from mminer/jsonhandler.py
A JSON request handler for Tornado.
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:
@thomasvnl
thomasvnl / nrftest.js
Last active December 14, 2016 22:04
Example of using the nRF24L01+ with Node.js on the Raspberry Pi
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({
@thomasvnl
thomasvnl / footer.php
Created December 22, 2014 12:34
WordPress Twenty Fifteen Disqus Thread modification to make it blend in with the rest of the template.