Skip to content

Instantly share code, notes, and snippets.

@MatMoore
MatMoore / loss.txt
Last active July 17, 2021 12:20
Github copilot
A poem about love, loss, and the universe.
This is a poem about love, loss, and the universe.
This is a poem about love, loss, and the universe.
This is a poem about love, loss, and the universe.
This is a poem about love, loss, and the universe.
This is a poem about love, loss, and the universe.
This is a poem about love, loss, and the universe.
This is a poem about love, loss, and the universe.
This is a poem about love, loss, and the universe.
@MatMoore
MatMoore / review.md
Last active June 10, 2021 18:58
Code review

Questions

This is a big bit of script, what's the best way to break it up? perhaps have lots of different scripts that are thematically linked and import them?

I guess I would start by making the parts of the script less dependent on each other.

For example, it's usually a bad idea to use global variables, as when you have global variables they can be written to from anywhere in your code, so it will quickly become hard to understand and even if you seperate the code things in one part of the code can have far reaching effects. This includes any variables you read from within a function, but declare in the main body of the script. On the other hand anything that is only assigned to within a function will be local to that function so you know it can't be modified by anything else.

Some ways to deal with global variables:

@MatMoore
MatMoore / 06-I-don't-have-time.md
Last active August 13, 2021 14:50
Working effectively with legacy code notes

I don't have much time and I have to change it (p58)

This chapter talks about ways to work around legacy code when you don't have time to refactor first. This happens a lot because it's hard to predict how long adding a feature to legacy code will take, and it's tempting to hack first and leave refactoring till the end (i.e. never).

Before using these techniques, see if you can get the legacy code into a test harness - it may be easier than you think.

If not, these techniques will reduce the risk and/or avoid making the legacy code incrementally worse over time.

The downside compared to refactoring the legacy code is that the legacy code won't go away, and the codebase will accumulate non-legacy bits that duplicate concepts from the legacy code. This is not so bad though, as it encourages further refactoring later as you find yourself reading more tested code.

@MatMoore
MatMoore / clarity.md
Last active February 10, 2021 14:02
Google Technical writing notes

Clarity

Examples of strong verbs: triggers, issues, generates, specify, omit

  • occured -> triggered
  • happens when -> generates
  • we are very careful to ensure that -> we carefully ensure
  • a compiler error happens -> the compiler generates an error
  • a variable declaration doesn't have a datatype -> you declare a variable but don't specify a datatype
  • errors occur when you leave off a semicolon -> the compiler triggers an error/issues errors when you leave off a semicolon
@MatMoore
MatMoore / cheat-sheet.md
Last active January 22, 2021 17:00
Javascript tools cheat sheet
@MatMoore
MatMoore / histogram.sql
Last active August 18, 2020 15:42
Creating a histogram in postgreSQL
with course_buckets as (
select
course_slug,
extract(days from open_for_enrolment_at - proposal_submitted_at) as days,
width_bucket(extract(days from open_for_enrolment_at - proposal_submitted_at), 0, 200,20) as bucket
from course_creation_milestones
where open_for_enrolment_at > current_timestamp - interval '3 months'
),
bucket_totals as (
@MatMoore
MatMoore / existing-process.plantuml
Created November 25, 2019 10:48
Deployment process for CCMS
@startuml
partition Development {
(*) --> "Write code in development environment"
"Write code in development environment" --> "Build for development environment"
"Build for development environment" --> "Deploy to development environment"
"Deploy to development environment" --> "Manual testing by developers"
"Manual testing by developers" --> "Push branch to github"
"Push branch to github" --> "Code review"
"Code review" --> "Merge code"
@MatMoore
MatMoore / Gems
Last active November 12, 2019 15:49
Libraries we reference in our Gemfiles and requirements.txt files
4 tzinfo-data
4 sass-rails
4 rails
3 uglifier
3 puma
3 govuk_notify_rails
3 bootsnap
2 wicked_pdf
2 sqlite3
2 simple_command