Skip to content

Instantly share code, notes, and snippets.

@j4rs
j4rs / client.js
Created July 9, 2012 22:26
NodeJS GCM Server to send message to android devices...
var GCM = require('./gcm');
var gcm = new GCM(<YOUR GOOGLE API KEY>); // https://code.google.com/apis/console
// create the message
var msg = {
registration_ids: [token], // this is the device token (phone)
collapse_key: "your_collapse_key", // http://developer.android.com/guide/google/gcm/gcm.html#send-msg
time_to_live: 180, // just 30 minutes
data: {
@jameswalton
jameswalton / node_temperature.js
Created April 30, 2013 13:13
Node application to serve temperature readings
var http = require('http');
var fs = require('fs');
var url = require('url');
var fileLocation = '/sys/bus/w1/devices/28-000003b74282/w1_slave';
http.createServer(function (req, res) {
var request_url = url.parse(req.url).pathname;
if (request_url == '/temperature.json') {
fs.readFile(fileLocation, 'utf8', function(err, data) {
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';