Skip to content

Instantly share code, notes, and snippets.

@renanivo
renanivo / import-letsencrypt-java.sh
Created May 20, 2019 19:45 — forked from galan/import-letsencrypt-java.sh
Imports the letsencrypt certificates into the java keystore
#!/bin/bash -e
# JAVA_HOME can be passed as argument if not set
if [ ! -d $JAVA_HOME ]; then
JAVA_HOME=${1}
fi
KEYSTORE=$JAVA_HOME/jre/lib/security/cacerts
if [ ! -f "$KEYSTORE" ]; then
echo "Keystore not found in '$KEYSTORE'"
exit 1
@renanivo
renanivo / validated.py
Last active August 19, 2019 13:16
Validated Metaclass
import typing
import functools
from dataclasses import dataclass
def validated_set(self, value, field_name, field_type):
if not isinstance(value, field_type):
raise TypeError(
@renanivo
renanivo / json2dict
Last active December 30, 2016 17:32
Reads a JSON from STDIN and prints a python dict
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vi: set ft=python :
"""
Convert a JSON from stdin in a python dict. Ex:
$ echo '{"foo": "bar"}' | ./json2dict
> {u'foo': u'bar'}
Install:
@renanivo
renanivo / asyncio.py
Created January 1, 2016 03:34
First steps with prompt toolkit (Python 3)
import asyncio
from prompt_toolkit.shortcuts import prompt_async
@asyncio.coroutine
def my_coroutine():
while True:
result = yield from prompt_async('Say something: ', patch_stdout=True)
print('You said: %s' % result)
@renanivo
renanivo / pre-commit.sh
Created March 6, 2015 20:20
Pre-commit script to avoid an empty commit
LIST_MODIFIED=$(git diff-index --name-status --cached HEAD | grep -w '^.*$' | sed 's/^.\{2\}//')
if [ ${#LIST_MODIFIED[@]} -eq 0 ]; then
echo "\033[33mNothing to commit, genius!\033[39m""]]"
exit 1
fi

Legendas Clean Code

  • Organização do GitHub: Friends of Clean Code (clean-code-subtitles)
  • S/ lista de discução tag no github da issue
  • Usar repositório existente
    • Não, do zero
  • Repositório todo em inglês, mas pode-se usar português se necessário (dúvidas de gramática, tradução, etc)
    • tag para pt-BR nestes casos
  • mandar email p/ Uncle Bob e perguntar do transcript
@renanivo
renanivo / ctags.patch
Created October 22, 2013 15:19
ctags dev patch
diff --git a/Library/Formula/ctags.rb b/Library/Formula/ctags.rb
index 87dd0ca..9e44c23 100644
--- a/Library/Formula/ctags.rb
+++ b/Library/Formula/ctags.rb
@@ -6,7 +6,7 @@ class Ctags < Formula
sha1 '482da1ecd182ab39bbdc09f2f02c9fba8cd20030'
head do
- url 'https://ctags.svn.sourceforge.net/svnroot/ctags/trunk'
+ url 'https://svn.code.sf.net/p/ctags/code/trunk'
@renanivo
renanivo / delete-merged.sh
Last active December 13, 2015 23:09
delete local merged branches
#!/bin/bash
#usage:
# ./delete-merged.sh ignored_branch1 ignored_branch2 ignored_branch3 ...
FILTER="master\|integra"
for i in "$@"; do
FILTER+="\|$i"
done
git branch --merged | gsed "/$FILTER/d" | gsed 's/\*//' | gsed 's/^/git branch -D/' | sh
@renanivo
renanivo / .vimrc
Created November 1, 2012 21:36
example of auto test with MakeGreen
let g:makegreen_stay_on_file = 1 " do not jump to the test file on errors
autocmd BufNewFile,BufRead *.py compiler nose
autocmd BufWritePost *.py MakeGreen -c nose.cfg
@renanivo
renanivo / gist:3250346
Created August 3, 2012 18:45
get the hash of the last commit of a <file>
git log --format="%h" -n 1 <file>