Skip to content

Instantly share code, notes, and snippets.

@guionardo
guionardo / admin_os.py
Last active December 1, 2022 20:51
Bug OS/Contato
@admin.register(OS)
class AdminOS(DjangoObjectActions, AdminBaseModel):
list_display = ['__str__', 'situacao', # 'cliente',
'produto', 'nr_projeto', 'tempo', 'descricao', 'updated']
search_fields = ['nr_os', 'nr_projeto', 'descricao']
list_filter = ['situacao', 'produto__cliente__nome']
readonly_fields_on_update = ['created_by', 'updated'] # , 'cliente'
fields = (('data_abertura', 'solicitante'), # , 'cliente'
('produto', 'nr_projeto'),
@guionardo
guionardo / .bashrc_ps1
Created March 13, 2022 17:09
bash PS1 for git
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUPSTREAM="auto"
PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\]@\[\033[0;36m\]\h \w\[\033[0;32m\]$(__git_ps1)\n\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\] ▶\[\033[0m\] '
@guionardo
guionardo / combina_faturas.php
Created December 16, 2021 12:42
Combinação de faturas
<?php
function permutations($pool, $r = null) {
$n = count($pool);
if ($r == null) {
$r = $n;
}
if ($r > $n) {
return;
@guionardo
guionardo / delete_old.sh
Created December 8, 2021 10:17
Deleting files but keeping some in bash
#!/usr/bin/env bash
# With this tool you can delete files using a mask, but keeping some files
# I've wrote this tool to house keep log files
# Usage: bash delete_old.sh <number of files to keep> "folder/mask"
# If you use mask like * or ? in your command, add quotes to prevent enumeration
keep=$(($1))
folder=${2:-...}
@guionardo
guionardo / progress.py
Created June 2, 2021 18:21 — forked from vladignatyev/progress.py
Python command line progress bar in less than 10 lines of code.
# The MIT License (MIT)
# Copyright (c) 2016 Vladimir Ignatev
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the Software
# is furnished to do so, subject to the following conditions:
#
@guionardo
guionardo / bus_list.py
Created June 30, 2020 23:02
Bus List in python
from collections.abc import Iterable
class BusList(list):
""" Bus (FIFO) list
"""
def __init__(self, *args):
self._max_length = 0
for arg in args:
@guionardo
guionardo / example.py
Last active July 31, 2020 04:04
Python singleton decorator class
@Singleton
class DBConnection(object):
def __init__(self):
"""Initialize your database connection here."""
pass
def __str__(self):
return 'Database connection object'
@guionardo
guionardo / .bashrc
Created November 30, 2019 13:47
.bashrc with git informations
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@guionardo
guionardo / lambda_example.py
Last active November 27, 2018 17:58
Lambda operator example in Python
#!/bin/python
n1=int(input("digite numero :"))
n2=int(input("digite numero :"))
oper=input("digite soma = +,subtração = -,multiplicação = *,divisao = /:")
#soma
if (oper=="+"):
print("resultado = ",n1+n2)