Skip to content

Instantly share code, notes, and snippets.

View stefano-maggiolo's full-sized avatar

Stefano Maggiolo stefano-maggiolo

View GitHub Profile
#!/usr/bin/env python
import math
import sys
from collections import defaultdict
if __name__ == "__main__":
if len(sys.argv) != 3:
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Contest Management System - http://cms-dev.github.io/
# Copyright © 2014 Stefano Maggiolo <s.maggiolo@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
@stefano-maggiolo
stefano-maggiolo / UnmanagedCommunication.py
Created March 19, 2017 19:38
A first draft of a clone of communication but without stub and using stdin/stdout instead of named fifos.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Contest Management System - http://cms-dev.github.io/
# Copyright © 2010-2012 Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
# Copyright © 2010-2017 Stefano Maggiolo <s.maggiolo@gmail.com>
# Copyright © 2010-2012 Matteo Boscariol <boscarim@hotmail.com>
# Copyright © 2012-2014 Luca Wehrstedt <luca.wehrstedt@gmail.com>
# Copyright © 2016 Masaki Hara <ackie.h.gmai@gmail.com>
#
@stefano-maggiolo
stefano-maggiolo / aggregate.sh
Last active August 29, 2017 00:56
git blame aggregations
#!/usr/bin/env bash
find ./ -type f -and \! -path './.git/*' -print0 | xargs -0 -L1 git blame -wMMMCCC --line-porcelain >> /tmp/allblames
cat /tmp/allblames | grep ^author\ | cut -d\ -f 2- | sort | uniq -c | sed -r -e 's/( *[0-9]+ )/\1\t/g' | sort -n -r > /tmp/loc-by-author
cat /tmp/allblames | grep ^committer-time\ | cut -d\ -f 2 | xargs -L1 -I{} date -d @{} +%Y-%m | sort | uniq -c | sed -r -e 's/( *[0-9]+ )/\1\t/g > /tmp/loc-by-month
cat /tmp/allblames | grep ^committer-time\ | cut -d\ -f 2 | xargs -L1 -I{} date -d @{} +%Y | sort | uniq -c | sed -r -e 's/( *[0-9]+ )/\1\t/g > /tmp/loc-by-year
for EXP in py js rst html; do
find ./ -type f -and -name "*.$EXP" -and \! -path './.git/*' -print0 | xargs -0 -L1 git blame -wMMMCCC --line-porcelain >> /tmp/allblames-$EXP
cat /tmp/allblames-$EXP | grep ^author\ | cut -d\ -f 2- | sort | uniq -c | sed -r -e 's/( *[0-9]+ )/\1\t/g' | sort -n -r > /tmp/loc-by-author-$EXP