Skip to content

Instantly share code, notes, and snippets.


Nick Charlton nickcharlton

View GitHub Profile
nickcharlton / websockets-demo.html
Created September 8, 2022 13:47
A basic Web Sockets client demo
View websockets-demo.html
const webSocket = new WebSocket("ws://localhost:4283/ws");
webSocket.onmessage = (event) => {
window.webSocket = webSocket;
nickcharlton /
Created August 31, 2022 13:15
Gist from Drafts

Homebrew: Install specific version

# jump into the Homebrew repo
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
# find the sha to check out
git log master -- Formula/packer.rb
# uninstall the current version
HOMEBREW_NO_AUTO_UPDATE=1 brew uninstall packer
# check out the version, not allowing update
nickcharlton /
Created July 25, 2022 17:15
Checking for valid MSIX certificates using Visual Studio

Checking a certificate will work is a bit of an awkward one to solve, but a built-in tool will do it:

 PS> Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\TailoredProjectServices\"
 PS> .\VSCertificateChecker.exe -f "C:\Users\NickCharlton\Documents\Certificates\DevelopmentTesting.pfx" -t msix
The file ALBAIKDevelopmentTesting.pfx is password-protected.
Enter password: ************************

Certificate Details:
        Private Key Found: True
nickcharlton /
Last active May 24, 2022 09:41
RSpec: Testing ActiveStorage

RSpec: Testing ActiveStorage

Testing file uploads in ActiveStorage is a little awkward. Fortunately, fixtures comes to the rescue and we can provide a file to be passed through to the parameters. This works across model and system/feature specs.

In your factory, you might define it like:

factory :document do
    name { "Example File" }
nickcharlton /
Last active October 6, 2021 11:01
Domain Driven Design & Event Storming

Domain Driven Design

  • Ubiquitous Language: the language used by everyone to describe the concepts spoken about (so that they are all on the same page)
  • Bounded Context: "a semantic contextual boundary"; within the boundary, each component has a specific meaning and does specific things
  • Domain:
    • Core Domain: the strategic scope which is core to the business/software product
    • Sub-domain: a sub-part of the overall business domain (supporting is ancillary to the core, but worth implementing in-house, whilst generic isn't, e.g.: user invoicing)
  • Domain Event: a record of some significant event occurring in a bounded context, which can be consumed inside the originating bounded context or by other bounded contexts
  • Aggregate/Entity/Data: a high-level type or model (it may be composed of entities and value objects)
  • Command: an operation which causes a domain event
nickcharlton /
Last active September 28, 2021 16:42
Resources for Kafka/Event Streams
View gist:67835fb0ad3575d209682c806a0335b2
All T470s drivers:
BIOS Update:
Dock guide:
nickcharlton /
Last active May 28, 2021 16:49
Gist from Drafts

Debugging capybara-table

Bumping Nokogiri to 1.11.5, caused our tests around HTML tables to start failing with ERROR: Recursion limit exceeded. The change that caused this is in commit [#9fcb7d][1] (see also: [the full set of changes][2]), where the recursion limit is restricted to 500 (see: [libxml2 commit][3]), which is how it started happening with this Nokogiri update.

In investigating what was causing this to recur, it seems like we don't need all of capybara-table, as [enough is already included in Capybara itself][4].

I did consider just dropping the dependency, but the Matcher/Renderer classes are key to the usability of our tests — I even tried not using them but trying to factor out the dependency was a horrible experience.

My next step would be to try and switch the Capybara selector that CapybaraTable::RspecMatchers uses to the ones already in Capybara: [table.rb][5] and [table_row.rb][6]. This might be as simple as vendering the RspecMatchers.rb file into the project and seein

nickcharlton /
Created May 11, 2021 15:17
Gist from Drafts

Drafts → Basecamp / Trix Rich Text Fields

Problem: Copying text with reference links as Rich Text from Drafts into Basecamp mangles all of the formatting.


  1. Inspect Element on the editor
  2. $1.editor.setSelectedRange([0, 0])
  3. Copy as HTML in Drafts
  4. $1.editor.insertHTML(Daily Update …)
nickcharlton /
Created April 3, 2020 15:53
How Basecamp uses Basecamp Notes

How Basecamp uses Basecamp


  • Points out that nothing has changed with them now WFH; they've always worked this way,
  • HQ is equivalent of a company intranet: docs, files, discussions, etc. Every one has access,
  • Teams are like departments or groups: distinct workspaces for the given team, admin gets to choose who sees what; unless you're added they're hidden,
  • Everything is "commentable": you can discuss things in context on every item,
  • DHH points out that they come back to these; sometimes two years later, giving the example of a an AB test,
  • Everything item exists under a URL; it's always referencable,