Skip to content

Instantly share code, notes, and snippets.

View EdThePro101's full-sized avatar
In High School

Edwin Pratt EdThePro101

In High School
View GitHub Profile

C++ Coding Standards Part 0: Automated Code Analysis

Automated analysis is the main advantage to working with a modern statically typed compiled language like C++. Code analysis tools can inform us when we have implemented an operator overload with a non-canonical form, when we should have made a method const, or when the scope of a variable can be reduced.

In short, these tools catch the most commonly agreed best practice mistakes we are making and help educate us to write better code. We will be fully utilizing these tools.


All reasonable warning levels should be enabled. Some warning levels, such as GCC's -Weffc++ warning mode can be too noisy and will not be recommended for normal compilation.

EdThePro101 / instalike.js
Last active January 7, 2021 18:10
A simple implementation of an Instagram bot that likes photos
View instalike.js
// Copyright (c) 2020 Edwin Pratt
// The author of this file is not responsible for any problems this script may cause.
// This file was created as toy while learning JavaScript.
// ------------------------------
// I was always interested in bots and how they work. So I created this simple bot that will like photos on Instagram.
// To use this script, go to and login.
EdThePro101 /
Created August 9, 2020 00:07
Update all Python packages with pip.
# python
# This file will upgrade all Python packages that are out of date.
# This file is a snippet from a Stack Overflow answer.
# Link:
import pkg_resources as pkg_res
from subprocess import call
EdThePro101 / prng.f95
Created September 24, 2020 14:19
A simple pseudo-random number generator written in Fortran.
View prng.f95
! A simple pseudo-random number generator made in Fortran 2018.
! The .f95 extension is used only for syntax highlighting.
! Compile with:
! gfortran -std=f2018 -Wall -Werror -Wextra prng.f95 -o prng
! -----------------------
! Equation used:
EdThePro101 /
Last active December 9, 2020 05:30
This Makefile is used in most of my projects. It's simple, easy to modify and is legible.
# Copyright (c) 2020 Edwin Pratt
# Licenced under the MIT Licence
# Example project structure
# awesome_project
# |---Makefile
# |
# |---bin
# | |---[empty for Makefile]
# |---obj
EdThePro101 / melody-gen.c
Created January 3, 2021 14:47
This is a very simple melody generator made in C.
View melody-gen.c
// Copyright (c) 2021 Edwin Pratt
// This software is released under the MIT License.
// Compile with
// gcc -Wall -Werror -Wextra -o melody-gen melody-gen.c
EdThePro101 / remapper.js
Created January 6, 2021 12:18
Remap a number from one range to another range. For example, remap celsius to fahrenheit or remap kilometres to miles.
View remapper.js
// To remap a value x in range [a, b] to [c, d], we can use:
// y = (x - a) * ((d - c) / (b - a)) + c
function remapper(x, a, b, c, d) {
let y = (x - a) * ((d - c) / (b - a)) + c;
return y;
EdThePro101 / tokenise-string.c
Created January 6, 2021 12:30
Tokenise a string in C by whitespaces.
View tokenise-string.c
#include <stdio.h>
#include <string.h>
// Check if a character is a digit
char is_digit(char curr) {
return (curr >= '0' && curr <= '9');
// Check if a character is a letter
char is_letter(char curr) {
EdThePro101 / file-io.c
Created January 12, 2021 12:30
File IO operations in C.
View file-io.c
// file-io.h
// #ifndef FILE_IO_H
// #define FILE_IO_H
// // Read and write files.
// // filename - The file's name.
// // buffer - Buffer that will contain file characters.
// // buffer_length - The length of the buffer.
// //
EdThePro101 / styles.js
Created January 21, 2021 20:39
This is a small modification of the `styles.js` file of colors.js.
View styles.js
// Original:
// This is a slight modification of the `styles.js` file of colors.js.
// I've made it a bit more readable and added comments to explain what it does.
// I've also added a helper function that can be used to make your codes a bit more readable.
// Example usage:
// ```js
// const styles = require("/path/to/styles.js");