Skip to content

Instantly share code, notes, and snippets.

@luiscoms
luiscoms / cvs-patch.sh
Created April 17, 2015 14:56
CVS Utils
#!/bin/bash
PROJECT_PATH=$(pwd);
APPLY=false
IDENTIFIER=""
echoerror() {
printf "$@\n" 1>&2
}
@luiscoms
luiscoms / CallApplicationFragment.java
Created November 11, 2015 17:48
Call another application if is installed
package com.example.app.fragments;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@luiscoms
luiscoms / docker-utils.sh
Last active October 3, 2016 18:11
Docker utils
# Delete all containers
docker rm $(docker ps -aq --filter status="exited" --filter status="dead")
docker rm $(docker ps -aq)
# Delete all untaged images
docker rmi $(docker images --filter "dangling=true" -q | sort -u)
http://serverspec.org/resource_types.html
https://docs.docker.com/engine/installation/linux/ubuntulinux/#create-a-docker-group
# -*- coding: utf-8 -*-
#!/usr/bin/env python
import logging
from pprint import pprint, pformat
import sys
logging.basicConfig(
stream=sys.stdout,
# level=logging.DEBUG,
format='[%(asctime)s] %(levelname)s:%(name)s:%(lineno)d - %(message)s'
@luiscoms
luiscoms / wrapper.py
Created September 12, 2016 14:23
Python Wrapper behaviours
from functools import wraps
def dec_wrapper(name):
def dec(func):
@wraps(func)
def wrapper(*args, **kw):
print(name)
print(args)
result = func(*args, **kw)
print('acabou')
@luiscoms
luiscoms / detect-os.sh
Created September 27, 2016 12:54
Bash script to detect OS by type
#!/bin/bash -x
case "$OSTYPE" in
darwin*) echo "I am a Mac" ;;
*) echo "I am not a Mac" ;;
esac
@luiscoms
luiscoms / SemVer.java
Last active December 14, 2016 20:40
Compare versions
class SemVer {
public int compareVersion(String v1, String v2) {
String[] v1Parts = v1.split("\\.");
String[] v2Parts = v2.split("\\.");
int length = Math.max(v1Parts.length, v2Parts.length);
for (int i=0; i<length ;i++) {
int numV1 = (i < v1Parts.length)? Integer.parseInt(v1Parts[i]) : 0;
int numV2 = (i < v2Parts.length)? Integer.parseInt(v2Parts[i]) : 0;
@luiscoms
luiscoms / .editorconfig
Last active July 25, 2019 12:56
Editor Config
# Se tiver essa diretiva, a recursividade para, ou seja,
# esse é o arquivo raiz da configuração
root = true
# Comentários podem começar com ; ou #
# Pra todos os arquivos
# [*]
# Para arquivos em extensões abaixo
[{*.{c,cpp,conf,cfg,js,py,php,sh},Makefile}]
# Defino que serão todos utf-8
@luiscoms
luiscoms / .pypirc
Last active July 3, 2020 19:13
My pypirc
[distutils]
index-servers =
pypi
pypitest
[pypi]
repository=https://pypi.python.org/pypi
username=luiscoms
password=
@luiscoms
luiscoms / performance_algorithm.py
Created July 28, 2017 13:12
Python performance test
import timeit
black_list = ["status", "components", "exposed_id", "external_id", "gaucha_id", "publish_scheduled",
"created", "origin_link", "canonical", "friendly_title", "friendly_title_history"]
input_data = {
"x": 1,
"_id": 1,
"_created": 1,
"_updated": 1,