Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

# -*- 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 / gist:3378b204ab7513bc6024
Last active August 29, 2015 14:09
monitor_filter_non_reporting_nodes.py
#!/usr/bin/env python2
import argparse
import os
import shutil
from datetime import datetime, timedelta
RRD_PATH='/var/lib/collectd/rrd/'
parser = argparse.ArgumentParser()
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import cgi
import json
import logging
import logging.handlers
import urllib2
import cgitb
#import sys
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import cgi
import json
import logging
import logging.handlers
import urllib2
import cgitb
import sys
@cholin
cholin / pygit2 api reference
Created March 29, 2013 13:48
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)
@cholin
cholin / tree.c
Created April 17, 2012 12:52
simple libgit2 tree walker (like tree cli tool)
#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;