Skip to content

Instantly share code, notes, and snippets.

View heartbeat.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import cgi
import json
import logging
import logging.handlers
import urllib2
import cgitb
import sys
View mapconvert.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import cgi
import json
import logging
import logging.handlers
import urllib2
import cgitb
#import sys
@cholin
cholin / gist:3378b204ab7513bc6024
Last active Aug 29, 2015
monitor_filter_non_reporting_nodes.py
View gist:3378b204ab7513bc6024
#!/usr/bin/env python2
import argparse
import os
import shutil
from datetime import datetime, timedelta
RRD_PATH='/var/lib/collectd/rrd/'
parser = argparse.ArgumentParser()
View api_node_updater.py
# -*- coding: utf-8 -*-
import os
import json
import urllib2
from datetime import datetime, timedelta
from sh import git, rm, cd
DATE_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'
@cholin
cholin / tree.c
Created Apr 17, 2012
simple libgit2 tree walker (like tree cli tool)
View tree.c
#include <git2.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
int strocc(char* str, char c) {
int occ = 0, i = 0;
while(str[i] != '\0')
if(str[++i] == c)
++occ;
@cholin
cholin / pygit2 api reference
Created Mar 29, 2013
pygit2 api reference
View pygit2 api reference
#### Basic API (low-level)
* public libgit2 structs should be python objects (classes) - Example: git_repository => Repository()
* nameing convention: strip git_`struct_name`_* - Example: git_repository_config() => Repository.config()
* iterations should be implemented as a generator, if this is not possible we
need to change libgit2 (other bindings will benefit from this as well)
* every method should map to one libgit2 function (exceptions are iterations)
* return values of methods
* no lists use generators instead
* no dictionaries use tuples or objects instead
* no instantiation of objects use strings instead (important for generators)