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

In your models.py put:

from django.db import models

@classmethod
def model_field_exists(cls, field):
    try:
        cls._meta.get_field(field)
 return True
@pmutua
pmutua / commit_format_examples.txt
Created December 6, 2018 08:29 — forked from mutewinter/commit_format_examples.txt
Examples of my commit format.
chore: add Oyster build script
docs: explain hat wobble
feat: add beta sequence
fix: remove broken confirmation message
refactor: share logic between 4d3d3d3 and flarhgunnstow
style: convert tabs to spaces
test: ensure Tayne retains clothing
- General
[ ] The code works
[ ] The code is easy to understand
[ ] Follows coding conventions
[ ] Names are simple and if possible short
[ ] Names are spelt correctly
[ ] Names contain units where applicable
[ ] Enums are used instead of int constants where applicable
[ ] There are no usages of 'magic numbers'
[ ] All variables are in the smallest scope possible
@pmutua
pmutua / API.md
Created October 17, 2018 11:58 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@pmutua
pmutua / fix-cordova-6.4.0-semver.patch
Created August 31, 2018 07:49 — forked from oidualc/fix-cordova-6.4.0-semver.patch
Fix for semver error in cordova 6.4.0
--- a/platforms/android/cordova/lib/emulator.js 2018-08-08 12:34:38.000000000 +0200
+++ b/platforms/android/cordova/lib/emulator.js 2018-08-08 14:14:35.000000000 +0200
@@ -187,7 +187,7 @@
var api_level = avd.target.match(/\d+/);
if (api_level) {
var level = android_versions.get(api_level);
- avd.target = 'Android ' + level.semver + ' (API level ' + api_level + ')';
+ avd.target = 'Android ' + (level ? level.semver : '') + ' (API level ' + api_level + ')';
}
}
@pmutua
pmutua / index.md
Created August 4, 2018 08:00
Creating Login, Register page with Ionic

Create new Ionic project with blank template

ionic start login blank
cd login
ionic g provider authService
ionic g page register
ionic g page login
@pmutua
pmutua / golang_setup
Created July 25, 2018 10:39 — forked from xXPhenomXx/golang_setup
Go Setup on Ubuntu & Revel
** To install Golang on Ubuntu 17.xx server **
sudo add-apt-repository ppa:gophers/archive
sudo apt-get update
sudo apt-get install golang-1.9-go
export PATH=$PATH:/usr/lib/go-1.9/bin
go version (To verify its mapped correctly, should see something like: go version go1.9.2 linux/amd64)
* make a directory for your go applications, I use /home/apps/go
export GOPATH=/home/apps/go
(Now from inside your /home/apps/go folder you can start creating your go apps)
@pmutua
pmutua / 100Doors.py
Created July 20, 2018 08:50
100 Doors Problem
'''
100 Doors Problem:
There are 100 doors in a row that are all initially closed.
You make 100 passes by the doors.
The first time through, visit every door and toggle the door (if the door is closed, open it; if it is open, close it).
The second time, only visit every 2nd door (door #2, #4, #6, ...), and toggle it.
The third time, visit every 3rd door (door #3, #6, #9, ...), etc, until you only visit the 100th door.
Task:
Answer the question: what state are the doors in after the last pass? Which are open, which are closed?
@pmutua
pmutua / update-golang.md
Created July 18, 2018 09:14 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@pmutua
pmutua / RAILS_5_CHEATSHEET.md
Created July 12, 2018 08:22 — forked from harrietty/RAILS_5_CHEATSHEET.md
Ruby on Rails 5 Cheatsheet

Ruby on Rails Cheatsheet (5.1)

Architecture

RVM

$ rvm list - show currently installed Rubies