- add the couch view to back the collection (or database)
- add the model
- add the model's form view
- add the route for model's CRUD using form view
- add the collection
- add the table and row views
- add the corresponding table and row templates
- add the route for the model's collection
This file contains hidden or 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 Settings = require('../Settings.js') | |
| var request = require('request') | |
| var log = require('../util/log.js') | |
| var curl = require('node-curl') | |
| var nano = require('nano')(Settings.jerry.CouchDB.URL) | |
| var urlsDb = nano.db.use('urls') | |
| var S = require('string') | |
| var alertAdmins = require('./AlertAdmins.js') | |
| module.exports = function(urlDoc, callback) { |
This file contains hidden or 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
| <html>\n\t | |
| <head>\n\t\t | |
| <title>MtGox.com</title>\n\t</head>\n\t | |
| <body>\n\t\t | |
| <p> | |
| <img src=\ "/img/mtgox_loego_mail.png\"/> | |
| </p>\n\t\t\n\t | |
| <form id=\ "memberBlock\" class=\ "memberBlock\" action=\ "#\" method=\ "post\" autocomplete=\ "off\">\n\t\t<span class=\ "icons iconPeople\"></span>\n\t\t |
This file contains hidden or 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
| // Boiler Backbone.js helper code for a Form Route to do CRUD operations on a Model. | |
| FormRoute = function(modelId, modelClass, formClass, redirect) { | |
| var model = new App.Models[modelClass]() | |
| var form = new App.Views[formClass]({model: model}) | |
| App.$el.children('.body').html(form.el) | |
| form.once('Form:done', function() { | |
| Backbone.history.navigate(redirect, {trigger: true}) | |
| }) | |
| if (modelId) { | |
| model.id = modelId |
This file contains hidden or 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
| #copy your ssh key to root@raspberrypi | |
| ssh [email protected] 'aptitude install screen iotop' | |
| ssh [email protected] 'screen -d -m -S clone' | |
| ssh [email protected] 'echo u > /proc/sysrq-trigger' | |
| ssh [email protected] 'screen -x clone' | |
| dd if=/dev/mmcblk0 bs=1M of=/dev/sda | |
| #detach with "CRTL-a d" | |
| iotop |
This file contains hidden or 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 dirty = require("dirty")('./var/dirty.db') | |
| var ueber = require("./db/DB") | |
| ueber.init(function() { | |
| console.log('ueber initialized') | |
| var db = ueber.db | |
| dirty.on("load", function() { | |
| console.log('dirty load complete') |
Chain API is a server that your devices can interact with using HTTP POSTs and HTTP GETs for finding and managing a hierarchy of Sites>Devices>Sensors. After a device has been described to the Chain API server, that Device can then send its data via HTTP POST to the CHAIN API server. The Chain API server then publishes URIs so that other Devices can HTTP GET the historical data of a Device's Sensor(s) as well as a WebSockets URI for each Sensor for subscribing to a live feed of the data as it comes in.
To explain how to accomplish the said purpose of Chain API, I'll interact with a Chain API server using curl from the command line to carry out the following tasks.
- Create a Site on a Chain API Server
- Create a Device at that Site
- Create a Sensor at that Device
- Post data to that Sensor
This file contains hidden or 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 db = new PouchDB('http://localhost:5984/dbname'); | |
| var Thing = Backbone.Model.extend({ | |
| idAttribute: "_id", | |
| initialize: function() { | |
| var model = this | |
| var changes = db.changes({ | |
| live: true, |
This file contains hidden or 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 fs = require('fs') | |
| var New = fs.readFileSync('new.html', 'utf-8') | |
| New = New.replace(/\s/g, '') | |
| var Old = fs.readFileSync('old.html', 'utf-8') | |
| Old = Old.replace(/\s/g, '') | |
| if(New == Old) { | |
| console.log('same') | |
| } |
This file contains hidden or 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
| void setup() | |
| { | |
| Serial.begin(9600); | |
| } | |
| void loop() | |
| { | |
| Serial.println(random(300)); | |
| Serial.println("x"); | |
| delay(500); |