Skip to content

Instantly share code, notes, and snippets.

View codingedward's full-sized avatar

Edward Njoroge codingedward

View GitHub Profile
/**
* if n >= 2 => f(n) = f(n - 1) + f(n - 2)
* else 1
*
* f(30) = f(29) + f(28)
* f(29) = f(28) + f(27)
*
* f(3) = f(2) + f(1) (1 + 1) => 2
* f(2) = 1
* f(1) = 1
@codingedward
codingedward / fix_github_https_repo.sh
Created October 15, 2021 17:59 — forked from m14t/fix_github_https_repo.sh
Convert HTTPS github clones to use SSH
#/bin/bash
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password
REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'`
if [ -z "$REPO_URL" ]; then
echo "-- ERROR: Could not identify Repo url."
echo " It is possible this repo is already using SSH instead of HTTPS."
exit
fi
@codingedward
codingedward / stack_fibonacci.cpp
Last active June 22, 2021 02:12
Fibonacci using explict stack.
int fib(int n) {
// Init:
if (n <= 2) {
return 1;
}
int a = fib(n - 1);
// Resume 1:
int b = fib(n - 2);
// Resume 2:
return a + b;
@codingedward
codingedward / countries.js
Last active September 9, 2020 22:34
ISO 3166-1 alpha-3 codes
const countries = {
ABW: "Aruba",
AFG: "Afghanistan",
AGO: "Angola",
AIA: "Anguilla",
ALA: "Åland Islands",
ALB: "Albania",
AND: "Andorra",
ARE: "United Arab Emirates",
ARG: "Argentina",
@codingedward
codingedward / EmojiRichText.dart
Created July 22, 2019 11:29
Using a custom emoji font to solve emoji compatibility issues on flutter.
import 'package:flutter/material.dart';
class EmojiRichText extends StatelessWidget {
const EmojiRichText({
Key key,
@required this.text,
this.textAlign = TextAlign.start,
this.softWrap = true,
this.overflow = TextOverflow.clip,
this.textScaleFactor = 1.0,
""" File location: authors/apps/authentication/tests.py
Description: tests that a user cannot login with an invalid email address format.
"""
from django.test import TestCase, Client
from .models import UserManager
class AuthenticationTest(TestCase):
""" Tests authentication functionality of the application such as registration,
logging in, log out and refreshing of JWT tokens.