Skip to content

Instantly share code, notes, and snippets.

@danyg
danyg / .zshrc
Created January 25, 2024 11:33
FIX VSCODE `clear` command not clearing the scrollback
alias clear="printf "\e[3J"; clear"
@danyg
danyg / question.md
Last active February 7, 2023 13:43
How to use an interface with type literals as methods names effectively?

Hi, thanks for check in this in before hand.

So what I would like to achieve, is to define an interface, that specify how a certain type of object can be defined.

In this case PageObject, objects that will work as adaptor between the tests and the ui.

export interface PageObject {
// eslint-disable-next-line prettier/prettier
[key: `get${string}`]: (options?: CypressGetOptions, ...args: unknown[]) => Cypress.Chainable>
@danyg
danyg / whereTheHeckIs.js
Created January 5, 2023 15:41
DEBUG TOOL: whereTheHeckIs
/**
* - Open Chrome Dev tools
* - Go To Sources
* - in the left side, go to Snippets
* - add new snippet
* - paste this code
* - save and execute
* - > whereTheHeckIs(store.getState(), 'stringToSearch');
*/
(() => {
@danyg
danyg / README.md
Last active January 5, 2023 15:56
RUN your checks in parallel

Run your checks in parallel

This script allows you to

  • Do all the CI checks in parallel
  • Give it check a name (and emojis 😜)
  • Only show stdout and sterr of the first one to fail
  • Stops the build on the first check failed
  • Known which step is being checked (check Current Job perform explanation to reduce anxiety)

How to use

@danyg
danyg / consoleReduxDevTools.js
Created December 2, 2022 14:59
Console REDUX DEV TOOLS [wip]
/** at the moment the idea is to use CJS chrome extension to load
this but seems to add the script after window.load so it's too late
**/
(() => {
window.__STATE_HISTORY__ = {
dispatchedActions: [],
actionAndState: []
}
@danyg
danyg / dg.git.backup
Created November 9, 2022 17:08
command line helpers
#!/bin/bash
currentBranchName=$(git branch --show-current)
milestone=$1
backupBranchName=BACKUP/${currentBranchName}
if test -z "$milestone"; then #empty
milestone=$(date '+%Y%m%d-%H%M%S')
fi
@danyg
danyg / launch.json
Last active October 24, 2022 09:33
VSCode JEST debug current file
[
// USING jest for common configs
{
"type": "node",
"request": "launch",
"name": "Jest watch current test",
"cwd": "${workspaceFolder}",
"runtimeArgs": [
"--inspect",
"${workspaceRoot}/node_modules/.bin/jest",
@danyg
danyg / git-config-starter.sh
Last active May 27, 2020 07:45
Git Aliases & Config
#!/bin/bash
git config --global alias.co checkout
git config --global alias.cob "checkout -b"
git config --global alias.st status
# https://ma.ttias.be/pretty-git-log-in-one-line/
git config --global alias.l "log --graph --pretty=format:'%C(#00BAFF)%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(#81C4FF)<%an>%Creset' --abbrev-commit"
git config --global alias.ll "log --oneline"
git config --global push.default current
@danyg
danyg / .bash_profile.sample
Last active February 12, 2020 14:58
mac profile.d
#!/bin/bash
export USER_NAME='danyg'
source ~/profile.d/bash_profile
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
@danyg
danyg / wrappers.md
Last active August 8, 2019 08:05
How to use Wrappers in Tests

So in order to avoid this, we use wrappers which are easier to mock:

const defineGlobalWindow = (locationValue?: string) => {
  global.window = Object.create(window);
  const url = locationValue || "spTestHost";
  Object.defineProperty(window, "location", {
    value: { hostname: url },
    writable: true
  });
};