Skip to content

Instantly share code, notes, and snippets.

View stuartmclean's full-sized avatar
🙃

Stuart McLean stuartmclean

🙃
View GitHub Profile
@stuartmclean
stuartmclean / advent_of_code_2023_day_3.py
Last active December 3, 2023 14:40
Advent of Code 2023 Day 3 Python Solution
#!/usr/bin/env python3
import copy
import os
class Part():
def __init__(self) -> None:
self.digits = []
self.positions = set()
@stuartmclean
stuartmclean / advent_of_code_2023_day_1.py
Created December 1, 2023 22:50
Advent of Code 2023 Day 1
#!/usr/bin/env python3
import os
import sys
class DayOne:
_num_words_to_numbers = {
'one': '1',
'two': '2',
@stuartmclean
stuartmclean / essential-git-version-control.md
Created October 9, 2023 19:00
Essential Git Version Control

essential git

2 ways to start a repository:

  • start locally:
    • git init - intialize new git repository in the current directory
    • git remote add origin <address-in-github>
    • git push origin HEAD push current branch to a corresponding branch in git
  • download from the web (remote repository):
    • git clone <repository address> - locally download existing repository from the web
@stuartmclean
stuartmclean / gcloud_bearer_token.ts
Last active April 2, 2023 15:46
Generate a self-signed JWT token for use on GCP with Typescript
import { KJUR } from "jsrsasign";
function currentTimeInSeconds(): number {
return Math.floor(Date.now() / 1000);
}
class Payload {
iss: string;
sub: string;
email: string;
@stuartmclean
stuartmclean / where_to_go_for_help.md
Created March 14, 2023 20:38
Where Can ReDI School Learners go for Help?

Where to go for help if teachers aren’t available:

  • type your question into the class slack channel.
  • remember that internet was created by programmers and there’s lots of resources there for us.
  • do a google search.
  • check w3schools.com.
  • check stack-overflow.com.
  • read the python3 docs.
  • run help(<function>) (e.g. help(sum)) in colab, a python file or in the python console.
  • command click (ctrl-click on windows) in pycharm (links to documentation).
  • take a break - usually between 5 minutes and 2 days is best. Sometimes your subconscious mind will help you find the solution you’re looking for - here’s a great presentation about this.
@stuartmclean
stuartmclean / json_client.go
Created October 11, 2022 18:52
go http json client with timeouts
package util
import (
"bytes"
"context"
"encoding/json"
"io/ioutil"
"net"
"net/http"
"time"
@stuartmclean
stuartmclean / intro_to_git_with_PyCharm.md
Last active October 31, 2021 21:13
Intro to Git with PyCharm

Version Control

The concept of "SOFT"-ware is that it is something which should be easy to change and update (or roll-back).

Before you wrote code you've probably collaborated with other people on word documents or spreasheets.

  • Have you ever kept multiple versions of a file, in case you wanted to go back and get things you might have previously deleted or changed?
  • Have you ever emailed around versions of a file between several people and struggled to keep everone in sync without overwriting anything, or having changes and contributions get lost?
  • Have you ever had trouble with multiple people editing the same files and trying to merge together all their work?
@stuartmclean
stuartmclean / pycharm_and_debugging.md
Last active November 5, 2021 12:30
PyCharm and Debugging Session Handout

PyCharm and Debugging Session Handout

Acronyms and Key Terms

  • IDE - Integrated Development Environment - E.G. PyCharm
  • REPL - Read Eval Print Loop - E.G. Python Console
  • Debugger - Included in PyCharm allows you to pause and execute

Keyboard shortcuts

CTRL-SHIFT-A (COMMAND-SHIFT-A on Mac) - find a shortcut DOUBLE-SHIFT (press fast) - search for a class, file or function

@stuartmclean
stuartmclean / deploy.sh
Last active May 31, 2021 12:14
A quick deploy helper script that checks out merges a specified staging branch and merges it with latest master, giving an opportunity to check if the commit log makes sense before pushing and returning to the last branch you were working on.
#!/usr/bin/env bash
function printemphasized {
printf "\n**$1**\n\n"
}
function checkoutpull {
git checkout "$1"
git merge --ff-only @{u}
}
@stuartmclean
stuartmclean / first_time_programmers.md
Last active April 13, 2021 19:46
Some advice for first time programmers

Advice for first-time programmers

What you need:

A good free online course:

Like Harvard CS50.

A good note taking app - there's too much to remember

Apple "Notes" is ok, but Joplin is better.