Skip to content

Instantly share code, notes, and snippets.

@denibertovic
denibertovic / Makefile
Created October 17, 2017 21:27
Self documenting Makefile
.PHONY: help cmd1 cmd2
.DEFAULT_GOAL = help
## Runs cmd 1.
cmd1:
@echo "Running cmd one..."
## Runs cmd 2.
cmd2:

Keybase proof

I hereby claim:

  • I am denibertovic on github.
  • I am deni (https://keybase.io/deni) on keybase.
  • I have a public key whose fingerprint is 9C4B 20E3 BAF4 4208 F2FA 0A3F 9E5A 03FE 728A 9E5F

To claim this, I am signing this object:

#!/usr/bin/env python
# REPRO: ./main.py subcmd --customer=customer1 cmd
# PROBLEM: dummy still get's prompted
# DESIRED: dummy get's read from the "config file" and not prompted
from functools import update_wrapper
from copy import deepcopy
import click
@denibertovic
denibertovic / main.py
Created June 27, 2017 13:25
Click repro1
#!/usr/bin/env python
# REPRO
# pip install -r click==6.6
# chmod +x main.py
# ./main.py --customer customer1
# PROBLEM: dummy get's prompted regardless if it's set from the "config file"
from functools import update_wrapper
@denibertovic
denibertovic / hdoc.py
Created May 18, 2016 20:27
Get local docs for haskell libs (with stack)
#!/usr/bin/env python
# Author: Deni Bertovic <deni@denibertovic.com>
# LICENSE: BSD3
# A simple script that greps through local stack dependencies and tries to build
# a file url that you can click and open in your browser. This is useful for reading
# docs offline when they're not built on hackage for whatever reason.
# Obviously you need to build the docs first with "stack haddock" otherwise the
# links that get printed wont work.
rm -rf /var/lib/docker/volumes/*
# Dockerfile
FROM debian:jessie
RUN mkdir /tmp/ajmo
ADD dinamo.txt /tmp/ajmo/dinamo.txt
VOLUME /tmp/ajmo
docker build -t dinamo .
@denibertovic
denibertovic / gist:2372c3b7e822e93864cb
Created April 22, 2015 11:28
Lambda Zagreb Meetup: Haskell overview slides (Markdown)
# Haskell Overview
---
## About me
__Deni Bertovic__
_I blog sometimes:_
# After you update openssl you need to restart all services that depend on it
# So that they load the new library
# We could just reboot the server but that's not really an option
# Here's how you find out what services are using the old version
sudo grep -l 'libssl.*deleted' /proc/*/maps | tr -cd 0-9\\n | xargs -r ps u
# No go and restart all those services so you are secure again
# tnx to 'petern_' on freenode for this very helpful one-liner
@denibertovic
denibertovic / decorator_with_args.py
Last active September 6, 2018 22:23
Python decorator with arguments
from functools import wraps
## helper decorator for making new decorators with arguments
decorator_with_args = lambda decorator: lambda *args, **kwargs: lambda func: decorator(func, *args, **kwargs)
@decorator_with_args
def my_decorator(f, some_argument=None):
@wraps(f)
def wrapper(self, request, *args, **kwargs):
@denibertovic
denibertovic / Makefile
Last active January 12, 2016 21:10
Easily start a local Postgres instance for your development environment using docker
DATA_DIR="__data"
POSTGRES_VERSION=9.3
PORT=5432
.PHONY: docker-check postgres
docker-check:
@command -v docker >/dev/null 2>&1 || \
{ echo >&2 "Docker needs to be installed and on your PATH. Aborting."; exit 1; }