Skip to content

Instantly share code, notes, and snippets.

View mfonism's full-sized avatar

Mfon Kiwi Eti-mfon mfonism

View GitHub Profile
@mfonism
mfonism / index.html
Created March 4, 2020 12:22
Landing page for Project inQubate
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>inQubate</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="" content="">
<meta name="author" content="Mfon Eti-mfon">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Charm|Montserrat:300&display=swap">
@mfonism
mfonism / app-1.spec.ts
Created March 9, 2020 10:47 — forked from wkwiatek/app-1.spec.ts
Angular 2 test snippets for Angular final version. Codebase for https://developers.livechatinc.com/blog/category/programming/angular-2/
// App
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: '<span>{{ sayHello() }}</span>',
})
export class App {
public name: string = 'John';
@mfonism
mfonism / components-and-services.md
Created March 10, 2020 09:59
Snapshots of my mind when I was learning Angular

Hello Ng Component... Meet My Friend, Ng Service!

  • Create a component
  • Create a corresponding service
  • Add properties and methods to the service
  • Ask for the service to be injected into the component as a dependency: do this by specifying it as a property in the signature of the component's constructor
    • If there's need to access this service outside the component, for example, in a template, then specify a public property
@mfonism
mfonism / post.service.spec.ts
Last active March 12, 2020 15:51
Learning TDD in Angular
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { TestBed, async, inject } from '@angular/core/testing';
import { PostService } from './post.service';
describe('PostService', () => {
// before this entire suite of unit tests is run
// declare the http mock and the service to be tested
@mfonism
mfonism / finalImplementations.md
Created April 2, 2020 00:16 — forked from PercyPham/finalImplementations.md
Implementing Json Web Token (JWT) to secure your app
@mfonism
mfonism / 01_Running_Tests.md
Last active October 31, 2020 07:53
Notes on my experience learning aiohttp (and asyncio) by building a RESTful API (https://github.com/mfonism/Qriosity)

Battling with the Test Client

The aiohttp_client fixtures from pytest_aiohttp was (and still is) an excellent idea. The promise I saw in it was that I would be able to run my tests the way I do while working with Django. That is, the test runner will automatically run the app for the duration of the tests, a db will be created specifically for the tests, and the tests will be run in isolation with respect to each other.

However, this did not work out so well for me. aiohttp_client kept erroring out with a warning that the event loop was already in use.

In attempting to solve this problem, I learnt how to create a session-scoped event loop for tests - the default loop exposed by pytest_asyncio is function scoped, and a number of the fixtures I had created at that iteration of the app were session scoped and required a session scoped event loop.

A Honking Great Idea

@mfonism
mfonism / index.html
Last active May 28, 2020 03:53
Tabbed Page Layout with JavaScript
<!DOCTYPE html>
<html>
<head>
<title>Tabbed Page</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<main>
<section class="red"></section>
<section class="orange"></section>

Open file with vim

$ sudo vim <filename>

Press i to go into edit mode

Edit the file

import datetime
import json
from typing import Dict, List, Optional
from requests import Request, Response, Session
from requests_mock import Adapter
from requests_mock.request import _RequestObjectProxy
adapter = Adapter()
session = Session()
@mfonism
mfonism / console_log
Created October 13, 2020 17:48
Console log from my attempt at installing and testing out astropy on my Windows 10 PC
Microsoft Windows [Version 10.0.19041.508]
(c) 2020 Microsoft Corporation. All rights reserved.
C:\Users\Mfonism>python --version
Python 3.8.1
C:\Users\Mfonism>python -c "import sys; print(sys.executable)"
C:\Users\Mfonism\AppData\Local\Programs\Python\Python38\python.exe
C:\Users\Mfonism>python -m pip install -U pip