Skip to content

Instantly share code, notes, and snippets.

View kako-nawao's full-sized avatar

Claudio Omar Melendrez Baeza kako-nawao

  • Bahía Blanca, Argentina
View GitHub Profile
kako-nawao /
Last active October 16, 2016 13:47
Calculate the height for a row of images with different aspect ratios
def calculate_tiled_row_height(row_width, space_width, num_images, sum_aspect)
Calculate the height required for a row of tiled images based on the row width,
space between images, number of images and sum of aspect ratios of images.
return (row_width - (num_images - 1) * space_width) / float(sum_aspect)
def get_image_rows(image_iter, row_width, row_min_aspect, space_width):
kako-nawao /
Last active April 11, 2017 22:07
Example of a factory superclass, which constructor returns a new instance of the correct subclass for a given parameter.
class Animal(object):
def __new__(cls, common_name, *args, **kwargs):
for subclass in cls.__subclasses__():
if subclass.common_name == common_name:
return object.__new__(subclass, *args, **kwargs)
raise ValueError('No animal species matched for common name "{}"'.format(common_name))
kako-nawao /
Created February 22, 2016 16:43
SonarQube project properties sample
# Main SonarQube project information
# Source is everything minus typical django project and venv/ (CI server)
# Report paths (test results and coverage)
kako-nawao / init.sls
Last active October 14, 2016 23:31
SaltStack states for SonarQube scanner
# SonarQube continuous inspection scanner
- core.unzip
- name: curl -L -o {{ pillar['auth']['home'] }}/
- creates: {{ pillar['auth']['home'] }}/