Skip to content

Instantly share code, notes, and snippets.

@hendrikeng
Last active December 5, 2018 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hendrikeng/102a558e52493308dceb46fee109011a to your computer and use it in GitHub Desktop.
Save hendrikeng/102a558e52493308dceb46fee109011a to your computer and use it in GitHub Desktop.
Visual Studio Code Sync Settings Gist
{"lastUpload":"2018-12-05T09:39:51.027Z","extensionVersion":"v3.2.2"}
[
{
"metadata": {
"id": "e1efb0c8-2c62-4d86-bb6a-c88f198ddfcc",
"publisherId": "dustinsanders.an-old-hope-theme-vscode",
"publisherDisplayName": "dustinsanders"
},
"name": "an-old-hope-theme-vscode",
"publisher": "dustinsanders",
"version": "3.2.1"
},
{
"metadata": {
"id": "697255a9-3f36-44c8-b084-d3b91edfb23a",
"publisherId": "HookyQR.beautify",
"publisherDisplayName": "HookyQR"
},
"name": "beautify",
"publisher": "HookyQR",
"version": "1.4.7"
},
{
"metadata": {
"id": "7a0110bb-231a-4598-aa1b-0769ea46d28b",
"publisherId": "aaron-bond.better-comments",
"publisherDisplayName": "aaron-bond"
},
"name": "better-comments",
"publisher": "aaron-bond",
"version": "2.0.3"
},
{
"metadata": {
"id": "9c51dc38-4ae5-43ed-b921-60a8d379bebf",
"publisherId": "kaiwood.better-line-select",
"publisherDisplayName": "kaiwood"
},
"name": "better-line-select",
"publisher": "kaiwood",
"version": "1.0.1"
},
{
"metadata": {
"id": "e337c67b-55c2-4fef-8949-eb260e7fb7fd",
"publisherId": "Shan.code-settings-sync",
"publisherDisplayName": "Shan"
},
"name": "code-settings-sync",
"publisher": "Shan",
"version": "3.2.2"
},
{
"metadata": {
"id": "532533c9-a894-4a58-9eee-bbfbe7c06f71",
"publisherId": "mikestead.dotenv",
"publisherDisplayName": "mikestead"
},
"name": "dotenv",
"publisher": "mikestead",
"version": "1.0.1"
},
{
"metadata": {
"id": "f60a60a6-95ba-42d4-b41c-3d24c1b89588",
"publisherId": "EditorConfig.EditorConfig",
"publisherDisplayName": "EditorConfig"
},
"name": "EditorConfig",
"publisher": "EditorConfig",
"version": "0.12.5"
},
{
"metadata": {
"id": "8bb12ae3-73f8-40cf-86b7-4bd5729c6238",
"publisherId": "GrapeCity.gc-excelviewer",
"publisherDisplayName": "GrapeCity"
},
"name": "gc-excelviewer",
"publisher": "GrapeCity",
"version": "2.1.26"
},
{
"metadata": {
"id": "e5742230-050f-4ba9-95c0-8c7f6c1943a8",
"publisherId": "rubbersheep.gi",
"publisherDisplayName": "rubbersheep"
},
"name": "gi",
"publisher": "rubbersheep",
"version": "0.2.11"
},
{
"metadata": {
"id": "2bba45f2-4a48-41a6-bb86-d6ba5ab29a9f",
"publisherId": "felipecaputo.git-project-manager",
"publisherDisplayName": "felipecaputo"
},
"name": "git-project-manager",
"publisher": "felipecaputo",
"version": "1.7.1"
},
{
"metadata": {
"id": "6d2b4ef2-1d6d-4a1f-91fb-29fcadfb4b0a",
"publisherId": "vector-of-bool.gitflow",
"publisherDisplayName": "vector-of-bool"
},
"name": "gitflow",
"publisher": "vector-of-bool",
"version": "1.2.1"
},
{
"metadata": {
"id": "3e891cf9-53cb-49a3-8d01-8f0b1f0afb29",
"publisherId": "codezombiech.gitignore",
"publisherDisplayName": "codezombiech"
},
"name": "gitignore",
"publisher": "codezombiech",
"version": "0.6.0"
},
{
"metadata": {
"id": "4de763bd-505d-4978-9575-2b7696ecf94e",
"publisherId": "eamodio.gitlens",
"publisherDisplayName": "eamodio"
},
"name": "gitlens",
"publisher": "eamodio",
"version": "9.0.2"
},
{
"metadata": {
"id": "a3feeb85-0cfe-4b4b-b434-fb3ae0cf07c0",
"publisherId": "ihatetomatoes.gsap-code-snippets",
"publisherDisplayName": "ihatetomatoes"
},
"name": "gsap-code-snippets",
"publisher": "ihatetomatoes",
"version": "1.0.1"
},
{
"metadata": {
"id": "a30a3ba1-92eb-496b-b5be-86d04643d5d4",
"publisherId": "Hridoy.gsap-snippets",
"publisherDisplayName": "Hridoy"
},
"name": "gsap-snippets",
"publisher": "Hridoy",
"version": "1.0.0"
},
{
"metadata": {
"id": "aae00486-7e92-42b3-91b0-2b419e4f3875",
"publisherId": "vincaslt.highlight-matching-tag",
"publisherDisplayName": "vincaslt"
},
"name": "highlight-matching-tag",
"publisher": "vincaslt",
"version": "0.8.4"
},
{
"metadata": {
"id": "7b71fc1b-190d-4f7d-95d1-93e422649b0a",
"publisherId": "Zignd.html-css-class-completion",
"publisherDisplayName": "Zignd"
},
"name": "html-css-class-completion",
"publisher": "Zignd",
"version": "1.17.1"
},
{
"metadata": {
"id": "be992f3f-9f22-4b66-a1d2-ecad04c28a28",
"publisherId": "abusaidm.html-snippets",
"publisherDisplayName": "abusaidm"
},
"name": "html-snippets",
"publisher": "abusaidm",
"version": "0.2.1"
},
{
"metadata": {
"id": "9cd87837-c82a-4817-9b79-1c84775aa158",
"publisherId": "DigitalBrainstem.javascript-ejs-support",
"publisherDisplayName": "DigitalBrainstem"
},
"name": "javascript-ejs-support",
"publisher": "DigitalBrainstem",
"version": "0.3.2"
},
{
"metadata": {
"id": "a2cec723-5349-460d-9de9-0fd1f8d3456f",
"publisherId": "xabikos.JavaScriptSnippets",
"publisherDisplayName": "xabikos"
},
"name": "JavaScriptSnippets",
"publisher": "xabikos",
"version": "1.7.1"
},
{
"metadata": {
"id": "a96acff8-5197-43a6-b07c-d4d178558e56",
"publisherId": "neilding.language-liquid",
"publisherDisplayName": "neilding"
},
"name": "language-liquid",
"publisher": "neilding",
"version": "0.0.3"
},
{
"metadata": {
"id": "6618b055-469c-4f8e-860b-1d25f70d8852",
"publisherId": "cpylua.language-postcss",
"publisherDisplayName": "cpylua"
},
"name": "language-postcss",
"publisher": "cpylua",
"version": "1.0.5"
},
{
"metadata": {
"id": "b63c44fd-0457-4696-99e9-dbfdf70d77de",
"publisherId": "ritwickdey.LiveServer",
"publisherDisplayName": "ritwickdey"
},
"name": "LiveServer",
"publisher": "ritwickdey",
"version": "5.3.1"
},
{
"metadata": {
"id": "5db78037-f674-459f-a236-db622c427c5b",
"publisherId": "PKief.material-icon-theme",
"publisherDisplayName": "PKief"
},
"name": "material-icon-theme",
"publisher": "PKief",
"version": "3.6.1"
},
{
"metadata": {
"id": "b2382675-551b-476b-b37b-cc4961292ec2",
"publisherId": "digitalstreamio.mjml-syntax",
"publisherDisplayName": "digitalstreamio"
},
"name": "mjml-syntax",
"publisher": "digitalstreamio",
"version": "0.0.1"
},
{
"metadata": {
"id": "dff6b801-247e-40e9-82e8-8c9b1d19d1b8",
"publisherId": "christian-kohler.npm-intellisense",
"publisherDisplayName": "christian-kohler"
},
"name": "npm-intellisense",
"publisher": "christian-kohler",
"version": "1.3.0"
},
{
"metadata": {
"id": "a41c1549-4053-44d4-bf30-60fc809b4a86",
"publisherId": "christian-kohler.path-intellisense",
"publisherDisplayName": "christian-kohler"
},
"name": "path-intellisense",
"publisher": "christian-kohler",
"version": "1.4.2"
},
{
"metadata": {
"id": "044b4b31-2969-4af3-895d-855433b8b46d",
"publisherId": "felixfbecker.php-debug",
"publisherDisplayName": "felixfbecker"
},
"name": "php-debug",
"publisher": "felixfbecker",
"version": "1.12.6"
},
{
"metadata": {
"id": "5e69f001-f945-4c97-baf0-320d82a153b3",
"publisherId": "felixfbecker.php-intellisense",
"publisherDisplayName": "felixfbecker"
},
"name": "php-intellisense",
"publisher": "felixfbecker",
"version": "2.3.10"
},
{
"metadata": {
"id": "651dce1f-eda8-4a5b-aa26-0d1266de8ed1",
"publisherId": "MehediDracula.php-namespace-resolver",
"publisherDisplayName": "MehediDracula"
},
"name": "php-namespace-resolver",
"publisher": "MehediDracula",
"version": "1.1.0"
},
{
"metadata": {
"id": "96fa4707-6983-4489-b7c5-d5ffdfdcce90",
"publisherId": "esbenp.prettier-vscode",
"publisherDisplayName": "esbenp"
},
"name": "prettier-vscode",
"publisher": "esbenp",
"version": "1.7.2"
},
{
"metadata": {
"id": "aae0701b-111f-49c1-9000-abd37a442f28",
"publisherId": "WallabyJs.quokka-vscode",
"publisherDisplayName": "WallabyJs"
},
"name": "quokka-vscode",
"publisher": "WallabyJs",
"version": "1.0.171"
},
{
"metadata": {
"id": "797a79de-a0fd-4349-9034-bec47be9a941",
"publisherId": "2gua.rainbow-brackets",
"publisherDisplayName": "2gua"
},
"name": "rainbow-brackets",
"publisher": "2gua",
"version": "0.0.6"
},
{
"metadata": {
"id": "9a330091-5b29-403c-b37c-f9d4ae06bd7c",
"publisherId": "liximomo.remotefs",
"publisherDisplayName": "liximomo"
},
"name": "remotefs",
"publisher": "liximomo",
"version": "0.0.12"
},
{
"metadata": {
"id": "dda49fd5-1f3b-4d25-bf61-4fc41905ede5",
"publisherId": "humao.rest-client",
"publisherDisplayName": "humao"
},
"name": "rest-client",
"publisher": "humao",
"version": "0.20.4"
},
{
"metadata": {
"id": "f8b5562e-a2d9-49ab-9f91-e7da91998a92",
"publisherId": "shinnn.stylelint",
"publisherDisplayName": "shinnn"
},
"name": "stylelint",
"publisher": "shinnn",
"version": "0.47.0"
},
{
"metadata": {
"id": "4ae6dc82-7981-4f10-bd81-2d72aec37f39",
"publisherId": "jock.svg",
"publisherDisplayName": "jock"
},
"name": "svg",
"publisher": "jock",
"version": "0.1.4"
},
{
"metadata": {
"id": "bfcc4184-7b55-410e-a012-20ee54be9264",
"publisherId": "mblode.twig-language-2",
"publisherDisplayName": "mblode"
},
"name": "twig-language-2",
"publisher": "mblode",
"version": "0.3.1"
},
{
"metadata": {
"id": "2f5dd8cb-d251-4d70-abfe-ddebcb077483",
"publisherId": "octref.vetur",
"publisherDisplayName": "octref"
},
"name": "vetur",
"publisher": "octref",
"version": "0.14.3"
},
{
"metadata": {
"id": "dffaf5a1-2219-434b-9d87-cb586fd59260",
"publisherId": "Equinusocio.vsc-material-theme",
"publisherDisplayName": "Equinusocio"
},
"name": "vsc-material-theme",
"publisher": "Equinusocio",
"version": "2.6.2"
},
{
"metadata": {
"id": "085342db-9568-49b0-ad93-3223ac4c1baa",
"publisherId": "mrmlnc.vscode-apache",
"publisherDisplayName": "mrmlnc"
},
"name": "vscode-apache",
"publisher": "mrmlnc",
"version": "1.1.1"
},
{
"metadata": {
"id": "d7b592dd-41c9-4f2b-acf3-055ae65e55c6",
"publisherId": "dzannotti.vscode-babel-coloring",
"publisherDisplayName": "dzannotti"
},
"name": "vscode-babel-coloring",
"publisher": "dzannotti",
"version": "0.0.4"
},
{
"metadata": {
"id": "583b2b34-2c1e-4634-8c0b-0b82e283ea3a",
"publisherId": "dbaeumer.vscode-eslint",
"publisherDisplayName": "dbaeumer"
},
"name": "vscode-eslint",
"publisher": "dbaeumer",
"version": "1.7.0"
},
{
"metadata": {
"id": "ffda6552-0ad5-431b-a4fa-0905a7e4f3f0",
"publisherId": "bmewburn.vscode-intelephense-client",
"publisherDisplayName": "bmewburn"
},
"name": "vscode-intelephense-client",
"publisher": "bmewburn",
"version": "0.8.8"
},
{
"metadata": {
"id": "510e1d4e-1f9e-4910-8dbd-627c6f8a9791",
"publisherId": "akamud.vscode-javascript-snippet-pack",
"publisherDisplayName": "akamud"
},
"name": "vscode-javascript-snippet-pack",
"publisher": "akamud",
"version": "0.1.5"
},
{
"metadata": {
"id": "032ccf0d-9c21-43a5-8073-ae28e453ecef",
"publisherId": "whtouche.vscode-js-console-utils",
"publisherDisplayName": "whtouche"
},
"name": "vscode-js-console-utils",
"publisher": "whtouche",
"version": "0.7.0"
},
{
"metadata": {
"id": "39cefc2f-0175-44db-91f8-fe3230b4c3a1",
"publisherId": "killalau.vscode-liquid-snippets",
"publisherDisplayName": "killalau"
},
"name": "vscode-liquid-snippets",
"publisher": "killalau",
"version": "1.1.1"
},
{
"metadata": {
"id": "efc33846-2498-43d7-9699-47d0a7741345",
"publisherId": "attilabuti.vscode-mjml",
"publisherDisplayName": "attilabuti"
},
"name": "vscode-mjml",
"publisher": "attilabuti",
"version": "1.6.0"
},
{
"metadata": {
"id": "ae9e3eb0-3357-4cc0-90ee-598d2d384757",
"publisherId": "eg2.vscode-npm-script",
"publisherDisplayName": "eg2"
},
"name": "vscode-npm-script",
"publisher": "eg2",
"version": "0.3.5"
},
{
"metadata": {
"id": "8130e01f-ac60-4803-ab86-f05469dd7b4d",
"publisherId": "kokororin.vscode-phpfmt",
"publisherDisplayName": "kokororin"
},
"name": "vscode-phpfmt",
"publisher": "kokororin",
"version": "1.0.30"
},
{
"metadata": {
"id": "beb68b20-7c55-471c-9b63-3486f9423566",
"publisherId": "mrmlnc.vscode-scss",
"publisherDisplayName": "mrmlnc"
},
"name": "vscode-scss",
"publisher": "mrmlnc",
"version": "0.6.2"
},
{
"metadata": {
"id": "276fd2ee-2d7f-4a4c-b2ea-1780b1f8e59b",
"publisherId": "minhthai.vscode-todo-parser",
"publisherDisplayName": "minhthai"
},
"name": "vscode-todo-parser",
"publisher": "minhthai",
"version": "1.9.1"
},
{
"metadata": {
"id": "6f99be10-9aad-4b1c-8691-bcae8ae7b104",
"publisherId": "dariofuzinato.vue-peek",
"publisherDisplayName": "dariofuzinato"
},
"name": "vue-peek",
"publisher": "dariofuzinato",
"version": "1.0.2"
},
{
"metadata": {
"id": "c8d95916-cf54-455f-b324-cbd887b7d3a8",
"publisherId": "sdras.vue-vscode-snippets",
"publisherDisplayName": "sdras"
},
"name": "vue-vscode-snippets",
"publisher": "sdras",
"version": "1.3.0"
}
]
[{"projectPath":"/Users/hendrik/documents/github/projects/sellsius","gitRepo":"","lastUsed":1524231742225},{"projectPath":"/Users/hendrik/documents/github/projects/wewereyoung","gitRepo":"","lastUsed":1523812605198}]
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "down ctrl+",
"command": "workbench.action.interactivePlayground.pageDown",
"when": "interactivePlaygroundFocus && !editorTextFocus"
},
{
"key": "pagedown",
"command": "-workbench.action.interactivePlayground.pageDown",
"when": "interactivePlaygroundFocus && !editorTextFocus"
},
{
"key": "pagedown",
"command": "-cursorPageDown",
"when": "editorTextFocus"
},
{
"key": "pageup",
"command": "-cursorPageUp",
"when": "editorTextFocus"
},
{
"key": "alt+c",
"command": "editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+cmd+7",
"command": "-editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "alt+d",
"command": "extension.jumpy-word",
"when": "editorTextFocus"
}
]
{
// Definiert die Anzeigesprache von VSCode.
// Unter https://go.microsoft.com/fwlink/?LinkId=761051 finden Sie eine Liste der unterstützten Sprachen.
// Das Ändern des Werts erfordert einen Neustart von VSCode.
"locale":"en"
}
{
"name": "material-icon-theme",
"version": "2.1.0"
}
{
"better-comments.multilineComments": true,
"better-comments.tags": [{
"tag": "!",
"color": "#FF2D00",
"strikethrough": false
},
{
"tag": "?",
"color": "#3498DB",
"strikethrough": false
},
{
"tag": "//",
"color": "#474747",
"strikethrough": true
},
{
"tag": "todo",
"color": "#FF8C00",
"strikethrough": false
},
{
"tag": "*",
"color": "#98C379",
"strikethrough": false
}
],
"css.validate": false,
"editor.autoIndent": true,
"editor.fontLigatures": true,
"editor.fontFamily": "Operator Mono, Hasklug Nerd Font Mono, Monaco, 'Courier New', monospace",
"editor.letterSpacing": 0.5,
"editor.fontSize": 17,
"editor.formatOnPaste": false,
"editor.formatOnSave": false,
"editor.lineHeight": 36,
"editor.minimap.enabled": false,
"editor.renderIndentGuides": false,
"editor.snippetSuggestions": "top",
"editor.tabCompletion": true,
"editor.wordBasedSuggestions": false,
"editor.wordWrap": "on",
"editor.wordWrapColumn": 80,
"editor.wrappingIndent": "indent",
"emmet.includeLanguages": {
"vue-html": "html",
"blade": "html",
"html": "html",
"twig": "twig"
},
"emmet.showExpandedAbbreviation": "never",
"emmet.showSuggestionsAsSnippets": true,
"emmet.triggerExpansionOnTab": true,
"eslint.options": {
"extensions": [
".html",
".js",
".vue",
".jsx"
]
},
"eslint.validate": [
// {
// "language": "twig",
// "autoFix": true
// },
// {
// "language": "html",
// "autoFix": true
// },
{
"language": "vue",
"autoFix": true
},
{
"language": "javascript",
"autoFix": true
},
{
"language": "javascriptreact",
"autoFix": true
}
],
"emmet.syntaxProfiles": {
"vue-html": "html",
"html": {
"filters": "html"
},
"heml": {
"filters": "html"
},
"twig": {
"filters": "twig"
}
},
"files.associations": {
"*.html": "html",
"*.heml": "html",
"*.twig": "twig",
"*.ejs": "twig"
},
"files.exclude": {
"**/.DS_Store": true,
"**/.cache-loader": true,
"**/.git": true,
"**/.hg": true,
"**/.svn": true,
"**/.vscode": true,
"**/bower_components": true,
"**/dist": false,
"**/dist/craft/*.*": true,
"**/dist/craft/app": false,
"**/dist/craft/config": false,
"**/dist/craft/plugins": true,
"**/dist/craft/storage": true,
"**/dist/craft/templates": true,
"**/dist/public": false,
"**/jspm_packages": true,
"**/node_modules": false,
"**/src/plugins": false
},
"git.confirmSync": false,
"git.enableSmartCommit": true,
"gitProjectManager.baseProjectsFolders": [
"/Users/hendrik/documents/github/projects",
],
"html.format.enable": false,
"html.validate.scripts": false,
"javascript.validate.enable": false,
"prettier.eslintIntegration": true,
"prettier.singleQuote": true,
"prettier.stylelintIntegration": true,
"prettier.trailingComma": "all",
"scss.validate": false,
"search.exclude": {
"**/.cache-loader": true,
"**/.vscode": true,
"**/bower_components": true,
"**/dist": true,
"**/node_modules": true,
"**/src/plugins": true
},
"stylelint.configOverrides": {
"ignoreFiles": [
"dist/**",
"src/web/**",
"web/**",
]
},
"stylelint.enable": true,
"sync.askGistName": false,
"sync.autoDownload": false,
"sync.autoUpload": true,
"sync.forceDownload": false,
"sync.gist": "102a558e52493308dceb46fee109011a",
"sync.host": "",
"sync.lastDownload": "2018-05-04T08:49:25.963Z",
"sync.lastUpload": "2018-08-14T09:50:57.723Z",
"sync.pathPrefix": "",
"sync.quietSync": false,
"terminal.integrated.cursorBlinking": false,
"terminal.integrated.cursorStyle": "underline",
"terminal.integrated.fontFamily": "Operator Mono, Hasklug Nerd Font Mono",
"terminal.integrated.shell.osx": "/bin/zsh",
"TodoParser": {
"exclude": [
"cpp",
"c"
],
"include": [
"js",
"scss",
"twig",
"html",
"ejs",
"vue",
],
"folderExclude": [
"node_modules",
".vscode"
],
"only": [
"/src/js",
"/src/templates",
"/src/scss",
"/webpack"
],
"showInProblems": true,
"markers": [
"//!",
"//?",
"//*",
"// TODO",
"//TODO",
"FIXME",
"TODO",
"WARNING",
"ERROR",
"**",
"*!",
"*?",
],
"autoDefaultMarkers": true
},
"window.nativeTabs": true,
"window.zoomLevel": 0,
"workbench.colorTheme": "An Old Hope",
"workbench.editor.swipeToNavigate": true,
"workbench.fontAliasing": "default",
"workbench.iconTheme": "material-icon-theme",
"git.autofetch": true,
"gitlens.advanced.messages": {
"suppressCommitHasNoPreviousCommitWarning": false,
"suppressCommitNotFoundWarning": false,
"suppressFileNotUnderSourceControlWarning": false,
"suppressGitVersionWarning": false,
"suppressLineUncommittedWarning": false,
"suppressNoRepositoryWarning": false,
"suppressResultsExplorerNotice": true,
"suppressShowKeyBindingsNotice": true,
"suppressUpdateNotice": false,
"suppressWelcomeNotice": false
},
"liveServer.settings.donotShowInfoMsg": true,
"gitlens.keymap": "none",
"sync.removeExtensions": true,
"sync.syncExtensions": true,
"explorer.confirmDragAndDrop": false,
"gitlens.historyExplorer.enabled": true,
"explorer.confirmDelete": false,
"remotefs.remote": {
"Serverpilot": {
"scheme": "sftp",
"host": "engereauswahl.de",
"username": "engereauswahl",
// "privateKeyPath": "/Users/hendrik/.ssh/id_rsa.pub",
"rootPath": "/srv/users/engereauswahl/apps"
},
"wfw": {
"scheme": "sftp",
"host": "new.wfw.ch",
"username": "wfw_stag",
"rootPath": "/var/www"
},
},
"javascript.updateImportsOnFileMove.enabled": "always",
"gitlens.views.fileHistory.enabled": true,
"gitlens.views.lineHistory.enabled": true
}
{
/*
// Place your snippets for C++ here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
*/
}
{
/*
// Place your snippets for CSS here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
*/
"stylelint disable line": {
"prefix": "disline",
"body": ["/* stylelint-disable-next-line */ $1"],
"description": "stylelint disable line"
},
}
{
/*
// Place your snippets for Javascript (Babel) here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
*/
"eslint disable line": {
"prefix": "dline",
"body": ["// eslint-disable-next-line $1"],
"description": "eslint disable line"
},
"snippet-anagrams": {
"prefix": "anagrams",
"body":
"const anagrams = str => {\n if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str];\n return str\n .split('')\n .reduce(\n (acc, letter, i) =>\n acc.concat(anagrams(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)),\n []\n );\n};",
"description":
"Generates all anagrams of a string (contains duplicates). Use recursion. For each letter in the given string, create all the partial anagrams for the rest of its letters. Use `Array.map()` to combine the letter with each partial anagram, then `Array.reduce()` to combine all anagrams in one array. Base cases are for string `length` equal to `2` or `1`."
},
"snippet-arrayToHtmlList": {
"prefix": "arrayToHtmlList",
"body":
"const arrayToHtmlList = (arr, listID) =>\n arr.map(item => (document.querySelector('#' + listID).innerHTML += `<li>${item}</li>`));",
"description":
"Converts the given array elements into `<li>` tags and appends them to the list of the given id. Use `Array.map()` and `document.querySelector()` to create a list of html tags."
},
"snippet-average": {
"prefix": "average",
"body":
"const average = (...arr) => {\n const nums = [].concat(...arr);\n return nums.reduce((acc, val) => acc + val, 0) / nums.length;\n};",
"description":
"Returns the average of an of two or more numbers/arrays. Use `Array.reduce()` to add each value to an accumulator, initialized with a value of `0`, divide by the `length` of the array."
},
"snippet-bottomVisible": {
"prefix": "bottomVisible",
"body":
"const bottomVisible = () =>\n document.documentElement.clientHeight + window.scrollY >=\n (document.documentElement.scrollHeight || document.documentElement.clientHeight);",
"description":
"Returns `true` if the bottom of the page is visible, `false` otherwise. Use `scrollY`, `scrollHeight` and `clientHeight` to determine if the bottom of the page is visible."
},
"snippet-byteSize": {
"prefix": "byteSize",
"body": "const byteSize = str => new Blob([str]).size;",
"description":
"Returns the length of string. Convert a given string to a [`Blob` Object](https://developer.mozilla.org/en-US/docs/Web/API/Blob) and find its `size`."
},
"snippet-call": {
"prefix": "call",
"body": "const call = (key, ...args) => context => context[key](...args);",
"description":
"Given a key and a set of arguments, call them when given a context. Primarily useful in composition. Use a closure to call a stored key with stored arguments."
},
"snippet-capitalize": {
"prefix": "capitalize",
"body":
"const capitalize = ([first, ...rest], lowerRest = false) =>\n first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join(''));",
"description":
"Capitalizes the first letter of a string. Use destructuring and `toUpperCase()` to capitalize first letter, `...rest` to get array of characters after first letter and then `Array.join('')` to make it a string again. Omit the `lowerRest` parameter to keep the rest of the string intact, or set it to `true` to convert to lowercase."
},
"snippet-capitalizeEveryWord": {
"prefix": "capitalizeEveryWord",
"body":
"const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());",
"description":
"Capitalizes the first letter of every word in a string. Use `replace()` to match the first character of each word and `toUpperCase()` to capitalize it."
},
"snippet-chainAsync": {
"prefix": "chainAsync",
"body":
"const chainAsync = fns => {\n let curr = 0;\n const next = () => fns[curr++](next);\n next();\n};",
"description":
"Chains asynchronous functions. Loop through an array of functions containing asynchronous events, calling `next` when each asynchronous event has completed."
},
"snippet-chunk": {
"prefix": "chunk",
"body":
"const chunk = (arr, size) =>\n Array.from({ length: Math.ceil(arr.length / size) }, (v, i) =>\n arr.slice(i * size, i * size + size)\n );",
"description":
"Chunks an array into smaller arrays of a specified size. Use `Array.from()` to create a new array, that fits the number of chunks that will be produced. Use `Array.slice()` to map each element of the new array to a chunk the length of `size`. If the original array can't be split evenly, the final chunk will contain the remaining elements."
},
"snippet-clampNumber": {
"prefix": "clampNumber",
"body":
"const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));",
"description":
"Clamps `num` within the inclusive range specified by the boundary values `a` and `b`. If `num` falls within the range, return `num`. Otherwise, return the nearest number in the range."
},
"snippet-cleanObj": {
"prefix": "cleanObj",
"body":
"const cleanObj = (obj, keysToKeep = [], childIndicator) => {\n Object.keys(obj).forEach(key => {\n if (key === childIndicator) {\n cleanObj(obj[key], keysToKeep, childIndicator);\n } else if (!keysToKeep.includes(key)) {\n delete obj[key];\n }\n });\n return obj;\n};",
"description":
"Removes any properties except the ones specified from a JSON object. Use `Object.keys()` method to loop over given JSON object and deleting keys that are not `include`d in given array. Also if you give it a special key (`childIndicator`) it will search deeply inside it to apply function to inner objects too."
},
"snippet-coalesce": {
"prefix": "coalesce",
"body":
"const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_));",
"description":
"Returns the first non-null/undefined argument. Use `Array.find()` to return the first non `null`/`undefined` argument."
},
"snippet-coalesceFactory": {
"prefix": "coalesceFactory",
"body": "const coalesceFactory = valid => (...args) => args.find(valid);",
"description":
"Returns a customized coalesce function that returns the first argument that returns `true` from the provided argument validation function. Use `Array.find()` to return the first argument that returns `true` from the provided argument validation function."
},
"snippet-collatz": {
"prefix": "collatz",
"body": "const collatz = n => (n % 2 == 0 ? n / 2 : 3 * n + 1);",
"description":
"Applies the Collatz algorithm. If `n` is even, return `n/2`. Otherwise, return `3n+1`."
},
"snippet-collectInto": {
"prefix": "collectInto",
"body": "const collectInto = fn => (...args) => fn(args);",
"description":
"Changes a function that accepts an array into a variadic function. Given a function, return a closure that collects all inputs into an array-accepting function."
},
"snippet-compact": {
"prefix": "compact",
"body": "const compact = arr => arr.filter(Boolean);",
"description":
"Removes falsey values from an array. Use `Array.filter()` to filter out falsey values (`false`, `null`, `0`, `''`, `undefined`, and `NaN`)."
},
"snippet-compose": {
"prefix": "compose",
"body":
"const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));",
"description":
"Performs right-to-left function composition. Use `Array.reduce()` to perform right-to-left function composition. The last (rightmost) function can accept one or more arguments; the remaining functions must be unary."
},
"snippet-countOccurrences": {
"prefix": "countOccurrences",
"body":
"const countOccurrences = (arr, value) => arr.reduce((a, v) => (v === value ? a + 1 : a + 0), 0);",
"description":
"Counts the occurrences of a value in an array. Use `Array.reduce()` to increment a counter each time you encounter the specific value inside the array."
},
"snippet-countVowels": {
"prefix": "countVowels",
"body": "const countVowels = str => (str.match(/[aeiou]/gi) || []).length;",
"description":
"Retuns `number` of vowels in provided string. Use a regular expression to count the number of vowels `(A, E, I, O, U)` in a `string`."
},
"snippet-currentURL": {
"prefix": "currentURL",
"body": "const currentURL = () => window.location.href;",
"description":
"Returns the current URL. Use `window.location.href` to get current URL."
},
"snippet-curry": {
"prefix": "curry",
"body":
"const curry = (fn, arity = fn.length, ...args) =>\n arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);",
"description":
"Curries a function. Use recursion. If the number of provided arguments (`args`) is sufficient, call the passed function `fn`. Otherwise, return a curried function `fn` that expects the rest of the arguments. If you want to curry a function that accepts a variable number of arguments (a variadic function, e.g. `Math.min()`), you can optionally pass the number of arguments to the second parameter `arity`."
},
"snippet-deepFlatten": {
"prefix": "deepFlatten",
"body":
"const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v)));",
"description":
"Deep flattens an array. Use recursion. Use `Array.concat()` with an empty array (`[]`) and the spread operator (`...`) to flatten an array. Recursively flatten each element that is an array."
},
"snippet-detectDeviceType": {
"prefix": "detectDeviceType",
"body":
"const detectDeviceType = () =>\n /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)\n ? 'Mobile'\n : 'Desktop';",
"description":
"Detects wether the website is being opened in a mobile device or a desktop/laptop. Use a regular expression to test the `navigator.userAgent` property to figure out if the device is a mobile device or a desktop/laptop."
},
"snippet-difference": {
"prefix": "difference",
"body":
"const difference = (a, b) => {\n const s = new Set(b);\n return a.filter(x => !s.has(x));\n};",
"description":
"Returns the difference between two arrays. Create a `Set` from `b`, then use `Array.filter()` on `a` to only keep values not contained in `b`."
},
"snippet-differenceWith": {
"prefix": "differenceWith",
"body":
"const differenceWith = (arr, val, comp) => arr.filter(a => !val.find(b => comp(a, b)));",
"description":
"Filters out all values from an array for which the comparator function does not return `true`. Use `Array.filter()` and `Array.find()` to find the appropriate values."
},
"snippet-digitize": {
"prefix": "digitize",
"body": "const digitize = n => [...('' + n)].map(i => parseInt(i));",
"description":
"Converts a number to an array of digits. Convert the number to a string, using spread operators in ES6(`[...string]`) build an array. Use `Array.map()` and `parseInt()` to transform each value to an integer."
},
"snippet-distance": {
"prefix": "distance",
"body":
"const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0);",
"description":
"Returns the distance between two points. Use `Math.hypot()` to calculate the Euclidean distance between two points."
},
"snippet-distinctValuesOfArray": {
"prefix": "distinctValuesOfArray",
"body": "const distinctValuesOfArray = arr => [...new Set(arr)];",
"description":
"Returns all the distinct values of an array. Use ES6 `Set` and the `...rest` operator to discard all duplicated values."
},
"snippet-dropElements": {
"prefix": "dropElements",
"body":
"const dropElements = (arr, func) => {\n while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1);\n return arr;\n};",
"description":
"Removes elements in an array until the passed function returns `true`. Returns the remaining elements in the array. Loop through the array, using `Array.slice()` to drop the first element of the array until the returned value from the function is `true`. Returns the remaining elements."
},
"snippet-dropRight": {
"prefix": "dropRight",
"body": "const dropRight = (arr, n = 1) => arr.slice(0, -n);",
"description":
"Returns a new array with `n` elements removed from the right. Use `Array.slice()` to slice the remove the specified number of elements from the right."
},
"snippet-elementIsVisibleInViewport": {
"prefix": "elementIsVisibleInViewport",
"body":
"const elementIsVisibleInViewport = (el, partiallyVisible = false) => {\n const { top, left, bottom, right } = el.getBoundingClientRect();\n const { innerHeight, innerWidth } = window;\n return partiallyVisible\n ? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) &&\n ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))\n : top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;\n};",
"description":
"Returns `true` if the element specified is visible in the viewport, `false` otherwise. Use `Element.getBoundingClientRect()` and the `window.inner(Width|Height)` values to determine if a given element is visible in the viewport. Omit the second argument to determine if the element is entirely visible, or specify `true` to determine if it is partially visible."
},
"snippet-escapeHTML": {
"prefix": "escapeHTML",
"body":
"const escapeHTML = str =>\n str.replace(\n /[&<>'\"]/g,\n tag =>\n ({\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n \"'\": '&#39;',\n '\"': '&quot;'\n }[tag] || tag)\n );",
"description":
"Escapes a string for use in HTML. Use `String.replace()` with a regex that matches the characters that need to be escaped, using a callback function to replace each character instance with its associated escaped character using a dictionary (object)."
},
"snippet-escapeRegExp": {
"prefix": "escapeRegExp",
"body":
"const escapeRegExp = str => str.replace(/[.*+?^${}()|[]\\]/g, '\\$&');",
"description":
"Escapes a string to use in a regular expression. Use `replace()` to escape special characters."
},
"snippet-everyNth": {
"prefix": "everyNth",
"body":
"const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1);",
"description":
"Returns every nth element in an array. Use `Array.filter()` to create a new array that contains every nth element of a given array."
},
"snippet-extendHex": {
"prefix": "extendHex",
"body":
"const extendHex = shortHex =>\n '#' +\n shortHex\n .slice(shortHex.startsWith('#') ? 1 : 0)\n .split('')\n .map(x => x + x)\n .join('');",
"description":
"Extends a 3-digit color code to a 6-digit color code. Use `Array.map()`, `split()` and `Array.join()` to join the mapped array for converting a 3-digit RGB notated hexadecimal color-code to the 6-digit form. `String.slice()` is used to remove `#` from string start since it's added once."
},
"snippet-factorial": {
"prefix": "factorial",
"body":
"const factorial = n =>\n n < 0\n ? (() => {\n throw new TypeError('Negative numbers are not allowed!');\n })()\n : n <= 1 ? 1 : n * factorial(n - 1);",
"description":
"Calculates the factorial of a number. Use recursion. If `n` is less than or equal to `1`, return `1`. Otherwise, return the product of `n` and the factorial of `n - 1`. Throws an exception if `n` is a negative number."
},
"snippet-fibonacci": {
"prefix": "fibonacci",
"body":
"const fibonacci = n =>\n Array.from({ length: n }).reduce(\n (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),\n []\n );",
"description":
"Generates an array, containing the Fibonacci sequence, up until the nth term. Create an empty array of the specific length, initializing the first two values (`0` and `1`). Use `Array.reduce()` to add values into the array, using the sum of the last two values, except for the first two."
},
"snippet-fibonacciCountUntilNum": {
"prefix": "fibonacciCountUntilNum",
"body":
"const fibonacciCountUntilNum = num =>\n Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2));",
"description":
"Returns the number of fibonnacci numbers up to `num`(`0` and `num` inclusive). Use a mathematical formula to calculate the number of fibonacci numbers until `num`."
},
"snippet-filterNonUnique": {
"prefix": "filterNonUnique",
"body":
"const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));",
"description":
"Filters out the non-unique values in an array. Use `Array.filter()` for an array containing only the unique values."
},
"snippet-flatten": {
"prefix": "flatten",
"body": "const flatten = arr => [].concat(...arr);",
"description":
"Flattens an array. Use a new array and concatenate it with the spread input array causing a shallow de-nesting of any contained arrays."
},
"snippet-flattenDepth": {
"prefix": "flattenDepth",
"body":
"const flattenDepth = (arr, depth = 1) =>\n depth != 1\n ? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flattenDepth(v, depth - 1) : v), [])\n : arr.reduce((a, v) => a.concat(v), []);",
"description":
"Flattens an array up to the specified depth. Use recursion, decrementing `depth` by 1 for each level of depth. Use `Array.reduce()` and `Array.concat()` to merge elements or arrays. Base case, for `depth` equal to `1` stops recursion. Omit the second element, `depth` to flatten only to a depth of `1` (single flatten)."
},
"snippet-flip": {
"prefix": "flip",
"body": "const flip = fn => (...args) => fn(args.pop(), ...args);",
"description":
"Flip takes a function as an argument, then makes the first argument the last Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest."
},
"snippet-fromCamelCase": {
"prefix": "fromCamelCase",
"body":
"const fromCamelCase = (str, separator = '_') =>\n str\n .replace(/([a-zd])([A-Z])/g, '$1' + separator + '$2')\n .replace(/([A-Z]+)([A-Z][a-zd]+)/g, '$1' + separator + '$2')\n .toLowerCase();",
"description":
"Converts a string from camelcase. Use `replace()` to remove underscores, hyphens, and spaces and convert words to camelcase. Omit the second argument to use a default separator of `_`."
},
"snippet-functionName": {
"prefix": "functionName",
"body": "const functionName = fn => (console.debug(fn.name), fn);",
"description":
"Logs the name of a function. Use `console.debug()` and the `name` property of the passed method to log the method's name to the `debug` channel of the console."
},
"snippet-gcd": {
"prefix": "gcd",
"body":
"const gcd = (...arr) => {\n let data = [].concat(...arr);\n const helperGcd = (x, y) => (!y ? x : gcd(y, x % y));\n return data.reduce((a, b) => helperGcd(a, b));\n};",
"description":
"Calculates the greatest common divisor between two or more numbers/arrays. The `helperGcd `function uses recursion. Base case is when `y` equals `0`. In this case, return `x`. Otherwise, return the GCD of `y` and the remainder of the division `x/y`."
},
"snippet-getDaysDiffBetweenDates": {
"prefix": "getDaysDiffBetweenDates",
"body":
"const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>\n (dateFinal - dateInitial) / (1000 * 3600 * 24);",
"description":
"Returns the difference (in days) between two dates. Calculate the difference (in days) between two `Date` objects."
},
"snippet-getScrollPosition": {
"prefix": "getScrollPosition",
"body":
"const getScrollPosition = (el = window) => ({\n x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft,\n y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop\n});",
"description":
"Returns the scroll position of the current page. Use `pageXOffset` and `pageYOffset` if they are defined, otherwise `scrollLeft` and `scrollTop`. You can omit `el` to use a default value of `window`."
},
"snippet-getStyle": {
"prefix": "getStyle",
"body":
"const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName];",
"description":
"Returns the value of a CSS rule for the specified element. Use `Window.getComputedStyle()` to get the value of the CSS rule for the specified element."
},
"snippet-getType": {
"prefix": "getType",
"body":
"const getType = v =>\n v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase();",
"description":
"Returns the native type of a value. Returns lower-cased constructor name of value, 'undefined' or 'null' if value is undefined or null"
},
"snippet-getURLParameters": {
"prefix": "getURLParameters",
"body":
"const getURLParameters = url =>\n url\n .match(/([^?=&]+)(=([^&]*))/g)\n .reduce((a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), {});",
"description":
"Returns an object containing the parameters of the current URL. Use `match()` with an appropriate regular expression to get all key-value pairs, `Array.reduce()` to map and combine them into a single object. Pass `location.search` as the argument to apply to the current `url`."
},
"snippet-groupBy": {
"prefix": "groupBy",
"body":
"const groupBy = (arr, func) =>\n arr.map(typeof func === 'function' ? func : val => val[func]).reduce((acc, val, i) => {\n acc[val] = (acc[val] || []).concat(arr[i]);\n return acc;\n }, {});",
"description":
"Groups the elements of an array based on the given function. Use `Array.map()` to map the values of an array to a function or property name. Use `Array.reduce()` to create an object, where the keys are produced from the mapped results."
},
"snippet-hammingDistance": {
"prefix": "hammingDistance",
"body":
"const hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length;",
"description":
"Calculates the Hamming distance between two values. Use XOR operator (`^`) to find the bit difference between the two numbers, convert to a binary string using `toString(2)`. Count and return the number of `1`s in the string, using `match(/1/g)`."
},
"snippet-hasClass": {
"prefix": "hasClass",
"body":
"const hasClass = (el, className) => el.classList.contains(className);",
"description":
"Returns `true` if the element has the specified class, `false` otherwise. Use `element.classList.contains()` to check if the element has the specified class."
},
"snippet-head": {
"prefix": "head",
"body": "const head = arr => arr[0];",
"description":
"Returns the head of a list. Use `arr[0]` to return the first element of the passed array."
},
"snippet-hexToRGB": {
"prefix": "hexToRGB",
"body":
"const hexToRGB = hex => {\n let alpha = false,\n h = hex.slice(hex.startsWith('#') ? 1 : 0);\n if (h.length === 3) h = [...h].map(x => x + x).join('');\n else if (h.length === 8) alpha = true;\n h = parseInt(h, 16);\n return (\n 'rgb' +\n (alpha ? 'a' : '') +\n '(' +\n (h >>> (alpha ? 24 : 16)) +\n ', ' +\n ((h & (alpha ? 0x00ff0000 : 0x00ff00)) >>> (alpha ? 16 : 8)) +\n ', ' +\n ((h & (alpha ? 0x0000ff00 : 0x0000ff)) >>> (alpha ? 8 : 0)) +\n (alpha ? `, ${h & 0x000000ff}` : '') +\n ')'\n );\n};",
"description":
"Converts a color code to a `rgb()` or `rgba()` string if alpha value is provided. Use bitwise right-shift operator and mask bits with `&` (and) operator to convert a hexadecimal color code (with or without prefixed with `#`) to a string with the RGB values. If it's 3-digit color code, first convert to 6-digit version. If an alpha value is provided alongside 6-digit hex, give `rgba()` string in return."
},
"snippet-hide": {
"prefix": "hide",
"body":
"const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));",
"description":
"Hides all the elements specified. Use the spread operator (`...`) and `Array.forEach()` to apply `display: none` to each element specified."
},
"snippet-httpsRedirect": {
"prefix": "httpsRedirect",
"body":
"const httpsRedirect = () => {\n if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]);\n};",
"description":
"Redirects the page to HTTPS if its currently in HTTP. Also, pressing the back button doesn't take it back to the HTTP page as its replaced in the history. Use `location.protocol` to get the protocol currently being used. If it's not HTTPS, use `location.replace()` to replace the existing page with the HTTPS version of the page. Use `location.href` to get the full address, split it with `String.split()` and remove the protocol part of the URL."
},
"snippet-initial": {
"prefix": "initial",
"body": "const initial = arr => arr.slice(0, -1);",
"description":
"Returns all the elements of an array except the last one. Use `arr.slice(0,-1)` to return all but the last element of the array."
},
"snippet-initialize2DArray": {
"prefix": "initialize2DArray",
"body":
"const initialize2DArray = (w, h, val = null) =>\n Array(h)\n .fill()\n .map(() => Array(w).fill(val));",
"description":
"Initializes a 2D array of given width and height and value. Use `Array.map()` to generate h rows where each is a new array of size w initialize with value. If the value is not provided, default to `null`."
},
"snippet-initializeArrayWithRange": {
"prefix": "initializeArrayWithRange",
"body":
"const initializeArrayWithRange = (end, start = 0) =>\n Array.from({ length: end + 1 - start }).map((v, i) => i + start);",
"description":
"Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive. Use `Array((end + 1) - start)` to create an array of the desired length, `Array.map()` to fill with the desired values in a range. You can omit `start` to use a default value of `0`."
},
"snippet-initializeArrayWithValues": {
"prefix": "initializeArrayWithValues",
"body":
"const initializeArrayWithValues = (n, value = 0) => Array(n).fill(value);",
"description":
"Initializes and fills an array with the specified values. Use `Array(n)` to create an array of the desired length, `fill(v)` to fill it with the desired values. You can omit `value` to use a default value of `0`."
},
"snippet-inRange": {
"prefix": "inRange",
"body":
"const inRange = (n, start, end = null) => {\n if (end && start > end) end = [start, (start = end)][0];\n return end == null ? n >= 0 && n < start : n >= start && n < end;\n};",
"description":
"Checks if the given number falls within the given range. Use arithmetic comparison to check if the given number is in the specified range. If the second parameter, `end`, is not specified, the range is considered to be from `0` to `start`."
},
"snippet-intersection": {
"prefix": "intersection",
"body":
"const intersection = (a, b) => {\n const s = new Set(b);\n return a.filter(x => s.has(x));\n};",
"description":
"Returns a list of elements that exist in both arrays. Create a `Set` from `b`, then use `Array.filter()` on `a` to only keep values contained in `b`."
},
"snippet-isArmstrongNumber": {
"prefix": "isArmstrongNumber",
"body":
"const isArmstrongNumber = digits =>\n (arr => arr.reduce((a, d) => a + Math.pow(parseInt(d), arr.length), 0) == digits)(\n (digits + '').split('')\n );",
"description":
"Checks if the given number is an Armstrong number or not. Convert the given number into an array of digits. Use `Math.pow()` to get the appropriate power for each digit and sum them up. If the sum is equal to the number itself, return `true` otherwise `false`."
},
"snippet-isArray": {
"prefix": "isArray",
"body": "const isArray = val => !!val && Array.isArray(val);",
"description":
"Checks if the given argument is an array. Use `Array.isArray()` to check if a value is classified as an array."
},
"snippet-isBoolean": {
"prefix": "isBoolean",
"body": "const isBoolean = val => typeof val === 'boolean';",
"description":
"Checks if the given argument is a native boolean element. Use `typeof` to check if a value is classified as a boolean primitive."
},
"snippet-isDivisible": {
"prefix": "isDivisible",
"body":
"const isDivisible = (dividend, divisor) => dividend % divisor === 0;",
"description":
"Checks if the first numeric argument is divisible by the second one. Use the modulo operator (`%`) to check if the remainder is equal to `0`."
},
"snippet-isEven": {
"prefix": "isEven",
"body": "const isEven = num => num % 2 === 0;",
"description":
"Returns `true` if the given number is even, `false` otherwise. Checks whether a number is odd or even using the modulo (`%`) operator. Returns `true` if the number is even, `false` if the number is odd."
},
"snippet-isFunction": {
"prefix": "isFunction",
"body": "const isFunction = val => val && typeof val === 'function';",
"description":
"Checks if the given argument is a function. Use `typeof` to check if a value is classified as a function primitive."
},
"snippet-isNumber": {
"prefix": "isNumber",
"body": "const isNumber = val => typeof val === 'number';",
"description":
"Checks if the given argument is a number. Use `typeof` to check if a value is classified as a number primitive."
},
"snippet-isPrime": {
"prefix": "isPrime",
"body":
"const isPrime = num => {\n const boundary = Math.floor(Math.sqrt(num));\n for (var i = 2; i * i <= boundary; i++) if (num % i == 0) return false;\n return num >= 2;\n};",
"description":
"Checks if the provided integer is a prime number. Check numbers from `2` to the square root of the given number. Return `false` if any of them divides the given number, else return `true`, unless the number is less than `2`."
},
"snippet-isString": {
"prefix": "isString",
"body": "const isString = val => typeof val === 'string';",
"description":
"Checks if the given argument is a string. Use `typeof` to check if a value is classified as a string primitive."
},
"snippet-JSONToDate": {
"prefix": "JSONToDate",
"body":
"const JSONToDate = arr => {\n const dt = new Date(parseInt(arr.toString().substr(6)));\n return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`;\n};",
"description":
"Converts a JSON object to a date. Use `Date()`, to convert dates in JSON format to readable format (`dd/mm/yyyy`)."
},
"snippet-JSONToFile": {
"prefix": "JSONToFile",
"body":
"const fs = require('fs');\nconst JSONToFile = (obj, filename) =>\n fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));",
"description":
"Writes a JSON object to a file. Use `fs.writeFile()`, template literals and `JSON.stringify()` to write a `json` object to a `.json` file."
},
"snippet-last": {
"prefix": "last",
"body": "const last = arr => arr[arr.length - 1];",
"description":
"Returns the last element in an array. Use `arr.length - 1` to compute the index of the last element of the given array and returning it."
},
"snippet-lcm": {
"prefix": "lcm",
"body":
"const lcm = (...arr) => {\n const gcd = (x, y) => (!y ? x : gcd(y, x % y));\n const _lcm = (x, y) => x * y / gcd(x, y);\n return [].concat(...arr).reduce((a, b) => _lcm(a, b));\n};",
"description":
"Returns the least common multiple of two or more numbers/arrays. Use the greatest common divisor (GCD) formula and `Math.abs()` to determine the least common multiple. The GCD formula uses recursion."
},
"snippet-lowercaseKays": {
"prefix": "lowercaseKays",
"body":
"const lowercaseKeys = obj =>\n Object.keys(obj).reduce((acc, key) => {\n acc[key.toLowerCase()] = obj[key];\n return acc;\n }, {});",
"description":
"Creates a new object from the specified object, where all the keys are in lowercase. Use `Object.keys()` and `Array.reduce()` to create a new object from the specified object. Convert each key in the original object to lowercase, using `String.toLowerCase()`."
},
"snippet-mapObject": {
"prefix": "mapObject",
"body":
"const mapObject = (arr, fn) =>\n (a => (\n (a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {})\n ))();",
"description":
"Maps the values of an array to an object using a function, where the key-value pairs consist of the original value as the key and the mapped value. Use an anonymous inner function scope to declare an undefined memory space, using closures to store a return value. Use a new `Array` to store the array with a map of the function over its data set and a comma operator to return a second step, without needing to move from one context to another (due to closures and order of operations)."
},
"snippet-max": {
"prefix": "max",
"body": "const max = (...arr) => Math.max(...[].concat(...arr));",
"description":
"Returns the maximum value out of two or more numbers/arrays. Use `Math.max()` combined with the spread operator (`...`) to get the maximum value in the array."
},
"snippet-median": {
"prefix": "median",
"body":
"const median = arr => {\n const mid = Math.floor(arr.length / 2),\n nums = [...arr].sort((a, b) => a - b);\n return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;\n};",
"description":
"Returns the median of an array of numbers. Find the middle of the array, use `Array.sort()` to sort the values. Return the number at the midpoint if `length` is odd, otherwise the average of the two middle numbers."
},
"snippet-min": {
"prefix": "min",
"body": "const min = arr => Math.min(...[].concat(...arr));",
"description":
"Returns the minimum value in an array. Use `Math.min()` combined with the spread operator (`...`) to get the minimum value in the array."
},
"snippet-negate": {
"prefix": "negate",
"body": "const negate = func => (...args) => !func(...args);",
"description":
"Negates a predicate function. Take a predicate function and apply `not` to it with its arguments."
},
"snippet-nthElement": {
"prefix": "nthElement",
"body":
"const nthElement = (arr, n = 0) => (n > 0 ? arr.slice(n, n + 1) : arr.slice(n))[0];",
"description":
"Returns the nth element of an array. Use `Array.slice()` to get an array containing the nth element at the first place. If the index is out of bounds, return `[]`. Omit the second argument, `n`, to get the first element of the array."
},
"snippet-objectFromPairs": {
"prefix": "objectFromPairs",
"body":
"const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {});",
"description":
" Creates an object from the given key-value pairs. Use `Array.reduce()` to create and combine key-value pairs."
},
"snippet-objectToPairs": {
"prefix": "objectToPairs",
"body":
"const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);",
"description":
"Creates an array of key-value pair arrays from an object. Use `Object.keys()` and `Array.map()` to iterate over the object's keys and produce an array with key-value pairs."
},
"snippet-onUserInputChange": {
"prefix": "onUserInputChange",
"body":
"const onUserInputChange = callback => {\n let type = 'mouse',\n lastTime = 0;\n const mousemoveHandler = () => {\n const now = performance.now();\n if (now - lastTime < 20)\n (type = 'mouse'), callback(type), document.removeEventListener('mousemove', mousemoveHandler);\n lastTime = now;\n };\n document.addEventListener('touchstart', () => {\n if (type === 'touch') return;\n (type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler);\n });\n};",
"description":
"Run the callback whenever the user input type changes (`mouse` or `touch`). Useful for enabling/disabling code depending on the input device. This process is dynamic and works with hybrid devices (e.g. touchscreen laptops). Use two event listeners. Assume `mouse` input initially and bind a `touchstart` event listener to the document. On `touchstart`, add a `mousemove` event listener to listen for two consecutive `mousemove` events firing within 20ms, using `performance.now()`. Run the callback with the input type as an argument in either of these situations."
},
"snippet-orderBy": {
"prefix": "orderBy",
"body":
"const orderBy = (arr, props, orders) =>\n [...arr].sort((a, b) =>\n props.reduce((acc, prop, i) => {\n if (acc === 0) {\n const [p1, p2] = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]];\n acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0;\n }\n return acc;\n }, 0)\n );",
"description":
"Returns a sorted array of objects ordered by properties and orders. Uses a custom implementation of sort, that reduces the props array argument with a default value of 0, it uses destructuring to swap the properties position depending on the order passed. If no orders array is passed it sort by 'asc' by default."
},
"snippet-palindrome": {
"prefix": "palindrome",
"body":
"const palindrome = str => {\n const s = str.toLowerCase().replace(/[W_]/g, '');\n return (\n s ===\n s\n .split('')\n .reverse()\n .join('')\n );\n};",
"description":
"Returns `true` if the given string is a palindrome, `false` otherwise. Convert string `toLowerCase()` and use `replace()` to remove non-alphanumeric characters from it. Then, `split('')` into individual characters, `reverse()`, `join('')` and compare to the original, unreversed string, after converting it `tolowerCase()`."
},
"snippet-percentile": {
"prefix": "percentile",
"body":
"const percentile = (arr, val) =>\n 100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0) / arr.length;",
"description":
"Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value. Use `Array.reduce()` to calculate how many numbers are below the value and how many are the same value and apply the percentile formula."
},
"snippet-pick": {
"prefix": "pick",
"body":
"const pick = (obj, arr) =>\n arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {});",
"description":
"Picks the key-value pairs corresponding to the given keys from an object. Use `Array.reduce()` to convert the filtered/picked keys back to an object with the corresponding key-value pair if the key exists in the obj."
},
"snippet-pipeFunctions": {
"prefix": "pipeFunctions",
"body":
"const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));",
"description":
"Performs left-to-right function composition. Use `Array.reduce()` with the spread operator (`...`) to perform left-to-right function composition. The first (leftmost) function can accept one or more arguments; the remaining functions must be unary."
},
"snippet-powerset": {
"prefix": "powerset",
"body":
"const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]);",
"description":
"Returns the powerset of a given array of numbers. Use `Array.reduce()` combined with `Array.map()` to iterate over elements and combine into an array containing all combinations."
},
"snippet-primes": {
"prefix": "primes",
"body":
"const primes = num => {\n let arr = Array.from({ length: num - 1 }).map((x, i) => i + 2),\n sqroot = Math.floor(Math.sqrt(num)),\n numsTillSqroot = Array.from({ length: sqroot - 1 }).map((x, i) => i + 2);\n numsTillSqroot.forEach(x => (arr = arr.filter(y => y % x !== 0 || y == x)));\n return arr;\n};",
"description":
"Generates primes up to a given number, using the Sieve of Eratosthenes. Generate an array from `2` to the given number. Use `Array.filter()` to filter out the values divisible by any number from `2` to the square root of the provided number."
},
"snippet-promisify": {
"prefix": "promisify",
"body":
"const promisify = func => (...args) =>\n new Promise((resolve, reject) =>\n func(...args, (err, result) => (err ? reject(err) : resolve(result)))\n );",
"description":
"Converts an asynchronous function to return a promise. Use currying to return a function returning a `Promise` that calls the original function. Use the `...rest` operator to pass in all the parameters. *In Node 8+, you can use [`util.promisify`](https://nodejs.org/api/util.html#util_util_promisify_original)*"
},
"snippet-pull": {
"prefix": "pull",
"body":
"const pull = (arr, ...args) => {\n let argState = Array.isArray(args[0]) ? args[0] : args;\n let pulled = arr.filter((v, i) => !argState.includes(v));\n arr.length = 0;\n pulled.forEach(v => arr.push(v));\n};",
"description":
"Mutates the original array to filter out the values specified. Use `Array.filter()` and `Array.includes()` to pull out the values that are not needed. Use `Array.length = 0` to mutate the passed in an array by resetting it's length to zero and `Array.push()` to re-populate it with only the pulled values. _(For a snippet that does not mutate the original array see [`without`](#without))_"
},
"snippet-pullAtIndex": {
"prefix": "pullAtIndex",
"body":
"const pullAtIndex = (arr, pullArr) => {\n let removed = [];\n let pulled = arr\n .map((v, i) => (pullArr.includes(i) ? removed.push(v) : v))\n .filter((v, i) => !pullArr.includes(i));\n arr.length = 0;\n pulled.forEach(v => arr.push(v));\n return removed;\n};",
"description":
"Mutates the original array to filter out the values at the specified indexes. Use `Array.filter()` and `Array.includes()` to pull out the values that are not needed. Use `Array.length = 0` to mutate the passed in an array by resetting it's length to zero and `Array.push()` to re-populate it with only the pulled values. Use `Array.push()` to keep track of pulled values"
},
"snippet-pullAtValue": {
"prefix": "pullAtValue",
"body":
"const pullAtValue = (arr, pullArr) => {\n let removed = [],\n pushToRemove = arr.forEach((v, i) => (pullArr.includes(v) ? removed.push(v) : v)),\n mutateTo = arr.filter((v, i) => !pullArr.includes(v));\n arr.length = 0;\n mutateTo.forEach(v => arr.push(v));\n return removed;\n};",
"description":
"Mutates the original array to filter out the values specified. Returns the removed elements. Use `Array.filter()` and `Array.includes()` to pull out the values that are not needed. Use `Array.length = 0` to mutate the passed in an array by resetting it's length to zero and `Array.push()` to re-populate it with only the pulled values. Use `Array.push()` to keep track of pulled values"
},
"snippet-quickSort": {
"prefix": "quickSort",
"body":
"const quickSort = ([n, ...nums], desc) =>\n isNaN(n)\n ? []\n : [\n ...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc),\n n,\n ...quickSort(nums.filter(v => (!desc ? v > n : v <= n)), desc)\n ];",
"description":
"QuickSort an Array (ascending sort by default). Use recursion. Use `Array.filter` and spread operator (`...`) to create an array that all elements with values less than the pivot come before the pivot, and all elements with values greater than the pivot come after it. If the parameter `desc` is truthy, return array sorts in descending order."
},
"snippet-randomHexColorCode": {
"prefix": "randomHexColorCode",
"body":
"const randomHexColorCode = () => {\n let n = ((Math.random() * 0xfffff) | 0).toString(16);\n return '#' + (n.length !== 6 ? ((Math.random() * 0xf) | 0).toString(16) + n : n);\n};",
"description":
"Generates a random hexadecimal color code. Use `Math.random` to generate a random 24-bit(6x4bits) hexadecimal number. Use bit shifting and then convert it to an hexadecimal String using `toString(16)`."
},
"snippet-randomIntegerInRange": {
"prefix": "randomIntegerInRange",
"body":
"const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;",
"description":
"Returns a random integer in the specified range. Use `Math.random()` to generate a random number and map it to the desired range, using `Math.floor()` to make it an integer."
},
"snippet-randomNumberInRange": {
"prefix": "randomNumberInRange",
"body":
"const randomNumberInRange = (min, max) => Math.random() * (max - min) + min;",
"description":
"Returns a random number in the specified range. Use `Math.random()` to generate a random value, map it to the desired range using multiplication."
},
"snippet-readFileLines": {
"prefix": "readFileLines",
"body":
"const fs = require('fs');\nconst readFileLines = filename =>\n fs\n .readFileSync(filename)\n .toString('UTF8')\n .split('\n');",
"description":
"Returns an array of lines from the specified file. Use `readFileSync` function in `fs` node package to create a `Buffer` from a file. convert buffer to string using `toString(encoding)` function. creating an array from contents of file by `split`ing file content line by line (each `\n`)."
},
"snippet-redirect": {
"prefix": "redirect",
"body":
"const redirect = (url, asLink = true) =>\n asLink ? (window.location.href = url) : window.location.replace(url);",
"description":
"Redirects to a specified URL. Use `window.location.href` or `window.location.replace()` to redirect to `url`. Pass a second argument to simulate a link click (`true` - default) or an HTTP redirect (`false`)."
},
"snippet-remove": {
"prefix": "remove",
"body":
"const remove = (arr, func) =>\n Array.isArray(arr)\n ? arr.filter(func).reduce((acc, val) => {\n arr.splice(arr.indexOf(val), 1);\n return acc.concat(val);\n }, [])\n : [];",
"description":
"Removes elements from an array for which the given function returns `false`. Use `Array.filter()` to find array elements that return truthy values and `Array.reduce()` to remove elements using `Array.splice()`. The `func` is invoked with three arguments (`value, index, array`)."
},
"snippet-repeatString": {
"prefix": "repeatString",
"body":
"const repeatString = (str = '', num = 2) => {\n return num >= 0 ? str.repeat(num) : str;\n};",
"description":
"Repeats a string n times using `String.repeat()` If no string is provided the default is `''` and the default number of times is 2."
},
"snippet-reverseString": {
"prefix": "reverseString",
"body":
"const reverseString = str =>\n str\n .split('')\n .reverse()\n .join('');",
"description":
"Reverses a string. Use `split('')` and `Array.reverse()` to reverse the order of the characters in the string. Combine characters to get a string using `join('')`."
},
"snippet-RGBToHex": {
"prefix": "RGBToHex",
"body":
"const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');",
"description":
"Converts the values of RGB components to a color code. Convert given RGB parameters to hexadecimal string using bitwise left-shift operator (`<<`) and `toString(16)`, then `padStart(6,'0')` to get a 6-digit hexadecimal value."
},
"snippet-round": {
"prefix": "round",
"body":
"const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);",
"description":
"Rounds a number to a specified amount of digits. Use `Math.round()` and template literals to round the number to the specified number of digits. Omit the second argument, `decimals` to round to an integer."
},
"snippet-runPromisesInSeries": {
"prefix": "runPromisesInSeries",
"body":
"const runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve());",
"description":
"Runs an array of promises in series. Use `Array.reduce()` to create a promise chain, where each promise returns the next promise when resolved."
},
"snippet-sample": {
"prefix": "sample",
"body":
"const sample = arr => arr[Math.floor(Math.random() * arr.length)];",
"description":
"Returns a random element from an array. Use `Math.random()` to generate a random number, multiply it by `length` and round it of to the nearest whole number using `Math.floor()`. This method also works with strings."
},
"snippet-scrollToTop": {
"prefix": "scrollToTop",
"body":
"const scrollToTop = () => {\n const c = document.documentElement.scrollTop || document.body.scrollTop;\n if (c > 0) {\n window.requestAnimationFrame(scrollToTop);\n window.scrollTo(0, c - c / 8);\n }\n};",
"description":
"Smooth-scrolls to the top of the page. Get distance from top using `document.documentElement.scrollTop` or `document.body.scrollTop`. Scroll by a fraction of the distance from the top. Use `window.requestAnimationFrame()` to animate the scrolling."
},
"snippet-sdbm": {
"prefix": "sdbm",
"body":
"const sdbm = str => {\n let arr = str.split('');\n return arr.reduce(\n (hashCode, currentVal) =>\n (hashCode = currentVal.charCodeAt(0) + (hashCode << 6) + (hashCode << 16) - hashCode),\n 0\n );\n};",
"description":
"This algorithm is a simple hash-algorithm that hashes it input string `s` into a whole number. Use `split('')` and `Array.reduce()` to create a hash of the input string, utilizing bit shifting."
},
"snippet-select": {
"prefix": "select",
"body":
"const select = (from, selector) =>\n selector.split('.').reduce((prev, cur) => prev && prev[cur], from);",
"description":
"Retrieve a property that indicated by the selector from an object. If the property does not exists returns `undefined`."
},
"snippet-setStyle": {
"prefix": "setStyle",
"body":
"const setStyle = (el, ruleName, value) => (el.style[ruleName] = value);",
"description":
"Sets the value of a CSS rule for the specified element. Use `element.style` to set the value of the CSS rule for the specified element to `value`."
},
"snippet-shallowClone": {
"prefix": "shallowClone",
"body": "const shallowClone = obj => Object.assign({}, obj);",
"description":
"Creates a shallow clone of an object. Use `Object.assign()` and an empty object (`{}`) to create a shallow clone of the original."
},
"snippet-show": {
"prefix": "show",
"body":
"const show = (...el) => [...el].forEach(e => (e.style.display = ''));",
"description":
"Shows all the elements specified. Use the spread operator (`...`) and `Array.forEach()` to clear the `display` property for each element specified."
},
"snippet-shuffle": {
"prefix": "shuffle",
"body":
"const shuffle = ([...arr]) => {\n let m = arr.length;\n while (m) {\n const i = Math.floor(Math.random() * m--);\n [arr[m], arr[i]] = [arr[i], arr[m]];\n }\n return arr;\n};",
"description":
"Randomizes the order of the values of an array, returning a new array. Uses the Fisher-Yates algoritm to reorder the elements of the array, based on the [Lodash implementation](https://github.com/lodash/lodash/blob/b2ea6b1cd251796dcb5f9700c4911a7b6223920b/shuffle.js), but as a pure function."
},
"snippet-similarity": {
"prefix": "similarity",
"body":
"const similarity = (arr, values) => arr.filter(v => values.includes(v));",
"description":
"Returns an array of elements that appear in both arrays. Use `filter()` to remove values that are not part of `values`, determined using `includes()`."
},
"snippet-sleep": {
"prefix": "sleep",
"body":
"const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));",
"description":
"Delays the execution of an asynchronous function. Delay executing part of an `async` function, by putting it to sleep, returning a `Promise`."
},
"snippet-sortCharactersInString": {
"prefix": "sortCharactersInString",
"body":
"const sortCharactersInString = str =>\n str\n .split('')\n .sort((a, b) => a.localeCompare(b))\n .join('');",
"description":
"Alphabetically sorts the characters in a string. Split the string using `split('')`, `Array.sort()` utilizing `localeCompare()`, recombine using `join('')`."
},
"snippet-speechSynthesis": {
"prefix": "speechSynthesis",
"body":
"const speechSynthesis = message => {\n const msg = new SpeechSynthesisUtterance(message);\n msg.voice = window.speechSynthesis.getVoices()[0];\n window.speechSynthesis.speak(msg);\n};",
"description":
"Performs speech synthesis (experimental). Use `SpeechSynthesisUtterance.voice` and `window.speechSynthesis.getVoices()` to convert a message to speech. Use `window.speechSynthesis.speak()` to play the message. Learn more about the [SpeechSynthesisUtterance interface of the Web Speech API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance)."
},
"snippet-splitLines": {
"prefix": "splitLines",
"body": "const splitLines = str => str.split(/\r?\n/);",
"description":
"Splits a multiline string into an array of lines. Use `String.split()` and a regular expression to match line breaks and create an array."
},
"snippet-spreadOver": {
"prefix": "spreadOver",
"body": "const spreadOver = fn => argsArr => fn(...argsArr);",
"description":
"Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. Use closures and the spread operator (`...`) to map the array of arguments to the inputs of the function."
},
"snippet-standardDeviation": {
"prefix": "standardDeviation",
"body":
"const standardDeviation = (arr, usePopulation = false) => {\n const mean = arr.reduce((acc, val) => acc + val, 0) / arr.length;\n return Math.sqrt(\n arr\n .reduce((acc, val) => acc.concat(Math.pow(val - mean, 2)), [])\n .reduce((acc, val) => acc + val, 0) /\n (arr.length - (usePopulation ? 0 : 1))\n );\n};",
"description":
"Returns the standard deviation of an array of numbers. Use `Array.reduce()` to calculate the mean, variance and the sum of the variance of the values, the variance of the values, then determine the standard deviation. You can omit the second argument to get the sample standard deviation or set it to `true` to get the population standard deviation."
},
"snippet-sum": {
"prefix": "sum",
"body":
"const sum = (...arr) => [].concat(...arr).reduce((acc, val) => acc + val, 0);",
"description":
"Returns the sum of an of two or more numbers/arrays. Use `Array.reduce()` to add each value to an accumulator, initialized with a value of `0`."
},
"snippet-symmetricDifference": {
"prefix": "symmetricDifference",
"body":
"const symmetricDifference = (a, b) => {\n const sA = new Set(a),\n sB = new Set(b);\n return [...a.filter(x => !sB.has(x)), ...b.filter(x => !sA.has(x))];\n};",
"description":
"Returns the symmetric difference between two arrays. Create a `Set` from each array, then use `Array.filter()` on each of them to only keep values not contained in the other."
},
"snippet-tail": {
"prefix": "tail",
"body": "const tail = arr => (arr.length > 1 ? arr.slice(1) : arr);",
"description":
"Returns all elements in an array except for the first one. Return `arr.slice(1)` if the array's `length` is more than `1`, otherwise, return the whole array."
},
"snippet-take": {
"prefix": "take",
"body": "const take = (arr, n = 1) => arr.slice(0, n);",
"description":
"Returns an array with n elements removed from the beginning. Use `Array.slice()` to create a slice of the array with `n` elements taken from the beginning."
},
"snippet-takeRight": {
"prefix": "takeRight",
"body":
"const takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length);",
"description":
"Returns an array with n elements removed from the end. Use `Array.slice()` to create a slice of the array with `n` elements taken from the end."
},
"snippet-timeTaken": {
"prefix": "timeTaken",
"body":
"const timeTaken = callback => {\n console.time('timeTaken');\n const r = callback();\n console.timeEnd('timeTaken');\n return r;",
"description":
"Measures the time taken by a function to execute. Use `console.time()` and `console.timeEnd()` to measure the difference between the start and end times to determine how long the callback took to execute."
},
"snippet-toCamelCase": {
"prefix": "toCamelCase",
"body":
"const toCamelCase = str => {\n let s =\n str &&\n str\n .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)\n .map(x => x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase())\n .join('');\n return s.slice(0, 1).toLowerCase() + s.slice(1);\n};",
"description":
"Converts a string to camelcase. Break the string into words and combine them capitalizing the first letter of each word. For more detailed explanation of this Regex, [visit this Site](https://regex101.com/r/bMCgAB/1)."
},
"snippet-toDecimalMark": {
"prefix": "toDecimalMark",
"body": "const toDecimalMark = num => num.toLocaleString('en-US');",
"description":
"Use `toLocaleString()` to convert a float-point arithmetic to the [Decimal mark](https://en.wikipedia.org/wiki/Decimal_mark) form. It makes a comma separated string from a number."
},
"snippet-toEnglishDate": {
"prefix": "toEnglishDate",
"body":
"const toEnglishDate = time => {\n try {\n return new Date(time)\n .toISOString()\n .split('T')[0]\n .replace(/-/g, '/');\n } catch (e) {}\n};",
"description":
"Converts a date from American format to English format. Use `Date.toISOString()`, `split('T')` and `replace()` to convert a date from American format to the English format. Throws an error if the passed time cannot be converted to a date."
},
"snippet-toggleClass": {
"prefix": "toggleClass",
"body":
"const toggleClass = (el, className) => el.classList.toggle(className);",
"description":
"Toggle a class for an element. Use `element.classList.toggle()` to toggle the specified class for the element."
},
"snippet-toKebabCase": {
"prefix": "toKebabCase",
"body":
"const toKebabCase = str =>\n str &&\n str\n .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)\n .map(x => x.toLowerCase())\n .join('-');",
"description":
"Converts a string to kebab case. Break the string into words and combine them using `-` as a separator. For more detailed explanation of this Regex, [visit this Site](https://regex101.com/r/bMCgAB/1)."
},
"snippet-tomorrow": {
"prefix": "tomorrow",
"body":
"const tomorrow = () => new Date(new Date().getTime() + 86400000).toISOString().split('T')[0];",
"description":
"Results in a string representation of tomorrow's date. Use `new Date()` to get today's date, adding `86400000` of seconds to it(24 hours), using `toISOString` to convert Date object to string."
},
"snippet-toOrdinalSuffix": {
"prefix": "toOrdinalSuffix",
"body":
"const toOrdinalSuffix = num => {\n const int = parseInt(num),\n digits = [int % 10, int % 100],\n ordinals = ['st', 'nd', 'rd', 'th'],\n oPattern = [1, 2, 3, 4],\n tPattern = [11, 12, 13, 14, 15, 16, 17, 18, 19];\n return oPattern.includes(digits[0]) && !tPattern.includes(digits[1])\n ? int + ordinals[digits[0] - 1]\n : int + ordinals[3];\n};",
"description":
"Adds an ordinal suffix to a number. Use the modulo operator (`%`) to find values of single and tens digits. Find which ordinal pattern digits match. If digit is found in teens pattern, use teens ordinal."
},
"snippet-toSnakeCase": {
"prefix": "toSnakeCase",
"body":
"const toSnakeCase = str =>\n str &&\n str\n .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)\n .map(x => x.toLowerCase())\n .join('_');",
"description":
"Converts a string to snake case. Break the string into words and combine them using `_` as a separator. For more detailed explanation of this Regex, [visit this Site](https://regex101.com/r/bMCgAB/1)."
},
"snippet-truncateString": {
"prefix": "truncateString",
"body":
"const truncateString = (str, num) =>\n str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str;",
"description":
"Truncates a string up to a specified length. Determine if the string's `length` is greater than `num`. Return the string truncated to the desired length, with `...` appended to the end or the original string."
},
"snippet-truthCheckCollection": {
"prefix": "truthCheckCollection",
"body":
"const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]);",
"description":
"Checks if the predicate (second argument) is truthy on all elements of a collection (first argument). Use `Array.every()` to check if each passed object has the specified property and if it returns a truthy value."
},
"snippet-unescapeHTML": {
"prefix": "unescapeHTML",
"body":
"const unescapeHTML = str =>\n str.replace(\n /&amp;|&lt;|&gt;|&#39;|&quot;/g,\n tag =>\n ({\n '&amp;': '&',\n '&lt;': '<',\n '&gt;': '>',\n '&#39;': \"'\",\n '&quot;': '\"'\n }[tag] || tag)\n );",
"description":
"Unescapes escaped HTML characters. Use `String.replace()` with a regex that matches the characters that need to be unescaped, using a callback function to replace each escaped character instance with its associated unescaped character using a dictionary (object)."
},
"snippet-union": {
"prefix": "union",
"body": "const union = (a, b) => Array.from(new Set([...a, ...b]));",
"description":
"Returns every element that exists in any of the two arrays once. Create a `Set` with all values of `a` and `b` and convert to an array."
},
"snippet-UUIDGeneratorBrowser": {
"prefix": "UUIDGeneratorBrowser",
"body":
"const UUIDGeneratorBrowser = () =>\n ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>\n (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)\n );",
"description":
"Generates a UUID in a browser. Use `crypto` API to generate a UUID, compliant with [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) version 4."
},
"snippet-UUIDGeneratorNode": {
"prefix": "UUIDGeneratorNode",
"body":
"const crypto = require('crypto');\nconst UUIDGeneratorNode = () =>\n ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>\n (c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)\n );",
"description":
"Generates a UUID in Node.JS. Use `crypto` API to generate a UUID, compliant with [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) version 4."
},
"snippet-validateNumber": {
"prefix": "validateNumber",
"body":
"const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;",
"description":
"Returns `true` if the given value is a number, `false` otherwise. Use `!isNaN` in combination with `parseFloat()` to check if the argument is a number. Use `isFinite()` to check if the number is finite. Use `Number()` to check if the coercion holds."
},
"snippet-without": {
"prefix": "without",
"body":
"const without = (arr, ...args) => arr.filter(v => !args.includes(v));",
"description":
"Filters out the elements of an array, that have one of the specified values. Use `Array.filter()` to create an array excluding(using `!Array.includes()`) all given values. _(For a snippet that mutates the original array see [`pull`](#pull))_"
},
"snippet-words": {
"prefix": "words",
"body":
"const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean);",
"description":
"Converts a given string into an array of words. Use `String.split()` with a supplied pattern (defaults to non-alpha as a regex) to convert to an array of strings. Use `Array.filter()` to remove any empty strings. Omit the second argument to use the default regex."
},
"snippet-yesNo": {
"prefix": "yesNo",
"body":
"const yesNo = (val, def = false) =>\n /^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def;",
"description":
"Returns `true` if the string is `y`/`yes` or `false` if the string is `n`/`no`. Use `RegExp.test()` to check if the string evaluates to `y/yes` or `n/no`. Omit the second argument, `def` to set the default answer as `no`."
},
"snippet-zip": {
"prefix": "zip",
"body":
"const zip = (...arrays) => {\n const maxLength = Math.max(...arrays.map(x => x.length));\n return Array.from({ length: maxLength }).map((_, i) => {\n return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]);\n });\n};",
"description":
"Creates an array of elements, grouped based on the position in the original arrays. Use `Math.max.apply()` to get the longest array in the arguments. Creates an array with that length as return value and use `Array.from()` with a map-function to create an array of grouped elements. If lengths of the argument-arrays vary, `undefined` is used where no value could be found."
},
"snippet-zipObject": {
"prefix": "zipObject",
"body":
"const zipObject = (props, values) =>\n props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {});",
"description":
"Given an array of valid property identifiers and an array of values, return an object associating the properties to the values. Since an object can have undefined values but not undefined property pointers, the array of properties is used to decide the structure of the resulting object using `Array.reduce()`."
}
}
{
/*
// Place your snippets for JavaScript React here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
*/
}
{
/*
// Place your snippets for SASS here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
*/
}
{
// Place your snippets for Sass here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": ["console.log('$1');", "$2"],
"description": "Log output to console"
},
"title block": {
"prefix": "title",
"body": [
"/* ==========================================================================",
" #${title}",
" ========================================================================== */",
"",
"$0"
],
"description": "Simple title block"
},
"comment block": {
"prefix": "comment",
"body": ["/**", " * ${comment}", " */", "$0"],
"description": "Simple comment block"
},
"define BEMIT": {
"prefix": "define",
"body": ["/**", " * @define ${class}", " */", "$0"],
"description": "Simple comment block"
},
"@include": {
"prefix": "include",
"body": ["@include ${mixin-name};"],
"description": "add include mixin"
},
"breakpoints_all": {
"prefix": "abrk",
"body": [
"",
"/*",
"for-phone-only : max-width: 599px",
"for-tablet-portrait-up : min-width: 600px",
"for-tablet-portait-only : min-width: 600px and max-width: 899px",
"for-tablet-landscape-up : min-width: 900px",
"for-tablet-landscape-only : min-width: 900px max-width: 1199px",
"for-desktop-up : min-width: 1200px",
"for-desktop-only : min-width: 1200px max-width: 1799px",
"for-big-desktop-up : min-width: 1800px",
"*/",
""
],
"description": "all breakpoints"
},
"breakpoints_main": {
"prefix": "mbrk",
"body": [
"",
"/*",
"for-tablet-portrait-up : min-width: 600px",
"for-tablet-landscape-up : min-width: 900px",
"for-desktop-up : min-width: 1200px",
"for-big-desktop-up : min-width: 1800px",
"*/",
""
],
"description": "main breakpoints"
},
"stylelint disable line": {
"prefix": "disline",
"body": ["/* stylelint-disable-line */ $1"],
"description": "stylelint disable line"
},
"breakpoint": {
"prefix": "forb",
"body": ["@include for-${1} {", " $0", "}"],
"description": "add breakpoint mixin"
},
"bg": {
"prefix": "bg",
"body": [
"background: rgba(${lightblue}, 0.3); /* stylelint-disable-line */"
],
"description": "add breakpoint mixin"
},
"fluid": {
"prefix": "fluid",
"body": ["@include fluid-type(${font-size}, 320px, 1366px, 14px, 18px);"],
"description": "add fluidtype mixin"
},
// NEUE:
"container": {
"prefix": "container",
"body": ["@include grid-container;$0"],
"description": "add grid container"
},
"wrap": {
"prefix": "wrap",
"body": ["@include grid-wrap(${1:$$distance-xl}${2:, $$container});$0"],
"description": "add grid wrap"
},
"shift": {
"prefix": "shift",
"body": ["@include grid-shift(${1:1});$0"],
"description": "shift grid"
},
"push": {
"prefix": "push",
"body": ["@include grid-push(${1:1});$0"],
"description": "push grid"
},
"column": {
"prefix": "column",
"body": ["@include grid-column(${1:12}${2:, $$neat-grid});$0"],
"description": "grid column"
},
"collapse": {
"prefix": "collapse",
"body": ["@include grid-collapse();$0"],
"description": "grid collapse"
},
"vr": {
"prefix": "vr",
"body": ["@include vr(${1:$$font-body}, ${2:$$font-size-l});$0"],
"description": "vertical rythm"
},
"flexcell": {
"prefix": "fc",
"body": [
"@include flexcells($$i: false, $$gutters: false, $$self: auto, $$grow: 0, $$shrink: 1, $$basis: auto, $$order: false );$0"
],
"description": "flexbox cell"
},
"flexbox": {
"prefix": "fb",
"body": [
"@include flexbox($$maxWidth: false, $$outsideGutters: false, $$direction: row, $$wrap: wrap, $$justify: center, $$items: stretch, $$content: stretch);$0"
],
"description": "flexbox container"
}
}
{
/*
// Place your snippets for HTML (Twig) here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
*/
"imager macro options": {
"prefix": "imager",
"body": [
"{% set options = {",
" allowUpscale: false,",
" alt: false,",
" background: false,",
" class: '${class}',",
" format: 'jpg',",
" interlace: true,",
" lazy: true,",
" mode: 'crop',",
" openDiv: false,",
" position: false,",
" quality: 80,",
" ratio: false,",
" dataSizes: 'auto',",
" }",
" %}",
"{{ macroLazyFocusImager.LazyFocusImager(image, options) }}",
"$0"
],
"description": "Imager macro"
},
"commentt": {
"prefix": "comment",
"body": [
"{# ${comment} #}",
"$0"
],
"description": "comment"
},
"svg": {
"prefix": "svg",
"body": [
"{% include '_svg${}' %}"
],
"description": "svg include"
}
}
{"version":"7.3.0","status":2,"welcomeShown":true}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment