Skip to content

Instantly share code, notes, and snippets.

@lirsacc
lirsacc / script.py
Last active February 3, 2024 09:33
Playing with Python's operator overloading to support the pipe functional operator from Elixir.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Small experiment with Python's operator overloading to add support for
composing function with the pipe operator similar to Elixir's pipe operator.
The main use case of such technique I see is to build isolated DSL.
This approach uses decorators to achieve the given result which forces you
to wrap all the functions you want to use this way. The runtime cost should
be minimal however this might be a problem in some context. It also prevents you
@lirsacc
lirsacc / README.md
Last active October 22, 2017 17:43
Interview brain teaser: subset of London tube stations

Interview brain teaser: subset of London tube stations

Question was asked during the interview and this is implementation with notes left to be done separately.

Question

Find the minimal subset of London tube stations whose characters cover all the letters of the alphabet. (Or more generally find the minimal subset of terms in a corpus that covers a given alphabet).

Keybase proof

I hereby claim:

  • I am lirsacc on github.
  • I am lirsacc (https://keybase.io/lirsacc) on keybase.
  • I have a public key ASD-QCh_GT6lEpNV8J9jtn7p7ZLqht2FYN-_TsyGEnci3wo

To claim this, I am signing this object:

@lirsacc
lirsacc / _db
Created November 25, 2015 10:25
ZSH database connection shortcuts
#compdef db
local -a dbs
dbs=$(ls $HOME/.dbs)
_alternative "files:dbs:($dbs)"
@lirsacc
lirsacc / .dockerignore
Created July 31, 2015 14:06
Landmarkerio server Dockerfile
*
!Dockerfile
@lirsacc
lirsacc / npl.sh
Last active August 29, 2015 14:17
Run local npm packages
# Helper function to run local npm packages with tab completion
# usage: npl pkg options
# Will return 1 if ./node_modules/ or ./node_modules/.bin/pkg doesn't exist
# Otherwise runs ./node_modules/.bin/pkg options
# Run local npm packages
# Better completion thanks to http://stackoverflow.com/a/14524311
function _npl () {
local cur ff
if [ $COMP_CWORD -eq 1 ]; then
# First completion word -> list node modules with binary