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
@EdThePro101
EdThePro101 / how-to-setup-tlauncher.md
Created January 20, 2022 14:54
This is a guide to setting up TLauncher!

How to: Set up TLauncher

If you try installing TLauncher with JDK 17, you may end up with an error saying you need to install Java 8. The solution to this problem is a bit tedious, as you need two Java versions. So I hope this guide will clear everything up 😄

This was tested on Windows 10 and Adoptium's OpenJDK.

First and foremost, uninstall any Java versions on your system including TLauncher.

Afterwards, head over to Adoptium's OpenJDK 8 Archive and download the JRE Installer for your system. While the JRE is installing, make sure that all the features except Set JAVA_HOME variable is selected.

@EdThePro101
EdThePro101 / Matrix.hs
Last active February 4, 2021 06:09
This Gist contains some useful matrix operations such as addition, subtraction, exponentiation, etc.
module Matrix where
import Data.List (transpose)
newtype Matrix = Matrix [[Integer]] deriving (Show, Eq)
mFromList :: [[Integer]] -> Matrix
mFromList lst = Matrix lst
mToList :: Matrix -> [[Integer]]
@EdThePro101
EdThePro101 / styles.js
Created January 21, 2021 20:39
This is a small modification of the `styles.js` file of colors.js.
// Original: https://github.com/Marak/colors.js/blob/master/lib/styles.js
//
// 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");
@EdThePro101
EdThePro101 / file-io.c
Created January 12, 2021 12:30
File IO operations in 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
EdThePro101 / tokenise-string.c
Created January 6, 2021 12:30
Tokenise a string in C by whitespaces.
#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
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.
// 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
EdThePro101 / melody-gen.c
Created January 3, 2021 14:47
This is a very simple melody generator made in C.
// Copyright (c) 2021 Edwin Pratt
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
// Compile with
// gcc -Wall -Werror -Wextra -o melody-gen melody-gen.c
@EdThePro101
EdThePro101 / simple-makefile-v1.0.mk
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
# |---README.md
# |---bin
# | |---[empty for Makefile]
# |---obj
@EdThePro101
EdThePro101 / prng.f95
Created September 24, 2020 14:19
A simple pseudo-random number generator written in Fortran.
! 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
EdThePro101 / pip-upgrade-all.py
Created August 9, 2020 00:07
Update all Python packages with pip.
# python pip-upgrade-all.py
#
# This file will upgrade all Python packages that are out of date.
#
# This file is a snippet from a Stack Overflow answer.
# Link: https://stackoverflow.com/a/5839291/9591441
import pkg_resources as pkg_res
from subprocess import call