Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Mariano Anaya rmariano

🏠
Working from home
View GitHub Profile
View find_mon25.py
"""A small script to find all months that have a Monday 25th for a particular
year.
Input: year in format YYYY
Output: print list of dates that are a Monday 25 in that year
"""
import re
import sys
from typing import Iterator
from datetime import date
View Local-development-for-Python-gRPC.md

gRPC Python: Instructions for Local Development

Note: The compilation of the C files (make) requires GCC version 7. Maybe LLVM?

  1. Git clone & init the project
git clone ...
git submodule update --init
@rmariano
rmariano / README.md
Last active Jul 17, 2019
Proposal for exposing the aiogrpc interface to users
View README.md

Aio gRPC

A Proposal from the user's perspective

As a user, to use the new implementation of gRCP in the asynchronous version, I will compile by passing a specific flag:

$ python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. proto/echo.proto --aiogrpc

This compiles the stubs, generated with the asynchronous code.

@rmariano
rmariano / discovering_descriptors.py
Last active Jul 11, 2017
Discovering Descriptors
View discovering_descriptors.py
"""Code for the talk "Discovering Descriptors"
> PyCon CZ 2017 - 8 to 10 June - Prage, Czech Republic
June 9th, 2017 11:00 CET
> EuroPython 2017 - 9 to 16 July - Rimini, Italy
July 11th, 2017 15:45 CET
https://ep2017.europython.eu/conference/talks/discovering-descriptors
Python 3.6
@rmariano
rmariano / main.go
Created Mar 22, 2017 — forked from divan/main.go
Golang database/sql+http example (postgres)
View main.go
// 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
@rmariano
rmariano / oofunctional.py
Created Jan 5, 2017
Functional programming wrapped in object
View oofunctional.py
"""
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 / declarative programming repo problem.cs
Last active Dec 29, 2016 — forked from lifebeyondfife/declarative programming repo problem.cs
Declarative Programming Repo Problem. Problem available in C#, JavaScript and Python.
View declarative programming repo problem.cs
/*
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 / subcls.py
Last active Sep 15, 2020
LeaveClasses.md
View subcls.py
class Top(object):
pass
class A(Top): pass
class B(Top): pass
class A1(A): pass
@rmariano
rmariano / Vagrantfile
Created Jun 20, 2015
Vagrant: Ubuntu 1404 libvirt
View Vagrantfile
# -*- 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 / coding_guideline_python.rst
Last active May 16, 2017
Coding guildelines for Python
View coding_guideline_python.rst

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.