Skip to content

Instantly share code, notes, and snippets.

View codemoran's full-sized avatar

Code Moran codemoran

  • Seattle, WA
View GitHub Profile
#Steps to install RVM + Ruby 1.9.2 + Rails + nginx + Passenger on CentOS (tested on v5.5)
# Install git and curl, if not already installed
sudo yum install git
sudo yum install curl
# Create the rvm group and add any users who will be using rvm to the group
sudo su -
groupadd rvm
@codemoran
codemoran / simple-web-server-node-js-with-graphdat.js
Created January 29, 2013 06:40
Simple node.js HTTP webserver
require('graphdat'); // require the graphdat module first, always!
var http = require("http"); // require the HTTP module
//
// Create the simple HTTP Server
// ### function createServer (requestCallback)
// #### @requestCallback {function} function is called on every request made.
// Create a Simple HTTP server.
// The request parameter will hold all request parameters
// The response parameter will hold all of the repsonse values sent to the client
@codemoran
codemoran / simple-webserver-with-file-IO-and-graphdat.js
Last active December 11, 2015 21:28
A Simple node.js HTTP webserver with some file IO and graphdat integration
require('graphdat').config({suppress:{context_pop_automatic:true}}); // require the graphdat module first, always!
var fs = require("fs"); // require the Filesystem module so we can read and write files
var http = require("http"); // require the HTTP module
//
// ### function createServer (requestCallback)
// #### @requestCallback {function} function is called on every request made.
//
http.createServer(function (request, response) {
@codemoran
codemoran / install-graphdat-php-module-on-xampp-with-64-bit-linux
Last active December 13, 2015 22:08
Install the graphdat PHP extension on XAMPP with x64 linux
#!/bin/sh
# get the latest
sudo apt-get update
sudo apt-get -y upgrade
# download XAMPP
wget -Oxampp-linux-1.8.1.tar.gz http://www.apachefriends.org/download.php?xampp-linux-1.8.1.tar.gz
wget -Oxampp-linux-devel-1.8.1.tar.gz http://www.apachefriends.org/download.php?xampp-linux-devel-1.8.1.tar.gz
#! /usr/bin/env python
import time
from wsgiref.simple_server import make_server
import graphdat
def application(environ, start_response):
# get the graphdat timer
graphdat = environ['graphdat']
@codemoran
codemoran / send-disk-space-to-graphdat.js
Created September 4, 2013 05:23
Use the harddrive /dev/sda1 and send the usage percentage to Graphdat to create a custom graph
var _exec = require('child_process').exec;
var _https = require('https');
var _os = require('os');
var _options = {
method: 'POST',
host: 'api.graphdat.com',
port: 443,
path: '/v1/measurements',
auth: 'sigurd@graphdat.com:api.896a98bf4f',
@codemoran
codemoran / graphdat_udp_server.js
Created September 9, 2013 06:24
Graphdat Metrics collector that listens over UDP, batches up the messages using the Graphdat batch Metrics API. http://developer.graphdat.com/v1/post/measurements
var _dgram = require('dgram');
var _https = require('https');
// How often does the UDP server flush the message queue and send to Graphdat
// To keep the graphs flowing in real time, flush every 3s
var FLUSH_TIME = 3000;
// What port should the server start up on
var SERVER_PORT = 8900;
@codemoran
codemoran / graphdat-relay-debian-init
Last active December 28, 2015 04:19
Graphdat Relay Ubuntu/Debian init.d script
#!/bin/sh
### BEGIN INIT INFO
# Provides: graphdat-relay
# Required-Start: $local_fs $remote_fs $network $named
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop the graphdat-relay
# Description: The graphdat-relay hosts plugins that send data to graphdat.com
@codemoran
codemoran / graphdat-relay-redhat-init
Last active December 28, 2015 04:29
Graphdat Relay Redhat / CentOS init script
#!/bin/sh
##
## The graphdat-relay hosts and manages the graphdat plugins.
## Batching and sending data to graphdat.com
##
# chkconfig: 345 85 15
# description: Graphdat Relay Daemon
# processname: graphdat-relay
# Source init functions
@codemoran
codemoran / restart-graphdat-on-the-local-machine.js
Last active December 31, 2015 02:29
Restart a Service on your local machine
#!/bin/env node
var exec = require('child_process').exec;
var http = require('http');
var querystring = require('querystring');
var COMMAND_TO_RUN = 'supervisorctl restart graphdat';
var PATH = '/restart-server';
var PORT = 8000;
var USERNAME = 'restart';