Skip to content

Instantly share code, notes, and snippets.

View tangoabcdelta's full-sized avatar

tangoabcdelta

View GitHub Profile
@tangoabcdelta
tangoabcdelta / how.to.exit.vim.md
Created January 20, 2021 23:08
How to exit vim:

Remember this as a mantra: "Escape, Colon, Doublewww, Queue", Esc + : + w + q

@tangoabcdelta
tangoabcdelta / canvas.script.md
Created January 21, 2021 01:40
HTML5 Canvas quick commands to export the contents to an image (as Data URI)
export the contents of a canvas as an image
img.src = document.getElementById('canvas').toDataURL();
// src will look like data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNb...
bonus: export by specifying the quality
canvas.toDataURL('image/jpeg', 1.0); // full
canvas.toDataURL('image/jpeg', 0.5); // medium

canvas.toDataURL('image/jpeg', 0.1); // low

@tangoabcdelta
tangoabcdelta / shortcuts.md
Last active January 21, 2021 11:15
Visual Studio Code or vscode default keyboard shortcuts (only the ones that matter)

Table:

Purpose Command Remark
Move line up/down Alt + Up Arrow/Down Arrow If you're from a sublime background like me, this is the equivalent for ctrl + shift in Sublime.
Jump to matching bracket Ctrl+Shift+\ Chrome's ctrl + m equivalent or Sublime's ctrl + <bracket>
Indent/outdent line Ctrl + ] or [ --
Duplicate line Going to the end of the line and then doing Ctrl + C followed by Ctrl + V This is Sublime or Atom's Ctrl + D equivalent
@tangoabcdelta
tangoabcdelta / string.match.md
Last active January 27, 2021 08:21
How to check if a string contains another substring in JavaScript?

All possibilities

new RegExp('word')).test(str) // ES2
str.indexOf('word') !== -1 // ES2
str.includes('word') // ES6
str.match(/word/gi)?.length > 0 //ES2019
@tangoabcdelta
tangoabcdelta / semver.md
Last active January 30, 2021 14:31
semver for alpha and beta releases

MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when you make incompatible API changes,
  • MINOR version when you add functionality in a backwards compatible manner, and
  • PATCH version when you make backwards compatible bug fixes.
  • Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

H1

0.1.0
@tangoabcdelta
tangoabcdelta / my.sublime.settings.json
Created February 1, 2021 22:53
my sublime settings
{
"always_show_minimap_viewport": true,
"block_caret": true,
"color_scheme": "Packages/Color Scheme - Default/Mariana.sublime-color-scheme",
"detect_indentation": true,
"draw_white_space": "all",
"font_size": 11,
"hot_exit": true,
"ignored_packages": ["Vintage"],
"theme": "Default.sublime-theme",
@tangoabcdelta
tangoabcdelta / set.upstream.to.md
Created February 2, 2021 04:22
set upstream to

Set Upstream branch for a git branch

git branch --set-upstream-to=origin/feat-foobar

@tangoabcdelta
tangoabcdelta / prettier.instructions.md
Last active February 5, 2021 07:19
If you're working on a React App with thousands of eslint warnings, first run prettier from the command line and prettify all files in a repository. It makes the hunting down easier for you (as a human, does do no benefit for the machine). Then, follow the instruction in the part of the gist, add them to your `package.json` and run them to fix `…
  • Prettify all JavaScript files: npx prettier --write "./src/**/*.js"

  • Check if your files are formatted: `npx prettier --check "src/**/*.js"

  • For more: https://prettier.io/docs/en/cli.html#--check

  • Simple commands: npx eslint --fix

  • Somewhat complicated command: npx eslint --fix --ext .js,.jsx .

Add these to the root package.json.

@tangoabcdelta
tangoabcdelta / instructions.md
Last active February 6, 2021 17:35
enabling prettier for sublime

JsPrettier

  1. Command Palette

    "Ctrl/Cmd + Shift + P", then type "JsPrettier Format Code".

  2. Context Menu

Right-click the file view and select "JsPrettier Format Code".

@tangoabcdelta
tangoabcdelta / html.instead.of.ejs.instructions.md
Created February 7, 2021 13:47
keep the file extension of ejs file as .html, While developing an expressjs app using ejs templating engine you may want to use keep the extension as `*.html` instead of `*.ejs` e.g. `home.html` instead of using home.ejs. Main reason for using html is generally to use more effective code hint, formatting and syntax highlighting without adding an…

keep the file extension of ejs file as .html

  • While developing an expressjs app using ejs templating engine you may want to use keep the extension as *.html instead of *.ejs
  • e.g. home.html instead of using home.ejs.
  • Main reason for using html is generally to use more effective code hint, formatting and syntax highlighting without adding any extra settings. To accomplish it, you can perform any of the following:
1