Skip to content

Instantly share code, notes, and snippets.

View mreed4's full-sized avatar

Matthew mreed4

View GitHub Profile
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap');
/* ==UserStyle==
@name
@namespace github.com/openstyles/stylus
@version 1.0.0
@description A new userstyle
@author Me
==/UserStyle== */
bdi,
.Layout-main #user-profile-frame > div > div:first-child {
/* Targets the controls -- the "Find a repository" search, buttons, etc. */
border-bottom: 0 !important;
}
#user-repositories-list ul {
/* Targets the list of all repos */
display: flex;
flex-direction: row;
flex-wrap: wrap;
// mreed4 committed on Nov 27, 2022
function getExplodedNumber(number, toString) {
let digits = number.toString(10).length;
let explodedNumber = [];
for (let i = digits; i > 0; i--) {
let x = number % Math.pow(10, i);
let y = number % Math.pow(10, i - 1);
explodedNumber.push(x - y)
}
// mreed4 committed on Aug 8, 2021
const addLeadingZeros = n => {
let desiredLength = 3;
if (n.length === 1) {
while (n.length < desiredLength) {
n = `0` + n;
}
// mreed4 committed on Aug 4, 2021
function randNum() {
return Math.floor(Math.random() * 1000000);
}
function collatz(num = randNum()) {
// num = parseInt(prompt(`Input any number`)); // User input
const initialNumber = num; // Save number before it mutates
/* An "Expert" level exercise from Edabit.com.
Each person in Italy has an unique identifying ID code issued by the national
tax office after the birth registration: the Fiscal Code (Codice Fiscale). Given an
Object containing the personal data of a person (name, surname, gender and date of birth)
return the 11 code characters as a string, according to certain rules.
There are three parts of the fiscal code, corresponding to the four parts of the Object.
[Surname][Name][DOB & Gender]
/*
Input is a two-level nested object with values of all keys at all levels set to "" (a blank string). Output is another object, same level of nesting, with all values at all levels set to another string (or--as I used it--as to a class instantiation, etc.)
I built this for a specific purpose, for a much larger project.
This can/should probably be refactored to allow for it to work beyond two levels of nesting. Perhaps this could be accomplished via recursion, or perhaps via a wrapper for loop.
*/
@mreed4
mreed4 / index.html
Created May 20, 2021 22:55
HTML5 Boilerplate - No jQuery, no Bootstrap, async, responsive ready
<!doctype html>
<html lang="en">
<head>
<title>Title</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="css/styles.css">
@mreed4
mreed4 / OddOrEven.py
Created February 13, 2021 04:37
Exercise 2 from PracticePython.org
# http://www.practicepython.org/exercise/2014/02/05/02-odd-or-even.html
# Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the
# user. Hint: how does an even-odd number react differently when divided by 2?
# Note to self: This required you looking at the solution
# Greet user
print("\nGreetings, user.")
@mreed4
mreed4 / CharacterInput.py
Last active February 13, 2021 04:36
Exercise 1 from PracticePython.org
# http://www.practicepython.org/exercise/2014/01/29/01-character-input.html
# Create a program that asks the user to enter their name and their age. Print out a message addressed to them that
# tells them the year that they will turn 100 years old.
# Get current year
import datetime
date = datetime.datetime.now()
year = date.year