Skip to content

Instantly share code, notes, and snippets.


Carlos Domingues CarlosDomingues

View GitHub Profile
CarlosDomingues / Python 3.10 on Ubuntu 20 on Windows
Last active Jan 13, 2022
Python 3.10 on Ubuntu 20 on Windows 11
View Python 3.10 on Ubuntu 20 on Windows

A guide on how to install Python 10 on WSL2 under Windows 10 / 11.

Install pyenv

pyenv is a tool that allows switching the global Python version, or choosing a specific version per project.

sudo apt update --yes
sudo apt install --yes build-essential curl git libbz2-dev liblzma-dev libffi-dev libncurses5-dev libncursesw5-dev libreadline-dev libssl-dev libsqlite3-dev llvm make python3-openssl tk-dev wget xz-utils zlib1g-dev
curl | bash

Keybase proof

I hereby claim:

  • I am CarlosDomingues on github.
  • I am cfelipe ( on keybase.
  • I have a public key whose fingerprint is 0196 AC06 4E01 CC93 C0C3 CBEA BFEE EE81 7E26 3C9A

To claim this, I am signing this object:

CarlosDomingues /
Last active Oct 28, 2021
Implementing aws_cdk.core.ILocalBundling in Python (avoids using Docker for bundling)
from aws_cdk.core import (
from aws_cdk.aws_lambda import Code
from jsii import implements, member
class MyLocalBundler:
View spotinst provider error
No valid credentials found for Spotinst Provider.
Please see
for more information on providing credentials for Spotinst Provider.
on <empty> line 0:
(source code not available)

Create a new project

poetry new <project-name>

Add a new lib

potry add <library>

Remove a lib

CarlosDomingues / gist:b002d9af55ff86345fdabe201362fe33
Created Jun 8, 2018
Running SetUp a single time on Python unittests
View gist:b002d9af55ff86345fdabe201362fe33
import unittest
from my_program import MyClass
class MyClassTest(unittest.TestCase):
# First define a class variable that determines
# if setUp was ever run
ClassIsSetup = False
def setUp(self):
# If it was not setup yet, do it
CarlosDomingues / gist:31f37516b8f1b850b84a369e70d5f41e
Created Jun 6, 2018
Python - Getting correct time, date and timezone
View gist:31f37516b8f1b850b84a369e70d5f41e
import datetime
import time
import tzlocal
def get_formated_datetime():
"""Returns the current date and time, as a formated string with the
following formating:
'Wed Jan 31 2018 16:02:27 GMT-0200 (E. South America Daylight Time)'
View gist:21bc61b8ce8b690d52e5ea2e1f58349d
image: python:3.6
- apt-get update -q -y
- pip install pip -U
- pip install pipenv
- pipenv install
- pipenv run python -m unittest discover
CarlosDomingues / gist:8fd85d8bf5a56d9b76bfd25249cd370c
Created Jun 6, 2018
Getting the number of days since 1970/01/01, as a string.
View gist:8fd85d8bf5a56d9b76bfd25249cd370c
def datetime_to_unixtime(date):
"""Returns the number of days between 'date' and 1970/01/01, as a string.
date : datetime.datetime
A date object of the datetime.datetime class.
CarlosDomingues / gist:62cd70e698b7df9dea4ad0df0ee2e12d
Last active Jun 6, 2018
Making a library run unittests correctly for any Python > 2.6
View gist:62cd70e698b7df9dea4ad0df0ee2e12d
import sys
if sys.version_info[0] == 2 and sys.version_info[1] < 7:
sys.path.insert(0, "./<my_module>")
from <my_submodule> import fun1, fun2
from <my_module>.<my_submodule> import fun1, fun2
For Python 2 / 3: