Skip to content

Instantly share code, notes, and snippets.

View pmutua's full-sized avatar
🐲
You are awesome make things happen ✨

Philip Mutua pmutua

🐲
You are awesome make things happen ✨
View GitHub Profile
@pmutua
pmutua / PrintLocalesController.m
Created May 16, 2022 16:44 — forked from ncreated/PrintLocalesController.m
List of iOS locales with currency formatting.
//
// PrintLocalesController.m
// NSFormatterTest
//
// Created by Maciek Grzybowski on 02.04.2014.
//
#import "PrintLocalesController.h"
@interface PrintLocalesController ()
@pmutua
pmutua / gist:b9be78234ed7fe885140403e769e0afb
Created January 18, 2022 22:20 — forked from audreyfeldroy/gist:1095555
Django coverage walkthrough
Here is my django-coverage walkthrough. A nice minimal sample project showing django-coverage in action is https://github.com/pydanny/django-party-pack
1) Add to requirements.txt:
django-coverage==1.2
coverage==3.4
2) In your virtualenv, do a "pip install -r requirements.txt"
3) Add to settings.py:
@pmutua
pmutua / name.js
Created November 2, 2021 21:20 — forked from tkon99/name.js
Random Name Generator for Javascript
/*
(c) by Thomas Konings
Random Name Generator for Javascript
*/
function capFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function getRandomInt(min, max) {
@pmutua
pmutua / django_server_deployment.rst
Created October 27, 2021 08:00 — forked from studybuffalo/django_server_deployment.rst
Basic Django Server Deployment for Staging & Production
@pmutua
pmutua / GitCommitBestPractices.md
Created October 8, 2021 09:35 — forked from luismts/GitCommitBestPractices.md
Git Tips and Git Commit Best Practices

Git Commit Best Practices

Basic Rules

Commit Related Changes

A commit should be a wrapper for related changes. For example, fixing two different bugs should produce two separate commits. Small commits make it easier for other developers to understand the changes and roll them back if something went wrong. With tools like the staging area and the ability to stage only parts of a file, Git makes it easy to create very granular commits.

Commit Often

Committing often keeps your commits small and, again, helps you commit only related changes. Moreover, it allows you to share your code more frequently with others. That way it‘s easier for everyone to integrate changes regularly and avoid having merge conflicts. Having large commits and sharing them infrequently, in contrast, makes it hard to solve conflicts.

@pmutua
pmutua / upgrade-postgresql-service-centos-7.md
Created August 26, 2021 20:59 — forked from ShvaykaD/upgrade-postgresql-service-centos-7.md
Upgrading PostgreSQL service from 9.x or 10.x to 11 version on CentOS 7
"""
Django ORM Optimization Tips
Caveats:
* Only use optimizations that obfuscate the code if you need to.
* Not all of these tips are hard and fast rules.
* Use your judgement to determine what improvements are appropriate for your code.
"""
# ---------------------------------------------------------------------------
@pmutua
pmutua / test_auto_now_DateTime_Fields.md
Created June 3, 2021 12:15 — forked from linxuedong/test_auto_now_DateTime_Fields.md
Django test auto_now DateTime Fields
class Article(models.Model):    
    title = models.CharField()
    content = models.TextField()
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)

I want to an article which was created and modified yesterday. And test the things today.

@pmutua
pmutua / msisdn_regex.txt
Created April 24, 2021 19:49 — forked from muya/msisdn_regex.txt
Regex for Safaricom Kenya, Airtel Kenya & Tigo Tanzania Phone Numbers
# KE
SAFARICOM: "/(\+?254|0|^){1}[-. ]?[7]{1}([0-2]{1}[0-9]{1}|[9]{1}[0-2]{1})[0-9]{6}\z/"
AIRTEL: "/(\+254|0|^){1}[-. ]?[7]{1}([3]{1}[0-9]{1}|[8]{1}[5-9])[0-9]{6}\z/"
# TZ
TIGO: "/(\+?255|0|^){1}[-. ]?([7]{1}[1]{1}[2-9]{1}|[6]{1}[57]{1}[2-9]{1})[0-9]{6}\z/"