Skip to content

Instantly share code, notes, and snippets.

View TobeTek's full-sized avatar
🎹
Learning the piano...

Emmanuel Katchy TobeTek

🎹
Learning the piano...
View GitHub Profile
@tylermakin
tylermakin / Multipart MIME Email.md
Last active December 17, 2024 13:32
Multipart MIME Email Guide

Multipart MIME Email Guide

This is a guide on how to send a properly formatted multipart email. Multipart email strings are MIME encoded, raw text email templates. This method of structuring an email allows for multiple versions of the same email to support different email clients.

// Example Multipart Email:
From: [email protected]
To: [email protected]
Subject: Multipart Email Example
Content-Type: multipart/alternative; boundary="boundary-string"
@jcausey-astate
jcausey-astate / sendemail.py
Last active April 3, 2023 06:06
Send email using Python without requiring an MTA or installing sendmail. Adapted from https://moythreads.com/wordpress/2015/07/09/sending-email-with-python-without-an-mta/
#!/usr/bin/env python2.7
#
# Send email without requiring account credentials to be stored on the
# Docker instance.
#
# Adapted from:
# https://moythreads.com/wordpress/2015/07/09/sending-email-with-python-without-an-mta/
#
# Dependencies:
# `smtplib` (pip install smtplib to install)
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active May 4, 2025 18:46
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@treyhunner
treyhunner / time_count_functions.py
Last active September 18, 2023 20:21
Test performance of different counting functions in Python
"""
Test performance of these counting methods:
- count_if_else: Set to 1 if not yet seen and increment otherwise
- count_if: Set to 0 if not yet seen, then increment regardless of containment
- count_exception: Attempt to increment and set to 1 if KeyError caught
- count_setdefault: Set default value to 0, then increment
- count_fromkeys: Create dict with necessary keys set to 0, then increment each
- count_set_and_comprehension: Create dict of items and counts using a set
- count_defaultdict: Increment count, automatically setting unseen values to 0
@sehmaschine
sehmaschine / filters.py
Created September 14, 2015 18:47
OrderingFilter for Django Rest Framework
# coding: utf-8
# PYTHON IMPORTS
from django.utils import six
from django.core.exceptions import ImproperlyConfigured
# REST IMPORTS
from rest_framework.settings import api_settings
from rest_framework.filters import BaseFilterBackend
@kissgyorgy
kissgyorgy / sqlalchemy_conftest.py
Last active April 21, 2025 11:44
Python: py.test fixture for SQLAlchemy test in a transaction, create tables only once!
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from myapp.models import BaseModel
import pytest
@pytest.fixture(scope="session")
def engine():
return create_engine("postgresql://localhost/test_database")
@finalfantasia
finalfantasia / what_a_good_commit_message_looks_like.md
Last active August 8, 2024 06:53
What a good commit message looks like (Linus Torvalds)

A good commit message looks like this:

Header line: explain the commit in one line (use the imperative)

Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc.

The body of the commit message can be several paragraphs, and

please do proper word-wrap and keep columns shorter than about

@neomatrix369
neomatrix369 / PerformanceRelated.md
Last active November 3, 2023 20:27
Interesting links in the areas of HPC, low latency, mechanical harmony/sympathy, garbage collection