Skip to content

Instantly share code, notes, and snippets.

View Philipotieno's full-sized avatar
🏠
Working from home

Philip Mitchell Otieno Philipotieno

🏠
Working from home
View GitHub Profile
@wojteklu
wojteklu / clean_code.md
Last active January 28, 2026 14:55
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@parmentf
parmentf / GitCommitEmoji.md
Last active January 28, 2026 07:25
Git Commit message Emoji
@hodgesmr
hodgesmr / hijacking_flask_routing_for_fun_and_profit.py
Last active June 18, 2024 15:22
Automatically register Flask routes with and without trailing slash. This way you avoid the 301 redirects and don't have to muddy up your blueprint with redundant rules.
"""Flask Blueprint sublcass that overrides `route`.
Automatically adds rules for endpoints with and without trailing slash.
"""
from flask import Blueprint, Flask
class BaseBlueprint(Blueprint):
"""The Flask Blueprint subclass."""
@blixt
blixt / flask_cors.py
Created August 16, 2014 18:24
How to add CORS support to a Flask app in 9 lines of code
def add_cors_headers(response):
response.headers['Access-Control-Allow-Origin'] = '*'
if request.method == 'OPTIONS':
response.headers['Access-Control-Allow-Methods'] = 'DELETE, GET, POST, PUT'
headers = request.headers.get('Access-Control-Request-Headers')
if headers:
response.headers['Access-Control-Allow-Headers'] = headers
return response
app.after_request(add_cors_headers)
@pipermerriam
pipermerriam / emails.py
Created June 12, 2013 17:17
An example of sending a password reset email in django as a class-based email.
from urlparse import urljoin
from django.contrib.auth.tokens import default_token_generator
from django.utils.http import int_to_base36
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from emailtools import MarkdownEmail