Skip to content

Instantly share code, notes, and snippets.

View jvrplmlmn's full-sized avatar

Javier Palomo jvrplmlmn

View GitHub Profile
@jvrplmlmn
jvrplmlmn / configparser_example.py
Created October 28, 2013 13:02
Examples of the Python core library module "ConfigParser", that helps you creating and interacting with configuration files.
import os
import ConfigParser
def createConfig(path):
"""
Create a config file
"""
config = ConfigParser.ConfigParser()
config.add_section("Settings")
config.set("Settings", "font", "Courier")
@jvrplmlmn
jvrplmlmn / purgate_files.py
Created October 3, 2013 09:04
Purgate files older than the given days.
#!/usr/bin/env python
import os, time, sys, datetime
path = "/foo/bar"
days = 30
threshold = days * 86400
now = time.time()
timestamp = datetime.datetime.fromtimestamp(now).strftime('%Y-%m-%d %H:%M:%S')
@jvrplmlmn
jvrplmlmn / stars-rating.tex
Created September 28, 2013 17:47
A small LaTeX script to get an X out of Y rating using colored stars. Requires the tikz package
% Example of x-out of-y rating using stars
% http://tex.stackexchange.com/questions/11390/drawing-stars-similar-with-tikz
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\newcommand\score[2]{
\pgfmathsetmacro\pgfxa{#1+1}
\tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw, inner sep=1.3pt, anchor=outer point 3]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PyQt4 import QtCore, QtGui
class TreeItem(object):
def __init__(self, data, parent=None):
self.parentItem = parent
self.itemData = data
self.childItems = []
@jvrplmlmn
jvrplmlmn / Log.pm
Created June 16, 2013 22:13
Perl logger example, using a perl module
package Log;
my $filename = '';
sub start {
shift @_;
($filename) = @_;
return (-1, "Filename missing") if (!$filename);
open (F_LOG, ">>$filename") || return (-1, "Error in file $filename: $!");
@jvrplmlmn
jvrplmlmn / tree.py
Last active February 24, 2020 12:45
Python implementation of tree command
# -*- coding: utf-8 -*-
from os import walk, sep
from os.path import basename, isdir
from sys import argv
def tree(startpath, print_files=False):
for root, subdirs, files in walk(startpath):
level = root.replace(startpath, '').count(sep)
indent = ' |' * (level-1) + ' +- '
@jvrplmlmn
jvrplmlmn / gzcl2csv.py
Last active May 25, 2016 15:12
Calculator for the "GZCL method for powerlifting"
# -*- encoding: utf-8 -*-
import math
import csv
plate = 2.5
days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']
exercises = ['Squat', 'Bench', 'Deadlift', 'Bench', 'Squat']
tier1 = [[85, 1, 3], [87.5, 2, 2], [90, 3, 1]]
tier2 = [[70, 7, 5], [75, 6, 4], [80, 10, 3], [60, 3, 10]]