Skip to content

Instantly share code, notes, and snippets.

View rmariano's full-sized avatar
😀
Technically fearless; Exemplary practitioner.

Mariano Anaya rmariano

😀
Technically fearless; Exemplary practitioner.
View GitHub Profile
@rmariano
rmariano / function_parameters.md
Last active June 22, 2017 10:15
Pass default mutable arguments in Python

License

Python - How to pass empty lists as default argument

On this gist I would like to point out an aspect of Python that might present some issues if it is not implemented correctly.

Suppose we have a function and we need to define that some of its parameters take an empty list as a default argument. Something like the following, for example, might be a typical implementation:

@rmariano
rmariano / ShellScripting.md
Last active August 29, 2015 14:15
Shell scripting

A collection of shell scripts for common repetitive tasks, that might come in handy.

@rmariano
rmariano / gregorian_easter_gauss.py
Last active August 29, 2015 14:18
Gregorian Easter
#!/usr/bin/env python3
"""
Sunday 05 April, 2015 - Buenos Aires, Argentina
Python 3.4
Computes the date for the Gregorian Easter by using
Gauss's formula.
"""
from datetime import date
@rmariano
rmariano / coding_guideline_python.rst
Last active May 16, 2017 09:56
Coding guildelines for Python

Coding style

This file should summarize some important points to take into account in order to achieve a clean code base, enumerating not only style traits but also tips that might make the code more readable and maintainable.

1. PEP8_ with criteria: for example if a line goes beyond 80 cols, but breaking it would make an ugly code, or if the exceeding part is trivial (a comma, brackets, etc.), then leave it as it is, do not make pointless trims.

@rmariano
rmariano / Vagrantfile
Created June 20, 2015 21:30
Vagrant: Ubuntu 1404 libvirt
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
Vagrant.configure(2) do |config|
# This is an image of Ubuntu 14.04 LTS with libvirt support
config.vm.box = "baremettle/ubuntu-14.04"
config.vm.provision :shell, path: "provision.sh"
# config.vm.synced_folder "../data", "/vagrant_data"
@rmariano
rmariano / subcls.py
Last active September 15, 2020 17:59
LeaveClasses.md
class Top(object):
pass
class A(Top): pass
class B(Top): pass
class A1(A): pass
@rmariano
rmariano / declarative programming repo problem.cs
Last active December 29, 2016 00:08 — forked from lifebeyondfife/declarative programming repo problem.cs
Declarative Programming Repo Problem. Problem available in C#, JavaScript and Python.
/*
Code below can be run directly into LINQPad - https://www.linqpad.net/
Return the owner and repo name of the most starred project with more than 100 contributors, for each language
The declarative implementation can be solved using the Select, Where, Aggregate and GroupBy LINQ extension methods
*/
void Main()
{
var repos = new List<Repo> {
@rmariano
rmariano / oofunctional.py
Created January 5, 2017 10:20
Functional programming wrapped in object
"""
Object that allows chaining functional programming operations
over a provided data set.
"""
from operator import add
from functools import partialmethod, reduce
class ChainedFunctional:
@rmariano
rmariano / main.go
Created March 22, 2017 08:42 — forked from divan/main.go
Golang database/sql+http example (postgres)
// Run PostgreSQL server:
// docker run -e POSTGRES_PASSWORD="" -p 5432:5432 postgres
// Monitor running processes:
// watch -n 1 'echo "select pid,query_start,state,query from pg_stat_activity;" | psql -h localhost -U postgres
//
// For all handlers, call to db takes 5 seconds,
//
// Three endpoints:
// - "/" - take 5 seconds
// - "/ctx" - take 1 seconds, due to 1 second cancellation policy