Skip to content

Instantly share code, notes, and snippets.

View mgara's full-sized avatar
🎯
Focusing

Meher mgara

🎯
Focusing
  • Meher Gara Consulting
  • Montreal
  • 21:26 (UTC -04:00)
View GitHub Profile
// 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');
@mgara
mgara / graphite-client.py
Last active July 20, 2016 14:26 — forked from codification/graphite-client.py
Graphite client in python
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())
@mgara
mgara / decorators.py
Created June 9, 2016 15:04 — forked from codeinthehole/decorators.py
Basic auth for Django snippet
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:
@mgara
mgara / pysyslog.py
Created January 28, 2016 17:08 — forked from marcelom/pysyslog.py
Tiny Python Syslog Server
#!/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