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
// Restify Server CheatSheet. | |
// More about the API: http://mcavage.me/node-restify/#server-api | |
// Install restify with npm install restify | |
// 1.1. Creating a Server. | |
// http://mcavage.me/node-restify/#Creating-a-Server | |
var restify = require('restify'); |
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
import time | |
import socket | |
def collect_metric(name, value, timestamp): | |
sock = socket.socket() | |
sock.connect( ("localhost", 2003) ) | |
sock.send("%s %f %f\n" % (name, value, timestamp)) | |
sock.close() | |
def now(): | |
return int(time.time()) |
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
import base64 | |
from django.http import HttpResponse | |
from django.contrib.auth import authenticate | |
from django.conf import settings | |
def view_or_basicauth(view, request, *args, **kwargs): | |
# Check for valid basic auth header | |
if 'HTTP_AUTHORIZATION' in request.META: |
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
#!/usr/bin/env python | |
# Tiny Syslog Server in Python. | |
## | |
# This is a tiny syslog server that is able to receive UDP based syslog | |
# entries on a specified port and save them to a file. | |
# That's it... it does nothing else... | |
# There are a few configuration parameters. | |
# create a ramdisk if you want to use stoe logs on the ram disk. (faster thant |