Skip to content

Instantly share code, notes, and snippets.

@matzoe
matzoe / keepAlive.js
Last active August 29, 2015 14:00
keepAlive: heartbeat
(function(){
var http = require('http');
var hostUri = "http://XXX/gw/1.0/heartbeat";
var interval = 5000;
var postData = {
"gw_key": "192.168.2.2",
"heart-beat": {
"type": "xxx",
"totalclients": "12",
"version":"4,1,1,0"
@matzoe
matzoe / addon.cc
Last active March 18, 2019 11:09
Node.js callback cross threads
// http://nikhilm.github.io/uvbook/threads.html
#include <string>
#include <map>
#include <node.h>
#include <v8.h>
#include <uv.h>
#include <sys/syscall.h>
#include <stdlib.h>
@matzoe
matzoe / sona.c
Created January 26, 2014 11:54
sona.c - measure distance using HC-SR04 or HY-SRF05 ultrasonic sensor
#include <wiringPi.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <signal.h>