Skip to content

Instantly share code, notes, and snippets.

View charlesreid1's full-sized avatar

Chaz Reid charlesreid1

View GitHub Profile
@vgoklani
vgoklani / mongodb_drop.py
Created January 3, 2012 18:40
drop a database or collection via pymongo
# dropping a database via pymongo
from pymongo import Connection
c = Connection()
c.drop_database('mydatabase')
# drop a collection via pymongo
from pymongo import Connection
c = Connection()
c['mydatabase'].drop_collection('mycollection')
@textarcana
textarcana / git-log2json.sh
Last active August 4, 2025 13:00
Convert Git logs to JSON. The first script (git-log2json.sh) is all you need, the other two files contain only optional bonus features 😀THIS GIST NOW HAS A FULL GIT REPO: https://github.com/context-driven-testing-toolkit/git-log2json
#!/usr/bin/env bash
# Use this one-liner to produce a JSON literal from the Git log:
git log \
--pretty=format:'{%n "commit": "%H",%n "author": "%aN <%aE>",%n "date": "%ad",%n "message": "%f"%n},' \
$@ | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/'
@alexbowe
alexbowe / nltk-intro.py
Created March 21, 2011 12:59
Demonstration of extracting key phrases with NLTK in Python
import nltk
text = """The Buddha, the Godhead, resides quite as comfortably in the circuits of a digital
computer or the gears of a cycle transmission as he does at the top of a mountain
or in the petals of a flower. To think otherwise is to demean the Buddha...which is
to demean oneself."""
# Used when tokenizing words
sentence_re = r'''(?x) # set flag to allow verbose regexps
([A-Z])(\.[A-Z])+\.? # abbreviations, e.g. U.S.A.
@jmbr
jmbr / print_matrix.c
Created November 8, 2010 18:48
Print a GSL matrix.
#include <stdio.h>
#include <stddef.h>
#include <gsl/gsl_matrix.h>
int print_matrix(FILE *f, const gsl_matrix *m)
{
int status, n = 0;
for (size_t i = 0; i < m->size1; i++) {
for (size_t j = 0; j < m->size2; j++) {