Skip to content

Instantly share code, notes, and snippets.

View viniciusban's full-sized avatar

Vinicius Assef viniciusban

  • Rio de Janeiro, Brazil
View GitHub Profile
@viniciusban
viniciusban / bash_aliases.sh
Last active June 1, 2018 03:59
Basic .bash_aliases for virtual machines
# PS 1 green when $? is zero. Otherwise, red showing $?.
# Example:
# - [@virtualmachine:~/Documents]$ # <-- green
# - [ 127 @virtualmachine:~/Documents]$ # <-- red
PS1='[${debian_chroot:+($debian_chroot)}$(RC=$?;GREEN="\[\033[0;32m\]";RED="\[\033[0;31m\]";[ $RC -eq 0 ] && echo ${GREEN} || echo "${RED} ${RC} ")@\h\[\033[00m\]:\[\033[00;90m\]\w\[\033[00m\]]\$ '
set -o vi
unalias ls
@viniciusban
viniciusban / ramdisk.sh
Created May 17, 2018 00:53 — forked from rxin/ramdisk.sh
ramdisk create/delete on Mac OS X.
#!/bin/bash
# From http://tech.serbinn.net/2010/shell-script-to-create-ramdisk-on-mac-os-x/
#
ARGS=2
E_BADARGS=99
if [ $# -ne $ARGS ] # correct number of arguments to the script;
then
@viniciusban
viniciusban / Makefile
Created June 8, 2017 02:11
A good Makefile
# Define variables
project_name := $(shell pwd | xargs basename)
inifile := development.ini
dbfile := $(shell grep -e '^sqlalchemy\.url' ${inifile} \
| grep -o -e 'sqlite:.*' \
| xargs basename \
)
pip_cache := /Users/viniciusban/projects/pip-downloaded-packages
pip_options := --no-index --no-cache --find-links=${pip_cache}
@viniciusban
viniciusban / 00-detect-current-venv.py
Last active July 12, 2021 11:13 — forked from henriquebastos/00-detect-virtualenv-sitepackages.py
IPython startup script to detect and inject VIRTUAL_ENV's site-packages dirs.
"""IPython startup script to detect and inject VIRTUAL_ENV's site-packages dirs.
IPython can detect virtualenv's path and injects it's site-packages dirs into sys.path.
But it can go wrong if IPython's python version differs from VIRTUAL_ENV's.
This module fixes it looking for the actual directories. We use only old stdlib
resources so it can work with as many Python versions as possible.
References:
http://stackoverflow.com/a/30650831/443564

= Continuous Delivery Changelog

I have recently changed the Gentics Mesh release process from regular releases to a continous delivery release process. One of the questions that directly came up was how to manage a public changelog in continuous delivery workflow?

Previously (regular sequential releases) I would write the changelog entry upfront and since I knew what release version would be expected i could just refer to that version. With CD this changes. I can no longer refer to a specific version since i'm doing CD without actually knowing the version upfront.

I know that I could just fetch the SCM log and generate a changelog using that information but I don't like to use SCM messages for a public (enduser friendly) changelog. A changelog that just consists of SCM messages is way to noisy. Unfortunately it seems that all the open source changelog plugin utlize the git log to build a changelog.

For Gentics CMS I already wrote my own [maven changelog plugin](https://github.com/gentics/maven-changelog-

@viniciusban
viniciusban / deploy.sh
Created February 22, 2017 13:41
Minimal Race-free Deployment
#!/bin/sh
# deploy.sh
N="`readlink \"$1\"`"
mv -T "$1.stage" "$1"
ln -s "$N" "$1.stage"
rm -rf "$N"
cp -aH "$1" "$N"
@viniciusban
viniciusban / gist:83353d63bc4fa07e7c3e6fa05e8e97ed
Created February 22, 2017 12:52 — forked from datagrok/gist:2199506
Virtualenv's `bin/activate` is Doing It Wrong

Virtualenv's bin/activate is Doing It Wrong

I'm a Python programmer and frequently work with the excellent [virtualenv][] tool by Ian Bicking.

Virtualenv is a great tool on the whole but there is one glaring problem: the activate script that virtualenv provides as a convenience to enable its functionality requires you to source it with your shell to invoke it. The activate script sets some environment variables in your current environment and defines for you a deactivate shell function which will (attempt to) help you to undo those changes later.

This pattern is abhorrently wrong and un-unix-y. activate should instead do what ssh-agent does, and launch a sub-shell or sub-command with a modified environment.

Problems

@viniciusban
viniciusban / README.rst
Created February 22, 2016 15:36 — forked from dupuy/README.rst
Common markup for Markdown and reStructuredText

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

@viniciusban
viniciusban / hierarquia_models.py
Last active July 19, 2023 10:30
Django - Hierarquia de models
class VinculoGeral(models.Model):
'''Essa classe será criada pelo Django.
Ela não tem nenhuma validação.
'''
tipo_vinculo = models.ForeignKey('TipoVinculoProfissional')
profissional = models.ForeignKey('Profissional')
data_inicio = models.DateField()
data_fim = models.DateField()
@viniciusban
viniciusban / useful_functions_to_handle_class_attr_of_DOMNode.py
Created January 19, 2015 20:38
Useful functions to handle the class attribute of DOMNode.
"""Useful functions to handle the class attribute of DOMNode.
Usage:
```
>>> el = document['someid']
>>> add_class(el, 'class-one')
>>> add_class(el, 'old-class')
>>> change_class(el, 'old-class', 'new-class')
>>> remove_class(el, 'class-one')
>>> print(el.class_name)