Skip to content

Instantly share code, notes, and snippets.

@helxsz
helxsz / Currentcost_Pachube.pde
Created February 17, 2012 10:14
Currentcost to Pachube for Nanode
// Home monitoring CurrentCost monitors such as CC128 and EnviR
//
// Version specifically for Nanode, www.nanode.eu
// I am using with Arduino/Freeduino and EtherShield (ENC28J60 based)
// CC128 connected to pin 0 - UART Serial in and ground
//
// If using regular Arduino or clode with FTDI chip:
// PCB track between FTTDI chip and R11 is cut to disable USB/SERIAL.
// Just short gap to re-program
//
@helxsz
helxsz / node_app_start.sh
Last active December 28, 2015 13:49
node_app_start.sh
#! /bin/sh
# /etc/init.d/myapp
#
# Don't forget to reload init.d:
# update-rc.d myapp defaults
APP='myapp'
@helxsz
helxsz / create_images_json_object_from_dir.js
Created November 17, 2013 08:20
create_images_json_object_from_dir.js
var sys = require("sys"),
fs = require("fs");
function processImageDir(path, outFilename, cb) {
fs.readdir(path, function(err, files) {
var imgfiles = [];
// Check for images and push on the array if it's a match.
files.forEach(function(name) {
@helxsz
helxsz / failed-monit-memory-script.sh
Created November 17, 2013 08:21
failed-monit-memory-script.sh
description "Memory Monitor"
author "Joe McCann"
start on startup
stop on shutdown
script
if memory usage > 75% then exec killall node
end script
The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).
In a nutshell,
1) nginx is used to serve static files (css, js, images, etc.)
2) node serves all the "dynamic" stuff.
So for example, www.foo.com request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.
3) nginx listens on port 80. 4) node listens on port 8124 (for this example only. you can change this port for your node app).
@helxsz
helxsz / Grab your twitter timeline and save in a json file.
Created November 17, 2013 08:27
Grab your twitter timeline and save in a json file.
#!/usr/bin/python2.4
import httplib, urllib, sys
twitter_handle = 'joemccann'
params = urllib.urlencode([
('screen_name', twitter_handle)
])
###
#Step 1 - Generate server certificates etc... (most of this code is horribly ripped off from nodejs docs currently -> http://nodejs.org/docs/latest/api/tls.html)
###
#Assuming your starting from a clean directory
mkdir server
cd server
#generate private key
@helxsz
helxsz / s3
Created December 12, 2013 10:13
module.exports = {
deleteObject: function (client, deleteParams) {
client.deleteObject(deleteParams, function (err, data) {
if (err) {
console.log("delete err " + deleteParams.Key);
} else {
console.log("deleted " + deleteParams.Key);
}
});
},
@helxsz
helxsz / index.html
Created March 22, 2014 11:12 — forked from mbostock/.block
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.6"></script>
</head>
<body>
<script type="text/javascript">
var svg = d3.select("body").append("svg:svg")
.attr("width", 960)
@helxsz
helxsz / a.json
Last active August 29, 2015 14:05
{
"isActive": true,
"balance": "$2,504.16",
"age": 31,
"eyeColor": "green",
"name": "Mendez Gilmore",
"gender": "male",
"registered": "2014-07-20T04:47:48 -01:00",
"latitude": 79.452285,
"longitude": -163.151555