Skip to content

Instantly share code, notes, and snippets.

View samchouse's full-sized avatar

Samuel Corsi-House samchouse

View GitHub Profile
@samchouse
samchouse / auto_testing_grade_calc.md
Last active September 27, 2024 12:26
Grade calculation automated testing

Automated testing for Grade Calculation assignment

Made by me with test cases from Felix.

To run this script, follow these instructions:

  1. Create a file called test.py in the same directory as your calculation script and paste the contents of test.py from below.
  2. Create a file called tests.json in the same directory as your calculation script and paste the contents of tests.json from below.

Now to run the tests, go to the directory where all these files are located and open a terminal and run the following:

const scramble = (content: string) => {
return content.split(" ").map((word) =>
word.slice(0, 1) +
word.slice(1, word.length - 1).split("").sort(() => Math.random() - 0.5)
.join("") +
word.slice(word.length - 1)
).join(" ");
};
console.log(scramble(Deno.args[0] ?? ""));
@samchouse
samchouse / restoremongo.sh
Created August 23, 2021 17:34
Restore your MongoDB database
#!/bin/zsh
service="Mongo-Restore"
username='xenfo'
me=$(whoami)
as_user() {
if [ "$me" == $username ]; then
bash -c "$1"
else
@samchouse
samchouse / iconset.sh
Last active August 23, 2021 16:28
Create a set of icons to use for your PWA
#!/bin/zsh
filename=$1
sedFilename=$(echo $filename | sed -e 's/\..*$//g')
if [[ $filename == '' ]]; then
echo "Usage: iconset <file name>"
exit 1
fi
@samchouse
samchouse / backupmongo.sh
Last active August 23, 2021 17:34
Backup your MongoDB database
#!/bin/bash
service="Mongo-Backup"
username='xenfo'
me=$(whoami)
as_user() {
if [ "$me" == $username ]; then
bash -c "$1"
else
@samchouse
samchouse / screenshot.sh
Last active August 23, 2021 17:29
Screenshot something with FlameShot and upload it to an image host
#!/bin/zsh
keys=("upload.systems key")
urls=("https://api.upload.systems/images/upload")
rnd_idx=$(($RANDOM % 1 + 1))
key=${keys[rnd_idx]}
url=${urls[rnd_idx]}
@samchouse
samchouse / nginxmod.sh
Last active April 14, 2021 16:57
Nginx helper script
#!/bin/bash
##
# File:
# nginx_modsite
# Description:
# Provides a basic script to automate enabling and disabling websites found
# in the default configuration directories:
# /etc/nginx/sites-available and /etc/nginx/sites-enabled
# For easy access to this script, copy it into the directory:
@samchouse
samchouse / server.sh
Created January 29, 2021 16:02
Minecraft Server Management Script
#!/bin/bash
shopt -s nullglob
if [[ "$1" == '' ]]; then
:
elif [[ "$#" -gt "1" ]]; then
while getopts s: flag; do
case "${flag}" in
s)