AlanGreene / starter

Dotfiles starter project for new machines
1 stars 1 forks source link

Snippets #42

Open AlanGreene opened 2 years ago

AlanGreene commented 2 years ago

npm scripts access to npm-specific environment variables, e.g. $npm_new_version for npm version command

"check-env": "node -e 'console.log(process.env)' | grep npm"

https://www.twilio.com/blog/npm-scripts

"demo": "echo \"Hello $npm_config_first $npm_config_last\""

npm run demo --last=Kundel --first=Dominik

git merge histories (e.g. importing existing projects into monorepo)

# Add an external repository as a remote
git remote add -f <external-repo-name> <external-repo-path>
# Merge commit history of a required branch
git merge --allow-unrelated-histories <external-repo-name>/<branch-name>
# files will be merged to root of repo so then need to move to appropriate place in e.g. `packages/`
# also create branch to track original repo to preserve history
git branch init/$package $package/master
AlanGreene commented 1 year ago

detect clamshell mode (tested on macOS 12.6) ioreg -r -k AppleClamshellState -d 1 | grep AppleClamshellState | head -n1

AlanGreene commented 1 year ago

disable sleep on battery in clamshell mode:

pmset -g | grep hibernatemode (record this, was 3 when I checked)

sudo pmset -a sleep 0
sudo pmset -a hibernatemode 0
sudo pmset -a disablesleep 1

revert:

sudo pmset -a sleep 1
sudo pmset -a hibernatemode <original hibernatemode value | usually 3 on a MacBook>
sudo pmset -a disablesleep 0

may only need the disablesleep setting… (worked when testing on macOS 12.6 with 2021 16-inch M1 Max)

AlanGreene commented 1 year ago
# Delete a given line number in the known_hosts file.
knownrm() {
 re='^[0-9]+$'
 if ! [[ $1 =~ $re ]] ; then
   echo "error: line number missing" >&2;
 else
   sed -i '' "$1d" ~/.ssh/known_hosts
 fi
}
AlanGreene commented 1 year ago

You can also enable remote login on the command line:

sudo systemsetup -setremotelogin on
AlanGreene commented 10 months ago

GitHub Flavored Markdown - note / warning blocks

https://github.com/orgs/community/discussions/16925

> [!NOTE]  
> Highlights information that users should take into account, even when skimming.

[!NOTE]
Highlights information that users should take into account, even when skimming.

> [!IMPORTANT]  
> Crucial information necessary for users to succeed.

[!IMPORTANT]
Crucial information necessary for users to succeed.

> [!WARNING]  
> Critical content demanding immediate user attention due to potential risks.

[!WARNING]
Critical content demanding immediate user attention due to potential risks.

AlanGreene commented 6 months ago

Cypress - better CI logs

https://slides.com/bahmutov/fast-me?utm_source=substack&utm_medium=email#/20/2/0

// cypress.config.js
setupNodeEvents(on, config) {
  require('cypress-mochawesome-reporter/plugin')(on)
  require('cypress-terminal-report/src/installLogsPrinter')(on)
},

// spec or support file
require('cypress-mochawesome-reporter/register')
afterEach(() => {
  cy.wait(50, { log: false }).then(() => {
    cy.addTestContext(Cypress.TerminalReport.getLogs('txt'))
  })
})
require('cypress-terminal-report/src/installLogsCollector')()

Cypress test replay

https://currents.dev/posts/currents-cypress-replay-debugger https://github.com/currents-dev/cypress-debugger

The plugin is free and open source. You can start using it today on your CI setup. When installed it will capture:

capture Cypress test execution steps capture DOM snapshots for each step capture browser console messages capture browser the networks requests (HAR)

All this information will be dumped into a file that we can then load into a web player for replaying. The player is available at https://cypress-debugger.dev/