Lessons
Every lesson on Hone, in teaching order
701 short lessons across nine tracks. Each one is an idea in plain words, what it is for, how to think about it, a worked example that runs, and the trap.
Hone is a place to practise programming: you answer questions, solve problems, and it remembers what you got wrong so it can ask you again later. These are the written explanations behind that, free to read on their own. A track is one subject, like Python or the command line. A topic is one idea inside it.
Python 102 lessons
Python quick reference: every topic on one page, one line each.
Your first code · Values and names
- Storing a value in a name storing a value in a name
- Text that looks like a number is still text text vs numbers
- Turning a value into text turning a value into text
- Text that should have been a number text that should be a number
- Notes to the next reader, who is usually you comments (# notes)
Your first code · Doing things
- Functions hand something back calling a function
- Showing a value versus giving it back showing a value or handing it back
- How long is this text how long is this text
- One case to compare in one case to compare in
- Cleaning and reshaping text cleaning and reshaping text
Your first code · Numbers that behave
- The remainder % the remainder
- Whole parts and what is left over // and %
- Whole-number division // whole-number division
- Raising to a power ** raising to a power
- Which operator goes first which operator goes first
Your first code · Lists of things
- Counting from zero the first item is item 0
- Counting a fixed number of times range()
- Counting from the end counting from the end
- Build the list outside the loop build the list outside the loop
- Build a list in one line list comprehensions
- Adding one thing versus adding many adding one thing or many
Your first code · Deciding and repeating
- Choosing between two paths if / else
- Returning the answer, not a description of it returning True/False
- Repeat until something changes while loops
- Getting the position as well as the item enumerate (index + value)
- Asking whether something is there in (is it inside?)
Your first code · Looking things up
- Asking for a key that might not be there dict.get (missing keys)
- Position or name? list or dict?
- A collection that refuses duplicates sets remove duplicates
- A sorted copy sorted() gives a new list
- A window onto a sequence slicing a[start:stop]
Your first code · Objects that remember
- A class is a blueprint; an object is one thing made from it classes (a blueprint)
- __init__ runs when an object is built; self is that object __init__ and self
- Methods are functions that receive the object methods and attributes
- What an object shows, and when two are equal __repr__ and __eq__
- A subclass gets the parent's methods and can change some inheritance and super()
- A dataclass writes the boilerplate for you dataclasses
Read code you did not write · Which is which
- Same value, or the same thing two equal lists are not one list
- Why a is b can be False when a == b == vs is
- Assignment does not copy copy or the same thing?
- Text cannot be changed, only replaced strings cannot be changed
- What counts as true what counts as true
Read code you did not write · The traps
- The default argument that remembers the def f(x=[]) trap
- Do not change the list you are walking changing a list while walking it
- Two names for one list two names, one list
- A copy that is not all the way down shallow vs deep copy
- A lambda looks up its variable when it runs lambdas look up late
Read code you did not write · What it costs
- Why a dict finds things instantly dict lookup is fast
- One pass, one running fact scanning a list is slow
- A loop inside a loop multiplies loop inside a loop
- Where 'in' is fast in: list vs set
- Spend memory to save time memory for speed
Read code you did not write · Say why
- Where a name lives where a variable lives
- Nothing is a value too checking for None
- Plan for the failure try / except
- Catch the error you expect bare except
- Decimals that are almost equal comparing decimals
Read code you did not write · Prove it works
- assert says what must be true assert
- A test is a function that asserts one fact a test function
- Arrange, act, assert arrange, act, assert
- Test the ends first: nothing, one, everything the same edge cases first
Job-ready fundamentals · Reach for the right structure
- Remember what you have seen, in a dict look it up in a dict
- Sort by the thing that matters sorting with a key
Job-ready fundamentals · The classics
- Halve the search space every step searching sorted data
- A problem defined by a smaller version of itself a function that calls itself
Job-ready fundamentals · Say it in the interview
- Say the cost out loud, before you are asked saying the cost out loud
- Name both sides of the trade-off naming the trade-off
- What to say when you are stuck what to say when stuck
- The two-minute story: Situation, Task, Action, Result the STAR story
Keep the edge · Deep water
- Dicts remember insertion order dicts keep order
- A generator only runs once generators run once
- A function that takes any number of values *args
- setdefault hands you the stored object defaultdict adds keys
- Why 'is' flickers on numbers why 256 is 256
Keep the edge · Money and time
- Money is whole cents money is whole cents
- A time that knows where it is a time that knows its timezone
- Rounding halves to even round() sends halves to even
- Do not compare floats with == do not compare decimals with ==
Keep the edge · Data at scale
- Deduplicating records deduplicating records
- Sort by two things stable sorting
- When a join multiplies rows when a join multiplies rows
- Rows with no key vanish from a group-by rows with no key vanish from a group-by
- A comprehension keeps its variable to itself comprehension variables
Data structures and algorithms · Things in a line
- Nodes that point at the next node linked lists
- Last in first out, and first in first out stacks and queues
- Two fingers, one pass two pointers
- A window that grows and shrinks the sliding window
Data structures and algorithms · Things in a grid
- A grid is a list of lists grids (a list of lists)
Data structures and algorithms · Things in a tree
- A node, a left and a right binary trees
- Two ways to visit every node walking a tree
Data structures and algorithms · Things in an order
- What sorting costs, and what it buys what sorting costs
- Always hand me the smallest heaps (the smallest first)
Data structures and algorithms · Things joined to things
- Things joined to things graphs (things joined to things)
- Remember what you already worked out memoising (not doing it twice)
- Take the best step now, and never look back greedy choices
More
- Asking a question of every item at once any() and all()
- Walking a dict: keys, values, or both looping over a dict
- Putting values into text putting values into text
- Leave as soon as you know leave as soon as you know
- Sorting in place versus sorting a copy sort() vs sorted()
- From pieces to one string join (pieces to text)
- Walking two lists together zip (walk two lists)
JavaScript 75 lessons
JavaScript quick reference: every topic on one page, one line each.
Data structures and algorithms · Things in a line
- Objects that point at the next object linked lists
- Last in first out, and first in first out stacks and queues
- Two fingers, one pass two pointers
- A window that grows and shrinks the sliding window
Data structures and algorithms · Things in a grid
- A grid is an array of arrays grids (a list of lists)
- A loop inside a loop multiplies loop inside a loop
- One pass, one running fact scanning an array is slow
Data structures and algorithms · Things in a tree
- A node, a left and a right binary trees
- Two ways to visit every node walking a tree
- A problem defined by a smaller version of itself a function that calls itself
Data structures and algorithms · Things in an order
- What sorting costs, and what it buys what sorting costs
- Always hand me the smallest heaps (the smallest first)
- Sort by the thing that matters sort with a comparator
Data structures and algorithms · Things joined to things
- Things joined to things graphs (things joined to things)
- Remember what you already worked out memoising (not doing it twice)
- Take the best step now, and never look back greedy choices
JavaScript for the web · Values
- What kind of value is this typeof
- When + stops adding + with a string and a number
- Joining text joining two strings
- Plain addition adding two numbers
- Flipping a condition ! flips true and false
- A one-line if that has a value the one-line if
JavaScript for the web · Arrays
- Adding to the end push
- Picking an item by position the first item is item 0
- How many length and the last item
- Keeping what passes filter
- Gluing a list into text join (pieces to text)
- slice copies, splice cuts slice copies, splice changes
JavaScript for the web · Truth and equality
- What counts as true what counts as true
- Why === and not == why === and not ==
- Does it have a value null vs undefined vs empty
- Two kinds of nothing never set, or set to nothing
- Forcing a boolean !! makes a boolean
- A default only for missing ?? only catches null and undefined
JavaScript for the web · Functions and scope
- Where a variable lives let is bounded by its block
- What exists before its line reading a name before it exists
- A function that remembers where it was made functions that remember
- Arrows keep the this they were born in arrow functions and this
- A default when the argument is missing default parameters
- Copying with three dots ... spread
JavaScript for the web · Async
- An async function always returns a promise async always hands back a promise
- Catching a rejection catching a promise
- await pauses only its own function async / await
- What runs when the event loop
JavaScript for the web · Objects and classes
- A class builds objects with new classes and new
- this is the object before the dot this in methods
- extends shares a parent; super reaches it extends and super
- Getters read like properties; static lives on the class getters, static and #private
- A class is a prototype with nicer syntax prototypes under the hood
JavaScript for the web · Prove it works
- assert says what must be true assert
- A test is a named function that asserts one fact a test function
- Arrange, act, assert arrange, act, assert
- Test the ends first: nothing, one, everything the same edge cases first
More
- Asking a question of every item at once some() and every()
- Naming a value storing a value in a name
- Build a new array from an old one map and filter
- const fixes the name, not the contents reassigning a const
- Putting values into text template literals
- Remember what you have seen, in a Map look it up in a Map
- Is it in there? is it in there
- Whole parts and remainders in JavaScript Math.floor and %
- Array or object? array or Map?
- Changing what was handed to you copy before you change it
- Object keys are strings object keys are text
- Counting with a loop counting loops
- Fold a list into one value folding a list into one value
- Leave as soon as you know leave as soon as you know
- A collection that refuses duplicates Set removes duplicates
- A window onto an array or string slice()
- sort() sorts as text sorting numbers as text
- Halve the search space each step searching sorted data
- Spend memory to save time memory for speed
- Cleaning and reshaping text cleaning and reshaping text
- Repeat until something changes while loops
- Walking two arrays together zip (walk two lists)
TypeScript 107 lessons
TypeScript quick reference: every topic on one page, one line each.
Data structures and algorithms · Things in a line
- Objects that point at the next object linked lists
- Last in first out, and first in first out stacks and queues
- Two fingers, one pass two pointers
- A window that grows and shrinks the sliding window
Data structures and algorithms · Things in a grid
- A grid is an array of arrays grids (a list of lists)
- A loop inside a loop multiplies loop inside a loop
- One pass, one running fact scanning an array is slow
Data structures and algorithms · Things in a tree
- A node, a left and a right binary trees
- Two ways to visit every node walking a tree
- A problem defined by a smaller version of itself a function that calls itself
Data structures and algorithms · Things in an order
- What sorting costs, and what it buys what sorting costs
- Always hand me the smallest heaps (the smallest first)
- Sort by the thing that matters sort with a comparator
Data structures and algorithms · Things joined to things
- Things joined to things graphs (things joined to things)
- Remember what you already worked out memoising (not doing it twice)
- Take the best step now, and never look back greedy choices
TypeScript, properly · Why types
- Types, checked before it runs what TypeScript adds
- Saying what a thing is type annotations
- Types you did not write inference
- Types are gone at runtime types are gone at runtime
- any turns the checker off any turns the checking off
TypeScript, properly · Shapes
- The shape of an object interfaces and optional fields
- A property that may be missing a property that may not be there
- One of several types union types
- Exactly these strings a type of exact values
- A fixed shape of array a fixed-length, fixed-type array
TypeScript, properly · Narrowing
- Checks the compiler follows narrowing with checks
- A check the compiler remembers teaching the compiler what it is
- Nothing has a type too strict null checks
- Anything in, nothing out until checked unknown makes you check first
- null is not a string null is not every type's member
TypeScript, properly · Generics and beyond
- A function that keeps the type it was given generics
- A generic with a requirement extends: what a generic must have
- The keys as a type keyof: the names of the keys
- A tag that tells the variants apart discriminated unions
- Every case, or a compile error never: proving you covered every case
TypeScript, properly · Classes and interfaces
- Fields are declared with their types typed fields and parameter properties
- private, protected and readonly draw the fence private, protected, readonly
- An interface describes; a class implements and builds implements an interface
- An abstract class shares real code and demands the rest abstract classes
- extends with super first, a compatible override, and instanceof narrowing extends, override, instanceof
TypeScript, properly · Prove it works
- Types promise a shape; a test proves a value types promise, tests prove
- A typed test is checked before it runs a typed test
- Arrange, act, assert, with the fixture typed arrange, act, assert, typed
- The type names the edge; the test proves it the type names the edge
More
- Asking a question of every item at once some() and every()
- Naming a value storing a value in a name
- An async function always returns a promise async always hands back a promise
- A function that remembers where it was made functions that remember
- Build a new array from an old one map and filter
- const fixes the name, not the contents reassigning a const
- Putting values into text template literals
- Remember what you have seen, in a Map look it up in a Map
- What exists before its line reading a name before it exists
- Is it in there? is it in there
- Whole parts and remainders in JavaScript Math.floor and %
- Plain addition adding two numbers
- Arrange, act, assert arrange, act, assert
- Picking an item by position the first item is item 0
- Adding to the end push
- Arrows keep the this they were born in arrow functions and this
- assert says what must be true assert
- await pauses only its own function async / await
- A class builds objects with new classes and new
- Joining text joining two strings
- A default when the argument is missing default parameters
- Forcing a boolean !! makes a boolean
- Test the ends first: nothing, one, everything the same edge cases first
- Why === and not == why === and not ==
- What runs when the event loop
- extends shares a parent; super reaches it extends and super
- Keeping what passes filter
- Getters read like properties; static lives on the class getters, static and #private
- Gluing a list into text join (pieces to text)
- How many length and the last item
- Flipping a condition ! flips true and false
- Does it have a value null vs undefined vs empty
- A default only for missing ?? only catches null and undefined
- Catching a rejection catching a promise
- A class is a prototype with nicer syntax prototypes under the hood
- Copying with three dots ... spread
- When + stops adding + with a string and a number
- A one-line if that has a value the one-line if
- A test is a named function that asserts one fact a test function
- this is the object before the dot this in methods
- What kind of value is this typeof
- Where a variable lives let is bounded by its block
- Array or object? array or Map?
- Changing what was handed to you copy before you change it
- Two kinds of nothing never set, or set to nothing
- Object keys are strings object keys are text
- Counting with a loop counting loops
- Fold a list into one value folding a list into one value
- Leave as soon as you know leave as soon as you know
- A collection that refuses duplicates Set removes duplicates
- slice copies, splice cuts slice copies, splice changes
- A window onto an array or string slice()
- sort() sorts as text sorting numbers as text
- Halve the search space each step searching sorted data
- Spend memory to save time memory for speed
- Cleaning and reshaping text cleaning and reshaping text
- What counts as true what counts as true
- any switches checking off; unknown makes you prove it any vs unknown
- Promise not to change it readonly
- Check the shape, keep the detail satisfies
- Repeat until something changes while loops
- Walking two arrays together zip (walk two lists)
SQL 52 lessons
SQL quick reference: every topic on one page, one line each.
Queries that hold up · It ran, and it lied
- Where the filter goes in a LEFT JOIN a WHERE that undoes a LEFT JOIN
- Two totals from one pass adding up only some rows
- Arithmetic on dates date ranges
- A range, inclusive BETWEEN is inclusive
- AND binds tighter than OR AND before OR
Queries that hold up · Filter at the right moment
- Filter rows with WHERE, groups with HAVING HAVING vs WHERE
- What SELECT may contain after GROUP BY grouped SELECTs
- Sorting by more than one thing ORDER BY two columns
- Just some of the rows LIMIT
Queries that hold up · A question inside a question
- A query inside a query subqueries
- A query that returns one value comparing against one computed value
- Is there such a row is there at least one
Queries that hold up · One row per thing, and what it costs
- The whole row that holds the maximum the top row per group
- A subquery that runs per row a subquery that runs per row
- DISTINCT collapses duplicates why DISTINCT is slow
Queries that hold up · Changing data without regret
- UPDATE needs a WHERE UPDATE needs WHERE
- DELETE needs a WHERE DELETE needs WHERE
- Ranking with window functions transactions
- Adding a row INSERT
SQL for the workplace · Ask a question
- Asking a table for columns SELECT basics
- Keeping only the rows you mean WHERE
- Both conditions at once AND narrows the rows
- The top of a sorted list the top one, by order
- Each value once one row per value
- Pattern matching on text LIKE
SQL for the workplace · Count and sum
- One number from many rows COUNT, SUM, AVG
- How many rows counting rows
- Adding a column up adding a column up
- The largest value the largest value
- One number per group GROUP BY
- Bucketing by a computed value GROUP BY an expression
- Filtering groups filtering the groups, not the rows
- Averages skip the blanks AVG skips the NULLs
SQL for the workplace · Join the tables
- Rows from two tables, matched up JOIN
- Only the matches INNER JOIN
- Keep every row on the left keeping the rows with no match
- Keep everyone, spot the gaps LEFT JOIN and NULL
- When a join multiplies rows when a join multiplies rows
- An inner join drops the unmatched an inner join loses rows
SQL for the workplace · Nothing is something
- NULL means unknown None
- Finding the blanks testing for NULL
- A value instead of NULL COALESCE
- Why = NULL finds nothing comparing with NULL
- NOT IN and a single NULL NOT IN meets a NULL
- COUNT(*) versus COUNT(column) COUNT and NULL
SQL for the workplace · The real reports
- Naming a step naming a query with WITH
- Turning values into labels sorting rows into buckets
- Grouping by calendar month grouping by month across years
- The latest row per group the most recent one each
- A total beside every row a window keeps every row
- A running total a total that grows down the rows
More
- Naming a column or table aliases (AS)
Regex 52 lessons
Regex quick reference: every topic on one page, one line each.
Regex that reads · Literal to pattern
- Characters match themselves literal characters
- Any one character any one character
- Literal special characters escaping specials
- One character from a set character classes
- Matching a digit \d: any digit
Regex that reads · How many
- How many times + * ? quantifiers
- One or more +: one or more
- Zero or more *: none or more
- Zero or one ?: there or not
- Exactly, at least, between {2,4}: between two counts
Regex that reads · Where
- Pin the pattern to the edges ^ and $ anchors
- The edge of a word word boundaries
- This or that alternation (or)
- Capturing the parts capture groups
- Capturing a piece ( ): keeping the part you matched
Regex that reads · The sharp edges
- Greedy takes all it can greedy vs lazy
- As little as possible *?: stopping at the first match
- Check what follows without taking it lookahead
- The same thing again backreferences
- Patterns that never finish catastrophic backtracking
The pattern that is right about your data · Which call, and what it hands back
- Where the engine starts looking search or match: where it starts looking
- All of it, or nothing fullmatch: all of it or nothing
- The matches, and where they were finditer: matches and where they were
- Nothing is None, not empty a failed search hands back None
- Zero is the whole match group(0): the whole match
- findall hands back the group findall hands back the group, not the match
The pattern that is right about your data · Change the text, not just find it
- Putting the pieces back in a different order \1 in the replacement
- A replacement that decides replacing with a function
- Only the first few, and how many there were replacing only the first few
- Splitting, and keeping what you split on split: keeping the separator
The pattern that is right about your data · A flag changes the whole meaning
- One start, or one per line ^ and $: once, or once per line
- The dot stops at a newline the dot stops at a newline
- A pattern with room to breathe VERBOSE: a pattern with room to breathe
- A flag written inside the pattern (?i): a flag inside the pattern
- Two different ends $ and \Z: two different ends
The pattern that is right about your data · The data is not ASCII
- A letter is not always a-z \w is not only English
- More digits than you think \d is more digits than you think
- Narrowing it back to ASCII ASCII: back to a-z and 0-9
- Bytes are not text matching bytes rather than text
The pattern that is right about your data · Fast, or hanging
- A quantifier inside a quantifier a quantifier inside a quantifier
- Telling the engine where to start anchoring so it gives up early
- Compiling, and what it is really for the pattern cache, and when it stops helping
- The first branch that works, wins which alternative wins
The pattern that is right about your data · When not to reach for one
- HTML nests and a pattern cannot count why not to parse HTML with one
- The comma inside the quotes the comma inside the quotes
- An address you validate by sending to it an address you validate by sending to it
- It can find them; it cannot pair them a pattern cannot count brackets
The pattern that is right about your data · Prove the pattern
- Test it on what nearly matches testing it on what nearly matches
- A match that is not the whole value a match that is not the whole value
- What a person typed is not a pattern re.escape: anything a person typed
- The pattern you will have to read again the pattern you will have to read again
More
- Switches on the whole pattern flags: i, m, s and x
Git 62 lessons
Git quick reference: every topic on one page, one line each. Run these for real: a repository in this page that you cannot break.
Git without fear · The three areas
- Starting a repository starting a repository
- What Git thinks right now what git can see right now
- Choosing what the next commit contains choosing what goes in the commit
- Recording a snapshot recording a snapshot
- Working tree, index, repository the folder, the staging area, the last commit
- Reading the history reading the history
Git without fear · The daily rhythm
- Seeing the change before you record it what changed, line by line
- A message someone can use writing a commit message
- Files Git should never track files git should not watch
- Where HEAD points HEAD: where you are standing
- Taking a change back putting a file back
- Removing a file properly deleting a file git tracks
- Renaming so history follows renaming a tracked file
- Fixing the last commit redoing the last commit
Git without fear · Branches and merges
- A branch is a pointer a branch is a name for a commit
- Moving between branches moving between branches
- Bringing a branch in fast-forward: no merge needed
- When both sides moved when both sides moved
- Resolving a conflict when git will not guess
- Shelving work for a moment stash: putting work aside
Git without fear · Working with others
- Getting a copy of a project copying a whole repository
- Named places to sync with the other end, by name
- fetch looks, pull changes fetch, then merge
- Sending commits up sending your commits
- Proposing a change asking somebody to merge it
- Marking a release naming a commit for good
Git without fear · Undo, safely
- Which undo which undo, and when
- Undo by adding undoing by adding a commit
- Moving the branch back moving the branch back
- Replaying your commits on a new base replaying commits somewhere else
- Taking one commit taking one commit from another branch
- Looking around without a branch committing with no branch attached
- Who changed this line, and why who last changed this line
When git goes wrong · Before you type anything
- Look before you touch what to do before you touch anything
- Everywhere HEAD has been everywhere HEAD has been
- Three questions, three commands three commands that tell you where you are
- Unreachable is not deleted unreachable is not deleted
- Wrong files, or wrong history is it the tree or the history
When git goes wrong · Work you have not committed
- One file back to how it was putting one back, not the lot
- Taking it out of the next commit taking it out of the next commit
- Removing files git never knew about clearing out what was never tracked
- Getting a stash back getting a stash back
- Back to the branch you were on returning to the branch you were on
When git goes wrong · Work you have committed
- Undoing a commit and keeping the work undoing a commit, keeping the work
- Soft, mixed and hard soft, mixed and hard
- Rewriting history, or recording an undo rewriting history or recording an undo
- Amend replaces, it does not edit amend replaces, it does not edit
- The commit went on the wrong branch the commit went on the wrong branch
When git goes wrong · The history moved under you
- What force does to everybody else what force does to everybody else
- Merge or replay, when you pull merge or replay when you pull
- Both sides have moved both sides have moved
- Getting a lost commit back getting a lost commit back
- The branch it tracked is gone the branch it tracked is gone
When git goes wrong · A merge that stopped half way
- Reading a conflict reading a conflict
- The free way out the free way out of a merge or rebase
- Stop, resolve, continue the stop-resolve-continue loop
- Knowing you have finished knowing you have finished resolving
When git goes wrong · So the next one is smaller
- Small commits are cheap to undo small commits are cheap to undo
- A branch before anything risky a branch before anything risky
- A commit is a save, a push is a backup a commit is a save, a push is a backup
- Marking the known-good point marking the known-good point
- The short list git cannot get back the short list git cannot get back
Terminal 52 lessons
Terminal quick reference: every topic on one page, one line each. Run these for real: a terminal in this page that you cannot break.
The terminal, without fear · Where am I
- Where am I? where am I
- What is here? what is in here
- Moving around moving between folders
- . is here, .. is up . and ..
- ~ is home ~ (home)
The terminal, without fear · Files and folders
- Making folders making a folder
- Making an empty file making an empty file
- Copying copying a file
- Moving and renaming are one command moving and renaming
- Deleting, for good deleting, with no undo
The terminal, without fear · Look inside
- Reading a file cat: print it to the screen
- The start and the end of a file head and tail
- Counting lines counting lines and words
- Finding lines finding the lines that match
- Finding files by name finding files by name
The terminal, without fear · Plumbing
- The pipe the pipe |
- Sending output to a file > (save output)
- Adding to a file >> (add to the end)
- Two streams: output and errors 2> (errors)
- Then, or else, regardless && and ||
The terminal, without fear · Make it yours
- Variables, and export variables and export
- Every command reports success or failure $? (exit status)
- Permissions, and making a script runnable making a file runnable
- Using a command's output inside another $(...) (a command's output)
- A script: commands in a file, run as one a script with a shebang
Get the answer out of the file · What a pipe really is
- What a pipe actually carries what a pipe carries
- Each stage sees only the one before each stage sees only the one before
- Errors do not go down the pipe errors do not go down the pipe
- Build it one stage at a time build a pipeline one stage at a time
Get the answer out of the file · Find the lines you want
- grep -c counts lines, not matches grep -c counts lines, not matches
- Everything except grep -v: everything but
- Whole words only grep -w: whole words only
- However it was typed grep -i: however it was typed
- Somewhere to go back to grep -n: somewhere to go back to
Get the answer out of the file · Take the column you need
- Taking one column cut -d and -f
- The delimiter you did not name cut's delimiter is a tab
- When the columns are spaces runs of spaces are not fields
Get the answer out of the file · Put it in an order that means something
- sort compares text until you tell it otherwise sort -n: 9 before 100
- Sorting on a column sort -k: on which column
- The distinct values sort -u: the distinct values
Get the answer out of the file · Count what repeats
- uniq only sees its neighbour uniq only sees neighbours
- How many of each uniq -c: how many of each
- The ten commonest values the ten commonest values
- wc counts newlines wc -l counts newlines
Get the answer out of the file · When the answer looks wrong
- Nothing is an answer when a pipeline prints nothing
- How many rows, how many things how many rows, how many things
- Two different stars the shell's * and grep's *
- A space in a variable splits it a space in a variable splits it
Get the answer out of the file · On a file too big to open
- head stops the pipeline head stops a pipeline early
- Get it right on a thousand lines get it right on a thousand lines
- A pipeline's exit code is the last stage's a pipeline's code is the last stage's
- The one that worked, written down the one that worked, written down
HTML and CSS 54 lessons
HTML and CSS quick reference: every topic on one page, one line each.
Your first web page · The page
- The page skeleton the page skeleton
- Tags, elements, content tags and elements
- Headings headings
- Paragraphs and whitespace paragraphs
- Links links
Your first web page · More than text
- Images and alt text images and alt
- Lists lists
- Attributes attributes
- Forms forms
- Semantic tags semantic tags
Your first web page · Give it style
- A CSS rule a CSS rule
- Selectors selectors
- Attaching CSS attaching CSS
- Colour and background colour and background
- Fonts and sizes fonts and sizes
Your first web page · The box
- The box model the box model
- box-sizing box-sizing
- px, rem, em and % px, rem, em and %
- display display
- The cascade the cascade
Your first web page · Layout that holds
- Flexbox flexbox
- Grid grid
- position position
- Media queries media queries
- :hover and :focus :hover and :focus
The page everyone can use · Who cannot use this page
- Who a page can shut out who a page can shut out
- Role, name and state role, name and state
- Put the mouse down and Tab put the mouse down and Tab
- Cheapest while you are writing it cheapest while you are writing it
The page everyone can use · The label that is not attached
- for= and id=, or wrap it for= and id=, or wrap it
- A field that announces nothing a field that announces nothing
- A placeholder is not a label a placeholder is not a label
- Naming a group of controls naming a group of controls
The page everyone can use · The button that is a div
- A button, not a styled div a button, not a styled div
- A role does not make it reachable a role does not make it reachable
- Goes somewhere, or does something goes somewhere, or does something
- 0, -1, and never a positive one 0, -1, and never a positive one
The page everyone can use · Where the focus went
- The keyboard user's cursor the keyboard user's cursor
- :focus-visible, and a ring you can see :focus-visible, and a ring you can see
- The HTML decides, not the CSS the HTML decides, not the CSS
- Past the navigation, every page past the navigation, every page
The page everyone can use · Colour you can actually read
- What a contrast ratio measures what a contrast ratio measures
- 4.5 for text, 3 for the rest 4.5 for text, 3 for the rest
- Colour is never the only signal colour is never the only signal
- A dark theme is all new pairs a dark theme is all new pairs
The page everyone can use · Pictures, and what they are for
- What the image is for here what the image is for here
- alt= on purpose alt= on purpose
- No alt at all no alt at all
- Not "image of" not "image of"
The page everyone can use · The shape of the page
- Headings are the outline headings are the outline
- One h1: what this page is one h1: what this page is
- Regions you can jump to regions you can jump to
- Which language to pronounce which language to pronounce
- th, and which way it runs th, and which way it runs
Industrial control 54 lessons
Industrial control quick reference: every topic on one page, one line each.
Ladder logic from zero · What a PLC is
- What a PLC does what a PLC does
- Inputs: how the PLC senses an input: what the PLC can see
- Outputs: how the PLC acts an output: what the PLC drives
- One line of a ladder rungs
- The two rails the two rails a rung sits between
- Left to right, top to bottom reading a ladder, rung by rung
Ladder logic from zero · Contacts and coils
- Normally open: passes power when TRUE normally open contact
- Normally closed: passes power when FALSE normally closed contact
- The coil is the action the coil at the end of a rung
- Series is AND contacts in series are AND
- Parallel is OR contacts in parallel are OR
- Top to bottom, every scan the scan cycle
Ladder logic from zero · Hold and time
- Keep running after the button is released seal-in circuits
- Set and reset set and reset bits
- On-delay on-delay timer (TON)
- The off-delay the off-delay timer
- Counting edges counting events
- Exactly once acting on the change, not the state
Ladder logic from zero · Do no harm
- A broken wire must stop the machine fail-safe wiring
- Wired to fail safe wiring an emergency stop
- One coil, two rungs, one winner the double coil trap
- Never both at once two things that can never both be on
- Sequences and the timer that watches the watchdog
- The PLC is not the safety system safety is not the PLC
Why the machine stopped · Before you touch anything
- What changed what changed
- What one scan really does what one scan really does
- Finding the rung that stopped finding the rung that stopped
- Watching it run versus reading it watching it run versus reading it
Why the machine stopped · The coil written twice
- The coil written on two rungs the coil written on two rungs
- Finding a second writer finding a second writer
- One coil, one rung one coil, one rung
Why the machine stopped · Rung order
- Rung 2 sees what rung 1 wrote rung 2 sees what rung 1 wrote
- Logic that is one scan behind logic that is one scan behind
- Moving a rung is a change moving a rung is a change
Why the machine stopped · The seal-in
- How a seal-in holds how a seal-in holds
- Where the stop belongs where the stop belongs
- An output that will not drop out an output that will not drop out
- Hold-to-run, on purpose hold-to-run, on purpose
Why the machine stopped · Latches that stick
- A latch remembers, a coil does not a latch remembers, a coil does not
- The reset that can never run the reset that can never run
- Set and reset in the same scan set and reset in the same scan
- Latch, seal-in, or plain coil latch, seal-in, or plain coil
Why the machine stopped · Timers that never finish
- A timer adds up time a timer adds up time
- One false scan throws it away one false scan throws it away
- Done is not remembered done is not remembered
- An input that will not stay still an input that will not stay still
Why the machine stopped · The contact that must be normally closed
- A healthy stop button reads 1 a healthy stop button reads 1
- Closed in the field, open in the rung closed in the field, open in the rung
- What a broken wire does what a broken wire does
- Silence is a fault silence is a fault
- When both directions are called at once when both directions are called at once
More
- What the screen shows HMI tags
- True for exactly one scan one-shots
- Outputs update at the end of the scan when outputs update
Network switches 91 lessons
Network switches quick reference: every topic on one page, one line each. Run these for real: a terminal in this page that you cannot break.
Run a switch, start to finish · Get to the prompt
- What a switch is actually doing what a switch does
- Getting a screen on it console access
- Three rooms, and the door between them the mode stack
- The prompt is telling you where you are reading the prompt
- The switch will tell you what it accepts ? asks the switch
- Type less, and know exactly when you cannot abbreviating commands
Run a switch, start to finish · Make the switch yours
- Name the box naming the switch
- Label the port port descriptions
- The configuration is a document you can read the running config
- Running is not saved saving the configuration
- Keep a copy where the switch is not backing it up
- A password on the way in the enable secret
Run a switch, start to finish · Split it into VLANs
- One switch, several networks what a VLAN is
- What a VLAN actually separates broadcast domains
- Making a VLAN creating a VLAN
- Putting a port in a VLAN access ports
- Reading the VLAN table reading the VLAN table
- The VLAN that made itself the VLAN that made itself
- The desk that cannot see the server a port in the wrong VLAN
Run a switch, start to finish · Reach it over the network
- A switch does not have an IP address, a VLAN does the management interface
- Giving it an address the management address
- Reaching it from another subnet the default gateway
- A port that is administratively down shut and no shut
- The four things that make a switch reachable making it reachable
- Telnet sends your password across the network in the clear SSH instead of telnet
Run a switch, start to finish · Carry VLANs between switches
- One cable, every VLAN trunks
- The four bytes that carry the VLAN 802.1Q tagging
- 1 to 4094, and not 4096 the 1 to 4094 range
- VLAN 1 is not a good place to live VLAN 1
- The one VLAN on a trunk that goes untagged the native VLAN
- Let across only what belongs the allowed VLAN list
- Two switches disagreeing, quietly a native VLAN mismatch
- The trunk that is not trunking a trunk that is not trunking
Run a switch, start to finish · Keep it up and keep it safe
- What the switch has learned the MAC address table
- What it does when it has not learned yet flooding the unknown
- Thirty seconds of nothing, on every desk portfast
- The port that must never see another switch BPDU guard
- One address per desk port security
- Reading a switch you did not configure auditing a switch
Run a switch, start to finish · Look after the software
- The switch has a disk, and it can fill up the switch's flash
- What the .bin file actually is the software image
- Telling it which image to boot which image it boots
- An upgrade, in the order the steps depend on each other upgrading the software
- Restarting, and what that costs reloading
- A copy of the configuration that is not on the switch backing up to a server
- Back to how it came out of the box erasing the configuration
- Getting back into a switch nobody has the password for password recovery
Run a switch, start to finish · On the plant floor
- Allen-Bradley Stratix, and why Cisco knowledge carries over Allen-Bradley Stratix
- EtherNet/IP is ordinary Ethernet EtherNet/IP
- Designing VLANs for a production cell VLANs for a cell
- Multicast, and the switch that knows who asked IGMP snooping
- Why the plant floor is wired in a ring industrial ring topologies
- A phone and a PC on one socket voice VLANs
- The link that works badly rather than failing duplex and speed
- Power down the same cable power over Ethernet
- Why the link between buildings is fibre fibre links
Replace a switch without breaking anything · Before the box comes out
- The one thing that has to exist before the box comes out why a switch gets replaced
- The serial nobody can reconstruct later the part number and the serial
- What every port was doing, before you unplug it what every port was doing
- What is on the other end of the cable what is on the other end
- The old switch is the rollback being able to go back
Replace a switch without breaking anything · What a backup does and does not carry
- copy FROM TO, and there are no exceptions copy, source first
- A backup you have not read is a filename a backup you have read
- What a backup leaves behind what a backup leaves behind
- The VLAN database is not part of the configuration VLANs live outside the config
- Server, client, transparent server, client, transparent
- The secrets that travel, and the one that does not the secrets that do not travel
Replace a switch without breaking anything · Putting it on the new one
- Check, restore, verify, then save the order a restore goes in
- The lines that did not take the lines that did not take
- A configuration that does not fit the box a config that does not fit the box
- Two boxes, one address two boxes, one address
- Putting the VLAN names back putting the VLAN names back
Replace a switch without breaking anything · Proving it works
- Check the VLANs, because they are what is missing checking the VLANs came out right
- Line by line against the paper checking every port came back
- The console cannot prove remote access checking you can still get in
- Save last, and mean it saving it, last
- Two files, in two places wiping the one that is leaving
Replace a switch without breaking anything · In a corporate closet
- A desk port and a machine port are configured for different lives an office closet, not a plant floor
- One cable, two VLANs the phone and the PC on one port
- The switch does not hand out addresses where a desk gets its address
- The configuration arrives; the identity does not the port that asks who you are
- The serials are the part nobody can reconstruct the ticket and the window
Replace a switch without breaking anything · Remembering any of it
- copy FROM TO, with no exceptions copy FROM TO, source first
- Ask the box the switch will tell you
- Four questions answer almost everything the four questions at any console
- do: one command somewhere else, and back looking without leaving
- Filter it, and mind the capital letters finding one line in three hundred
- The note is the only history a switch has what you leave for the next person
More
- Building a switch out from nothing building one out
- Moving a port from one VLAN to another moving a port between VLANs
- Trunk or access: the decision, not the command trunk or access