Skip to content

Instantly share code, notes, and snippets.

View CarlosDomingues's full-sized avatar

Carlos Domingues CarlosDomingues

View GitHub Profile
@CarlosDomingues
CarlosDomingues / baremetalArduino.md
Last active March 6, 2021 20:43
Steps for Arduino bare metal programming

First install:

$sudo apt-get install avrdude gcc-avr avr-libc

Then:

$avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o led.o led.c

-DF_CPU is the CPU clock speed

@CarlosDomingues
CarlosDomingues / gist:62cd70e698b7df9dea4ad0df0ee2e12d
Last active June 6, 2018 03:51
Making a library run unittests correctly for any Python > 2.6
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
else:
from <my_module>.<my_submodule> import fun1, fun2
For Python 2 / 3:
@CarlosDomingues
CarlosDomingues / gist:8fd85d8bf5a56d9b76bfd25249cd370c
Created June 6, 2018 03:54
Getting the number of days since 1970/01/01, as a string.
def datetime_to_unixtime(date):
"""Returns the number of days between 'date' and 1970/01/01, as a string.
Parameters
----------
date : datetime.datetime
A date object of the datetime.datetime class.
Returns
-------
str
py36:
image: python:3.6
script:
- apt-get update -q -y
- pip install pip -U
- pip install pipenv
- pipenv install
- pipenv run python -m unittest discover
@CarlosDomingues
CarlosDomingues / gist:31f37516b8f1b850b84a369e70d5f41e
Created June 6, 2018 04:02
Python - Getting correct time, date and timezone
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)'
Parameters
----------
@CarlosDomingues
CarlosDomingues / gist:b002d9af55ff86345fdabe201362fe33
Created June 8, 2018 16:27
Running SetUp a single time on Python unittests
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
CarlosDomingues / python-poetry-cheatsheet.md
Last active March 23, 2024 09:56
Python Poetry Cheatsheet

Create a new project

poetry new <project-name>

Add a new lib

poetry add <library>

Remove a lib

Error:
No valid credentials found for Spotinst Provider.
Please see https://www.terraform.io/docs/providers/spotinst/index.html
for more information on providing credentials for Spotinst Provider.
on <empty> line 0:
(source code not available)
@CarlosDomingues
CarlosDomingues / local_bundler.py
Last active February 13, 2024 22:22
Implementing aws_cdk.core.ILocalBundling in Python (avoids using Docker for bundling)
from aws_cdk.core import (
BundlingDockerImage,
BundlingOptions,
ILocalBundling
)
from aws_cdk.aws_lambda import Code
from jsii import implements, member
@implements(ILocalBundling)
class MyLocalBundler:

Keybase proof

I hereby claim:

  • I am CarlosDomingues on github.
  • I am cfelipe (https://keybase.io/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: