Skip to content

Instantly share code, notes, and snippets.

View mfonism's full-sized avatar

Mfon Eti-mfon mfonism

View GitHub Profile
import subprocess
from collections import OrderedDict
def get_git_repo_authors(path_to_repo):
"""
Returns a generator object of the authors in a git repo.
"""
cmd = ["git", "-C", path_to_repo, "log", "--reverse", "--format=format:%aN <%aE>"]
resp = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
class QueryParamReader:
class Meta:
model = Event
grouping_params = [
"day",
"device_type",
"category",
"client",
"client_group",
"valid",
@mfonism
mfonism / .dockerignore
Created December 18, 2019 23:47 — forked from jefftriplett/.dockerignore
How I use Docker and Compose
.*
!.coveragerc
!.env
!.pylintrc
@mfonism
mfonism / admin.py
Created January 7, 2020 11:06 — forked from wsvincent/admin.py
Django Custom User Model for any new project
# users/admin.py
from django.contrib import admin
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin
from .forms import CustomUserCreationForm, CustomUserChangeForm
from .models import CustomUser
class CustomUserAdmin(UserAdmin):
add_form = CustomUserCreationForm
@mfonism
mfonism / dropping_python_2_from_pinax-ratings.md
Last active January 21, 2020 02:08
This gist documents the steps that were taken to drop Python 2 support in Pinax Ratings

Dropping Python 2 Support in Pinax-Ratings

This gist documents the steps that were taken to drop Python 2 support in Pinax Ratings. It is hoped that this will serve as a primer for dropping Python 2 support in other apps in the Pinax project.

Step 1: Remove Python 2 from Test Matrix

Initially, when the app's test suite was run with tox the system was found to exit with code 1 (signalling abnormal termination) for tests run in the test environment named py27-django111. This was due to syntax errors being raised when Python 2 incompatible test dependencies are run on Python 2.

The syntax errors were raised because of the following incompatibilities:

@mfonism
mfonism / dropping_python_2_support_in_django-user-accounts.md
Last active January 23, 2020 13:13
This gist documents the steps that were taken to drop Python 2 support in Django User Accounts
@mfonism
mfonism / KiwiTCMSonWindows.md
Last active February 3, 2020 12:25
Notes for contributing to KiwiTCMS on Windows

You will have to install all the node modules specified in packages.json manually

  • The first to bite you will be the absence of patternfly.js. Resolve that by installing it with npm like so:

    $ npm install patternfly --save
  • Installing with npm will fail for simplemde. In this case, download the zipped version of the library from the simplemde website

@mfonism
mfonism / gist:293cdeddfe1f2a418c7ffed6ec3018ff
Created February 3, 2020 14:47 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@mfonism
mfonism / weaving_words.md
Last active February 7, 2020 01:54
My answer to the question on https://stackoverflow.com/questions/60105887/in-python-how-to-mix-two-sentence which was sadly closed before it could be determined that the question was indeed valid.

The Problem

def weave_words(first, second):
    ...

The Logic Behind the Solution

Let's do this by hand.

@mfonism
mfonism / server_with_asyncio.py
Created February 8, 2020 15:33
A simple server with asyncio
import asyncio
async def handle_request(reader, writer):
data = await reader.read(1024)
message = data.decode()
addr = writer.get_extra_info("peername")
print(f"Received {message!r} from {addr!r}")