Skip to content

Instantly share code, notes, and snippets.

import time
import socket
def collect_metric(name, value, timestamp):
sock = socket.socket()
sock.connect( ("localhost", 2003) )
sock.send("%s %d %d\n" % (name, value, timestamp))
sock.close()
def now():
return int(time.time())
@mendhak
mendhak / gist:3996857
Created November 1, 2012 21:50
Mount an SSHFS share
sshfs username@machinename.local:/home/username /mnt/mountname -p 1234 -o allow_other -o IdentityFile=/home/mendhak/Documents/keys/id_rsa
@mendhak
mendhak / gist:1297742
Created October 19, 2011 08:37
Get a URL in Java
public static String GetUrl(String url) throws Exception
{
URL serverAddress = null;
HttpURLConnection connection = null;
// OutputStreamWriter wr = null;
BufferedReader rd = null;
StringBuilder sb = null;
String line = null;
try