Skip to content

Instantly share code, notes, and snippets.

View dotherightthing's full-sized avatar

Dan Smith dotherightthing

  • Do The Right Thing
  • Wellington, New Zealand
View GitHub Profile
@dotherightthing
dotherightthing / settings.json
Created February 14, 2020 22:15
[Visual Studio Code settings] #vscode
{
"editor.rulers": [130],
"workbench.colorTheme": "Default Light+",
"workbench.colorCustomizations": {
"editorRuler.foreground": "#eaeaea"
}
}
@dotherightthing
dotherightthing / sourcetree-rebasing-a-branch.md
Last active February 13, 2020 20:48
[Sourcetree: Rebasing a branch] #git #pr #pullrequest #merge

Sourcetree: Rebasing a branch

Submitting a Pull Request

After developing a feature in a branch, the next step is to submit a Pull Request (PR), to merge your changes into the master branch.

After submitting a PR, the PR page may show [C] on one or more files, indicating conflicts between your feature branch and the current version of the master branch.

Rebasing your branch's changes on top of the latest version of the master branch helps ensure that your code won't destabilise the code in the master branch, when it is merged into it.

@dotherightthing
dotherightthing / sourcetree-reset-changes-to-master-branch.md
Last active February 13, 2020 03:14
[Sourcetree: Reset changes to master branch] #git

Sourcetree: Reset changes to master branch

  1. Scroll down to Remotes
  2. Left click on master
  3. In the history pane, right click on the highlighted entry
  4. Select Reset master to this commit
@dotherightthing
dotherightthing / setting-up-ssh-to-work-with-sourcetree.md
Last active February 12, 2020 06:26
[Setting up SSH to work with Sourcetree] #git #ssh #macos
@dotherightthing
dotherightthing / migrating-gulp-build-tasks-to-npm-scripts.md
Last active January 20, 2020 01:09
[Migrating Gulp build tasks to NPM scripts] #npm #gulp #testing #shell

Migrating Gulp build tasks to NPM scripts

My Gulp build script does various things including linting code and packaging releases.

I'd like to extend this script, so that it can be reused by all of my different repos. This necessitates adding unit tests, so that I can be sure that the expected environment and config result in the right files being generated into the correct locations.

This testing is proving very difficult, as, when running shell commands from Node using execa, both Gulp and Mocha are adding layers of abstraction. These make it hard to see when tests are failing and why.

The solution seems to be to remove the abstraction by using raw shell commands in my npm scripts. So now I'm migrating my build script from Gulp to NPM.

@dotherightthing
dotherightthing / debugging-dom-attributes-using-debugger.js
Last active July 23, 2020 23:03
[Debugging DOM attributes using the debugger] #observer #mutation
/**
* @function debuggerOnAttributeMutation
* @summary Open the JavaScript debugger when a particular attribute is mutated on the target element.
* @public
*
* @param {boolean} debugMode - Whether debug mode is enabled (_options.debug)
* @param {external:jQuery} $elements - One or more elements to watch the attributes of
* @param {string} attribute - Attribute to watch for mutations on.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver}
*/
@dotherightthing
dotherightthing / revealing-module-pattern.js
Last active July 8, 2024 15:48
[Revealing module pattern] #js #jsdoc #es5 #trycatch #throw
// some-component.js
// see https://www.youtube.com/watch?v=pOfwp6VlnlM.
/**
* @file Do something
* @author [email protected]
* @requires jquery.js
*/
/**
@dotherightthing
dotherightthing / window-requestAnimationFrame.md
Created December 17, 2019 22:33
window.requestAnimationFrame #js #css

window.requestAnimationFrame

Animating with requestAnimationFrame Since the interval parameter is irrelevant in complex animations, as there’s no guarantee that it will be honored, a new API has been designed: requestAnimationFrame. It’s simply a way to tell the browser “before drawing the next frame on the screen, execute this game logic/animation processing”. The browser is in charge of choosing the best moment to execute the code, which results in a more efficient use of resources[3].

@dotherightthing
dotherightthing / webstorm-notes.md
Last active December 1, 2019 04:11
[WebStorm Notes] #ide

WebStorm Notes

Preferences

  • Change default directory: WebStorm > Preferences > System Settings > Default directory

Create a new Vue project

WebStorm: File > New > Project > Vue.js

@dotherightthing
dotherightthing / signing-a-pdf-contract.md
Last active November 11, 2019 01:11
[Signing a PDF contract] #acrobat #preview

Signing a PDF contract

  1. Open PDF in Preview
  2. Click View > Show Markup Toolbar
  3. Click the Sign icon
  4. Click Create Signature > Camera (the Trackpad option didn't work for me on my Mid-2012 Macbook Air 11")
  5. Click the Sign icon > Click the Signature
  6. Drag and drop the Signature to the correct place in the document, resize as necessary
  7. Click File > Save