This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import shutil | |
def clearscr(): | |
terminal_size=shutil.get_terminal_size() | |
print("\n"*(terminal_size.lines-2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
def v_fstring(row): | |
return f"{row['group']}.{row['sub']}.{row['num']:05}" | |
def v_format(row): | |
return "{group}.{sub}.{num:05}".format(**row) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ ! -f $0.pkgchkok ] ; then | |
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' bc 2> /dev/null |grep "install ok installed") | |
if [ "" = "$PKG_OK" ] ; then | |
echo "Required 'bc' package not installed" | |
exit 1 | |
else | |
touch $0.pkgchkok | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
last_out="$1" | |
shift | |
exec_cmd="$@" | |
script_date=$(date) | |
date_to_file=$(date '+%Y-%m-%d_%H.%M.%S') | |
base_dir=$(dirname ${last_out}) | |
name_out=$(basename ${last_out}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def method_idle_on_none(old_method): | |
''' | |
Decorator: Only execute the method if any argument is not None | |
''' | |
def new_method(self, *args): | |
for arg in args: | |
if arg is not None: | |
old_method(self, *args) | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Data Science: Introdução a Ciência de Dados.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"toc_visible": true | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update_dict(original, adding): | |
result = original.copy() | |
for key in adding.keys(): | |
if adding[key] is None: | |
continue | |
if isinstance(adding[key], dict): | |
if key not in result or not isinstance(result[key], dict): | |
result[key] = adding[key].copy() | |
else: | |
result[key] = update_dict(result[key], adding[key]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
from smb.SMBHandler import SMBHandler | |
def send_file_smb( | |
filename_orig, full_path_dest, filename_dest='', full_path_orig=''): | |
''' | |
Copy a local file to an remote SMB share folder and file. | |
''' | |
if filename_dest == '': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
def inc_month(dt, months): | |
''' | |
"months" can be positive or negative | |
If day in new month can't be the same, it will be the the closest possible. | |
''' | |
newmonth = (((dt.month - 1) + months) % 12) + 1 | |
newyear = dt.year + (((dt.month - 1) + months) // 12) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Avoid multiple instances of the script | |
# Sample script | |
# Based on description of | |
# man 1 flock | |
# Your code go inside of "main" function and other fuctions | |
function main { |