Skip to content

Instantly share code, notes, and snippets.

View nickcharlton's full-sized avatar
🐢

Nick Charlton nickcharlton

🐢
View GitHub Profile
@nickcharlton
nickcharlton / content.md
Created January 28, 2024 17:56
Gist from Drafts
@nickcharlton
nickcharlton / content.md
Created October 11, 2023 09:18
Gist from Drafts

GTD & Things Process

Some David Allen (GTD) and Merlin Mann wisdom (Inbox Zero guy who now makes podcasts)

  • Life is has lots of inboxes, try and move everything to one place
    • i.e.: email to Things inbox, Reminders to Things inbox, your memory to something written down
  • Similarly, make it easy to capture things
    • I use the Quick Entry dialog on macOS and now the Action Button on the iPhone 15 Pro,
    • You'll eventually find yourself doing this all the time
  • For you to trust the process and get the most out of it, you need to do the reviews, otherwise none of this will work
@nickcharlton
nickcharlton / content.md
Created September 19, 2023 11:10
Gist from Drafts

Installing multiple versions of Xcode

When Xcode is upgraded between major versions (for example 14 to 15), the whole compiler toolchain is upgraded along with support for the new platforms targeted. Sometimes this causes problems, like when deprecated APIs are finally removed.

These changes always happen around significant operating system releases, like when a new version of iOS is released towards the end of September. A good short-term solution is to install the old version of Xcode alongside the current one.

  1. Fetch the last Xcode (for example 14.3.1 which is the last before 15) from the Developer Console (you'll need to be signed in with your Apple Developer account): https://developer.apple.com/download/all/?q=xcode%2014
  2. Extract and move it to /Applications, but with a name matching the version, e.g.: Xcode 13.4.1.app
  3. You should now be able to open your project in Xcode and it build successfully again.
@nickcharlton
nickcharlton / content.md
Created May 10, 2023 16:03
Gist from Drafts

Jest: Changing Mocks per Test

I'd been trying to mock react-native-device-info differently per test, so that I could explore setting a more useful User-Agent based on the platform it was running on. But Jest doesn't make doing this particularly very easy, at least not until recently:

Jest 29 and up

We can use [jest.mocked][1] to replace the implementation inside the it:

import { getVersion } from 'react-native-device-info'
@nickcharlton
nickcharlton / content.md
Created April 13, 2023 16:09
Gist from Drafts

Clear Sidekiq Jobs

heroku run bundle exec rails c --app ynab-bridge

And then:

Sidekiq::Queue.all.each(&:clear)
@nickcharlton
nickcharlton / websockets-demo.html
Created September 8, 2022 13:47
A basic Web Sockets client demo
<html>
<head>
<script>
const webSocket = new WebSocket("ws://localhost:4283/ws");
webSocket.onmessage = (event) => {
console.log(event.data);
}
window.webSocket = webSocket;
@nickcharlton
nickcharlton / content.md
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
nickcharlton / doc.md
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
nickcharlton / content.md
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
nickcharlton / content.md
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