Skip to content

Instantly share code, notes, and snippets.

View migonzalvar's full-sized avatar

Miguel Gonzalez migonzalvar

  • Vigo, Pontevedra, Spain
View GitHub Profile
@migonzalvar
migonzalvar / expand_tree_diagram.py
Created December 12, 2011 22:12
Expands a list of lists as a tree diagram
def expand_tree_diagram(a_list, a_branch = []):
if a_list == []:
return [a_branch]
else:
result = []
for a_leaf in a_list[0]:
result += expand_tree_diagram(a_list[1:], a_branch + [a_leaf])
return result
if __name__ == '__main__':
#!/usr/bin/env python
import subprocess
import sys
# To create the database:
#
# $ mysqladmin -u root create cvsanaly_android
# > CREATE USER 'cvsanaly'@'localhost' IDENTIFIED BY 'cvsanaly';
# > GRANT ALL ON cvsanaly_android.* TO 'cvsanaly'@'localhost';
@migonzalvar
migonzalvar / vigbay2012.R
Created April 1, 2012 18:11
Visualization of Vig-Bay 2012 half marathon results
#!/usr/bin/Rscript --vanilla --default-packages=utils
#
# (c) 2012 Miguel Gonzalez <migonzalvar@gmail.com>
#
# This work is licensed under a Creative Commons Attribution 3.0 Unported
# License. (CC BY 3.0)
#
# Data source: http://www.vig-bay.com/index.php?option=com_content&view=article&id=518&Itemid=164
str_to_seconds <- function(s){
import os
import re
import time
import subprocess
import ajenti
from ajenti.api import *
from ajenti.api.http import *
from ajenti.plugins import manager
%define git_version %(git describe --tags 2> /dev/null || echo 0.0-`git log --oneline | wc -l`-g`git describe --always`)
%define git_get_ver %(echo %{git_version} | sed 's/^v\\?\\(.*\\)-\\([0-9]\\+\\)-g.*$/\\1/;s/-//')
%define git_get_rel %(echo %{git_version} | sed 's/^v\\?\\(.*\\)-\\([0-9]\\+-g.*\\)$/\\2/;s/-/_/')
Name: xsce-virtual
Summary: XSCE virtual package to isolate xs-config and xs-tools dependencies
Version: %git_get_ver
Release: %git_get_rel
License: GPLv3

Enable offline install using pip

This works as expected:

# export PIP_NO_INDEX=true                             
# export PIP_FIND_LINKS=http://xsce.activitycentral.com/wheelhouse/pip/ 
@migonzalvar
migonzalvar / imageholder.py
Created March 6, 2014 18:20
Create a square image. Requires PIL (or pillow)
#!/usr/bin/env python
"""Create a square image. Usage:
$ imageholder.py filename size color
"""
import sys
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#! /usr/bin/env python3
""" grep.py - Search a string in a file. """
import sys
# Parse arguments
pattern, file_name = sys.argv[1:3]
with open(file_name, 'rt') as f: