├── cheatsheets ├── index.md ├── rust │ ├── cli │ │ ├── index.md │ │ ├── rustup.md │ │ └── rustc.md │ ├── uninstall.md │ ├── install.md │ └── index.md ├── powershell │ ├── index.md │ ├── files.md │ ├── execution-policy.md │ └── shortcuts.md ├── sql │ ├── advanced │ │ ├── index.md │ │ └── update-table.md │ ├── rdbms │ │ └── index.md │ ├── basic │ │ ├── index.md │ │ ├── manage-tables.md │ │ ├── maths.md │ │ └── delete.md │ ├── index.md │ └── replace.md ├── shell │ ├── database │ │ └── index.md │ ├── commands │ │ ├── read-write │ │ │ ├── index.md │ │ │ ├── head.md │ │ │ ├── tail.md │ │ │ └── vis.md │ │ ├── date │ │ │ ├── index.md │ │ │ └── convert.md │ │ ├── index.md │ │ ├── dig.md │ │ ├── grep │ │ │ ├── regex-patterns │ │ │ │ └── index.md │ │ │ ├── match-types.md │ │ │ └── resources.md │ │ ├── ssh.md │ │ ├── scp.md │ │ └── fzf.md │ ├── files │ │ ├── index.md │ │ └── text-files │ │ │ ├── index.md │ │ │ ├── more.md │ │ │ ├── combine.md │ │ │ ├── clipboard.md │ │ │ ├── open.md │ │ │ ├── view.md │ │ │ ├── lines.md │ │ │ ├── dotenv.md │ │ │ └── head-and-tail.md │ ├── storage │ │ └── index.md │ ├── permissions │ │ ├── change-owner.md │ │ ├── change-group.md │ │ └── index.md │ ├── scripting │ │ ├── control-flow │ │ │ ├── index.md │ │ │ ├── and-or.md │ │ │ ├── if-else.md │ │ │ ├── negate.md │ │ │ ├── ignore.md │ │ │ └── true-false.md │ │ ├── index.md │ │ ├── size.md │ │ ├── copy.md │ │ ├── overview.md │ │ ├── docstring.md │ │ └── sequence.md │ ├── printing │ │ └── index.md │ ├── cross-language.md │ ├── hardware.md │ ├── ssh │ │ ├── index.md │ │ └── directory.md │ ├── architecture.md │ ├── compression │ │ └── view.md │ ├── batch.md │ ├── scheduling.md │ ├── searching.md │ └── network-manager.md ├── web │ ├── css │ │ ├── layouts │ │ │ ├── index.md │ │ │ └── align.md │ │ ├── pseudo-selectors │ │ │ ├── index.md │ │ │ ├── text.md │ │ │ ├── user-action.md │ │ │ └── overview.md │ │ ├── index.md │ │ ├── tables.md │ │ ├── github-pages.md │ │ ├── transform.md │ │ ├── boxes.md │ │ └── cursor.md │ ├── html │ │ ├── elements │ │ │ ├── index.md │ │ │ └── abbr.md │ │ ├── content-editable.md │ │ ├── selection.md │ │ ├── autofocus.md │ │ ├── open-graph.md │ │ ├── index.md │ │ ├── comments.md │ │ ├── encode-and-escape │ │ │ ├── html-entity-escaping.md │ │ │ └── index.md │ │ └── clickable.md │ ├── http-status-codes.md │ ├── index.md │ ├── seo │ │ ├── sitemaps.md │ │ └── index.md │ └── hosts.md ├── containers │ ├── docker │ │ ├── intro │ │ │ ├── index.md │ │ │ └── hello-world.md │ │ ├── index.md │ │ ├── dockerfile │ │ │ ├── aliases.md │ │ │ └── index.md │ │ ├── persist.md │ │ ├── volumes.md │ │ └── clean.md │ ├── kubernetes │ │ ├── cli │ │ │ ├── index.md │ │ │ ├── exec.md │ │ │ ├── logs.md │ │ │ └── replica-set.md │ │ ├── install.md │ │ └── index.md │ ├── podman │ │ ├── index.md │ │ ├── setup.md │ │ └── cli.md │ ├── index.md │ ├── colima │ │ └── index.md │ ├── docker-compose │ │ └── index.md │ └── docker-cli │ │ └── manage-volumes.md ├── data │ ├── json │ │ └── index.md │ ├── index.md │ ├── toml │ │ ├── index.md │ │ ├── data-types.md │ │ └── sample.md │ └── yaml │ │ ├── variable-names.md │ │ ├── file-formatting.md │ │ └── data-structures.md ├── go │ ├── code │ │ ├── networking │ │ │ └── index.md │ │ ├── index.md │ │ ├── printing │ │ │ ├── log.md │ │ │ └── index.md │ │ ├── cli-input.md │ │ └── structures.md │ ├── packages │ │ ├── index.md │ │ └── time.md │ ├── manage-packages │ │ └── index.md │ └── index.md ├── javascript │ ├── packages │ │ ├── vue │ │ │ ├── cli │ │ │ │ └── index.md │ │ │ ├── components │ │ │ │ ├── index.md │ │ │ │ └── conditional.md │ │ │ ├── directives │ │ │ │ ├── index.md │ │ │ │ └── v-bind.md │ │ │ ├── text.md │ │ │ ├── index.md │ │ │ ├── events │ │ │ │ ├── emit.md │ │ │ │ ├── key-modifiers.md │ │ │ │ ├── custom.md │ │ │ │ └── types.md │ │ │ └── white-space.md │ │ ├── dataviz │ │ │ ├── index.md │ │ │ └── apex-charts │ │ │ │ ├── index.md │ │ │ │ ├── installation.md │ │ │ │ ├── formatting.md │ │ │ │ ├── logarithm.md │ │ │ │ └── basic.md │ │ ├── react │ │ │ ├── hooks │ │ │ │ ├── importing.md │ │ │ │ ├── custom-hooks.md │ │ │ │ ├── index.md │ │ │ │ └── callback.md │ │ │ ├── basics │ │ │ │ ├── index.md │ │ │ │ └── component-lifecycle.md │ │ │ ├── index.md │ │ │ ├── download.md │ │ │ ├── refs.md │ │ │ └── setup.md │ │ ├── npkill │ │ │ └── index.md │ │ ├── esbuild │ │ │ ├── script.md │ │ │ └── formats.md │ │ ├── jquery │ │ │ └── index.md │ │ ├── index.md │ │ ├── express │ │ │ └── index.md │ │ └── http │ │ │ └── index.md │ ├── browser │ │ ├── events │ │ │ └── index.md │ │ ├── index.md │ │ ├── design-mode.md │ │ ├── clipboard.md │ │ ├── network.md │ │ └── styles.md │ ├── general │ │ ├── strings │ │ │ ├── index.md │ │ │ └── encoding │ │ │ │ └── index.md │ │ ├── timers │ │ │ └── index.md │ │ ├── functions │ │ │ └── index.md │ │ ├── control-flow │ │ │ ├── index.md │ │ │ ├── some.md │ │ │ └── switch.md │ │ ├── data-structures │ │ │ ├── index.md │ │ │ └── iterables.md │ │ ├── index.md │ │ ├── request │ │ │ ├── http.md │ │ │ └── index.md │ │ ├── object-shorthand.md │ │ ├── modules │ │ │ └── index.md │ │ ├── promises │ │ │ └── callback.md │ │ ├── variable-declaration │ │ │ └── reassign.md │ │ ├── es6.md │ │ ├── style-console-log.md │ │ └── printing.md │ ├── deno │ │ ├── cli │ │ │ ├── commands │ │ │ │ ├── index.md │ │ │ │ └── test.md │ │ │ ├── index.md │ │ │ ├── format.md │ │ │ └── releasing-asset.md │ │ ├── modules │ │ │ └── index.md │ │ ├── package-list │ │ │ └── index.md │ │ ├── managing-imports │ │ │ └── inline.md │ │ ├── code.md │ │ └── ignoring-rules.md │ ├── node │ │ ├── index.md │ │ ├── classes.md │ │ └── install.md │ ├── typescript.md │ └── format-and-lint │ │ ├── eslint │ │ ├── rules │ │ │ ├── index.md │ │ │ └── format.md │ │ ├── install.md │ │ ├── config-files │ │ │ ├── index.md │ │ │ └── main.md │ │ ├── index.md │ │ └── init.md │ │ ├── prettier │ │ ├── index.md │ │ ├── resources.md │ │ ├── options.md │ │ ├── ignoring-rules.md │ │ └── install.md │ │ └── index.md ├── maker-projects │ ├── index.md │ └── arduino.md ├── hugo │ ├── index.md │ └── installation.md ├── jekyll │ ├── themes │ │ └── index.md │ ├── liquid │ │ ├── conditionals │ │ │ └── index.md │ │ ├── posts │ │ │ └── index.md │ │ ├── comment.md │ │ ├── hashes.md │ │ ├── index.md │ │ ├── strings.md │ │ ├── variables.md │ │ └── paths.md │ ├── cli │ │ ├── index.md │ │ ├── commands │ │ │ └── index.md │ │ ├── container.md │ │ └── testing.md │ ├── configuration │ │ ├── index.md │ │ ├── null-values.md │ │ ├── load-multiple-configs.md │ │ ├── urls.md │ │ ├── resources.md │ │ └── build-settings.md │ ├── code-blocks │ │ └── index.md │ ├── templating │ │ ├── index.md │ │ ├── collections.md │ │ └── static-files.md │ ├── overview.md │ ├── plugins │ │ └── index.md │ ├── dependencies │ │ └── index.md │ ├── dashes.md │ └── windows.md ├── python │ ├── libraries │ │ ├── built-in │ │ │ ├── index.md │ │ │ └── http-server.md │ │ ├── database │ │ │ ├── redis │ │ │ │ └── data-types │ │ │ │ │ └── index.md │ │ │ └── index.md │ │ ├── index.md │ │ ├── boto3.md │ │ ├── queue-messaging │ │ │ ├── rq.md │ │ │ ├── celery.md │ │ │ ├── apache-kafka.md │ │ │ ├── zmq.md │ │ │ └── amazon-sqs.md │ │ └── ipython.md │ ├── strings │ │ ├── encoding │ │ │ ├── index.md │ │ │ └── html-escape.md │ │ ├── wrap.md │ │ ├── index.md │ │ ├── case.md │ │ ├── truncate.md │ │ └── regex.md │ ├── type-checks │ │ ├── basics │ │ │ ├── index.md │ │ │ └── union.md │ │ ├── data-structures │ │ │ ├── index.md │ │ │ ├── tuple.md │ │ │ └── no-structure.md │ │ ├── index.md │ │ └── install-and-run-mypy.md │ ├── linting │ │ └── index.md │ ├── formatting │ │ ├── index.md │ │ └── black.md │ ├── project-administration │ │ ├── index.md │ │ ├── linting │ │ │ └── index.md │ │ └── formatting.md │ ├── install │ │ └── index.md │ ├── builtins │ │ ├── data-structures │ │ │ ├── tuple.md │ │ │ └── deque.md │ │ └── index.md │ ├── databases.md │ ├── files-and-paths │ │ ├── index.md │ │ └── read-and-write │ │ │ └── index.md │ ├── tests │ │ ├── index.md │ │ └── nose.md │ ├── virtual-environments.md │ ├── configs │ │ ├── python.md │ │ ├── toml.md │ │ ├── index.md │ │ └── setup-cfg.md │ ├── challenges.md │ ├── resources.md │ ├── pitfalls.md │ ├── transpose-array.md │ ├── convert.md │ └── browser.md ├── version-control │ ├── git │ │ ├── branches │ │ │ └── index.md │ │ ├── submodules │ │ │ ├── index.md │ │ │ └── github-view.md │ │ ├── restore │ │ │ ├── index.md │ │ │ ├── unstage.md │ │ │ └── undo.md │ │ ├── count-files-in-repo.md │ │ ├── committing │ │ │ ├── skip-hooks.md │ │ │ ├── index.md │ │ │ ├── auto.md │ │ │ └── ci.md │ │ ├── commands │ │ │ ├── gc.md │ │ │ └── whatchanged.md │ │ ├── resources.md │ │ ├── search-stashes.md │ │ ├── permissions-error.md │ │ ├── changes-key.md │ │ ├── tags.md │ │ ├── log-tips.md │ │ └── index.md │ ├── github │ │ ├── api │ │ │ ├── v3 │ │ │ │ ├── index.md │ │ │ │ ├── limitations.md │ │ │ │ └── gists.md │ │ │ ├── index.md │ │ │ └── v4 │ │ │ │ └── index.md │ │ └── index.md │ └── index.md ├── graphql │ ├── index.md │ └── spread.md ├── package-managers │ ├── index.md │ ├── javascript │ │ ├── yarn │ │ │ ├── commands │ │ │ │ ├── index.md │ │ │ │ ├── add.md │ │ │ │ ├── install.md │ │ │ │ ├── create.md │ │ │ │ └── npm-vs-yarn.md │ │ │ └── index.md │ │ ├── npm │ │ │ ├── index.md │ │ │ ├── manage.md │ │ │ └── commands │ │ │ │ └── index.md │ │ └── index.md │ ├── php │ │ └── index.md │ ├── python │ │ ├── index.md │ │ ├── pip │ │ │ ├── uninstall.md │ │ │ ├── index.md │ │ │ ├── resources.md │ │ │ ├── overview.md │ │ │ ├── manage-pip.md │ │ │ ├── protect.md │ │ │ └── show.md │ │ └── pipenv.md │ ├── ruby │ │ ├── bundler │ │ │ ├── subcommands │ │ │ │ ├── index.md │ │ │ │ ├── clean.md │ │ │ │ └── add.md │ │ │ ├── env.md │ │ │ ├── clean.md │ │ │ ├── list.md │ │ │ ├── other.md │ │ │ ├── init.md │ │ │ └── upgrade.md │ │ ├── gem │ │ │ ├── remove.md │ │ │ ├── env.md │ │ │ ├── index.md │ │ │ └── show.md │ │ └── index.md │ └── os │ │ ├── index.md │ │ ├── snap.md │ │ └── homebrew │ │ ├── overview.md │ │ ├── install-homebrew.md │ │ ├── index.md │ │ └── services.md ├── typescript │ ├── data-types │ │ ├── index.md │ │ └── primitives.md │ ├── tsconfig.md │ ├── index.md │ ├── run.md │ ├── ignoring-rules.md │ ├── variables.md │ └── type-assertions.md ├── other │ ├── vscode │ │ ├── index.md │ │ ├── python-imports.md │ │ └── emmet.md │ ├── index.md │ ├── cli │ │ ├── index.md │ │ └── interface.md │ ├── vscode-extensions │ │ ├── workflows │ │ │ ├── index.md │ │ │ └── publish.md │ │ └── index.md │ ├── regex │ │ ├── repeat.md │ │ ├── insert.md │ │ ├── groups.md │ │ ├── index.md │ │ └── exclude.md │ ├── quick-links.md │ ├── indentation.md │ └── share-code.md ├── ruby │ ├── strings.md │ ├── gems │ │ ├── index.md │ │ └── user-directory.md │ ├── index.md │ ├── functions.md │ ├── types.md │ └── ruby-managers.md ├── make │ ├── index.md │ ├── variables │ │ ├── date.md │ │ ├── index.md │ │ ├── current-directory.md │ │ ├── access.md │ │ └── defaults-file.md │ ├── copy.md │ └── command-modifiers.md ├── ci-cd │ ├── index.md │ ├── netlify │ │ ├── functions │ │ │ ├── index.md │ │ │ ├── response-type.md │ │ │ └── function-params.md │ │ └── index.md │ ├── circleci │ │ ├── index.md │ │ └── definitions.md │ └── github-actions │ │ └── working-directory.md ├── tools │ ├── index.md │ └── helm.md ├── markdown │ ├── wiki.md │ ├── emojis.md │ ├── todo-list.md │ ├── flavors.md │ └── contact.md ├── terraform │ ├── index.md │ ├── code │ │ ├── conditionals.md │ │ └── index.md │ ├── atlantis.md │ ├── environment.md │ ├── tfenv.md │ └── cli-usage │ │ ├── import.md │ │ └── console.md ├── artificial-intelligence │ ├── deepseek │ │ └── index.md │ ├── ollama │ │ └── index.md │ └── index.md └── nosql │ └── mongodb │ └── advanced-features.md ├── 404.html ├── sample-shell.png ├── sample-cheatsheets.png ├── .gitignore ├── docs ├── usage.md ├── development.md ├── README.md ├── deploy.md └── installation.md ├── Gemfile ├── hooks └── pre-push ├── .editorconfig ├── .vscode └── settings.json └── Makefile /cheatsheets/index.md: -------------------------------------------------------------------------------- 1 | # Cheatsheets 2 | -------------------------------------------------------------------------------- /404.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: 404 3 | --- 4 | -------------------------------------------------------------------------------- /cheatsheets/rust/cli/index.md: -------------------------------------------------------------------------------- 1 | # CLI 2 | -------------------------------------------------------------------------------- /cheatsheets/powershell/index.md: -------------------------------------------------------------------------------- 1 | # PowerShell 2 | -------------------------------------------------------------------------------- /cheatsheets/sql/advanced/index.md: -------------------------------------------------------------------------------- 1 | # Advanced 2 | -------------------------------------------------------------------------------- /cheatsheets/shell/database/index.md: -------------------------------------------------------------------------------- 1 | # Database 2 | -------------------------------------------------------------------------------- /cheatsheets/sql/rdbms/index.md: -------------------------------------------------------------------------------- 1 | # RDBMS flavors 2 | -------------------------------------------------------------------------------- /cheatsheets/web/css/layouts/index.md: -------------------------------------------------------------------------------- 1 | # Layouts 2 | -------------------------------------------------------------------------------- /cheatsheets/web/html/elements/index.md: -------------------------------------------------------------------------------- 1 | # Elements 2 | -------------------------------------------------------------------------------- /cheatsheets/containers/docker/intro/index.md: -------------------------------------------------------------------------------- 1 | # Intro 2 | -------------------------------------------------------------------------------- /cheatsheets/containers/kubernetes/cli/index.md: -------------------------------------------------------------------------------- 1 | # CLI 2 | -------------------------------------------------------------------------------- /cheatsheets/data/json/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # JSON 4 | -------------------------------------------------------------------------------- /cheatsheets/go/code/networking/index.md: -------------------------------------------------------------------------------- 1 | # Networking 2 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/vue/cli/index.md: -------------------------------------------------------------------------------- 1 | # CLI 2 | -------------------------------------------------------------------------------- /cheatsheets/maker-projects/index.md: -------------------------------------------------------------------------------- 1 | # Maker projects 2 | -------------------------------------------------------------------------------- /cheatsheets/go/code/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Code 3 | --- 4 | -------------------------------------------------------------------------------- /cheatsheets/hugo/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Hugo 3 | 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/javascript/browser/events/index.md: -------------------------------------------------------------------------------- 1 | # Events 2 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/strings/index.md: -------------------------------------------------------------------------------- 1 | # Strings 2 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/timers/index.md: -------------------------------------------------------------------------------- 1 | # Timers 2 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/dataviz/index.md: -------------------------------------------------------------------------------- 1 | # Dataviz 2 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/themes/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Themes 4 | -------------------------------------------------------------------------------- /cheatsheets/python/libraries/built-in/index.md: -------------------------------------------------------------------------------- 1 | # Built-in 2 | -------------------------------------------------------------------------------- /cheatsheets/python/strings/encoding/index.md: -------------------------------------------------------------------------------- 1 | # Encoding 2 | -------------------------------------------------------------------------------- /cheatsheets/python/type-checks/basics/index.md: -------------------------------------------------------------------------------- 1 | # Basics 2 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/read-write/index.md: -------------------------------------------------------------------------------- 1 | # Read and write -------------------------------------------------------------------------------- /cheatsheets/shell/files/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Files 4 | -------------------------------------------------------------------------------- /cheatsheets/data/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Data formats 3 | --- 4 | -------------------------------------------------------------------------------- /cheatsheets/javascript/deno/cli/commands/index.md: -------------------------------------------------------------------------------- 1 | # Commands 2 | -------------------------------------------------------------------------------- /cheatsheets/javascript/deno/cli/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # CLI 4 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/functions/index.md: -------------------------------------------------------------------------------- 1 | # Functions 2 | -------------------------------------------------------------------------------- /cheatsheets/sql/basic/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Basic 3 | --- 4 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/branches/index.md: -------------------------------------------------------------------------------- 1 | # Branches 2 | -------------------------------------------------------------------------------- /cheatsheets/web/css/pseudo-selectors/index.md: -------------------------------------------------------------------------------- 1 | # Pseudo selectors 2 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/control-flow/index.md: -------------------------------------------------------------------------------- 1 | # Control flow 2 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/strings/encoding/index.md: -------------------------------------------------------------------------------- 1 | # Encoding 2 | -------------------------------------------------------------------------------- /cheatsheets/python/linting/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Linting 3 | --- 4 | -------------------------------------------------------------------------------- /cheatsheets/shell/storage/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Space on disk 4 | -------------------------------------------------------------------------------- /cheatsheets/sql/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: postgresql 3 | --- 4 | # SQL 5 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/submodules/index.md: -------------------------------------------------------------------------------- 1 | # Submodules 2 | 3 | -------------------------------------------------------------------------------- /cheatsheets/graphql/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: graphql 3 | --- 4 | # GraphQL 5 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Package managers 4 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/javascript/yarn/commands/index.md: -------------------------------------------------------------------------------- 1 | # Commands 2 | -------------------------------------------------------------------------------- /cheatsheets/python/formatting/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Formatting 3 | --- 4 | -------------------------------------------------------------------------------- /cheatsheets/python/libraries/database/redis/data-types/index.md: -------------------------------------------------------------------------------- 1 | # Data types -------------------------------------------------------------------------------- /cheatsheets/typescript/data-types/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Data types 4 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/data-structures/index.md: -------------------------------------------------------------------------------- 1 | # Data structures 2 | 3 | -------------------------------------------------------------------------------- /cheatsheets/javascript/node/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Node 3 | logo: nodedotjs 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/php/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: PHP 3 | logo: php 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/python/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: python 3 | --- 4 | # Python 5 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/bundler/subcommands/index.md: -------------------------------------------------------------------------------- 1 | # Subcommands 2 | 3 | 4 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/liquid/conditionals/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Truthy and falsy logic 3 | --- 4 | -------------------------------------------------------------------------------- /cheatsheets/python/project-administration/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Project administration 4 | -------------------------------------------------------------------------------- /cheatsheets/rust/uninstall.md: -------------------------------------------------------------------------------- 1 | # Uninstall 2 | 3 | ```sh 4 | $ rustup self uninstall 5 | ``` 6 | -------------------------------------------------------------------------------- /sample-shell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MichaelCurrin/dev-cheatsheets/HEAD/sample-shell.png -------------------------------------------------------------------------------- /cheatsheets/other/vscode/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: VS Code 3 | logo: visualstudiocode 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /cheatsheets/shell/files/text-files/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Working with text files 3 | --- 4 | 5 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/gem/remove.md: -------------------------------------------------------------------------------- 1 | # Remove 2 | 3 | ```sh 4 | gem uninstall GEM 5 | ``` 6 | -------------------------------------------------------------------------------- /cheatsheets/ruby/strings.md: -------------------------------------------------------------------------------- 1 | # Strings 2 | 3 | ## Join 4 | 5 | ```ruby 6 | File.join(foo, bar) 7 | ``` 8 | -------------------------------------------------------------------------------- /cheatsheets/go/packages/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Packages 3 | description: Recommended Go packages 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/cli/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Running Jekyll in the command-line 3 | --- 4 | # CLI 5 | -------------------------------------------------------------------------------- /cheatsheets/make/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Make 3 | description: Using GNU `make` with a `Makefile` 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/javascript/npm/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: NPM 3 | logo: npm 4 | 5 | --- 6 | 7 | 8 | -------------------------------------------------------------------------------- /cheatsheets/python/install/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Installing and managing Python 3 | --- 4 | # Install 5 | -------------------------------------------------------------------------------- /cheatsheets/shell/permissions/change-owner.md: -------------------------------------------------------------------------------- 1 | # Change owner 2 | 3 | ```sh 4 | $ chown USERNAME PATH 5 | ``` 6 | -------------------------------------------------------------------------------- /sample-cheatsheets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MichaelCurrin/dev-cheatsheets/HEAD/sample-cheatsheets.png -------------------------------------------------------------------------------- /cheatsheets/jekyll/configuration/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: How to configure Jekyll 3 | --- 4 | # Configuration 5 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/python/pip/uninstall.md: -------------------------------------------------------------------------------- 1 | # Uninstall 2 | 3 | ```sh 4 | $ pip uninstall foo 5 | ``` 6 | -------------------------------------------------------------------------------- /cheatsheets/ci-cd/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: CI/CD 3 | description: Continuous Integration / Continuous Deployment 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/javascript/browser/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: JavaScript guide for the browser 3 | --- 4 | # Browser 5 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/liquid/posts/index.md: -------------------------------------------------------------------------------- 1 | # Posts 2 | 3 | See [Posts](https://jekyllrb.com/docs/posts/) in the docs. 4 | -------------------------------------------------------------------------------- /cheatsheets/other/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Topics which don't fit into the other categories 3 | --- 4 | # Other 5 | -------------------------------------------------------------------------------- /cheatsheets/shell/permissions/change-group.md: -------------------------------------------------------------------------------- 1 | # Change group 2 | 3 | 4 | ```sh 5 | $ chgrp GROUPNAME PATH 6 | ``` 7 | -------------------------------------------------------------------------------- /cheatsheets/other/cli/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: General guide to designing Command-line Interfaces 3 | --- 4 | # CLI 5 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/os/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: OS level 3 | description: System dependency managers 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /cheatsheets/javascript/deno/cli/format.md: -------------------------------------------------------------------------------- 1 | # Format 2 | 3 | [Formatter](https://deno.land/manual/tools/formatter) in the docs. 4 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/cli/commands/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Reference for supported `jekyll` commands 3 | --- 4 | # Commands 5 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/gem/env.md: -------------------------------------------------------------------------------- 1 | # Environment 2 | 3 | Check the environment 4 | 5 | ```sh 6 | $ gem env 7 | ``` 8 | -------------------------------------------------------------------------------- /cheatsheets/shell/permissions/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Permissions 3 | description: Set permissions on a file or directory 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/version-control/github/api/v3/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: V3 REST 3 | description: About the GitHub V3 REST API 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/bundler/env.md: -------------------------------------------------------------------------------- 1 | # Environment 2 | 3 | Check the environment 4 | 5 | ```sh 6 | $ bundle env 7 | ``` 8 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/gem/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Working with the `gem` package manager command 3 | --- 4 | # gem 5 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/date/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Date 4 | 5 | 6 | Note that `date` works differently on Linux and macOS. 7 | -------------------------------------------------------------------------------- /cheatsheets/data/toml/index.md: -------------------------------------------------------------------------------- 1 | # TOML 2 | 3 | - [Homepage](https://toml.io/) 4 | - [Wikipedia](https://en.wikipedia.org/wiki/TOML) 5 | 6 | -------------------------------------------------------------------------------- /cheatsheets/javascript/deno/cli/commands/test.md: -------------------------------------------------------------------------------- 1 | # test 2 | 3 | Example: 4 | 5 | ```sh 6 | $ deno test --unstable --allow-all 7 | ``` 8 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/code-blocks/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Code blocks 3 | description: Guide to displaying code snippets in Jekyll 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/shell/scripting/control-flow/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Control flow 3 | description: Conditional logic in shell scripting 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/restore/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Restore 4 | 5 | See also the `restore` command in the Commands section. 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .jekyll-cache/ 2 | .sass-cache/ 3 | .jekyll-metadata 4 | 5 | .bundle/ 6 | vendor/ 7 | 8 | _site/ 9 | 10 | Gemfile.lock 11 | -------------------------------------------------------------------------------- /cheatsheets/go/manage-packages/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Package management 3 | description: Install Go packages globally or for a project 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/shell/files/text-files/more.md: -------------------------------------------------------------------------------- 1 | # More command 2 | 3 | `man less` and `man more` both go to less. But there is `more (1)` mentioned. 4 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: JavaScript guide that is not specific to the browser or Node.js 3 | --- 4 | # General 5 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/react/hooks/importing.md: -------------------------------------------------------------------------------- 1 | # Importing 2 | 3 | ```javascript 4 | import { useState, useEffect } from "react"; 5 | ``` 6 | -------------------------------------------------------------------------------- /cheatsheets/javascript/deno/modules/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Modules 4 | 5 | 6 | See also online docs: 7 | 8 | - [deno doc](https://doc.deno.land/) 9 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/vue/components/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Components 3 | description: Handling `.vue` files, as views and components 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Info on Bash shell commands on Linux or macOS (builtin and installable) 3 | --- 4 | # Commands 5 | -------------------------------------------------------------------------------- /cheatsheets/shell/printing/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: How to use the `echo` and `printf` commands to show output in the terminal 3 | --- 4 | # Printing 5 | -------------------------------------------------------------------------------- /docs/usage.md: -------------------------------------------------------------------------------- 1 | # Usage 2 | 3 | ```sh 4 | $ make serve 5 | ``` 6 | 7 | Open the browser at: 8 | 9 | - http://localhost:4000/dev-cheatsheets/ 10 | -------------------------------------------------------------------------------- /cheatsheets/go/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: go 3 | --- 4 | # Go 5 | 6 | See [Go](https://michaelcurrin.github.io/dev-resources/resources/go/) in Dev Resources site. 7 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/vue/directives/index.md: -------------------------------------------------------------------------------- 1 | # Directives 2 | 3 | See [Directives](https://v3.vuejs.org/api/directives.html) in the Vue 3 docs. 4 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/templating/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Cheatsheet for using Liquid templating and plain HTML in Jekyll projects 3 | --- 4 | # Templating 5 | -------------------------------------------------------------------------------- /cheatsheets/rust/install.md: -------------------------------------------------------------------------------- 1 | # Install Rust 2 | 3 | Follow the [Install Rust](https://gist.github.com/MichaelCurrin/6b619f1b035b922f4d883265b2ffcdcf) guide. 4 | -------------------------------------------------------------------------------- /cheatsheets/containers/docker/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Docker 3 | logo: docker 4 | description: Pack, ship and run any application as a lightweight container 5 | --- 6 | -------------------------------------------------------------------------------- /cheatsheets/hugo/installation.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | Follow the [Install Hugo](https://gohugo.io/getting-started/installing/) doc to install Hugo globally. 4 | -------------------------------------------------------------------------------- /cheatsheets/python/builtins/data-structures/tuple.md: -------------------------------------------------------------------------------- 1 | # Tuple 2 | 3 | Immutable. 4 | 5 | ```python 6 | p = (11, 22) 7 | 8 | p 9 | # => (11, 2) 10 | ``` 11 | -------------------------------------------------------------------------------- /cheatsheets/shell/scripting/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Scripting 3 | description: Guide to shell scripting for `.sh` scripts mainly but also command-line use 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/count-files-in-repo.md: -------------------------------------------------------------------------------- 1 | # Count files in repo 2 | 3 | Count files known to Git. 4 | 5 | ```sh 6 | $ git ls-files | wc -l 7 | ``` 8 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/react/basics/index.md: -------------------------------------------------------------------------------- 1 | # Basics 2 | 3 | Some content is from the [tutorial](https://reactjs.org/docs/hello-world.html) in the React docs. 4 | -------------------------------------------------------------------------------- /cheatsheets/python/builtins/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Built-ins 3 | --- 4 | 5 | See [Standard types](https://docs.python.org/3/library/stdtypes.html) in Python 3 docs. 6 | -------------------------------------------------------------------------------- /cheatsheets/python/type-checks/data-structures/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Data structures 3 | description: How to choose a type approach for your data structure 4 | --- 5 | -------------------------------------------------------------------------------- /cheatsheets/rust/cli/rustup.md: -------------------------------------------------------------------------------- 1 | # Rustup 2 | 3 | The Rust toolchain manager. 4 | 5 | Rustup allows switching between and updating stable, beta or nightly compilers. 6 | -------------------------------------------------------------------------------- /cheatsheets/typescript/tsconfig.md: -------------------------------------------------------------------------------- 1 | # TS Config 2 | 3 | See [TS Config](https://michaelcurrin.github.io/code-cookbook/recipes/typescript/tsconfig.html) in Code Cookbook. 4 | -------------------------------------------------------------------------------- /cheatsheets/javascript/typescript.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: typescript 3 | --- 4 | # TypeScript 5 | 6 | This section has moved [here]({% link cheatsheets/typescript/index.md %}). 7 | -------------------------------------------------------------------------------- /cheatsheets/python/databases.md: -------------------------------------------------------------------------------- 1 | # Databases 2 | 3 | See [Database][] in the libraries section. 4 | 5 | [Database]: {% link cheatsheets/python/libraries/database/index.md %} 6 | -------------------------------------------------------------------------------- /cheatsheets/python/files-and-paths/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Files and paths 4 | 5 | 6 | Note the `os` library is older but the `pathlib` is newer and is more convenient. 7 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "jekyll", "~> 4.3" 4 | gem "webrick", "~> 1.7" 5 | 6 | gem "fractal", "~> 5", git: "https://github.com/MichaelCurrin/fractal" 7 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/vue/text.md: -------------------------------------------------------------------------------- 1 | # Text 2 | 3 | {% raw %} 4 | 5 | ## Space 6 | 7 | ```html 8 | {{ fruit }}{{ ' ' }} 9 | ``` 10 | 11 | {% endraw %} 12 | -------------------------------------------------------------------------------- /cheatsheets/other/vscode-extensions/workflows/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Guide to workflows so you can to export, install and publish a VSIX extension file 3 | --- 4 | # Workflows 5 | -------------------------------------------------------------------------------- /cheatsheets/sql/basic/manage-tables.md: -------------------------------------------------------------------------------- 1 | # Manage DB 2 | 3 | 4 | ## Drop 5 | 6 | ```sql 7 | DROP TABLE foo; 8 | ``` 9 | 10 | ```sql 11 | DROP TABLE IF EXISTS foo; 12 | ``` 13 | -------------------------------------------------------------------------------- /cheatsheets/tools/index.md: -------------------------------------------------------------------------------- 1 | # Tools 2 | 3 | 4 | ### Related 5 | 6 | - [AWS CLI][] in Python libraries section. 7 | 8 | [AWS CLI]: {% link cheatsheets/python/libraries/aws-cli.md %} 9 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/react/hooks/custom-hooks.md: -------------------------------------------------------------------------------- 1 | # Custom hooks 2 | 3 | Build your own custom Hooks if you have stateful logic that needs to be reused in several components. 4 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/liquid/comment.md: -------------------------------------------------------------------------------- 1 | # Comment 2 | 3 | {% raw %} 4 | 5 | ```liquid 6 | {% comment %} 7 | Comment message 8 | {% endcomment %} 9 | ``` 10 | 11 | {% endraw %} 12 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/committing/skip-hooks.md: -------------------------------------------------------------------------------- 1 | # Skip hooks 2 | 3 | If you have commit hooks like linting. 4 | 5 | ```sh 6 | $ git commit --no-verify 7 | $ git commit -n 8 | ``` 9 | -------------------------------------------------------------------------------- /hooks/pre-push: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | # On a feature branch that has no remote yet, this first part would fail. 4 | git pull --rebase || git pull --rebase origin master 5 | 6 | make all 7 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/configuration/null-values.md: -------------------------------------------------------------------------------- 1 | # Null values 2 | 3 | ```yaml 4 | foo: null 5 | bar: "" 6 | baz: 7 | ``` 8 | 9 | Note that YAML uses `null`, while Ruby uses `nil`. 10 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/python/pip/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # pip 4 | 5 | 6 | ### Releases of pip 7 | 8 | - [pip](https://pypi.org/project/pip/) project on PyPI. See Release History. 9 | -------------------------------------------------------------------------------- /cheatsheets/web/css/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: css3 3 | description: Cascading Style Sheets (CSS) is a language used most often to style and improve upon the appearance of views. 4 | --- 5 | # CSS 6 | -------------------------------------------------------------------------------- /cheatsheets/python/project-administration/linting/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Linting 4 | 5 | Some VS Code choices - there are flags for each (so multiple can be used), plus a linting enabled switch. 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | 7 | [*.{html,md}] 8 | indent_size = 4 9 | 10 | [Makefile] 11 | indent_style = tab 12 | indent_size = 4 13 | -------------------------------------------------------------------------------- /cheatsheets/ci-cd/netlify/functions/index.md: -------------------------------------------------------------------------------- 1 | # Functions 2 | 3 | 4 | ### Related 5 | 6 | - [Netlify Functions](https://michaelcurrin.github.io/code-cookbook/recipes/ci-cd/netlify/functions/) recipes. 7 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/cli/container.md: -------------------------------------------------------------------------------- 1 | # Container 2 | 3 | For running Jekyll with Docker, see the [Jekyll Containers](https://michaelcurrin.github.io/code-cookbook/recipes/containers/jekyll.html) recipe. 4 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Overview 3 | description: Concise view of Jekyll Liquid syntax available 4 | --- 5 | 6 | - [All filters]({% link cheatsheets/jekyll/liquid/all-filters.md %}) 7 | -------------------------------------------------------------------------------- /cheatsheets/rust/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Rust 3 | logo: rust 4 | --- 5 | 6 | 7 | ### Related 8 | 9 | - [Rust](https://michaelcurrin.github.io/dev-resources/resources/rust) in Dev Resources. 10 | -------------------------------------------------------------------------------- /cheatsheets/web/http-status-codes.md: -------------------------------------------------------------------------------- 1 | # HTTP status codes 2 | 3 | - [List of HTTP status codes](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) on Wikipedia 4 | - [http.cat/](https://http.cat/) 5 | -------------------------------------------------------------------------------- /cheatsheets/javascript/browser/design-mode.md: -------------------------------------------------------------------------------- 1 | # Design mode 2 | 3 | ## Turn on 4 | 5 | ```javascript 6 | document.designMode = "on" 7 | ``` 8 | 9 | Now you can click and edit text on a website. 10 | -------------------------------------------------------------------------------- /cheatsheets/make/variables/date.md: -------------------------------------------------------------------------------- 1 | # Date 2 | 3 | Use the `date` command for the current time and format as date and time. 4 | 5 | ```makefile 6 | BUILD_DATE = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") 7 | ``` 8 | -------------------------------------------------------------------------------- /cheatsheets/web/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: html5 3 | --- 4 | # Web 5 | 6 | ### Related 7 | 8 | - [Browser][] in the JS section. 9 | 10 | [Browser]: {% link cheatsheets/javascript/browser/index.md %} 11 | -------------------------------------------------------------------------------- /cheatsheets/javascript/format-and-lint/eslint/rules/index.md: -------------------------------------------------------------------------------- 1 | # Rules 2 | 3 | See the [Rules](https://eslint.org/docs/rules/) page in the ESLint docs. It provides descriptions and link to the page of each rule. 4 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Ruby 3 | logo: ruby 4 | --- 5 | 6 | 7 | 8 | ### Related 9 | 10 | - [Jekyll Plugins]({% link cheatsheets/jekyll/plugins/index.md %}) section. 11 | -------------------------------------------------------------------------------- /cheatsheets/typescript/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: typescript 3 | --- 4 | # TypeScript 5 | 6 | See [TypeScript](https://michaelcurrin.github.io/dev-resources/resources/javascript/typescript/) in Dev Resources site. 7 | -------------------------------------------------------------------------------- /cheatsheets/version-control/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: git 3 | --- 4 | # Version control 5 | 6 | See [Version control](https://michaelcurrin.github.io/dev-resources/resources/version-control/) in my Dev Resources. 7 | -------------------------------------------------------------------------------- /cheatsheets/markdown/wiki.md: -------------------------------------------------------------------------------- 1 | # Wiki 2 | 3 | Note that if you editing markdown content in a GitHub, the rules are different for some elements. See this [gist](https://gist.github.com/subfuzion/0d3f19c4f780a7d75ba2). 4 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/bundler/clean.md: -------------------------------------------------------------------------------- 1 | # Clean 2 | 3 | ```sh 4 | $ bundle clean 5 | ``` 6 | 7 | ```sh 8 | $ bundle pristine [GEMS...] # Restores installed gems to pristine condition 9 | ``` 10 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/dig.md: -------------------------------------------------------------------------------- 1 | # dig 2 | 3 | 4 | ## Basic 5 | 6 | ```sh 7 | $ dig example.com 8 | ``` 9 | 10 | 11 | ## Trace 12 | 13 | ```sh 14 | $ dig @8.8.8.8 A example.com +noedns +trace 15 | ``` 16 | -------------------------------------------------------------------------------- /cheatsheets/python/tests/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Cheatsheets for testing in Python 3 | --- 4 | # Tests 5 | 6 | 7 | See [Getting started with testing in Python](https://realpython.com/python-testing/) on RealPython. 8 | -------------------------------------------------------------------------------- /cheatsheets/terraform/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Terraform 3 | logo: terraform 4 | --- 5 | 6 | 7 | ### Resources 8 | 9 | - [Terraform](https://michaelcurrin.github.io/dev-resources/resources/) in Dev Resources. 10 | -------------------------------------------------------------------------------- /docs/development.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Notes for developers working on this project 3 | --- 4 | # Development 5 | 6 | See [Development](https://github.com/MichaelCurrin/fractal/tree/master/docs/development/) in the theme. 7 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/configuration/load-multiple-configs.md: -------------------------------------------------------------------------------- 1 | # Load multiple configs 2 | 3 | Use a comma and no spaces. 4 | 5 | ```sh 6 | $ bundle exec jekyll build --trace \ 7 | --config _config.yml,_config_prod.yml 8 | ``` 9 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/plugins/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Plugins 4 | 5 | 6 | Note that Jekyll plugins are just Ruby gems set up to work in a Jekyll project. 7 | 8 | Some Jekyll gems are not plugins, like a theme or Jekyll itself. 9 | -------------------------------------------------------------------------------- /cheatsheets/python/project-administration/formatting.md: -------------------------------------------------------------------------------- 1 | # Formatting 2 | 3 | Some VS Code choices - this is a free text field for provider, plug configurations for each. 4 | 5 | - autopep8 6 | - black (PY 3 only) 7 | - yapf 8 | -------------------------------------------------------------------------------- /cheatsheets/web/html/content-editable.md: -------------------------------------------------------------------------------- 1 | # content editable 2 | 3 | The attribute specifies whether the content of an element is editable or not. 4 | 5 | ```htmk 6 |

An editable paragraph.

7 | ``` 8 | -------------------------------------------------------------------------------- /cheatsheets/ci-cd/netlify/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Netlify 3 | logo: netlify 4 | --- 5 | 6 | 7 | ### Related 8 | 9 | - [Netlify](https://michaelcurrin.github.io/dev-resources/resources/ci-cd/netlify/) under Dev Resources. 10 | -------------------------------------------------------------------------------- /cheatsheets/containers/podman/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Podman 3 | description: Drop-in replacement for Docker 4 | --- 5 | 6 | Accessible with commands the same as Docker CLI. 7 | 8 | For more info see [podman.io](https://podman.io). 9 | -------------------------------------------------------------------------------- /cheatsheets/make/variables/index.md: -------------------------------------------------------------------------------- 1 | # Variables 2 | 3 | Variables are sometimes useful to define at the top of your `Makefile`. These can be fixed values to be reused across your file. Or they could be dynamic like a list of files. 4 | -------------------------------------------------------------------------------- /cheatsheets/other/regex/repeat.md: -------------------------------------------------------------------------------- 1 | # Repeat 2 | 3 | ```re 4 | \w+ 5 | \w* 6 | \w? 7 | 8 | \w{2} 9 | \w{4} 10 | \w{2,4} 11 | ``` 12 | 13 | 14 | Find lines longer than 80 characters: 15 | 16 | ``` 17 | .{81,200} 18 | ``` 19 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/committing/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Committing 4 | 5 | See [Authors][] cheatsheet for how to change the author of a commit. 6 | 7 | [Authors]: {% link cheatsheets/version-control/git/authors.md %} 8 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Dev Cheatsheets documentation 2 | 3 | - [Installation](installation.md) 4 | - [Usage](usage.md) 5 | - [Deploy](deploy.md) 6 | - [Development](development.md) 7 | 8 | See also [Contributing](/CONTRIBUTING.md) guide. 9 | -------------------------------------------------------------------------------- /cheatsheets/powershell/files.md: -------------------------------------------------------------------------------- 1 | # Files 2 | 3 | ## Write to a file 4 | 5 | ```sh 6 | COMMAND | Set-Content -Path OUT_PATH 7 | ``` 8 | 9 | e.g. 10 | 11 | ```sh 12 | kubectl logs my-pod | Set-Content -Path my-log.txt 13 | ``` 14 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/vue/directives/v-bind.md: -------------------------------------------------------------------------------- 1 | # v-bind 2 | 3 | ## Resources 4 | 5 | - [Form input bindings](https://v3.vuejs.org/guide/forms.html) 6 | - [v-bind migration to Vue 3](https://v3.vuejs.org/guide/migration/v-bind.html) 7 | -------------------------------------------------------------------------------- /cheatsheets/markdown/emojis.md: -------------------------------------------------------------------------------- 1 | # Emojis 2 | 3 | Note, this works in GitHub-flavored Markdown, but might not work in certain markdown viewers unless you use a plugin. 4 | 5 | ```markdown 6 | :sparkles: 7 | ``` 8 | 9 | :sparkles: 10 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/javascript/yarn/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Yarn 3 | logo: yarn 4 | --- 5 | 6 | 7 | ### Resources 8 | 9 | - [Yarn](https://michaelcurrin.github.io/dev-resources/resources/package-managers/javascript/yarn/) 10 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/grep/regex-patterns/index.md: -------------------------------------------------------------------------------- 1 | # Regex patterns 2 | 3 | 4 | Grep supports three types of Regex: 5 | 6 | 1. Basic (BRE) 7 | 2. Extended (ERE) 8 | 3. Perl (PCRE) 9 | 10 | See the other pages for using each. 11 | -------------------------------------------------------------------------------- /cheatsheets/typescript/run.md: -------------------------------------------------------------------------------- 1 | # Run 2 | > How to run TypeScript files without converting to JS 3 | 4 | ```sh 5 | $ npx --yes ts-node PATH 6 | ``` 7 | 8 | Or setup an alias: 9 | 10 | ```sh 11 | alias ts='npx --yes ts-node' 12 | ``` 13 | -------------------------------------------------------------------------------- /cheatsheets/web/seo/sitemaps.md: -------------------------------------------------------------------------------- 1 | # Sitemaps 2 | 3 | ## Resources 4 | 5 | - [Learn about sitemaps](https://support.google.com/webmasters/answer/156184?hl=en&ref_topic=4581190&visit_id=637252521210246285-24299986&rd=1) on Google support docs. 6 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/javascript/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: javascript 3 | --- 4 | # JavaScript 5 | 6 | 7 | ### Related sections 8 | 9 | - [Install]({% link cheatsheets/javascript/node/install.md %}) guide for Node, NPM and Yarn. 10 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/gem/show.md: -------------------------------------------------------------------------------- 1 | # Show 2 | 3 | ```sh 4 | $ gem list 5 | $ gem list D # Filter to names starting with string. 6 | ``` 7 | 8 | ```sh 9 | $ bundle list 10 | ``` 11 | 12 | ```sh 13 | $ gem environment 14 | ``` 15 | -------------------------------------------------------------------------------- /cheatsheets/shell/cross-language.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: How to run a shell command from another language 3 | --- 4 | # Cross language 5 | 6 | - [Python]({% link cheatsheets/python/shell.md %}) 7 | - [Ruby]({% link cheatsheets/ruby/shell.md %}) 8 | -------------------------------------------------------------------------------- /cheatsheets/shell/files/text-files/combine.md: -------------------------------------------------------------------------------- 1 | # Combine 2 | 3 | Mix two files together. 4 | 5 | This will read the contents of the one file and append it to the end of another file. 6 | 7 | ```sh 8 | $ < file-a.txt >> file-b.txt 9 | ``` 10 | -------------------------------------------------------------------------------- /cheatsheets/terraform/code/conditionals.md: -------------------------------------------------------------------------------- 1 | # Conditionals 2 | 3 | ## Ternary 4 | 5 | ```terraform 6 | condition ? true_val : false_val 7 | ``` 8 | 9 | e.g. 10 | 11 | ```terraform 12 | foo = var.abc === true ? "dev" : "prod" 13 | ``` 14 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/javascript/yarn/commands/add.md: -------------------------------------------------------------------------------- 1 | # add 2 | 3 | See [yarn add](https://classic.yarnpkg.com/en/docs/cli/add) docs. 4 | 5 | ```sh 6 | $ yarn add PACKAGE 7 | ``` 8 | 9 | ```sh 10 | $ yarn add PACKAGE --dev 11 | ``` 12 | -------------------------------------------------------------------------------- /cheatsheets/tools/helm.md: -------------------------------------------------------------------------------- 1 | # Helm 2 | 3 | - [helm.sh](https://helm.sh) 4 | - [docs](https://duckduckgo.com/?q=helm+cli&t=ffab&ia=web) 5 | 6 | ```sh 7 | $ helm histoy RELEASE NAME 8 | ``` 9 | 10 | ```sh 11 | $ helm delete RELEASE NAME 12 | ``` 13 | -------------------------------------------------------------------------------- /cheatsheets/javascript/format-and-lint/eslint/install.md: -------------------------------------------------------------------------------- 1 | # Install 2 | 3 | 4 | ## Install in project 5 | 6 | ```sh 7 | $ npm install eslint --save-dev 8 | ``` 9 | 10 | ## Install globally 11 | 12 | ```sh 13 | $ npm install eslint -g 14 | ``` 15 | -------------------------------------------------------------------------------- /cheatsheets/javascript/format-and-lint/prettier/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Prettier 3 | description: Format your JS scripts with Prettier 4 | --- 5 | 6 | > Prettier is an opinionated code formatter. Use Prettier for formatting and linters for catching bugs. 7 | -------------------------------------------------------------------------------- /cheatsheets/version-control/github/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: github 3 | --- 4 | # GitHub 5 | 6 | 7 | ### Related 8 | 9 | - [GitHub SSH keys](https://michaelcurrin.github.io/code-cookbook/recipes/shell/ssh/github-ssh-access.html) in Code Cookbook. 10 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/request/http.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: http 3 | description: Built-in for Node 4 | --- 5 | 6 | See `http.get` or `http.request` in the Node API docs. 7 | 8 | 9 | - [http](https://nodejs.org/dist/latest/docs/api/http.htm) module 10 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/commands/gc.md: -------------------------------------------------------------------------------- 1 | # gc 2 | 3 | [git-gc](https://git-scm.com/docs/git-gc) docs 4 | 5 | 6 | If you have issues pushing your code, you can try using this to clean up the local objects. 7 | 8 | ```sh 9 | $ git gc 10 | ``` 11 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/resources.md: -------------------------------------------------------------------------------- 1 | # Resources 2 | 3 | Provided on the git website: 4 | 5 | - Downloadable [cheatsheet](https://github.github.com/training-kit/) provided by GitHub 6 | - [Visual cheatsheet](https://ndpsoftware.com/git-cheatsheet.html) 7 | -------------------------------------------------------------------------------- /cheatsheets/web/html/selection.md: -------------------------------------------------------------------------------- 1 | # Selection 2 | 3 | > Using CSS selectors 4 | 5 | Style an element based on state. 6 | 7 | - [CSS checked selector](https://www.geeksforgeeks.org/css-checked-selector/) reference. For radio buttons, checkbox and option elements 8 | -------------------------------------------------------------------------------- /cheatsheets/javascript/deno/package-list/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Package list 3 | description: Ways to put your external package dependencies in a central place 4 | --- 5 | 6 | See docs - [Linking to external code](https://deno.land/manual/linking_to_external_code) 7 | -------------------------------------------------------------------------------- /cheatsheets/shell/hardware.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Hardware 3 | description: Get info on your hardware from the shell 4 | --- 5 | 6 | 7 | ## Number of processes 8 | 9 | On Linux and macOS: 10 | 11 | ```console 12 | $ getconf _NPROCESSORS_ONLN 13 | 8 14 | ``` 15 | -------------------------------------------------------------------------------- /cheatsheets/shell/ssh/index.md: -------------------------------------------------------------------------------- 1 | # SSH 2 | 3 | ### Related 4 | 5 | - [SSH](https://michaelcurrin.github.io/code-cookbook/recipes/shell/ssh/) section of my Code Cookbook project. 6 | - [SSH command][] 7 | 8 | [SSH command]: {% link cheatsheets/shell/commands/ssh.md %} 9 | -------------------------------------------------------------------------------- /cheatsheets/data/toml/data-types.md: -------------------------------------------------------------------------------- 1 | # Data types 2 | 3 | The syntax is similar Python's. 4 | 5 | ```toml 6 | [datatypes] 7 | my_string = "abc def" 8 | my_int = 123 9 | my_list = [ 123, 456 ] 10 | my_hash = { abc = 123, def = 456 } 11 | my_bool = true 12 | ``` 13 | -------------------------------------------------------------------------------- /cheatsheets/python/libraries/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Packages 4 | 5 | For installing 3rd-party packages in Python, see the [Package managers][] Python cheatsheets. 6 | 7 | [Package managers]: {% link cheatsheets/package-managers/python/index.md %} 8 | 9 | 10 | -------------------------------------------------------------------------------- /cheatsheets/ci-cd/circleci/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: CircleCI 3 | logo: circleci 4 | --- 5 | 6 | See also [CircleCI](https://michaelcurrin.github.io/code-cookbook/recipes/ci-cd/circle-ci/) Cookbook section. 7 | 8 | [Concepts](https://circleci.com/docs/2.0/concepts/) in the docs. 9 | -------------------------------------------------------------------------------- /cheatsheets/javascript/format-and-lint/eslint/config-files/index.md: -------------------------------------------------------------------------------- 1 | # Config files 2 | 3 | See the [ESLint](https://michaelcurrin.github.io/code-cookbook/recipes/javascript/format-and-lint/eslint.html) section of my Code Cookbook for entire configs you can copy and paste. 4 | 5 | -------------------------------------------------------------------------------- /cheatsheets/python/type-checks/data-structures/tuple.md: -------------------------------------------------------------------------------- 1 | # Tuple 2 | 3 | ```python 4 | Tuple[TYPE, TYPE, ...] 5 | ``` 6 | 7 | e.g. 8 | 9 | ```python 10 | from typing import Tuple 11 | 12 | 13 | def foo() -> Tuple[bool, str]: 14 | return True, 'Yes' 15 | ``` 16 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/dependencies/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Dependencies 3 | description: Managing gems in a Jekyll site 4 | --- 5 | 6 | ## Related 7 | 8 | - [Bundler]({% link cheatsheets/package-managers/ruby/bundler/index.md %}) section - for installing gems in your Jekyll project. 9 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/liquid/hashes.md: -------------------------------------------------------------------------------- 1 | # Hashes 2 | 3 | {% raw %} 4 | 5 | 6 | Get a value on a hash. 7 | 8 | ```liquid 9 | {{ my_hash.some_key }} 10 | {{ my_hash['some_key'] }} 11 | ``` 12 | 13 | You can't use `assign` to set a value in an array. 14 | 15 | {% endraw %} 16 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/liquid/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Liquid 3 | description: Guide to Liquid templating syntax in Jekyll 4 | --- 5 | 6 | 7 | See also [Templating][] cheatsheets for using this in Jekyll. 8 | 9 | [Templating]: {% link cheatsheets/jekyll/templating/index.md %} 10 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/read-write/head.md: -------------------------------------------------------------------------------- 1 | # head 2 | 3 | 4 | ## Start of file 5 | 6 | Get the fiirst 10 lines of a file. 7 | 8 | ```sh 9 | $ head file.txt 10 | ``` 11 | 12 | Get the first 100 lines of a file. 13 | 14 | ```sh 15 | $ head -n 100 file.txt 16 | ``` 17 | -------------------------------------------------------------------------------- /cheatsheets/version-control/github/api/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: API 3 | description: About the GitHub APIs 4 | --- 5 | 6 | 7 | ### Related 8 | 9 | - [GitHub API](https://michaelcurrin.github.io/dev-resources/resources/version-control/github/api/) in Dev Resources. 10 | 11 | -------------------------------------------------------------------------------- /cheatsheets/powershell/execution-policy.md: -------------------------------------------------------------------------------- 1 | # Execution policy 2 | 3 | Based on [docs](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy). 4 | 5 | ```sh 6 | Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine 7 | ``` 8 | -------------------------------------------------------------------------------- /cheatsheets/python/virtual-environments.md: -------------------------------------------------------------------------------- 1 | # Virtual environments 2 | 3 | 4 | ## Create 5 | 6 | ```sh 7 | $ python -m venv venv 8 | ``` 9 | 10 | 11 | ## Activate 12 | 13 | ```sh 14 | $ source venv/bin/activate 15 | ``` 16 | 17 | ```sh 18 | > venv\Scripts\activate 19 | ``` 20 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | // Use "Jekyll (HTML)" so that Jekyll Liquid syntax is picked up correctly for validation and highlighting. 4 | // Remember to switch a script to HTML though, when you want formatting. 5 | "*.html": "jekyll", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /cheatsheets/javascript/node/classes.md: -------------------------------------------------------------------------------- 1 | # Classes 2 | 3 | ```javascript 4 | export default class Foo extends Bar { 5 | constructor(props) { 6 | super(props); 7 | console.log('Setting up a Foo'); 8 | } 9 | 10 | fizz() { 11 | return 'Buzz'; 12 | } 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /cheatsheets/terraform/atlantis.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Atlantis 3 | 4 | description: Terraform Pull Request Automation 5 | --- 6 | 7 | [https://www.runatlantis.io/](https://www.runatlantis.io/) homepage 8 | 9 | [runatlantis/atlantis](https://github.com/runatlantis/atlantis) on GitHub 10 | -------------------------------------------------------------------------------- /cheatsheets/make/copy.md: -------------------------------------------------------------------------------- 1 | # Copy 2 | 3 | This will make sure the order-only prerequisite exists (`abc.example.txt`) and then copy it to the target (`abc.txt`). 4 | ```make 5 | abc.txt: | abc.example.txt 6 | cp $| $@ 7 | ``` 8 | 9 | Usage: 10 | 11 | ```sh 12 | $ make abc.txt 13 | ``` 14 | -------------------------------------------------------------------------------- /cheatsheets/shell/architecture.md: -------------------------------------------------------------------------------- 1 | # Architecture 2 | 3 | With `dpkg`: 4 | 5 | ```console 6 | $ dpkg --print-architecture 7 | amd64 8 | ``` 9 | 10 | With [uname][] 11 | 12 | [uname]: {% link cheatsheets/shell/commands/uname.md %} 13 | 14 | ```console 15 | $ uname -m 16 | x86_64 17 | ``` 18 | -------------------------------------------------------------------------------- /cheatsheets/typescript/ignoring-rules.md: -------------------------------------------------------------------------------- 1 | # Ignoring rules 2 | 3 | Ignore on the next line. 4 | 5 | ```typescript 6 | // @ts-ignore 7 | myCode 8 | ``` 9 | 10 | Also ignore on the next line but require an error to exist. 11 | 12 | ```typescript 13 | // @ts-expect-error 14 | myCode 15 | ``` 16 | -------------------------------------------------------------------------------- /cheatsheets/ci-cd/circleci/definitions.md: -------------------------------------------------------------------------------- 1 | # Definitions 2 | 3 | - A **pipeline** is the full set of processes that run when you trigger work on your projects. 4 | - **Workflows** define a list of jobs and their run order. 5 | - **Jobs** are the building blocks of your config, which run commands and scripts. 6 | -------------------------------------------------------------------------------- /cheatsheets/javascript/format-and-lint/prettier/resources.md: -------------------------------------------------------------------------------- 1 | # Resources 2 | 3 | - [Prettier](https://prettier.io/) homepage 4 | - [Configuration file](https://prettier.io/docs/en/configuration.html) 5 | - [Options](https://prettier.io/docs/en/options.html) 6 | - [Ignore](https://prettier.io/docs/en/ignore.html) 7 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/object-shorthand.md: -------------------------------------------------------------------------------- 1 | # Object shorthand 2 | 3 | ```javascript 4 | const x = 123 5 | 6 | const y = { 7 | x 8 | } 9 | 10 | y 11 | // { x: 123 } 12 | ``` 13 | 14 | That is the equivalent of setting: 15 | 16 | ```javascript 17 | const y = { 18 | x: x 19 | } 20 | ``` 21 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/configuration/urls.md: -------------------------------------------------------------------------------- 1 | # URLs 2 | 3 | Include protocol. No trailing forwardslash. 4 | ```yaml 5 | url: "http://example.com" 6 | ``` 7 | 8 | ```yaml 9 | baseurl: "" 10 | baseurl: "/my-repo" 11 | ``` 12 | 13 | If not empty, must start with a forwardlash and not end with one, as above. 14 | -------------------------------------------------------------------------------- /cheatsheets/go/packages/time.md: -------------------------------------------------------------------------------- 1 | # time 2 | 3 | Docs: [time](https://golang.org/pkg/time/) in standard lib. 4 | 5 | ```go 6 | time.Now() 7 | time.Now().String() 8 | ``` 9 | 10 | ```sh 11 | $ godoc time Now String 12 | PACKAGE DOCUMENTATION 13 | 14 | package time 15 | import "time" 16 | ... 17 | ``` 18 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/python/pip/resources.md: -------------------------------------------------------------------------------- 1 | # Resources 2 | 3 | - [pip docs](https://pip.readthedocs.io/) 4 | - [pip on PyPI](https://pypi.org/project/pip/) 5 | - My [Installation](https://github.com/MichaelCurrin/python-package-quickstart/blob/master/docs/installation.md) guide on my Quickstart project. 6 | -------------------------------------------------------------------------------- /cheatsheets/python/configs/python.md: -------------------------------------------------------------------------------- 1 | # Python modules as configs 2 | 3 | Various ways to store config values. 4 | 5 | Such as `config.py` or `setup.py`. 6 | 7 | If the file should be for local use only and ignored by `git`, then use `config.local.py` or `config_local.py`. And perhaps supply `config.template.py`. 8 | -------------------------------------------------------------------------------- /cheatsheets/shell/files/text-files/clipboard.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Copy to and paste from clipboard. Especially useful for very large files or when you use SSH with no GUI. 3 | --- 4 | # Clipboard 5 | 6 | 7 | See [Clipboard commands]({% link cheatsheets/shell/commands/clipboard/index.md %}) cheatsheet section. 8 | -------------------------------------------------------------------------------- /cheatsheets/web/seo/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # SEO 4 | 5 | 6 | - [Guidelines](https://support.google.com/webmasters/answer/9526064?hl=en&ref_topic=9456575) on Google support. 7 | - [Crawling and indexing overview](https://support.google.com/webmasters/topic/9427949?hl=en&ref_topic=9428048) on Google support docs. 8 | -------------------------------------------------------------------------------- /cheatsheets/javascript/format-and-lint/eslint/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ESLint 3 | description: Find and fix problems in your JS code 4 | --- 5 | 6 | ### About 7 | 8 | ESLint can statically analyze your JS code to find and fix problems. 9 | 10 | It can check syntax that is invalid. It gives errors and warnings. 11 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/dataviz/apex-charts/index.md: -------------------------------------------------------------------------------- 1 | # ApexCharts 2 | 3 | 4 | Note that mixed Y axes are only allowed for line chart (not bar) and that must also be standard orientation. 5 | 6 | See also [Dev Resources](https://michaelcurrin.github.io/dev-resources/resources/javascript/packages/dataviz/apex-charts/). 7 | -------------------------------------------------------------------------------- /cheatsheets/python/strings/wrap.md: -------------------------------------------------------------------------------- 1 | 2 | # Wrap 3 | 4 | Using the built-in `textwrap` module. 5 | 6 | 7 | ## Dedent 8 | 9 | Remove common whitespace. 10 | 11 | ```python 12 | text = textwrap.dedent("""\ 13 | a 14 | b 15 | c 16 | """) 17 | print(text) 18 | ``` 19 | ``` 20 | a 21 | b 22 | c 23 | ``` 24 | -------------------------------------------------------------------------------- /cheatsheets/shell/scripting/control-flow/and-or.md: -------------------------------------------------------------------------------- 1 | # AND OR 2 | 3 | ## AND 4 | 5 | ```sh 6 | [[ EXPRESSION ]] && [[ EXPRESSION ]] 7 | ``` 8 | 9 | That is preferred to: 10 | 11 | ```sh 12 | [[ EXPRESSION && EXPRESSION ]] 13 | ``` 14 | 15 | ## OR 16 | 17 | ```sh 18 | [[ EXPRESSION ]] || [[ EXPRESSION ]] 19 | ``` 20 | -------------------------------------------------------------------------------- /cheatsheets/shell/scripting/control-flow/if-else.md: -------------------------------------------------------------------------------- 1 | # if else 2 | 3 | Use with `if`. 4 | 5 | ```sh 6 | if true; then 7 | echo 'True!' 8 | fi 9 | # True! 10 | ``` 11 | 12 | Use with `if` and `else`. 13 | 14 | ```sh 15 | if true; then 16 | echo 'True!' 17 | else 18 | echo 'False!' 19 | fi 20 | # True! 21 | ``` 22 | -------------------------------------------------------------------------------- /cheatsheets/version-control/github/api/v3/limitations.md: -------------------------------------------------------------------------------- 1 | # Limitations 2 | 3 | > Unauthenticated clients can make 60 requests per hour. To get more requests per hour, we'll need to _authenticate_. In fact, doing anything interesting with the GitHub API requires [authentication](https://developer.github.com/v3/#authentication). 4 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/javascript/yarn/commands/install.md: -------------------------------------------------------------------------------- 1 | # install 2 | 3 | See [yarn install](https://classic.yarnpkg.com/en/docs/cli/install/) docs. 4 | 5 | 6 | ```sh 7 | $ yarn install 8 | ``` 9 | 10 | ```sh 11 | $ yarn install --frozen-lockfile 12 | ``` 13 | 14 | ```sh 15 | $ yarn install --silent 16 | ``` 17 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/python/pip/overview.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | 4 | - `pip install PACKAGE` 5 | - `pip install PACKAGE==VERSION` 6 | - `pip install PACKAGE --user` 7 | - `pip install PACKAGE -U|--upgrade` 8 | - `pip install -r REQUIREMENTS_TXT_PATH` 9 | - `pipinstall pip --upgrade` 10 | - ` pipuninstall PACKAGE` 11 | -------------------------------------------------------------------------------- /cheatsheets/python/strings/index.md: -------------------------------------------------------------------------------- 1 | # Strings 2 | 3 | 4 | ### Resources 5 | 6 | - Python docs 7 | - [Built-in types - String methods](https://docs.python.org/3/library/stdtypes.html#string-methods) 8 | - [string — Common string operations](https://docs.python.org/3/library/string.html) from Python standard library docs. 9 | -------------------------------------------------------------------------------- /cheatsheets/ruby/gems/index.md: -------------------------------------------------------------------------------- 1 | # Gems 2 | 3 | 4 | ### Related 5 | 6 | - [Jekyll][] section. 7 | - [Ruby package managers][] section for using Bundler and `gem` commands. 8 | 9 | 10 | [Jekyll]: {% link cheatsheets/jekyll/index.md %} 11 | [Ruby package managers]: {% link cheatsheets/package-managers/ruby/index.md %} 12 | -------------------------------------------------------------------------------- /cheatsheets/shell/scripting/control-flow/negate.md: -------------------------------------------------------------------------------- 1 | # Negate 2 | 3 | # Negate 4 | 5 | ```sh 6 | if ! false; then 7 | echo 'Yes!' 8 | fi 9 | ``` 10 | 11 | ```sh 12 | if [[ ! "$x" == 'abc' ]]; then 13 | echo 'Yes!' 14 | fi 15 | ``` 16 | 17 | ```sh 18 | if [[ "$x" != 'abc' ]]; then 19 | echo 'Yes!' 20 | fi 21 | ``` 22 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/bundler/subcommands/clean.md: -------------------------------------------------------------------------------- 1 | # clean subcommand 2 | 3 | Remove unused gems from the vendor directory. i.e. Remove the gems and subdependencies not covered by `Gemfile`. 4 | 5 | ```sh 6 | $ bundle clean 7 | ``` 8 | 9 | Dry run: 10 | 11 | ```sh 12 | $ bundle clean --dry-run 13 | ``` 14 | 15 | -------------------------------------------------------------------------------- /cheatsheets/shell/compression/view.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Look at the contents of a zipped file without unpacking it 3 | --- 4 | # View 5 | 6 | 7 | ```sh 8 | unzip -l ZIPPED_TARGET 9 | ``` 10 | 11 | ```sh 12 | tar ztvf TAR_ZIPPED_TARGET 13 | ``` 14 | 15 | ```sh 16 | view ZIPPED_TARGET 17 | 18 | vim ZIPPED_TARGET 19 | ``` 20 | -------------------------------------------------------------------------------- /cheatsheets/shell/files/text-files/open.md: -------------------------------------------------------------------------------- 1 | # Open 2 | 3 | See [open][] command for more info. 4 | 5 | ```sh 6 | $ open file.txt 7 | ``` 8 | 9 | [open]: {% link cheatsheets/shell/commands/open.md %} 10 | 11 | If you have this command enabled for your IDE. Use `code` for VS Code. 12 | 13 | ```sh 14 | $ code file.txt 15 | ``` 16 | -------------------------------------------------------------------------------- /cheatsheets/web/html/autofocus.md: -------------------------------------------------------------------------------- 1 | # Autofocus 2 | 3 | [Tutorial](https://www.w3schools.com/tags/att_input_autofocus.asp) 4 | 5 | The `autofocus` attribute is a boolean attribute. 6 | 7 | It specifies that an `input` element should get focus on the page load. 8 | 9 | e.g. 10 | 11 | ```html 12 | 13 | ``` 14 | -------------------------------------------------------------------------------- /cheatsheets/containers/kubernetes/cli/exec.md: -------------------------------------------------------------------------------- 1 | # exec command 2 | 3 | ## Interactive 4 | 5 | ```sh 6 | $ kubectl exec -it POD_NAME -- bash 7 | ``` 8 | 9 | ## Run command 10 | 11 | e.g. Running a Postgres dump command and writing the file. 12 | 13 | ```sh 14 | $ kubectl exec -it POD_NAME -- bash -c 'ls > my_files.txt' 15 | ``` 16 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/vue/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: vuedotjs 3 | --- 4 | # Vue 5 | 6 | ### Related 7 | 8 | - [Vue in Dev Resources](https://michaelcurrin.github.io/dev-resources/resources/javascript/packages/vue/) 9 | - [Vue in Code Cookbook](https://michaelcurrin.github.io/code-cookbook/recipes/javascript/packages/vue/) 10 | -------------------------------------------------------------------------------- /cheatsheets/python/configs/toml.md: -------------------------------------------------------------------------------- 1 | # TOML 2 | 3 | ## Example 4 | 5 | 6 | `config.toml` 7 | 8 | 9 | ```toml 10 | [project] 11 | foo: "Bar" 12 | buzz: 123 13 | version: "1.0.0" 14 | updated: 1979-05-27T07:32:00Z 15 | 16 | ``` 17 | 18 | ```python 19 | import toml 20 | config = toml.load('config.toml') 21 | print(config) 22 | ``` 23 | -------------------------------------------------------------------------------- /cheatsheets/python/strings/case.md: -------------------------------------------------------------------------------- 1 | # Case 2 | 3 | 4 | ## Title case 5 | 6 | ```python 7 | >>> 'abc d'.title() 8 | 'Abc D' 9 | ``` 10 | 11 | 12 | ## Capitalize 13 | 14 | ```python 15 | >>> 'abc d'.capitalize() 16 | 'Abc d' 17 | ``` 18 | 19 | 20 | ## Uppercase 21 | 22 | ```python 23 | >>> 'abc d'.upper() 24 | 'ABC D' 25 | ``` 26 | -------------------------------------------------------------------------------- /cheatsheets/sql/replace.md: -------------------------------------------------------------------------------- 1 | # Replace 2 | 3 | ### Remove newline 4 | 5 | Replace newline with a space. 6 | 7 | `CHAR(13)` is carriage return and `CHAR(10)` is a line feed. Usually they are there together. 8 | 9 | ```sql 10 | SELECT 11 | REPLACE( REPLACE( foo, CHAR(13), ''), CHAR(10), ' ') AS foo 12 | FROM bar 13 | ; 14 | ``` 15 | -------------------------------------------------------------------------------- /cheatsheets/python/files-and-paths/read-and-write/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Read and write 3 | description: Guide to reading and writing files in Python - including text, JSON and CSVs 4 | --- 5 | 6 | ### Related 7 | 8 | - [Convert between file types](https://michaelcurrin.github.io/code-cookbook/recipes/python/convert-data.html) in Code Cookbook 9 | -------------------------------------------------------------------------------- /cheatsheets/web/html/open-graph.md: -------------------------------------------------------------------------------- 1 | # Open graph tags 2 | 3 | The Open Graph protocol - [ogp.me](https://ogp.me/) homepage. 4 | 5 | ## Sample 6 | 7 | ```html 8 | 9 | 10 | 11 | 12 | ``` 13 | -------------------------------------------------------------------------------- /cheatsheets/containers/kubernetes/cli/logs.md: -------------------------------------------------------------------------------- 1 | # Logs 2 | 3 | ```sh 4 | $ kubectl get logs POD_ID 5 | ``` 6 | 7 | For example 8 | 9 | 1. Use `kubectl get pods` to get a pod's ID (which changes on running a deploy). 10 | 1. Then run: 11 | ```sh 12 | $ kubectl get logs foobarb-backend-stg-abcd55cdc4-7qqxz 13 | ``` 14 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/npkill/index.md: -------------------------------------------------------------------------------- 1 | # npkill 2 | 3 | A command-line tool to help you find and delete unneeded `node_modules` directories. Using a GUI which is interactive. 4 | 5 | 6 | Choose a directory and run it there to find node packages at the current level and below. 7 | 8 | ```sh 9 | $ cd ~ 10 | $ npx npkill 11 | ``` 12 | -------------------------------------------------------------------------------- /cheatsheets/ruby/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: ruby 3 | --- 4 | # Ruby 5 | 6 | 7 | ### Related 8 | 9 | - [Ruby]({% link cheatsheets/package-managers/ruby/index.md %}) under the Package Managers section - that covers using `gem` and `bundle` commands 10 | - [Ruby](https://michaelcurrin.github.io/d⁹ev-resources/resources/ruby/) in Dev Resources 11 | -------------------------------------------------------------------------------- /cheatsheets/web/html/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: html5 3 | --- 4 | # HTML 5 | 6 | ### Related 7 | 8 | - [Markdown HTML]({% link cheatsheets/markdown/html.md %}) cheatsheet 9 | - [HTML](https://michaelcurrin.github.io/code-cookbook/recipes/web/html/) cookbook. 10 | - [Visual HTML Cheat Sheet](https://www.git-tower.com/learn/cheat-sheets/html) 11 | -------------------------------------------------------------------------------- /cheatsheets/python/libraries/database/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Databases 3 | --- 4 | 5 | If you need to handle raw SQL queries and no ORM: 6 | 7 | - Use SQLite library - already installed but only works with SQLite DBs. 8 | - Install and run SQLAlchemy or Peewee. See [pee-wee vs SQLAlchemy](https://stackshare.io/stackups/peewee-vs-sqlalchemy) comparison. 9 | -------------------------------------------------------------------------------- /cheatsheets/ruby/functions.md: -------------------------------------------------------------------------------- 1 | # Functions 2 | 3 | 4 | ## Basic 5 | 6 | ```ruby 7 | def foo(x) 8 | x*2 9 | end 10 | 11 | foo(5) 12 | # 10 13 | ``` 14 | 15 | 16 | ## Return tuple 17 | 18 | ```ruby 19 | def foo 20 | return "abc", 2, true 21 | end 22 | 23 | a, b, c = foo() 24 | a 25 | # "abc" 26 | b 27 | # 2 28 | c 29 | # true 30 | ``` 31 | -------------------------------------------------------------------------------- /cheatsheets/web/html/elements/abbr.md: -------------------------------------------------------------------------------- 1 | # abbr 2 | 3 | 4 | The `` tag defines an abbreviation or an acronym, like "HTML", "CSS" and shows the title when you hover this tag. 5 | 6 | 7 | ```html 8 |

9 | I like CSS and HTML. 10 |

11 | ``` 12 | -------------------------------------------------------------------------------- /cheatsheets/containers/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Containers 3 | logo: docker 4 | description: Cheatsheets for building containerized applications with Docker, Docker-compose and Kubernetes 5 | --- 6 | 7 | 8 | ### Resources 9 | 10 | - [Containers](https://michaelcurrin.github.io/code-cookbook/recipes/containers/) section of my Code Cookbook project. 11 | -------------------------------------------------------------------------------- /cheatsheets/go/code/printing/log.md: -------------------------------------------------------------------------------- 1 | # log 2 | 3 | ```go 4 | import ( 5 | "log" 6 | ) 7 | ``` 8 | 9 | 10 | ## Print and exit 11 | 12 | The docstring says this is equivalent to calling `Print()` and `os.Exit(1)`. 13 | 14 | ```go 15 | err := foo() 16 | 17 | if err != nil { 18 | log.Fatal(err) 19 | } 20 | ``` 21 | 22 | You can also use `Fatalln`. 23 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/configuration/resources.md: -------------------------------------------------------------------------------- 1 | # Resources 2 | 3 | Jekyll docs. 4 | 5 | - [Configuration options](https://jekyllrb.com/docs/configuration/options/). That covers both CLI and config file options together. 6 | - [Frontmatter Defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/) - setting page values using the `defaults` field. 7 | -------------------------------------------------------------------------------- /cheatsheets/python/challenges.md: -------------------------------------------------------------------------------- 1 | # Challenges 2 | 3 | 4 | ## Fibonacci 5 | 6 | [Fibonacci sequence](https://www.mathsisfun.com/numbers/fibonacci-sequence.html) 7 | 8 | ### While loop 9 | 10 | ```python 11 | a, b = 0, 1 12 | while b < 10: 13 | a, b = b, a+b 14 | print(b) 15 | ``` 16 | ``` 17 | 1 18 | 2 19 | 3 20 | 5 21 | 8 22 | 13 23 | ``` 24 | -------------------------------------------------------------------------------- /cheatsheets/web/html/comments.md: -------------------------------------------------------------------------------- 1 | # Comments 2 | 3 | [W3 Schools](https://www.w3schools.com/html/html_comments.asp) tutorial. 4 | 5 | Add a note. 6 | 7 | ```html 8 | 9 | ``` 10 | 11 | Prevent code from running. 12 | 13 | ```html 14 | 17 | ``` 18 | -------------------------------------------------------------------------------- /cheatsheets/shell/files/text-files/view.md: -------------------------------------------------------------------------------- 1 | # View files 2 | 3 | - `less` 4 | - `more` 5 | - `view` 6 | - `cat` 7 | - `<` 8 | 9 | 10 | e.g. 11 | 12 | ```sh 13 | # Show entire file at once. 14 | cat file.txt 15 | 16 | # Page over large file. 17 | < file.txt 18 | view file.txt 19 | vim file.txt 20 | 21 | less file.txt 22 | 23 | more file.txt 24 | ``` 25 | -------------------------------------------------------------------------------- /cheatsheets/python/type-checks/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: How to add type safety to Python 3 | --- 4 | # Type checks 5 | 6 | In Python 3.6, type-hints were added as allowed syntax which can optionally be checked with a tool like Mypy. 7 | 8 | Getting started - see [Type hints cheat sheat](https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html) on the Mypy docs. 9 | -------------------------------------------------------------------------------- /cheatsheets/javascript/deno/managing-imports/inline.md: -------------------------------------------------------------------------------- 1 | 2 | # Inline 3 | 4 | - `index.ts` 5 | ```typescript 6 | import { assert, assertEquals, assertStrContains } from "https://deno.land/std@0.85.0/testing/asserts.ts"; 7 | 8 | assertEquals("hello", "hello"); 9 | assertEquals("world", "world"); 10 | 11 | console.log("Asserted! ✓"); 12 | ``` 13 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/bundler/list.md: -------------------------------------------------------------------------------- 1 | # List 2 | 3 | ```sh 4 | $ bundle list 5 | ``` 6 | ``` 7 | Gems included by the bundle: 8 | * addressable (2.7.0) 9 | * ... 10 | ``` 11 | 12 | Names of directories: 13 | 14 | ```sh 15 | $ ls vendor/bundle/ruby/2.6.0/gems 16 | ``` 17 | ``` 18 | addressable-2.7.0 i18n-0.9.5 ... 19 | ... 20 | ``` 21 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/ssh.md: -------------------------------------------------------------------------------- 1 | # ssh 2 | 3 | 4 | ## Basic 5 | 6 | ```sh 7 | $ ssh USERNAME@HOSTNAME 8 | ``` 9 | 10 | Or if your username is the same on both machines, or you've configured your SSH config. 11 | 12 | ```sh 13 | $ ssh HOSTNAME 14 | ``` 15 | 16 | 17 | ## Identity 18 | 19 | ```sh 20 | $ ssh USERNAME@HOSTNAME -i ~/.ssh/id_rsa_abc 21 | ``` 22 | -------------------------------------------------------------------------------- /cheatsheets/shell/scripting/control-flow/ignore.md: -------------------------------------------------------------------------------- 1 | # Ignore 2 | 3 | Have a command fail silently, or without breaking the flow. 4 | 5 | ```sh 6 | CMD || true 7 | ``` 8 | 9 | Optionally hide output. 10 | 11 | ```sh 12 | CMD > /dev/null || true 13 | ``` 14 | 15 | Or just 16 | 17 | ```sh 18 | set -e 19 | 20 | # ... 21 | 22 | set +e 23 | CMD 24 | set -e 25 | ``` 26 | -------------------------------------------------------------------------------- /cheatsheets/shell/batch.md: -------------------------------------------------------------------------------- 1 | # Batch 2 | 3 | How to perform multiple actions easily. 4 | 5 | Pipe output, use awk to get the first column, then split into separate commands. I think `xargs` is more efficient `for` loop and more inline with Functional Programming. 6 | 7 | ```sh 8 | FOO | \ 9 | awk '{print $1}' | \ 10 | xargs -I{} sh -c 'BAR "$1"' - {} 11 | ``` 12 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/dataviz/apex-charts/installation.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | ## Install with NPM 4 | 5 | ```sh 6 | $ npm install apexcharts 7 | ``` 8 | 9 | Then 10 | 11 | ```javascript 12 | import ApexCharts from 'apexcharts' 13 | ``` 14 | 15 | 16 | ## CDN 17 | 18 | ```html 19 | 20 | ``` 21 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/vue/components/conditional.md: -------------------------------------------------------------------------------- 1 | # Conditional 2 | 3 | {% raw %} 4 | 5 | ```html 6 |

7 | {{ bazz }} 8 |

9 |

10 | ... 11 |

12 |

13 | ... 14 |

15 | ``` 16 | 17 | ```html 18 | 19 |

{{ note }}

20 |
21 | ``` 22 | 23 | {% endraw %} 24 | -------------------------------------------------------------------------------- /cheatsheets/artificial-intelligence/deepseek/index.md: -------------------------------------------------------------------------------- 1 | # DeepSeek 2 | 3 | ### Models 4 | 5 | - [deepseek-coder](https://ollama.com/library/deepseek-coder) 6 | - [deepseek-coder-v2](https://ollama.com/library/deepseek-coder-v2) 7 | - [deepseek-r1](https://ollama.com/library/deepseek-r1) - range of models from 1GB to 400GB+ 8 | - [deepseek-v3](https://ollama.com/library/deepseek-v3) - 400GB+ 9 | -------------------------------------------------------------------------------- /cheatsheets/containers/colima/index.md: -------------------------------------------------------------------------------- 1 | # Colima 2 | 3 | Start in the foreground. 4 | 5 | ```sh 6 | colima start -f 7 | ``` 8 | 9 | Start SSH tunnel. 10 | 11 | ```sh 12 | colima ssh 13 | ``` 14 | 15 | Run command in the machine. 16 | 17 | ```sh 18 | colima ssh -- CMD 19 | # e.g. 20 | colima ssh -- sudo cp "/path/to/cert" /usr/local/share/ca-certificates/nscacert.crt 21 | ``` 22 | -------------------------------------------------------------------------------- /cheatsheets/go/code/printing/index.md: -------------------------------------------------------------------------------- 1 | # Printing 2 | 3 | This summarizes some of the most likely printing scenarios you'll encounter. 4 | 5 | Read more on the [fmt][] package cheatsheet or the documentation linked from there. 6 | 7 | See also [Go by Example: String Formatting](https://gobyexample.com/string-formatting) 8 | 9 | [fmt]: {% link cheatsheets/go/packages/fmt.md %} 10 | -------------------------------------------------------------------------------- /cheatsheets/python/tests/nose.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Python package. Uses unittest-style tests. More advanced than PyTest and it recommends PyTest for starting out. 3 | --- 4 | # Nose 5 | 6 | - [nose docs](https://nose.readthedocs.io/en/latest/) 7 | 8 | ## Install 9 | 10 | ```sh 11 | $ pip install nose 12 | ``` 13 | 14 | ## Run tests 15 | 16 | ```sh 17 | $ nosetests 18 | ``` 19 | -------------------------------------------------------------------------------- /cheatsheets/shell/scripting/control-flow/true-false.md: -------------------------------------------------------------------------------- 1 | # true false 2 | 3 | These are built in commands. 4 | 5 | ```sh 6 | $ true 7 | ``` 8 | 9 | ```sh 10 | $ false 11 | ``` 12 | 13 | You can use them to test your conditional statements. 14 | 15 | ```sh 16 | [[ true ]] && 'echo Yes' || echo 'No' 17 | # Yes 18 | 19 | [[ false ]] && 'echo Yes' || echo 'No' 20 | # No 21 | ``` 22 | -------------------------------------------------------------------------------- /cheatsheets/shell/ssh/directory.md: -------------------------------------------------------------------------------- 1 | # SSH directory 2 | 3 | 4 | For quick reference, here is an example what is in the `~/.ssh` directory: 5 | 6 | ## Contents 7 | 8 | ### Minimum 9 | 10 | Just two files. Commonly `dsa` or `rsa`. 11 | 12 | - `id_rsa` 13 | - `id_rsa.pub` 14 | 15 | ### Additional 16 | 17 | ```sh 18 | authorized_keys 19 | config 20 | known_hosts 21 | ``` 22 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/search-stashes.md: -------------------------------------------------------------------------------- 1 | # Search stashes 2 | 3 | Search Git stashes for a keyword and print the stash ID if one is found. 4 | 5 | ```sh 6 | QUERY='my term' 7 | 8 | git stash list | awk '{sub(/:$/, "", $1); print $1}' | while read stash; do 9 | if git stash show -p "$stash" | grep -q "$QUERY"; then 10 | echo "$stash" 11 | fi 12 | done 13 | ``` 14 | -------------------------------------------------------------------------------- /cheatsheets/artificial-intelligence/ollama/index.md: -------------------------------------------------------------------------------- 1 | # Ollama 2 | 3 | See [CLI reference](https://github.com/ollama/ollama?tab=readme-ov-file#cli-reference) in the docs on GitHub. 4 | 5 | ## Install 6 | 7 | See [Downloads](https://ollama.com/download) page. 8 | 9 | On macOS, install with `brew` using the command here - [formulae.brew.sh/cask/ollama](https://formulae.brew.sh/cask/ollama). 10 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/dashes.md: -------------------------------------------------------------------------------- 1 | # Dashes 2 | 3 | When using [Kramdown](https://github.com/gettalong/kramdown) in Jekyll and maybe others, you can write an en dash of em dash using plain hyphens. 4 | 5 | You can escape this conversion by using code formatting. 6 | 7 | Examples below 8 | 9 | - en dash 10 | - `A -- B` 11 | - A -- B 12 | - em dash 13 | - `A --- B` 14 | - A --- B 15 | -------------------------------------------------------------------------------- /cheatsheets/markdown/todo-list.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Turn your bullet list into a checklist of done and not done items 3 | --- 4 | # Todo list 5 | 6 | Use hard brackets. With either a space (not done) or lowercase `x` (done). 7 | 8 | ## Sample code 9 | 10 | ```markdown 11 | - [ ] not done. 12 | - [x] done 13 | ``` 14 | 15 | ## Sample result 16 | 17 | - [ ] not done 18 | - [x] done 19 | -------------------------------------------------------------------------------- /cheatsheets/typescript/data-types/primitives.md: -------------------------------------------------------------------------------- 1 | # Primitives 2 | 3 | 4 | ```typescript 5 | any 6 | 7 | boolean 8 | number 9 | string 10 | 11 | void 12 | null 13 | undefined 14 | 15 | unknown 16 | 17 | never // unreachable 18 | ``` 19 | 20 | ## Examples 21 | 22 | ### Unknown 23 | 24 | ```typescript 25 | let foo: unknown = 4; 26 | foo = "maybe a string instead"; 27 | foo = false; 28 | ``` 29 | -------------------------------------------------------------------------------- /cheatsheets/web/hosts.md: -------------------------------------------------------------------------------- 1 | # Hosts 2 | 3 | 4 | - `/etc/hosts` 5 | ``` 6 | ## 7 | # Host Database 8 | # 9 | # localhost is used to configure the loopback interface 10 | # when the system is booting. Do not change this entry. 11 | ## 12 | 127.0.0.1 localhost dev.localhost 13 | 255.255.255.255 broadcasthost 14 | ::1 localhost 15 | ``` 16 | -------------------------------------------------------------------------------- /cheatsheets/containers/podman/setup.md: -------------------------------------------------------------------------------- 1 | # Setup 2 | 3 | 4 | ## Install 5 | 6 | ```sh 7 | brew install podman 8 | ``` 9 | ```sh 10 | podman machine init 11 | ``` 12 | 13 | ## Use as Docker drop-in replacement 14 | 15 | Set in your shell config like this based on the CLI output. 16 | 17 | ```sh 18 | export DOCKER_HOST='unix:///var/folders/.../.../.../podman/podman-machine-default-api.sock' 19 | ``` 20 | -------------------------------------------------------------------------------- /cheatsheets/maker-projects/arduino.md: -------------------------------------------------------------------------------- 1 | # Arduinio 2 | 3 | ## Basic 4 | 5 | The default script you get when installing and running [Arduino IDE][]. 6 | 7 | [Arduino IDE]: https://www.arduino.cc/en/software 8 | 9 | ```c 10 | void setup() { 11 | // put your setup code here, to run once: 12 | 13 | } 14 | 15 | void loop() { 16 | // put your main code here, to run repeatedly: 17 | 18 | } 19 | ``` 20 | -------------------------------------------------------------------------------- /docs/deploy.md: -------------------------------------------------------------------------------- 1 | # Deploy 2 | 3 | Set up this project on GitHub Pages. 4 | 5 | 1. Add this project to your GitHub repos. 6 | 2. Go to Settings. 7 | 3. Enable GitHub Pages on the `master` branch. 8 | 4. Go to the environment tab and wait for your site to build. 9 | 5. Go to the GitHub Pages URL. e.g. 10 | - [michaelcurrin.github.io/dev-cheatsheets](https://michaelcurrin.github.io/dev-cheatsheets/) 11 | -------------------------------------------------------------------------------- /cheatsheets/javascript/format-and-lint/eslint/init.md: -------------------------------------------------------------------------------- 1 | # Init 2 | 3 | 4 | From ESLint [docs](https://github.com/eslint/eslint#installation-and-usage). 5 | 6 | ```sh 7 | $ eslint --init 8 | ``` 9 | 10 | Result: 11 | 12 | - `.eslintrc` 13 | ```json 14 | { 15 | "rules": { 16 | "semi": ["error", "always"], 17 | "quotes": ["error", "double"] 18 | } 19 | } 20 | ``` 21 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/request/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: HTTP request 3 | description: How to get and send data over HTTP using JavaScript 4 | --- 5 | 6 | 7 | A few common options: 8 | 9 | - `fetch` - built-in for the browser and for Node 17+ 10 | - `node-fetch` - polyfill for the Node server side 11 | - `axios` package 12 | - `request` package 13 | - `jquery` package - use the `ajax` function. 14 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/configuration/build-settings.md: -------------------------------------------------------------------------------- 1 | # Build settings 2 | 3 | This can be set with CLI flags, or in the config here if you prefer. 4 | 5 | ```yaml 6 | future: true 7 | profile: true 8 | livereload: true 9 | ``` 10 | 11 | Cause a build to fail if there is a YAML syntax error in a page's frontmatter. Only works in Jekyll 4 though. 12 | 13 | ```yaml 14 | strict_front_matter: true 15 | ``` 16 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/permissions-error.md: -------------------------------------------------------------------------------- 1 | # Permissions error 2 | 3 | Sometimes the root user will make changes to files in the Git repo in `.git` and change the owner to be `root`. Perhaps when using Windows Subsystem for Linux or Dev Containers (VS Code). 4 | 5 | Solution - recursively set permissions to your own user and group. 6 | 7 | ```sh 8 | $ sudo chmod -R michael:michael .git 9 | ``` 10 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/dataviz/apex-charts/formatting.md: -------------------------------------------------------------------------------- 1 | # Formatting 2 | 3 | From [Stacked](https://apexcharts.com/javascript-chart-demos/bar-charts/stacked/). 4 | 5 | ```js 6 | { 7 | xaxis: { 8 | categories: [2008, 2009, 2010, 2011, 2012, 2013, 2014], 9 | labels: { 10 | formatter: function (val) { 11 | return val + "K" 12 | } 13 | } 14 | }, 15 | } 16 | ``` 17 | -------------------------------------------------------------------------------- /cheatsheets/sql/basic/maths.md: -------------------------------------------------------------------------------- 1 | # Maths 2 | 3 | 4 | ## Float division 5 | 6 | ```sql 7 | SELECT 123 / 2.0; 8 | ``` 9 | ``` 10 | 61.5 11 | ``` 12 | 13 | Another option is to cast either value to a float. 14 | 15 | ```sql 16 | SELECT 123 / 2 :: FLOAT; 17 | ``` 18 | 19 | 20 | ## Floor division 21 | 22 | Warning, this will round down. 23 | 24 | ```sql 25 | SELECT 123 / 2; 26 | ``` 27 | ``` 28 | 61 29 | ``` 30 | -------------------------------------------------------------------------------- /cheatsheets/containers/docker/dockerfile/aliases.md: -------------------------------------------------------------------------------- 1 | # Aliases 2 | 3 | Given an image an alias and then use it later. 4 | 5 | ```Dockerfile 6 | FROM IMAGE AS ALIAS 7 | ``` 8 | 9 | Example: 10 | 11 | `Dockerfile` 12 | ```Dockerfile 13 | FROM python:alpine AS base 14 | 15 | FROM base AS dev 16 | CMD ["mkdocs", "serve", "-a", "0.0.0.0:8000"] 17 | 18 | FROM base AS build 19 | COPY . . 20 | RUN mkdocs build 21 | ``` 22 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/vue/events/emit.md: -------------------------------------------------------------------------------- 1 | # Emit 2 | 3 | 4 | When a native event (e.g. `click`) is defined in the emits option, the component event will be used instead of a native event listener. 5 | 6 | Here is the syntax for adding an emit event to an input tag, with the pushed value set to the value on the element. 7 | 8 | ``` 9 | v-on:input="$emit('input', $event.target.modelValue)" 10 | ``` 11 | 12 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/python/pip/manage-pip.md: -------------------------------------------------------------------------------- 1 | # Manage pip 2 | 3 | 4 | ## Update 5 | 6 | Keep `pip` and its related packages up to date. 7 | 8 | ```sh 9 | $ pip3 install --upgrade pip setuptools wheel 10 | ``` 11 | 12 | Inside a virtual environment you can use `pip` instead of `pip3`. 13 | 14 | You could also do: 15 | 16 | ```sh 17 | $ python3 -m pip3 install --upgrade pip setuptools wheel 18 | ``` 19 | -------------------------------------------------------------------------------- /cheatsheets/python/builtins/data-structures/deque.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: deque 3 | description: The double-ended queue in Python 4 | --- 5 | 6 | 7 | See [deque](https://docs.python.org/3/library/collections.html#collections.deque) in the docs. 8 | 9 | 10 | > list-like container with fast appends and pops on either end 11 | 12 | Not to be confused with terminology to "enqueue" (append) and "dequeue" (pop) an item. 13 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/date/convert.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Convert 3 | description: Specify an input datetime and convert to another format. 4 | --- 5 | 6 | 7 | ## Convert unix timestamp to date and time 8 | 9 | Give seconds as a number. 10 | 11 | ```console 12 | $ date -r 0 13 | Thu 1 Jan 1970 02:00:00 SAST 14 | ``` 15 | 16 | ```console 17 | $ date -r 1000000000 18 | Sun 9 Sep 2001 03:46:40 SAST 19 | ``` 20 | -------------------------------------------------------------------------------- /cheatsheets/shell/scripting/size.md: -------------------------------------------------------------------------------- 1 | # Size 2 | 3 | Directories (or at least paths without `.` to indicated extension. 4 | 5 | ```sh 6 | $ du -a | grep -v '.git' | grep -v 'pycache' | grep -v '\.\w' | sort -h -r 7 | ``` 8 | 9 | e.g. 10 | 11 | ``` 12 | 39920 . 13 | 15064 ./abc 14 | 6568 ./abc/def 15 | 23 ./xyz 16 | ... 17 | ``` 18 | 19 | Remove the `-v` of the last `grep` to show just files. 20 | 21 | -------------------------------------------------------------------------------- /cheatsheets/markdown/flavors.md: -------------------------------------------------------------------------------- 1 | # Flavors 2 | 3 | - [Flavored Markdown](https://flavoredmarkdown.com/) overview of flavors. 4 | - [CommonMark](https://commonmark.org/) 5 | - [GitHub Flavored Markdown](https://github.github.com/gfm/) 6 | - [Kramdown](https://kramdown.gettalong.org/) 7 | - > Ruby library for parsing and converting a superset of Markdown 8 | - [Quick reference](https://kramdown.gettalong.org/quickref.html) 9 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/react/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: React 3 | logo: react 4 | --- 5 | 6 | ### Related 7 | 8 | - [React recipes][] in Code Cookbook 9 | - [React resources][] in Dev Resources 10 | 11 | [React recipes]: https://michaelcurrin.github.io/code-cookbook/recipes/javascript/packages/react/ 12 | [React resources]: https://michaelcurrin.github.io/dev-resources/resources/javascript/packages/react/react.html 13 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/cli/testing.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | If you want to test a snippet or part of another site in your own, create a subdirectory. You can use the gems from the top-level directory. 4 | 5 | ``` 6 | _site 7 | test_site/ # Sub directory project 8 | _site 9 | index.md 10 | _config.yml 11 | Gemfile 12 | index.md 13 | _config.yml 14 | ``` 15 | 16 | ```sh 17 | cd test_site 18 | bundle exec jekyll serve 19 | ``` 20 | -------------------------------------------------------------------------------- /cheatsheets/terraform/environment.md: -------------------------------------------------------------------------------- 1 | # Environment 2 | > Setting environment variables 3 | 4 | 5 | Set up a variable. 6 | 7 | ```terraform 8 | variable "FOO" {} 9 | ``` 10 | 11 | Set up your code. 12 | 13 | ``` 14 | { 15 | foo = var.FOO 16 | } 17 | ``` 18 | 19 | Set the variable using `TF_VAR_` prefix. 20 | 21 | ```sh 22 | export TF_VAR_FOO=bar 23 | ``` 24 | 25 | Run. 26 | 27 | ```sh 28 | $ terraform plan 29 | ``` 30 | -------------------------------------------------------------------------------- /cheatsheets/go/code/cli-input.md: -------------------------------------------------------------------------------- 1 | # CLI input 2 | 3 | Read keyboard input from the user. 4 | 5 | There's no simple function, so you have to set up a buffered IO reader and read a line from it. 6 | 7 | ```go 8 | package main 9 | 10 | import ( 11 | "bufio" 12 | "fmt" 13 | "os" 14 | ) 15 | 16 | func main() { 17 | reader := bufio.NewReader(os.Stdin) 18 | s, _ := reader.ReadString('\n') 19 | fmt.Println(s) 20 | } 21 | ``` 22 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/vue/events/key-modifiers.md: -------------------------------------------------------------------------------- 1 | # Key modifiers 2 | 3 | 4 | From [docs](https://v3.vuejs.org/guide/events.html#key-modifiers). 5 | 6 | ```html 7 | 8 | ``` 9 | 10 | 11 | ## Aliases 12 | 13 | - `.enter` 14 | - `.tab` 15 | - `.delete` (captures both "Delete" and "Backspace" keys) 16 | - `.esc` 17 | - `.space` 18 | - `.up` 19 | - `.down` 20 | - `.left` 21 | - `.right` 22 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/restore/unstage.md: -------------------------------------------------------------------------------- 1 | # Unstage 2 | 3 | If a new file has been created and staged and you want to unstage it (but not delete it), you can follow this (from the tip in the `git status` output). 4 | 5 | ```sh 6 | $ git restore --staged PATH 7 | ``` 8 | 9 | e.g. 10 | 11 | ```sh 12 | $ touch abc.txt 13 | $ git add abc.txt 14 | $ git status 15 | $ git restore --staged abc.txt 16 | $ git status 17 | ``` 18 | -------------------------------------------------------------------------------- /cheatsheets/web/html/encode-and-escape/html-entity-escaping.md: -------------------------------------------------------------------------------- 1 | # HTML entity escaping 2 | 3 | In the content of HTML pages, escape certain characters. 4 | 5 | e.g. `<` becomes `%lt;`. 6 | 7 | - [w3schools.com/html/html_entities.asp](https://www.w3schools.com/html/html_entities.asp) - Reference and conversion tool 8 | - [https://www.freeformatter.com/html-entities.html](https://www.freeformatter.com/html-entities.html) - Conversion tool. 9 | -------------------------------------------------------------------------------- /cheatsheets/containers/docker/persist.md: -------------------------------------------------------------------------------- 1 | # Persist 2 | 3 | 4 | ## Snapshot 5 | 6 | If you create a container from an image and want to keep the file changes as an image for further containers, you can write the container as a snapshot, which makes a new image. 7 | 8 | 9 | ## Volume 10 | 11 | If you want to persist file changes such as in a user directory or database storage even after deleting a container, then set up a volume. 12 | -------------------------------------------------------------------------------- /cheatsheets/other/vscode-extensions/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: VS Code extensions 3 | logo: visualstudiocode 4 | description: From how to develop an extension all the way to publishing it 5 | --- 6 | 7 | If you are new to developing an extension, see one of the _Beginner_ links in [VS Code extensions][] under Dev Resources. 8 | 9 | [VS Code extensions]: https://michaelcurrin.github.io/dev-resources/resources/other/vscode-extensions/ 10 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/javascript/npm/manage.md: -------------------------------------------------------------------------------- 1 | # Manage NPM 2 | 3 | ## Install 4 | 5 | See [Install Node.js and NPM](https://gist.github.com/MichaelCurrin/aa1fc56419a355972b96bce23f3bccba) gist instructions. 6 | 7 | 8 | ## Update 9 | 10 | You should probably update Node.js as a whole but you can update just NPM if you need to. NPM will prompt you to do this sometimes. 11 | 12 | ```sh 13 | $ npm i -g --update npm 14 | ``` 15 | -------------------------------------------------------------------------------- /cheatsheets/powershell/shortcuts.md: -------------------------------------------------------------------------------- 1 | # Shortcuts 2 | 3 | ## Alias 4 | 5 | ```sh 6 | Set-Alias -Name NAME -Value VALUE 7 | ``` 8 | 9 | e.g. 10 | 11 | ```sh 12 | Set-Alias -Name kdev -Value "kubectl config set-context atlas-develop" 13 | ``` 14 | 15 | 16 | ## Functions 17 | 18 | ```sh 19 | function FUNCTIONAME { BODY } 20 | ``` 21 | 22 | e.g. 23 | 24 | ```sh 25 | function kenv { kubectl config use-context atlas-$args } 26 | ``` 27 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/changes-key.md: -------------------------------------------------------------------------------- 1 | # Changes key 2 | 3 | This is relevant for `git status`, `git diff` and `git diff-index`. 4 | 5 | - `M` modified - File has been modified 6 | - `C` copy-edit - File has been copied and modified 7 | - `R` rename-edit - File has been renamed and modified 8 | - `A` added - File has been added 9 | - `D` deleted - File has been deleted 10 | - `U` unmerged - File has conflicts after a merge 11 | -------------------------------------------------------------------------------- /cheatsheets/containers/kubernetes/install.md: -------------------------------------------------------------------------------- 1 | # Install 2 | 3 | Install Docker Desktop and you'll get Kubernetes CLI. 4 | 5 | Otherwise install directly as below. 6 | 7 | 8 | ## macOS 9 | 10 | See [Install and Set Up kubectl on macOS](https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/) for more details, autocompletion, and for installing with cURL. 11 | 12 | ### Homebrew 13 | 14 | ```sh 15 | $ brew install kubectl 16 | ``` 17 | -------------------------------------------------------------------------------- /cheatsheets/go/code/structures.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Structures 3 | description: Understanding the `struct` type 4 | --- 5 | 6 | 7 | ## Syntax 8 | 9 | ``` 10 | struct { 11 | KEY_NAME VALUE_TYPE 12 | [...] 13 | }[ optional instances ] 14 | ``` 15 | 16 | ## Examples 17 | 18 | ```go 19 | person := struct { 20 | Name string 21 | Age int 22 | }{"Kim", 22} 23 | ``` 24 | 25 | ```go 26 | point := struct { 27 | x, y int 28 | } 29 | ``` 30 | -------------------------------------------------------------------------------- /cheatsheets/shell/scheduling.md: -------------------------------------------------------------------------------- 1 | # Scheduling 2 | 3 | See [crontab](https://github.com/MichaelCurrin/learn-to-code/blob/master/Shell/Scheduling/crontab.md) guide. 4 | 5 | 6 | Send stdout and stderror to stdout and mail the result. Useful in a cronjob. Note this assumes global mail is disabled with `MAILTO=''`. 7 | 8 | ```sh 9 | RESULT="$(cd DIR && COMMAND)"; [[ $? -ne 0 ]] || echo "$RESULT" | mail -s 'Task foo failed!' $USER 10 | ``` 11 | -------------------------------------------------------------------------------- /cheatsheets/terraform/code/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Code 3 | description: How to write code for Terraform files 4 | --- 5 | 6 | The native language of Terraform is HCL - Hashicorp Configuration Language. 7 | 8 | 9 | Recommended - use this command to start interactive mode. 10 | 11 | ```sh 12 | $ terraform console 13 | ``` 14 | 15 | Then enter Terraform statements. 16 | 17 | ``` 18 | > join(", ", ["abc","def"]) 19 | "abc, def" 20 | ``` 21 | -------------------------------------------------------------------------------- /cheatsheets/web/css/pseudo-selectors/text.md: -------------------------------------------------------------------------------- 1 | ## Text 2 | 3 | 4 | ## Selectors 5 | 6 | - `::first-line` 7 | - `::last-child` 8 | - `::only-child` 9 | 10 | 11 | ## Examples 12 | 13 | Instead of adding `span` with `first` as class, you can use a selector for the first line like this: 14 | 15 | ```css 16 | /* The first line of every

element. */ 17 | p::first-line { 18 | color: blue; 19 | text-transform: uppercase; 20 | } 21 | ``` 22 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/modules/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Modules 3 | description: How to export and import modules 4 | --- 5 | 6 | ### Resources 7 | 8 | - [CDNs](https://michaelcurrin.github.io/dev-resources/resources/javascript/cdns/) for JS in Dev Resources. 9 | - [Modules](https://nodejs.org/api/modules.html) in the Node docs 10 | - [Different module formats](https://www.sitepoint.com/understanding-module-exports-exports-node-js/) 11 | -------------------------------------------------------------------------------- /cheatsheets/python/libraries/built-in/http-server.md: -------------------------------------------------------------------------------- 1 | # HTTP Server 2 | 3 | A module for simple HTTP web servers for development - not recommended for production. 4 | 5 | See [http.server](https://docs.python.org/3/library/http.server.html) docs. 6 | 7 | 8 | ## Usage 9 | 10 | Start a static file server. 11 | 12 | ```sh 13 | $ python3 -m http.server 14 | ``` 15 | 16 | Open in the browser: 17 | 18 | - [localhost:8000](http://localhost:8000) 19 | -------------------------------------------------------------------------------- /cheatsheets/containers/docker/volumes.md: -------------------------------------------------------------------------------- 1 | # Volumes 2 | 3 | 4 | ## Resources 5 | 6 | - [Volumes](https://docs.docker.com/storage/volumes/) 7 | 8 | 9 | ## Related 10 | 11 | See cheatsheets here: 12 | 13 | - [Docker Compose Volumes][] 14 | - [Docker CLI Volumes][] 15 | 16 | 17 | [Docker Compose Volumes]: {% link cheatsheets/containers/docker-compose/volumes.md %} 18 | [Docker CLI Volumes]: {% link cheatsheets/containers/docker-cli/volumes.md %} 19 | -------------------------------------------------------------------------------- /cheatsheets/containers/kubernetes/cli/replica-set.md: -------------------------------------------------------------------------------- 1 | 2 | # Replica set 3 | 4 | A new replicaset is created with each deploy and a history is saved. You’ll see 10 or so for each deployment: 5 | 6 | ```sh 7 | $ kubectl get rs 8 | ``` 9 | 10 | To find which replicaset is active for the deployment, describe the deployment and look for NewReplicaSet: 11 | 12 | ```sh 13 | kubectl describe deploy my-pod-name | grep NewReplicaSet 14 | ``` 15 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/templating/collections.md: -------------------------------------------------------------------------------- 1 | # Collections 2 | 3 | {% raw %} 4 | 5 | 6 | ## Iterate over collection 7 | 8 | - `_config.yml` 9 | ```yaml 10 | collections: 11 | foo: 12 | output: true 13 | ``` 14 | - `_foo/bars/*.md` 15 | - `index.md` 16 | ```liquid 17 | --- 18 | --- 19 | {% for item in site.foo.bars %} 20 | {{ item.title }} 21 | {% endfor %} 22 | ``` 23 | 24 | {% endraw %} 25 | -------------------------------------------------------------------------------- /cheatsheets/python/configs/index.md: -------------------------------------------------------------------------------- 1 | 2 | # Configs 3 | 4 | 5 | 6 | See this [blog post](https://hackersandslackers.com/simplify-your-python-projects-configuration/#commento-login-box-container) 7 | 8 | 9 | 10 | See also [Python Package Quickstart repo](https://github.com/MichaelCurrin/python-package-quickstart). 11 | -------------------------------------------------------------------------------- /cheatsheets/terraform/tfenv.md: -------------------------------------------------------------------------------- 1 | # TFEnv 2 | 3 | If you want to have multiple versions of Terraform installed, use this tool. 4 | 5 | - [tfenv](https://github.com/tfutils/tfenv) 6 | 7 | 8 | ## Install TFEnv 9 | 10 | ```sh 11 | $ brew install tfenv 12 | ``` 13 | 14 | ## Install a version of Terraform 15 | 16 | ```sh 17 | $ tfenv install 1.2.3 18 | ``` 19 | 20 | 21 | ## Use a version of Terraform 22 | 23 | ```sh 24 | $ terraform1.2.3 25 | ``` 26 | -------------------------------------------------------------------------------- /cheatsheets/web/css/tables.md: -------------------------------------------------------------------------------- 1 | # Tables 2 | 3 | From [CSS table](https://www.w3schools.com/Css/css_table.asp) guide. 4 | 5 | 6 | ## Add border 7 | 8 | ```css 9 | table, th, td { 10 | border: 1px solid; 11 | } 12 | ``` 13 | 14 | Collapse borders to not have double borders. 15 | 16 | ```css 17 | table { 18 | border-collapse: collapse; 19 | } 20 | ``` 21 | 22 | ## Full width 23 | 24 | ```css 25 | table { 26 | width: 100%; 27 | } 28 | ``` 29 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/templating/static-files.md: -------------------------------------------------------------------------------- 1 | # Static files 2 | 3 | {% raw %} 4 | 5 | From [StackOverflow](https://stackoverflow.com/questions/17677094/jekyll-for-loop-over-all-images-in-a-folder). 6 | 7 | ```liquid 8 | {% for asset in site.static_files %} 9 | {% if asset.path contains '' %} 10 | {{ asset.path }} 11 | {% endif %} 12 | {% endfor %} 13 | ``` 14 | 15 | {% endraw %} 16 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/tags.md: -------------------------------------------------------------------------------- 1 | # Tags 2 | 3 | ## Related 4 | 5 | - [tag][] command 6 | 7 | [tag]: {% link cheatsheets/version-control/git/commands/tag.md %} 8 | 9 | 10 | ## View latest tag 11 | 12 | Using [git describe][] command. 13 | 14 | [git describe]: {% link cheatsheets/version-control/git/commands/describe.md %} 15 | 16 | 17 | ## Checkout latest tag 18 | 19 | ```sh 20 | $ git checkout $(git describe --abbrev=0 --tags) 21 | ``` 22 | -------------------------------------------------------------------------------- /cheatsheets/javascript/format-and-lint/prettier/options.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Options 3 | description: Options you can set in the CLI or config file 4 | --- 5 | 6 | Prettier is designed to work with zero configuration and you are encouraged to do that. Let the community and Prettier decide for you. 7 | 8 | If your project or team needs something specific, you can overrided options. 9 | 10 | See [Options](https://prettier.io/docs/en/options.html) in the docs. 11 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/javascript/yarn/commands/create.md: -------------------------------------------------------------------------------- 1 | # create 2 | 3 | - [yarn create](https://classic.yarnpkg.com/en/docs/cli/create/) docs. 4 | 5 | 6 | ## Syntax 7 | 8 | ```sh 9 | $ yarn create PACKAGE_NAME OPTIONS 10 | ``` 11 | 12 | 13 | ## Example 14 | 15 | ```sh 16 | $ yarn create react-app my-app 17 | ``` 18 | 19 | That is equivalent to: 20 | 21 | ```sh 22 | $ yarn global add create-react-app 23 | $ create-react-app my-app 24 | ``` 25 | -------------------------------------------------------------------------------- /cheatsheets/version-control/github/api/v3/gists.md: -------------------------------------------------------------------------------- 1 | # Gists 2 | 3 | [Gists reference](https://docs.github.com/en/rest/reference/gists) doc 4 | 5 | [Gists for user](https://docs.github.com/en/rest/reference/gists#list-gists-for-a-user) 6 | 7 | e.g. `https://api.github.com/users/MichaelCurrin/gists` 8 | 9 | [Get a gist](https://docs.github.com/en/rest/reference/gists#get-a-gist) 10 | 11 | e.g. `https://api.github.com/gists/aa1fc56419a355972b96bce23f3bccba` 12 | -------------------------------------------------------------------------------- /cheatsheets/web/css/github-pages.md: -------------------------------------------------------------------------------- 1 | # GitHub Pages 2 | 3 | If you have a GitHub Pages site of HTML files that do not use Jekyll, you can still prettify them using this: 4 | 5 | ```html 6 | 7 | ``` 8 | 9 | Note the URL here is relative to the current page. 10 | 11 | If you are adding styling to a subpage, you can use a prefix: 12 | 13 | - `/repo-name/` - make it absolute 14 | - `../` - make it relative 15 | -------------------------------------------------------------------------------- /cheatsheets/rust/cli/rustc.md: -------------------------------------------------------------------------------- 1 | 2 | # Rustc 3 | 4 | From [What is Rustc?](https://doc.rust-lang.org/rustc/what-is-rustc.html): 5 | 6 | > rustc is the compiler for the Rust programming language, provided by the project itself. Compilers take your source code and produce binary code, either as a library or executable. 7 | 8 | 9 | ## Version 10 | 11 | Check your _Rustc_ version. 12 | 13 | ```sh 14 | $ rustc -V 15 | rustc 1.31.1 (b6c32da9b 2018-12-18) 16 | ``` 17 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/liquid/strings.md: -------------------------------------------------------------------------------- 1 | # Strings 2 | 3 | {% raw %} 4 | 5 | 6 | ## Contains 7 | 8 | Maybe using Regex for startswith? There is no `startswith` or `starts_with` alone or on a string. 9 | 10 | ```liquid 11 | {% if my_string contains 'foo' %} 12 | Yes! 13 | {% endif %} 14 | ``` 15 | 16 | 17 | ## Case 18 | 19 | ```liquid 20 | {{ my_string | upcase }} 21 | ``` 22 | 23 | ```liquid 24 | {{ my_string | downcase }} 25 | ``` 26 | 27 | 28 | {% endraw %} 29 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/log-tips.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: tips for using git-log for data manipulation 3 | --- 4 | # log tips 5 | 6 | 7 | ## Years 8 | 9 | List the years where there were commits. 10 | 11 | ```sh 12 | $ git log --date=format:'%Y' --pretty=format:'%ad' | uniq 13 | ``` 14 | 15 | See this [Data manipulation][] page for how to apply grouping and counting to this. 16 | 17 | [Data manipulation]: {% link cheatsheets/shell/data-manipulation.md %} 18 | -------------------------------------------------------------------------------- /cheatsheets/data/yaml/variable-names.md: -------------------------------------------------------------------------------- 1 | # Variable names 2 | 3 | YAML is weird in that is supports a `dash` in a variable name. 4 | 5 | ```yaml 6 | abc-def: 'xyz' 7 | 8 | abc_def: 'xyz' 9 | ``` 10 | 11 | But, it is probably better to stick to underscores, to be consistent with programming languages. 12 | 13 | In other languages, a dash is actually a minus sign. 14 | 15 | So 16 | 17 | ``` 18 | abc-def 19 | ``` 20 | 21 | Means 22 | 23 | ``` 24 | abc - def 25 | ``` 26 | -------------------------------------------------------------------------------- /cheatsheets/other/regex/insert.md: -------------------------------------------------------------------------------- 1 | # Insert 2 | 3 | Note use of `$1` to keep the original text. Brackets seem to be needed for this to work. 4 | 5 | Applied VS Code regex replace. 6 | 7 | ### Add character 8 | 9 | Add header symbol before a number. 10 | 11 | - Find: `\d` 12 | - Replace with: `# $1` 13 | 14 | ### Add break tag 15 | 16 | Insert `br` tag at the end of lines which are not headings or empty lines. 17 | 18 | - Find: `(^[^#].+)` 19 | - Replace with: `$1
` 20 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/bundler/other.md: -------------------------------------------------------------------------------- 1 | # Other 2 | 3 | ```sh 4 | bundle version # Prints the bundler's version information 5 | ``` 6 | 7 | ```sh 8 | bundle console [GROUP] # Opens an IRB session with the bundle pre-loaded 9 | ``` 10 | 11 | ```sh 12 | bundle exec [OPTIONS] # Run the command in context of the bundle 13 | ``` 14 | 15 | ```sh 16 | bundle gem NAME [OPTIONS] # Creates a skeleton for creating a rubygem 17 | ``` 18 | -------------------------------------------------------------------------------- /cheatsheets/javascript/format-and-lint/eslint/config-files/main.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Main 3 | description: The ESLint main config 4 | --- 5 | 6 | 7 | From [Configuration file format](https://eslint.org/docs/2.0.0/user-guide/configuring#configuration-file-formats) in the docs. 8 | 9 | 1. `.eslintrc.js` 10 | 1. `.eslintrc.yaml` or `.eslintrc.yml` 11 | 1. `.eslintrc.json` 12 | 1. `.eslintrc` - DEPRECATED, as it can be JSON or YAML 13 | 1. `package.json` - `eslintConfig` field. 14 | 15 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/promises/callback.md: -------------------------------------------------------------------------------- 1 | # Callback function 2 | 3 | ```javascript 4 | foo('bar', function (bazz) { 5 | console.log(bazz.toUpperCase()); 6 | }); 7 | ``` 8 | 9 | This is the infamous "callback hell" where you have to nest function calls to chain them. This what the only way for a long time. 10 | 11 | ```javascript 12 | foo('bar', function (bazz) { 13 | fizz(bazz, function(boo) { 14 | console.log(boo.toUpperCase()); 15 | } 16 | }); 17 | ``` 18 | -------------------------------------------------------------------------------- /cheatsheets/other/regex/groups.md: -------------------------------------------------------------------------------- 1 | # Groups 2 | 3 | A non-captured and a captured part of a pattern. 4 | 5 | ```re 6 | \w (\w) 7 | ``` 8 | 9 | Named group. 10 | 11 | ```re 12 | (?\w) 13 | ``` 14 | 15 | Non-capturing group. If you want to use brackets to make a group such as to make it be repeated, but don't care about capturing it. 16 | 17 | ```re 18 | (?:\w) (\w) 19 | ``` 20 | 21 | Match any one of these groups: 22 | 23 | ```re 24 | (abc def)|(Foo bar)(fizz) 25 | ``` 26 | -------------------------------------------------------------------------------- /cheatsheets/python/strings/encoding/html-escape.md: -------------------------------------------------------------------------------- 1 | # HTML escape 2 | 3 | 4 | See [Escaping HTML][] in the Python Wiki 5 | 6 | [Escaping HTML]: https://wiki.python.org/moin/EscapingHtml 7 | 8 | 9 | ## CGI 10 | 11 | ```python 12 | import cgi 13 | 14 | s = cgi.escape( """& < >""" ) # s = "& < >" 15 | ``` 16 | 17 | 18 | ## HTML 19 | 20 | ```python 21 | import html 22 | 23 | 24 | s = html.escape( """& < " ' >""" ) # s = '& < " ' >' 25 | ``` 26 | -------------------------------------------------------------------------------- /cheatsheets/artificial-intelligence/index.md: -------------------------------------------------------------------------------- 1 | # Artificial Intelligence 2 | 3 | ### Related 4 | - [Artificial Intelligence](https://michaelcurrin.github.io/code-cookbook/recipes/artificial-intelligence/) under Code Cookbook. 5 | - [Artificial Intelligence](https://michaelcurrin.github.io/dev-resources/resources/artificial-intelligence/) under Dev Resources. 6 | 7 | To compare models and stats for each on cost and max tokens, see [Token Translator](https://michaelcurrin.github.io/token-translator/). 8 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/vue/events/custom.md: -------------------------------------------------------------------------------- 1 | # Custom events 2 | 3 | ## Custom event names 4 | 5 | From the docs: 6 | 7 | ```javascript 8 | this.$emit('myEvent') 9 | ``` 10 | 11 | ```html 12 | 13 | ``` 14 | 15 | 16 | ## Custom events 17 | 18 | Emitted events can be defined on the component via the emits option. 19 | 20 | ```javascript 21 | app.component('custom-form', { 22 | emits: ['inFocus', 'submit'] 23 | }) 24 | ``` 25 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/os/snap.md: -------------------------------------------------------------------------------- 1 | # snap 2 | 3 | Use the package manager GUI (like "Ubuntu Software") or the CLI. 4 | 5 | See [Snapcraft](https://snapcraft.io/) Linux app store or [Getting started](https://snapcraft.io/docs/getting-started) for CLI help. 6 | 7 | 8 | ## Help 9 | 10 | ```sh 11 | $ snap help COMMAND 12 | ``` 13 | 14 | ## Install 15 | 16 | ```sh 17 | $ snap install PACKAGE 18 | ``` 19 | 20 | 21 | ## Update 22 | 23 | ```sh 24 | $ snap refresh package 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /cheatsheets/ruby/types.md: -------------------------------------------------------------------------------- 1 | # Types 2 | 3 | ## Basic 4 | 5 | ```ruby 6 | foo = "abc" 7 | 8 | foo.class 9 | # String 10 | 11 | foo.is_a? String # true 12 | foo.kind_of? String # true 13 | foo.instance_of? String # true 14 | ``` 15 | 16 | ## Class 17 | 18 | ```ruby 19 | class X < String 20 | end 21 | 22 | foo = X.new 23 | 24 | foo.is_a? String # true 25 | foo.kind_of? String # true 26 | foo.instance_of? String # false 27 | foo.instance_of? X # true 28 | ``` 29 | -------------------------------------------------------------------------------- /cheatsheets/javascript/format-and-lint/prettier/ignoring-rules.md: -------------------------------------------------------------------------------- 1 | # Ignoring rules 2 | 3 | 4 | ## Ignore next line 5 | 6 | ```javascript 7 | // prettier-ignore 8 | console.log("Hello, World") 9 | ``` 10 | 11 | If using ESLint: 12 | 13 | ```javascript 14 | // eslint-disable-next-line prettier/prettier 15 | console.log('foo') 16 | ``` 17 | 18 | 19 | ## Global ignore config 20 | 21 | A plain text file. 22 | 23 | - `.prettierignore` e.g. 24 | ``` 25 | build/ 26 | *.html 27 | ``` 28 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/python/pipenv.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: pipenv 3 | --- 4 | 5 | 6 | ## Configure 7 | 8 | From [issue comment](https://github.com/pypa/pipenv/issues/2122#issuecomment-386207878). 9 | 10 | ```sh 11 | echo 'export PATH="${HOME}/.local/bin:$PATH"' >> ~/.bashrc 12 | ``` 13 | 14 | 15 | ## Install 16 | 17 | Install with `pip`. 18 | 19 | ```sh 20 | $ pip install pipenv 21 | ``` 22 | 23 | Or more precisely: 24 | 25 | ```sh 26 | $ python3 -m pip install --user pipenv 27 | ``` 28 | -------------------------------------------------------------------------------- /cheatsheets/python/resources.md: -------------------------------------------------------------------------------- 1 | # Resources 2 | 3 | See a cheatsheet [pythoncheatsheet.org](https://www.pythoncheatsheet.org/) 4 | 5 | Find example usage - see [programcreek.com/python/index/module/list](https://www.programcreek.com/python/index/module/list). When you go into functions of a module, you can see where other code uses that. 6 | 7 | More resources: 8 | 9 | - [Tutorial](https://docs.python.org/3/tutorial/) on Python 3 docs. 10 | - [Python docs](https://docs.python.org/3/) homepage 11 | -------------------------------------------------------------------------------- /cheatsheets/javascript/deno/code.md: -------------------------------------------------------------------------------- 1 | # Code 2 | 3 | ## Enviroment variables 4 | 5 | ```typescript 6 | const env = Deno.env.toObject() 7 | const PORT = env.PORT || 4000 8 | const HOST = env.HOST || '127.0.0.1' 9 | ``` 10 | 11 | 12 | ## Browser vs CLI 13 | 14 | From [1.7](https://deno.land/posts/v1.7) release notes. 15 | 16 | > Use `typeof Deno !== "undefined"` to determine if you are running in Deno, 17 | 18 | > and use `typeof document !== "undefined" `to determine if the DOM is available or not. 19 | -------------------------------------------------------------------------------- /cheatsheets/typescript/variables.md: -------------------------------------------------------------------------------- 1 | # Variables 2 | 3 | ## Inferred type 4 | 5 | ```typescript 6 | let foo = true 7 | ``` 8 | 9 | ```typescript 10 | const foo = true 11 | ``` 12 | 13 | 14 | ## Explicit 15 | 16 | ```typescript 17 | let foo: boolean = false 18 | ``` 19 | 20 | ```typescript 21 | let bar: string = "hello" 22 | ``` 23 | 24 | Set type initially and initialized with a null value then change value. 25 | 26 | ```typescript 27 | let foo: boolean 28 | foo = true 29 | foo = false 30 | ``` 31 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/control-flow/some.md: -------------------------------------------------------------------------------- 1 | # Some 2 | 3 | - [Array.prototype.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some) in MDN docs 4 | 5 | 6 | ## Syntax 7 | 8 | ``` 9 | ARRAY.some(EXPRESSION) 10 | ``` 11 | 12 | 13 | ## Examples 14 | 15 | Here checking if at least one value is even. 16 | 17 | ```j 18 | const myArray = [1, 2, 3, 4, 5]; 19 | 20 | myArray.some(i => i % 2 === 0)); 21 | // true 22 | ``` 23 | 24 | Similar to `any` in Python. 25 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/control-flow/switch.md: -------------------------------------------------------------------------------- 1 | # Switch 2 | 3 | [W3 Schools](https://www.w3schools.com/js/js_switch.asp) 4 | 5 | Note use of break, otherwise a matched level _and_ all levels underneath it will be evaluated. 6 | 7 | ```javascript 8 | const x = 2; 9 | 10 | switch(x) { 11 | case 1: 12 | console.log('Hello'); 13 | break; 14 | case 2: 15 | console.log('Hi'); 16 | break; 17 | default: 18 | console.log('Howdy'); 19 | } 20 | ``` 21 | 22 | See also `switch` in C. 23 | -------------------------------------------------------------------------------- /cheatsheets/shell/files/text-files/lines.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Lines 3 | description: Iterate over lines in a file 4 | --- 5 | 6 | e.g. 7 | 8 | ```sh 9 | for ROW in $(< requirements.txt); do 10 | echo "pip install $ROW" 11 | done 12 | ``` 13 | 14 | From `xargs` manpage: 15 | 16 | > The xargs utility reads space, tab, newline and end-of-file delimited strings from the standard input and executes utility with the strings as arguments. 17 | 18 | ```sh 19 | cat requirements.txt | xargs pip install 20 | ``` 21 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/variable-declaration/reassign.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Reassign 3 | description: Variable reassignment comparison 4 | --- 5 | 6 | Reassignment is allowed for `let` and `var`. 7 | 8 | ```javascript 9 | var x = 123; 10 | x = 10 11 | x = 'a' 12 | ``` 13 | 14 | ```javascript 15 | let x = 123; 16 | x = 10 17 | x = 'a' 18 | ``` 19 | 20 | But not for `const` variables. 21 | 22 | ```javascript 23 | const x = 123 24 | x = 10 25 | // Uncaught TypeError: Assignment to constant variable. 26 | ``` 27 | -------------------------------------------------------------------------------- /cheatsheets/python/pitfalls.md: -------------------------------------------------------------------------------- 1 | # Pitfalls 2 | 3 | Don't define data structures in function parameters. Only constants. 4 | 5 | ```python 6 | def foo(x=[]): 7 | x.append('test') 8 | print(x) 9 | 10 | foo() 11 | # => ['test'] 12 | foo() 13 | # => ['test', 'test'] 14 | ``` 15 | 16 | Best practice way: 17 | 18 | ```python 19 | def foo(x=None): 20 | if x is None: 21 | x = [] 22 | x.append('test') 23 | print(x) 24 | 25 | foo() 26 | # => ['test'] 27 | foo() 28 | # => ['test'] 29 | ``` 30 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/grep/match-types.md: -------------------------------------------------------------------------------- 1 | # Match types 2 | 3 | 4 | ## Basic 5 | 6 | Find word. 7 | 8 | ```sh 9 | grep foo PATH 10 | ``` 11 | 12 | 13 | ## Exact match 14 | 15 | ```sh 16 | grep -w 'foo' bar.txt 17 | ``` 18 | 19 | 20 | ## Invert match 21 | 22 | ```sh 23 | grep -v 'foo' bar.txt 24 | ``` 25 | 26 | That will invert the match on each line. 27 | 28 | If you want to want to find entire files which do not match a pattern, use: 29 | 30 | ```sh 31 | grep -L 'foo' bar.txt baz.txt 32 | ``` 33 | -------------------------------------------------------------------------------- /cheatsheets/ci-cd/github-actions/working-directory.md: -------------------------------------------------------------------------------- 1 | # Working directory 2 | 3 | If you need to have all job commands start in a target directory. 4 | 5 | This is useful for example if you are build a docs site where all the code is in `docs` directory. 6 | 7 | See [defaults.run](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#defaultsrun) in the Workflow Syntax docs. 8 | 9 | ```yaml 10 | defaults: 11 | run: 12 | working-directory: docs 13 | 14 | jobs: 15 | # ... 16 | ``` 17 | -------------------------------------------------------------------------------- /cheatsheets/other/vscode/python-imports.md: -------------------------------------------------------------------------------- 1 | # Python imports 2 | 3 | Fix issues where imports are not recognized in your app. 4 | 5 | e.g. If you have `myapp` directory and your code has imports relative to that which are not recognized. 6 | 7 | In `.vscode/settings.json`. 8 | 9 | ```json 10 | { 11 | "python.analysis.extraPaths": [ 12 | "./myapp" 13 | ], 14 | } 15 | ``` 16 | 17 | Note setting `.env` with `PYTHONPATH=myapp` does not solve the issue in VS Code but it might help with CLI tools like testing. 18 | -------------------------------------------------------------------------------- /cheatsheets/sql/basic/delete.md: -------------------------------------------------------------------------------- 1 | # Delete 2 | 3 | 4 | ## Delete select rows 5 | 6 | ```sql 7 | DELETE FROM my_table 8 | WHERE id IN (1, 2, 3) 9 | ; 10 | ``` 11 | 12 | ## Cascade 13 | 14 | If you get an error from foreign key constraints: 15 | 16 | ```sql 17 | DELETE FROM my_table CASCADE 18 | -- WHERE ... 19 | ; 20 | ``` 21 | 22 | ## Delete **all** rows 23 | 24 | ```sql 25 | DELETE FROM my_table; 26 | ``` 27 | 28 | ```sql 29 | TRUNCATE my_table; 30 | ``` 31 | ```sql 32 | TRUNCATE my_table; 33 | CASCADE 34 | ``` 35 | -------------------------------------------------------------------------------- /cheatsheets/other/quick-links.md: -------------------------------------------------------------------------------- 1 | # Quick links 2 | 3 | > My favorite docs and tutorials for programming topics, all in one place. 4 | 5 | 6 | - Python 7 | - [PY 3 docs](https://docs.python.org/3/) 8 | - JavaScript 9 | - [W3 schools](https://www.w3schools.com/js/default.asp) 10 | - [Mozilla](https://developer.mozilla.org/en-US/docs/Web/JavaScript) 11 | - CSS 12 | - [Mozilla](https://developer.mozilla.org/en-US/docs/Web/CSS) 13 | - [W3 schools](https://www.w3schools.com/cssref/css3_pr_background.asp) 14 | -------------------------------------------------------------------------------- /cheatsheets/other/regex/index.md: -------------------------------------------------------------------------------- 1 | # Regex 2 | 3 | 4 | ### Resources 5 | 6 | - [Regex](https://michaelcurrin.github.io/dev-resources/resources/other/regex/) resources. 7 | - [Regex Cheatsheet](https://www.keycdn.com/support/regex-cheatsheet) on Key CDN 8 | 9 | ### Related 10 | 11 | - [JavaScript Regex][] cheatsheet. 12 | - [Regex][] in Code Cookbook. 13 | 14 | [JavaScript Regex]: {% link cheatsheets/javascript/general/strings/regex.md %} 15 | [Regex]: https://michaelcurrin.github.io/code-cookbook/recipes/other/regex/ 16 | -------------------------------------------------------------------------------- /cheatsheets/python/libraries/boto3.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: boto3 3 | description: AWS SDK for Python 4 | --- 5 | 6 | ## Resources 7 | 8 | - [aws.amazon.com/sdk-for-python/](http://aws.amazon.com/sdk-for-python/) homepage 9 | - [boto3](https://pypi.org/project/boto3/) on PyPi. 10 | 11 | 12 | ## Example 13 | 14 | ```python 15 | import boto3 16 | 17 | 18 | s3_client = boto3.client('s3') 19 | 20 | s3_client.download_file(bucket, key, download_path) 21 | s3_client.upload_file(upload_path, f'{bucket}-resized', key) 22 | ``` 23 | -------------------------------------------------------------------------------- /cheatsheets/data/yaml/file-formatting.md: -------------------------------------------------------------------------------- 1 | # File formatting 2 | 3 | ## Extension 4 | 5 | Use `.yml` or `.yaml` extension. 6 | 7 | 8 | ## Start of file 9 | 10 | YAML files strictly should start with triple dash, but in practice this is only used sometimes. 11 | 12 | e.g. 13 | 14 | ```yaml 15 | my_string: Hello 16 | ``` 17 | 18 | ```yaml 19 | --- 20 | my_string: Hello 21 | ``` 22 | 23 | For a Jekyll site: 24 | 25 | ```yaml 26 | --- 27 | title: Hello 28 | my_string: Greetings 29 | --- 30 | 31 | My page content. 32 | ``` 33 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/os/homebrew/overview.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | ## Install 4 | 5 | ```sh 6 | $ brew install PACKAGE 7 | $ brew install python 8 | ``` 9 | 10 | Specific version: 11 | 12 | ```sh 13 | $ brew install PACKAGE@VERSION 14 | $ # e.g. 15 | $ brew install python@3.9 16 | ``` 17 | 18 | ## Uninstall 19 | 20 | ```sh 21 | $ brew remove PACKAGE 22 | ``` 23 | 24 | ## Upgrade all packages 25 | 26 | ```sh 27 | $ brew upgrade 28 | ``` 29 | 30 | ## List installed packages 31 | 32 | ```sh 33 | $ brew list 34 | ``` 35 | -------------------------------------------------------------------------------- /cheatsheets/web/html/encode-and-escape/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | # Encoding and escaping 4 | 5 | 6 | How to convert text into encoded or escaped text and back. 7 | 8 | This deals with these areas: 9 | 10 | - [URL Encoding][] - For text in a website **URL**. 11 | - [HTML entity escaping][] - For the HTML **contents of a webpage**. 12 | 13 | [URL Encoding]: {% link cheatsheets/web/html/encode-and-escape/url-encoding.md %} 14 | [HTML entity escaping]: {% link cheatsheets/web/html/encode-and-escape/html-entity-escaping.md %} 15 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/esbuild/script.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Script 3 | description: Use in a script 4 | --- 5 | 6 | See also the [CLI][] section. 7 | 8 | [CLI]: {% link cheatsheets/javascript/packages/esbuild/cli.md %} 9 | 10 | Using ES Modules, import from CDN URL. 11 | 12 | - `index.js` 13 | ```javascript 14 | import build from "https://cdn.jsdelivr.net/npm/esbuild"; 15 | 16 | esbuild.build({ 17 | entryPoints: ['app.jsx'], 18 | bundle: true, 19 | outfile: 'out.js', 20 | }) 21 | ``` 22 | -------------------------------------------------------------------------------- /cheatsheets/markdown/contact.md: -------------------------------------------------------------------------------- 1 | # Contact 2 | 3 | 4 | ## Email 5 | 6 | - Markdown 7 | ```markdown 8 | 9 | ``` 10 | - HTML 11 | ```html 12 | foo@bar.com 13 | ``` 14 | - Result 15 | - 16 | 17 | 18 | ## Phone number 19 | 20 | - Markdown 21 | ```markdown 22 | [+44 20 7123 4567](tel:+442071234567) 23 | ``` 24 | - Rendered HTML 25 | ```html 26 | +44 20 7123 4567 27 | ``` 28 | - Result 29 | - [+44 20 7123 4567](tel:+442071234567) 30 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/bundler/init.md: -------------------------------------------------------------------------------- 1 | # Init 2 | 3 | Generate a Gemfile. 4 | 5 | ```sh 6 | $ bundle init [OPTIONS] 7 | ``` 8 | 9 | - `Gemfile` result. 10 | ```ruby 11 | # frozen_string_literal: true 12 | 13 | source "https://rubygems.org" 14 | 15 | git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } 16 | 17 | # gem "rails" 18 | ``` 19 | 20 | Note the file is only readable, you change the permissions first. 21 | 22 | ```sh 23 | $ chmod +w Gemfile 24 | $ nano Gemfile 25 | ``` 26 | -------------------------------------------------------------------------------- /cheatsheets/ruby/gems/user-directory.md: -------------------------------------------------------------------------------- 1 | # User directory 2 | 3 | Run this in `irb`: 4 | 5 | ```ruby 6 | puts Gem.user_dir 7 | ``` 8 | 9 | Or run this in the shell: 10 | 11 | ```sh 12 | $ ruby -r rubygems -e 'puts Gem.user_dir' 13 | ``` 14 | 15 | On macOS and Linux this will be like: 16 | 17 | ``` 18 | ~/.gem/ruby/2.7.0 19 | ``` 20 | 21 | The use of `-r` is to import the `rubygems` library before executing the script. I found that shell command and use it but I don't know why `-r` is needed as I get the same result without it. 22 | -------------------------------------------------------------------------------- /cheatsheets/web/css/layouts/align.md: -------------------------------------------------------------------------------- 1 | # Align 2 | 3 | 4 | ## Text align 5 | 6 | From [text-align](https://www.w3schools.com/cssref/pr_text_text-align.ASP) on W3 schools. 7 | 8 | ```css 9 | el { 10 | text-align: center; 11 | } 12 | ``` 13 | 14 | Values: `left|right|center|justify|initial|inherit` 15 | 16 | ```css 17 | el { 18 | align-content: center; 19 | } 20 | ``` 21 | 22 | 23 | ## Align content 24 | 25 | Use of `align-content` is for [Flexbox][]. 26 | 27 | [Flexbox]: {% link cheatsheets/web/css/layouts/flexbox.md %} 28 | -------------------------------------------------------------------------------- /cheatsheets/javascript/browser/clipboard.md: -------------------------------------------------------------------------------- 1 | # Clipboard 2 | 3 | ## Copy to clipboard 4 | 5 | [Source](https://stackoverflow.com/questions/33855641/copy-output-of-a-javascript-variable-to-the-clipboard) 6 | 7 | ```javascript 8 | function copyToClipboard(text) { 9 | var dummy = document.createElement("textarea"); 10 | document.body.appendChild(dummy); 11 | dummy.value = text; 12 | dummy.select(); 13 | document.execCommand("copy"); 14 | document.body.removeChild(dummy); 15 | } 16 | copyToClipboard('hello\nworld') 17 | ``` 18 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/jquery/index.md: -------------------------------------------------------------------------------- 1 | # jQuery 2 | 3 | ## Ajax 4 | 5 | ```javascript 6 | const params = { 7 | url: URL, 8 | crossDomain: true 9 | }; 10 | 11 | $.ajax(params) 12 | .then(result => console.log(result)); 13 | ``` 14 | 15 | 16 | ## Get JSON 17 | 18 | ```javascript 19 | const params = { 20 | url: URL, 21 | headers: { 22 | "accept": "application/json", 23 | "Access-Control-Allow-Origin": "*" 24 | } 25 | }; 26 | 27 | $.getJSON(params) 28 | .then(result => console.log(result)); 29 | ``` 30 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/os/homebrew/install-homebrew.md: -------------------------------------------------------------------------------- 1 | # Install Homebrew 2 | 3 | See the [brew.sh](https://brew.sh) homepage. 4 | 5 | This will request your password as it needs _root_ permissions. 6 | 7 | ```sh 8 | $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 9 | ``` 10 | 11 | See [install.sh](https://github.com/Homebrew/install/blob/master/install.sh) on GitHub. 12 | 13 | If upgrading Homebrew, it is recommended to then [upgrade all packages](#upgrade-all-packages). 14 | 15 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/python/pip/protect.md: -------------------------------------------------------------------------------- 1 | 2 | # Protect global environment 3 | 4 | Prevent accidentally installing or upgrading in your user's global Python environment. 5 | 6 | In Linux or macOS, set this value in your `~/.bashrc` or `~/.zshrc` file. 7 | 8 | ```sh 9 | PIP_REQUIRE_VIRTUALENV=true 10 | ``` 11 | 12 | Now, any time you run `pip install` **outside** a virtual environment you'll get an error. 13 | 14 | How to force global install: 15 | 16 | ```sh 17 | $ PIP_REQUIRE_VIRTUALENV=false pip install PACKAGE 18 | ``` 19 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Guide to JavaScript packages aka libraries 3 | --- 4 | # Packages 5 | 6 | 7 | ### Related 8 | 9 | - [Package managers][] cheatsheet for JS. 10 | - [NPM versions][] cheatsheet. 11 | - [JS Packages](https://michaelcurrin.github.io/dev-resources/resources/javascript/packages/) in my Dev Resources. 12 | 13 | 14 | [Package managers]: {% link cheatsheets/package-managers/javascript/index.md %} 15 | [NPM versions]: {% link cheatsheets/package-managers/javascript/npm/versions.md %} 16 | -------------------------------------------------------------------------------- /cheatsheets/python/strings/truncate.md: -------------------------------------------------------------------------------- 1 | # Truncate 2 | 3 | Truncate long strings. 4 | 5 | ```python 6 | import textwrap 7 | 8 | 9 | textwrap.shorten("Hello world!", width=12) 10 | # => 'Hello world!' 11 | textwrap.shorten("Hello world!", width=11) 12 | # > 'Hello [...]' 13 | textwrap.shorten("Hello world", width=10, placeholder="...") 14 | # => 'Hello...' 15 | ``` 16 | 17 | [source](https://stackoverflow.com/questions/2872512/python-truncate-a-long-string) 18 | 19 | ```python 20 | '{:.5}'.format('xylophone') 21 | # => 'xylop' 22 | ``` 23 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/javascript/npm/commands/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: How to run the NPM CLI's commands 3 | --- 4 | # Commands 5 | 6 | 7 | ### Logging tip 8 | 9 | From [loglevel](https://docs.npmjs.com/cli/v7/using-npm/config#loglevel) in config docs. 10 | 11 | Change the verbosity of logging. 12 | 13 | Default: `"notice"` 14 | 15 | Values allowed: 16 | 17 | > "silent", "error", "warn", "notice", "http", "timing", "info", "verbose", or "silly" 18 | 19 | 20 | e.g. 21 | 22 | ```sh 23 | $ npm install --loglevel warn 24 | ``` 25 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/react/download.md: -------------------------------------------------------------------------------- 1 | # Download 2 | 3 | 4 | ## CDN 5 | 6 | - [unpkg.com/react@17/umd/react.development.js](https://unpkg.com/react@17/umd/react.development.js) 7 | - [unpkg.com/react-dom@17/umd/react-dom.development.js](https://unpkg.com/react-dom@17/umd/react-dom.development.js) 8 | - [dev.jspm.io/react@17.0.1](https://dev.jspm.io/react@17.0.1). Variations: `react`, `react@17`, `react@17.0` and `react@17.0.2`. 9 | 10 | 11 | ## NPM 12 | 13 | - [npmjs.com/package/react](https://www.npmjs.com/package/react) 14 | 15 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/vue/white-space.md: -------------------------------------------------------------------------------- 1 | # Whitespace 2 | 3 | Show a value as multi-line text. 4 | 5 | ```javascript 6 | text = "abc\n\ndef" 7 | ``` 8 | 9 | Use CSS. 10 | 11 | ```html 12 |

13 | {{ text }} 14 |
15 | ``` 16 | 17 | Or you can replace `\n` with `
` and also use `v-html` so it sets as `innerHTML` rather than just as literal `\n` text. But it has a security concern if you use user-generated data. 18 | 19 | ```javascript 20 | text.replace(/(?:\r\n|\r|\n)/g, '
'); 21 | ``` 22 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/os/homebrew/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: A commonly-used macOS package manager 3 | --- 4 | # Homebrew 5 | 6 | 7 | ### Resources 8 | 9 | - [Homebrew Cheatsheet](https://devhints.io/homebrew) on _DevHints_. 10 | - [Homebrew docs](https://docs.brew.sh/) homepage 11 | - [Homebrew Tips N' Tricks](https://docs.brew.sh/Tips-N%27-Tricks) in the docs 12 | 13 | 14 | 15 | ### Install Devtools 16 | 17 | This is for Xcode but may be needed when installing with Brew. 18 | 19 | ```sh 20 | $ xcode-select --install 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/python/pip/show.md: -------------------------------------------------------------------------------- 1 | # Show 2 | 3 | Find where a package is installed. 4 | 5 | For a global install: 6 | 7 | ```console 8 | $ pip install requests 9 | $ pip show requests 10 | Name: requests 11 | Version: 2.26.0 12 | Summary: Python HTTP for Humans. 13 | Home-page: https://requests.readthedocs.io 14 | Author: Kenneth Reitz 15 | Author-email: me@kennethreitz.org 16 | License: Apache 2.0 17 | Location: /usr/local/lib/python3.9/site-packages 18 | Requires: certifi, charset-normalizer, urllib3, idna 19 | Required-by: 20 | ``` 21 | -------------------------------------------------------------------------------- /cheatsheets/python/formatting/black.md: -------------------------------------------------------------------------------- 1 | # Black 2 | 3 | Format with the [black](https://pypi.org/project/black/) command. 4 | 5 | 6 | ## Apply fixes 7 | 8 | This is useful for local development. 9 | 10 | This command will apply fixes in place and show any fatal errors. 11 | 12 | ```sh 13 | $ black . 14 | ``` 15 | 16 | ## Check 17 | 18 | This is useful for a CI flow. 19 | 20 | This command will print the fixes needed without applying them and exit with error status if fixes need to be applied. 21 | 22 | ```sh 23 | $ black . --diff --check 24 | ``` 25 | -------------------------------------------------------------------------------- /cheatsheets/javascript/format-and-lint/prettier/install.md: -------------------------------------------------------------------------------- 1 | # Install 2 | 3 | Install it globally. 4 | 5 | ```sh 6 | $ npm i -g prettier 7 | $ prettier -h 8 | ``` 9 | 10 | Or install it in a project. 11 | 12 | ```sh 13 | $ npm i --save-dev prettier 14 | ``` 15 | 16 | If you've set it up in your NPM scripts, you can run like this: 17 | 18 | ```sh 19 | $ npm run format 20 | ``` 21 | 22 | Otherwise, run ad hoc commands on the CLI as: 23 | 24 | ```sh 25 | $ npx prettier 26 | ``` 27 | 28 | Using `npx` here works even if `prettier` is not installed anywhere. 29 | -------------------------------------------------------------------------------- /cheatsheets/python/libraries/queue-messaging/rq.md: -------------------------------------------------------------------------------- 1 | # Redis Queue (RQ) 2 | 3 | RQ is a simple Python library for queueing jobs and processing them in the background with workers. 4 | 5 | ## Key Features 6 | - Simple to use and deploy 7 | - Uses Redis as its backend 8 | - Supports job prioritization 9 | 10 | ## Basic Usage 11 | 12 | ```python 13 | from redis import Redis 14 | from rq import Queue 15 | 16 | q = Queue(connection=Redis()) 17 | 18 | 19 | def my_job(param1, param2): 20 | return param1 + param2 21 | 22 | 23 | job = q.enqueue(my_job, 1, 2) 24 | ``` -------------------------------------------------------------------------------- /cheatsheets/ruby/ruby-managers.md: -------------------------------------------------------------------------------- 1 | # Ruby managers 2 | 3 | Install Ruby with an environment manager. 4 | 5 | You might prefer to use Ruby environment managers like: 6 | 7 | - [rbenv](https://github.com/rbenv/rbenv) - see [blog post](https://richstone.io/where-is-ruby-3-0-0-on-rbenv/) 8 | - [rvm](https://rvm.io/) 9 | 10 | ```sh 11 | $ rbenv install 3.0.0 12 | 13 | $ rvm install 3.0 14 | $ rvm use 3.0 15 | ``` 16 | 17 | I've never used them as I've never had to. 18 | 19 | If your Linux distro doesn't support Ruby 3 yet, you might have to use one of the above. 20 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/committing/auto.md: -------------------------------------------------------------------------------- 1 | # Auto commit 2 | 3 | Shell flow to apply remote changes, run a script to update a versioned file then commit and push changes. 4 | 5 | A pre-configured commit message is used. 6 | 7 | ```sh 8 | FILENAME=foo.txt 9 | 10 | git pull --no-edit 11 | 12 | # ... do work 13 | 14 | if [ -z "$(git status --porcelain)" ]; then 15 | echo 'No changes to commit' 16 | else 17 | echo 'Committing and pushing changes' 18 | git commit $FILENAME -m "Cron task - Update $FILENAME" 19 | git push 20 | fi 21 | ``` 22 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/scp.md: -------------------------------------------------------------------------------- 1 | # scp 2 | 3 | See [tutorial](https://www.computerhope.com/unix/scp.htm). 4 | 5 | 6 | ## Copy to remote 7 | 8 | Copy file. 9 | 10 | ```sh 11 | $ scp ~/images/foo.jpg my-user@myhost.com:~/my_images 12 | ``` 13 | 14 | Copy files. 15 | 16 | ```sh 17 | $ scp ~/images/*.jpg my-user@myhost.com:~/my_images 18 | ``` 19 | 20 | Copy directory. 21 | 22 | ```sh 23 | $ scp -r ~/images my-user@myhost.com:~/my_images 24 | ``` 25 | 26 | 27 | ## Copy to local 28 | 29 | ```sh 30 | $ scp my-user@myhost.com:~/my_images/*.jpg ~/images/ 31 | ``` 32 | -------------------------------------------------------------------------------- /cheatsheets/other/vscode/emmet.md: -------------------------------------------------------------------------------- 1 | # Emmet shortcuts 2 | 3 | See [Emmet](https://docs.emmet.io/) homepage. 4 | 5 | Smart code generation for less typing. 6 | 7 | Description | Input 8 | --- | --- 9 | HTML boilerplate | `!` + `spacebar` 10 | Nested elements | `div` + `>` + `p` + `spacebar` 11 | Multiple elements | `li` + `*` + `3` + `spacebar` 12 | Div with class | `.class-name` + `spacebar` 13 | Any element With class | `h1` + `.class-name` + `spacebar` 14 | Lorem Ipsum in element | `p` + `>` + `lorem` + `spacebar` 15 | Sibling element | `h2` + `+` + `p` + `spacebar` 16 | -------------------------------------------------------------------------------- /cheatsheets/shell/searching.md: -------------------------------------------------------------------------------- 1 | # Searching 2 | 3 | 4 | Based on [Find it Faster](https://marketplace.visualstudio.com/items?itemName=TomRijndorp.find-it-faster) VS Code extension, which depends on these being installed: 5 | 6 | - [fzf][] - find files by name using fuzzy search pattern 7 | - [rg][] - search contents across files, using `.gitignore`. 8 | - [bat][] - find a pattern within a file. 9 | 10 | [fzf]: {% link cheatsheets/shell/commands/fzf.md %} 11 | [bat]: {% link cheatsheets/shell/commands/bat.md %} 12 | [rg]: {% link cheatsheets/shell/commands/grep/rg.md %} 13 | -------------------------------------------------------------------------------- /cheatsheets/containers/docker/dockerfile/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: docker 3 | description: Guide to synax for a `Dockerfile` file 4 | --- 5 | # Dockerfile 6 | 7 | See [Dockerfile reference](https://docs.docker.com/engine/reference/builder/) doc. 8 | 9 | 10 | ### Overview 11 | 12 | 13 | 14 | `Dockerfile` 15 | ```Dockerfile 16 | FROM image-name 17 | 18 | ENV foo=bar 19 | ARG fizz=buzz 20 | 21 | RUN apt-get update 22 | RUN apt install -q -y foo 23 | 24 | RUN echo "Hello" 25 | ``` 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /cheatsheets/python/transpose-array.md: -------------------------------------------------------------------------------- 1 | # Transpose array 2 | 3 | Given a 2D array. 4 | 5 | ```python 6 | matrix = [ 7 | [1,2,3], 8 | [4,5,6], 9 | [7,8,9] 10 | ] 11 | ``` 12 | 13 | And you want result: 14 | 15 | ```python 16 | [ 17 | [1,4,7], 18 | [2,5,8], 19 | [3,6,9] 20 | ] 21 | ``` 22 | 23 | Do this: 24 | 25 | ```python 26 | result = zip(*matrix) 27 | ``` 28 | 29 | Explanation: 30 | 31 | ``` 32 | x = ['a', 'b', 'c'] 33 | y = 1, 2, 3] 34 | list(zip(x, y)) 35 | # [ 36 | # ('a', 1), 37 | # ('b', 2), 38 | # ('c', 3) 39 | # ] 40 | ``` 41 | -------------------------------------------------------------------------------- /cheatsheets/python/type-checks/data-structures/no-structure.md: -------------------------------------------------------------------------------- 1 | # No structure 2 | 3 | Using parameters only. 4 | 5 | For some cases you might be okay without a naming a structure as a type. Go for a simpler approach of just using a function expecting 2 or 3 named parameters with types. 6 | 7 | ```python 8 | def foo(name: str, age: int, height: Optional[float]): -> None 9 | print(name) 10 | print(age >= 18) 11 | print(height) 12 | ``` 13 | 14 | If there are more fields and if you want to use the type outside the function, rather make a type or class, like `Person`. 15 | -------------------------------------------------------------------------------- /cheatsheets/version-control/github/api/v4/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: V4 GraphQL 3 | logo: graphql 4 | 5 | description: About the GitHub V4 GraphQL API 6 | --- 7 | 8 | 9 | ## Resources 10 | 11 | - [GitHub GQL Resources](https://michaelcurrin.github.io/dev-resources/resources/version-control/github/graphql.html) 12 | - [Explorer](https://developer.github.com/v4/explorer/) 13 | 14 | 15 | ## Steps 16 | 17 | 1. Go to the GraphQL API explorer: 18 | 1. Sign in as your GitHub account. 19 | 1. Paste a query. 20 | 1. Include JSON data payload in Query Variables section. 21 | 1. Run query. 22 | -------------------------------------------------------------------------------- /cheatsheets/data/yaml/data-structures.md: -------------------------------------------------------------------------------- 1 | # Data structures 2 | 3 | YAML is a superset of JSON, so you can use JSON syntax, or the ligher YAML syntax, even without quotes. 4 | 5 | 6 | ## Arrays 7 | 8 | Empty array. 9 | 10 | ```yaml 11 | my_array: [] 12 | ``` 13 | 14 | Two strings and an integer. 15 | 16 | ```yaml 17 | my_array: [abc, def, 123] 18 | my_array: 19 | - abc 20 | - def 21 | - 123 22 | ``` 23 | 24 | 25 | ## Dictionaries 26 | 27 | ```yaml 28 | my_dict: {} 29 | 30 | my_dict: { "abc": "Hello", "def": 20 } 31 | my_dict: 32 | abc: Hello 33 | def: 20 34 | ``` 35 | -------------------------------------------------------------------------------- /cheatsheets/nosql/mongodb/advanced-features.md: -------------------------------------------------------------------------------- 1 | # Advanced Features 2 | 3 | ## Replication 4 | 5 | Replication allows you to create redundant copies of your data across multiple servers, providing high availability and fault tolerance. 6 | 7 | ## Sharding 8 | 9 | Sharding is a horizontal scaling technique that allows you to distribute data across multiple servers, enabling your database to scale out as your data grows. 10 | 11 | ## Transactions 12 | 13 | MongoDB supports multi-document transactions, allowing you to perform multiple operations as an all-or-nothing unit of work. 14 | 15 | -------------------------------------------------------------------------------- /cheatsheets/python/libraries/queue-messaging/celery.md: -------------------------------------------------------------------------------- 1 | # Celery 2 | 3 | Celery is a distributed task queue system for Python. 4 | 5 | ## Key Features 6 | 7 | - Asynchronous task execution 8 | - Distributed architecture 9 | - Multiple broker support (RabbitMQ, Redis, etc.) 10 | - Periodic task scheduling 11 | 12 | ## Basic Usage 13 | 14 | ```python 15 | from celery import Celery 16 | 17 | app = Celery('tasks', broker='pyamqp://guest@localhost//') 18 | 19 | 20 | @app.task 21 | def add(x, y): 22 | return x + y 23 | 24 | 25 | # To call the task 26 | result = add.delay(4, 4) 27 | ``` -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | default: install 2 | 3 | all: hooks install build 4 | 5 | h help: 6 | @grep '^[a-z]' Makefile 7 | 8 | 9 | .PHONY: hooks 10 | hooks: 11 | cd .git/hooks && ln -s -f ../../hooks/pre-push pre-push 12 | 13 | install: 14 | bundle config set --local path vendor/bundle 15 | bundle install 16 | 17 | upgrade: 18 | bundle clean 19 | bundle update 20 | 21 | 22 | s serve: 23 | bundle exec jekyll serve --trace --livereload 24 | i serve-i: 25 | bundle exec jekyll serve --trace --livereload --incremental 26 | 27 | build: 28 | JEKYLL_ENV=production bundle exec jekyll build --trace 29 | -------------------------------------------------------------------------------- /cheatsheets/containers/docker-compose/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Docker Compose 3 | description: A tool that makes docker containers easier to manage 4 | --- 5 | 6 | Docker compose allows orchestration of multiple containers. It allows you to store and run parameters against those containers without typing each time. 7 | 8 | From CLI help: 9 | 10 | > Define and run multi-container applications with Docker. 11 | 12 | 13 | ### Resources 14 | 15 | - [Docker compose](https://michaelcurrin.github.io/dev-resources/resources/containers/docker-compose.html) section of my Dev Resources project. 16 | -------------------------------------------------------------------------------- /cheatsheets/containers/docker/intro/hello-world.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Hello world 3 | description: The most basic use of Docker CLI and way to test that Docker works 4 | --- 5 | 6 | ```sh 7 | $ docker run hello-world 8 | ``` 9 | 10 | Output: 11 | 12 | ``` 13 | Unable to find image 'hello-world:latest' locally 14 | latest: Pulling from library/hello-world 15 | ... 16 | 17 | Hello from Docker! 18 | This message shows that your installation appears to be working correctly. 19 | ... 20 | ``` 21 | 22 | If you installed using `sudo apt install ...` then you might have to run `sudo docker ...`. 23 | -------------------------------------------------------------------------------- /cheatsheets/other/indentation.md: -------------------------------------------------------------------------------- 1 | # Indentation 2 | 3 | All my favorite languages and formats in one place. 4 | 5 | 6 | ## 2 spaces 7 | 8 | - Ruby 9 | - Bash 10 | - JavaScript 11 | - Sometimes 4 spaces 12 | - Sometimes tabs. 13 | 14 | 15 | ## 4 spaces 16 | 17 | - Python 18 | - Although some argue for tabs. 19 | - Java 20 | - Markdown 21 | - You can use 2 spaces, but in some cases around nesting bullet points you must use 4 spaces to get desired functionality. 22 | - Tabs also work, but less common. 23 | 24 | 25 | ## Tabs 26 | 27 | - GraphQL 28 | - Makefile 29 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/bundler/subcommands/add.md: -------------------------------------------------------------------------------- 1 | # add subcommand 2 | 3 | > Adds the specified gem to Gemfile (if valid) and run 'bundle install' in one step. 4 | 5 | ```sh 6 | $ bundle add GEM VERSION 7 | ``` 8 | 9 | Example: 10 | 11 | ```sh 12 | $ bundle add jekyll-optional-front-matter 13 | ``` 14 | 15 | Line appended to `Gemfile`: 16 | 17 | ```ruby 18 | gem "jekyll-optional-front-matter", "~> 0.3.2" 19 | ``` 20 | 21 | Output: 22 | 23 | ``` 24 | Fetching gem metadata from https://rubygems.org/.......... 25 | ... 26 | Using jekyll-optional-front-matter 0.3.2 27 | ``` 28 | -------------------------------------------------------------------------------- /cheatsheets/shell/files/text-files/dotenv.md: -------------------------------------------------------------------------------- 1 | # Dotenv 2 | 3 | > A load a dotenv file. 4 | 5 | Export the vars in `.env` file into your shell. 6 | 7 | Simple 8 | 9 | ```sh 10 | export $(< .env) | xargs) 11 | ``` 12 | 13 | Check if it exists first and ignore comments. 14 | 15 | ```sh 16 | if [ -f .env ]; then 17 | export $(egrep -v '^#' .env | xargs) 18 | fi 19 | ``` 20 | 21 | [Gist source](https://gist.github.com/judy2k/7656bfe3b322d669ef75364a46327836) 22 | 23 | See also in my cookbook: 24 | 25 | - [dotenv](https://michaelcurrin.github.io/code-cookbook/recipes/shell/dotenv.html) 26 | -------------------------------------------------------------------------------- /cheatsheets/other/regex/exclude.md: -------------------------------------------------------------------------------- 1 | # Exclude 2 | 3 | ## Exclude characters 4 | 5 | Use `^` inside `[]` to exclude. Note `a-z` will work and a `-` must be at the start of the end to match a literal `-`. 6 | 7 | ```re 8 | [^\w-] 9 | ``` 10 | 11 | ## Exclude words 12 | 13 | Source: [regextester](https://www.regextester.com/15) 14 | 15 | ```re 16 | ^((?!badword).)*$ 17 | ``` 18 | 19 | ``` 20 | badword 21 | test # match 22 | one two # match 23 | abadwords 24 | three # match 25 | ``` 26 | 27 | Multiple exclusions: 28 | 29 | ```re 30 | ?!(foo|bar) 31 | 32 | ?!(http|[{#]) 33 | ``` 34 | -------------------------------------------------------------------------------- /cheatsheets/shell/network-manager.md: -------------------------------------------------------------------------------- 1 | # Network manager 2 | 3 | - [Network Manager on Linux with Examples](https://devconnected.com/network-manager-on-linux-with-examples/) 4 | 5 | The Network Manager provides the following tools: 6 | 7 | - `nmcli` - CLI tool to configure, add, edit, and remove connections. 8 | - `nmtui` - GUI tool with a subset of features. You can edit a connection, activate a connection or change the hostname of your computer. 9 | - `nm-applet` - available in GNOME desktop environments. An interface overlay which can be used in order to connect or disconnect from networks. 10 | -------------------------------------------------------------------------------- /cheatsheets/shell/scripting/copy.md: -------------------------------------------------------------------------------- 1 | # Copy 2 | 3 | See also `cp` under Commands section. 4 | 5 | 6 | ## Directory 7 | 8 | ```sh 9 | cp -R SOURCE DEST 10 | ``` 11 | 12 | ## Interactive 13 | 14 | ```sh 15 | cp -i SOURCE DEST 16 | ``` 17 | 18 | ## Force 19 | 20 | ```sh 21 | cp -f SOURCE DEST 22 | ``` 23 | 24 | Note that will not work if you have interactive aliased. So you'll to reference the non-aliased form. Or do this. 25 | 26 | ```sh 27 | yes | cp SOURCE DEST 28 | ``` 29 | 30 | [answer on SO](https://stackoverflow.com/questions/8488253/how-to-force-cp-to-overwrite-without-confirmation) 31 | -------------------------------------------------------------------------------- /cheatsheets/terraform/cli-usage/import.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: How to import resources in TF 3 | --- 4 | # Import 5 | 6 | 7 | See [import](https://www.terraform.io/docs/commands/import.html) command in the docs. 8 | 9 | ```sh 10 | $ terraform import RESOURCE_TYPE.NAME ID 11 | ``` 12 | 13 | ```sh 14 | $ terraform import module.MODULE_NAME.RESOURCE_TYPE.NAME ID 15 | ``` 16 | 17 | ```sh 18 | $ terraform import 'RESOURCE_TYPE.NAME[0]' ID 19 | $ # e.g. 20 | $ terraform import 'datadog_synthetics_test.this[0]' ID 21 | $ terraform import 'module.my_module[0].datadog_synthetics_test.this' ID 22 | ``` 23 | -------------------------------------------------------------------------------- /cheatsheets/web/css/pseudo-selectors/user-action.md: -------------------------------------------------------------------------------- 1 | # User action 2 | 3 | - `:focus` - using keyboard (or mouse) 4 | - `:hover` - hover with mouse) 5 | - `:checked` for certain for elements 6 | - `:visited` for links 7 | 8 | 9 | ## Examples 10 | 11 | ### Button 12 | 13 | ```css 14 | /* Any button over which the user's pointer is hovering */ 15 | button:hover { 16 | color: blue; 17 | } 18 | ``` 19 | 20 | ### Links 21 | 22 | ```css 23 | a:link, 24 | a:visited { 25 | color: rebeccapurple; 26 | font-weight: bold; 27 | } 28 | 29 | a:hover { 30 | color:hotpink; 31 | } 32 | ``` 33 | -------------------------------------------------------------------------------- /docs/installation.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | 4 | ## Install system dependencies 5 | 6 | Install Ruby and Bundler - follow [gist](https://gist.github.com/MichaelCurrin/3af38fca4e2903cdedfb8402c18b2936). 7 | 8 | 9 | ## Clone 10 | 11 | Clone the repo or your fork. 12 | 13 | ```sh 14 | $ git clone git@github.com:MichaelCurrin/dev-cheatsheets.git 15 | $ cd dev-cheatsheets 16 | ``` 17 | 18 | ## Set up hooks 19 | 20 | ```sh 21 | $ make hooks 22 | ``` 23 | 24 | 25 | ## Install project dependencies 26 | 27 | Install gems - this includes Jekyll 4. 28 | 29 | ```sh 30 | $ make install 31 | ``` 32 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/es6.md: -------------------------------------------------------------------------------- 1 | # ES6 2 | 3 | Features introduced to JavaScript in ES6 aka ECMAScript 2015. 4 | 5 | - [map, reduce, filter][] 6 | - [spread or rest operator][] 7 | - [template literals][] 8 | - [closures][] 9 | 10 | [map, reduce, filter]: {% link cheatsheets/javascript/general/map-reduce-filter.md %} 11 | [spread or rest operator]: {% link cheatsheets/javascript/general/spread-operator.md %} 12 | [template literals]: {% link cheatsheets/javascript/general/strings/template-literals.md %} 13 | [closures]: {% link cheatsheets/javascript/general/variable-declaration/closures.md %} 14 | -------------------------------------------------------------------------------- /cheatsheets/shell/scripting/overview.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | A quick reference of basic syntax. 4 | 5 | Tip - if you use Bash and use a multi-line statement in the console, then when you press up to run it again it will be flattened to one line. 6 | 7 | 8 | ## If 9 | 10 | ```sh 11 | if true; then 12 | echo 'Success' 13 | fi 14 | 15 | if true; then echo 'Success'; fi 16 | ``` 17 | 18 | 19 | ## For 20 | 21 | ```sh 22 | for X in A B C; do 23 | echo $X 24 | done 25 | 26 | # One line. 27 | for X in A B C; do echo $x; done 28 | 29 | for X in ${MY_ARRAY[@]; do 30 | echo $X 31 | done 32 | ``` 33 | -------------------------------------------------------------------------------- /cheatsheets/javascript/deno/cli/releasing-asset.md: -------------------------------------------------------------------------------- 1 | # Releasing assets 2 | 3 | A bundled JS and compiled executable file can both be distributed. 4 | 5 | They both uploaded and attached as an asset on a GitHub Release. Use can even use GH Actions as CI to do this for you. 6 | 7 | Those assets be downloaded and run by others. 8 | 9 | Someone might download your binary and run it directly. 10 | 11 | You might use the bundle JS file in your own site's `index.html` page. Or serve it as a JS file or others to use. Like on NPM you can include your `dist` directory as assets, for use as NPM package installs. 12 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/liquid/variables.md: -------------------------------------------------------------------------------- 1 | # Variables 2 | 3 | {% raw %} 4 | 5 | 6 | ## Page variables 7 | 8 | For a page with path `demo/python/index.md`: 9 | 10 | ```liquid 11 | {{ page | inspect }} 12 | ``` 13 | 14 | ```ruby 15 | { 16 | "layout"=>"page", 17 | "title"=>"Python", 18 | "content"=>"", 19 | 20 | "dir"=>"/demo/python/", 21 | "name"=>"index.md", 22 | "path"=>"demo/python/index.md", 23 | 24 | "url"=>"/demo/python/" 25 | } 26 | ``` 27 | 28 | The value of `page.dir` is equivalent to: 29 | 30 | ```liquid 31 | {{ page.path | remove: page.name }} 32 | ``` 33 | 34 | {% endraw %} 35 | -------------------------------------------------------------------------------- /cheatsheets/python/libraries/queue-messaging/apache-kafka.md: -------------------------------------------------------------------------------- 1 | # Apache Kafka 2 | 3 | Kafka is a distributed streaming platform that can be used for building real-time data pipelines and streaming apps. 4 | 5 | ## Key Features 6 | - High-throughput, fault-tolerant, publish-subscribe messaging system 7 | - Scalable and durable storage 8 | - Stream processing 9 | 10 | ## Basic Usage with kafka-python 11 | 12 | ```python 13 | from kafka import KafkaProducer 14 | 15 | producer = KafkaProducer(bootstrap_servers=['localhost:9092']) 16 | 17 | producer.send('my-topic', b'Hello, Kafka!') 18 | producer.flush() 19 | ``` -------------------------------------------------------------------------------- /cheatsheets/shell/files/text-files/head-and-tail.md: -------------------------------------------------------------------------------- 1 | # Head and tail commands 2 | 3 | ## Head 4 | 5 | Get first 10 lines. 6 | 7 | ``` 8 | head PATH 9 | ``` 10 | 11 | Get first N lines. 12 | 13 | ```sh 14 | head -n N PATH 15 | ``` 16 | 17 | ## Tail 18 | 19 | ```sh 20 | tail PATH 21 | ``` 22 | 23 | ```sh 24 | tail -n PATH 25 | ``` 26 | 27 | Watch file. There is also `-f` but I think `-F` works even if the file does not exist initially. 28 | 29 | ```sh 30 | tail -F PATH 31 | ``` 32 | 33 | ## Head and tail 34 | 35 | Get a portion of a file. 36 | 37 | ```sh 38 | head -n 20 PATH | tail -n 10 39 | ``` 40 | -------------------------------------------------------------------------------- /cheatsheets/shell/scripting/docstring.md: -------------------------------------------------------------------------------- 1 | # Docstring 2 | 3 | 4 | ## Format 5 | 6 | 7 | ```sh 8 | # FUNCTION_NAME ARG1 ARG2 9 | # ----------------------- 10 | # MY_DESCRIPTION 11 | # ... 12 | # ... 13 | FUNCTION_NAME () { 14 | MY_LOGIC 15 | } 16 | ``` 17 | 18 | ## Example 19 | 20 | See [configure](https://github.com/python/cpython/blob/main/configure) in CPython repo. 21 | 22 | ```sh 23 | # as_fn_executable_p FILE 24 | # ----------------------- 25 | # Test if FILE is an executable regular file. 26 | as_fn_executable_p () 27 | { 28 | test -f "$1" && test -x "$1" 29 | } # as_fn_executable_p 30 | ``` 31 | -------------------------------------------------------------------------------- /cheatsheets/python/type-checks/basics/union.md: -------------------------------------------------------------------------------- 1 | # Union 2 | 3 | Use Union to allow a variable to be one of given types or values. 4 | 5 | ## Python 3.10 6 | 7 | ```python 8 | TYPE | TYPE | TYPE 9 | 10 | # e.g. 11 | float | int | str 12 | ``` 13 | 14 | 15 | 16 | ## Python 3.8 17 | 18 | ```python 19 | Union[TYPE, TYPE, ...] 20 | 21 | # e.g. 22 | Union[float, int, str] 23 | ``` 24 | 25 | 26 | ## Example 27 | 28 | Here we allow return value as integer or string. 29 | 30 | ```python 31 | def bar(bazz: bool) -> int | str: 32 | if bazz: 33 | return 'Yes' 34 | 35 | return 12 36 | ``` 37 | 38 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/read-write/tail.md: -------------------------------------------------------------------------------- 1 | # tail 2 | 3 | 4 | ## End of file 5 | 6 | Get the last 10 lines of a file. 7 | 8 | ```sh 9 | $ tail file.txt 10 | ``` 11 | 12 | Get the last 100 lines of a file. 13 | 14 | ```sh 15 | $ tail -n 100 file.txt 16 | ``` 17 | 18 | 19 | ## Follow 20 | 21 | This command will watch continuously for output and not exit. 22 | 23 | ```sh 24 | $ tail -f 25 | ``` 26 | 27 | Or 28 | 29 | ```sh 30 | $ tail -f > /dev/null 31 | ``` 32 | 33 | 34 | ## Selection 35 | 36 | Get lines 300 to 450 of a file. 37 | 38 | ```sh 39 | $ head -n 450 file.txt | tail -n 150 40 | ``` 41 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/submodules/github-view.md: -------------------------------------------------------------------------------- 1 | # GitHub view 2 | 3 | If you view a submodule on GitHub, you get a reference to the directory name and the commit. 4 | 5 | e.g. 6 | 7 | In the [themes](https://github.com/MichaelCurrin/hugo-quickstart/tree/master/themes) directory on my Hugo Quickstart, the submodule `ananke` is displayed in the GitHub UI as: 8 | 9 | - `ananke @ 0cc2c6c` 10 | 11 | In the [themes](https://github.com/MichaelCurrin/hexo-quickstart/tree/master/themes) directory of my Hexo Quickstart, the submodule `landscape` shows as 12 | 13 | - `landscape @ f20626c` 14 | 15 | 16 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/react/hooks/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Hooks 3 | description: Manage state in React components 4 | --- 5 | 6 | Hooks were added in React 16.8 and let you use state and lifecycle methods in a functional component, where before you had to use a class component. 7 | 8 | Note that hooks must be used in functions and not nested within each other. You cannot add a `useState` hook within a `useEffect` hook. 9 | 10 | 11 | ## Resources 12 | 13 | - [Intro to Hooks](https://reactjs.org/docs/hooks-intro.html) in the docs. 14 | - [Hooks at a glance](https://reactjs.org/docs/hooks-overview.html) 15 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/vue/events/types.md: -------------------------------------------------------------------------------- 1 | # Types 2 | 3 | Use like `@click`. Or chain events and modifiers as in other cheatsheet pages. 4 | 5 | 6 | ## Common event types 7 | 8 | Event name | Description 9 | --- | --- 10 | `click` | When the element is clicked 11 | `input` | Fires when user changes an input value. 12 | `change` | Fires when user changes the value and unfocusses input (for example, clicked somewhere outside) 13 | `keyup` | listen for keyboard events. 14 | 15 | There are a lot more. Use VS Code and a Vue extension and it will suggest all values when adding `@` to an element. 16 | 17 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/read-write/vis.md: -------------------------------------------------------------------------------- 1 | # vis 2 | 3 | ## Help 4 | 5 | ``` 6 | NAME 7 | vis -- display non-printable characters in a visual format 8 | 9 | SYNOPSIS 10 | vis [-cbflnostw] [-F foldwidth] [file ...] 11 | 12 | DESCRIPTION 13 | The vis utility is a filter for converting non-printable characters into a visual representation. 14 | It differs from `cat -v' in that the form is unique and invertible. By default, all non-graphic 15 | characters except space, tab, and newline are encoded. A detailed description of the various 16 | visual formats is given in vis(3). 17 | ``` 18 | -------------------------------------------------------------------------------- /cheatsheets/sql/advanced/update-table.md: -------------------------------------------------------------------------------- 1 | # Update table 2 | 3 | Recommended - do this in a **transaction**. 4 | 5 | Here we change the type of a column such as `VARCHAR(8)` to `VARCHAR(1024)`. We have to create an new column, copy the data to it and then get rid of the old column and rename the new one. 6 | 7 | - `query.sql` 8 | ```sql 9 | LOCK table_name; 10 | ALTER TABLE table_name ADD COLUMN column_new column_type; 11 | UPDATE table_name SET column_new = column_name; 12 | ALTER TABLE table_name DROP column_name; 13 | ALTER TABLE table_name RENAME column_new TO column_name; 14 | ``` 15 | -------------------------------------------------------------------------------- /cheatsheets/web/css/transform.md: -------------------------------------------------------------------------------- 1 | # Transform 2 | 3 | ## Examples 4 | 5 | ### Rotate 6 | 7 | ```css 8 | div.a { 9 | transform: rotate(20deg); 10 | } 11 | ``` 12 | 13 | ### Skew 14 | 15 | ```css 16 | div.b { 17 | transform: skewY(20deg); 18 | } 19 | ``` 20 | 21 | ### Scale 22 | 23 | `scale` or `scaleX` or `scaleY`. 24 | 25 | ```css 26 | div.c { 27 | transform: scaleY(1.5); 28 | } 29 | ``` 30 | 31 | ### Translate 3D 32 | 33 | ``` 34 | translate3d(-20%, 12%, 0); 35 | ``` 36 | 37 | ### Combined 38 | 39 | ```css 40 | el { 41 | transform: skewY(-10deg) scale(1.2) translate3d(-20%, 12%, 0); 42 | } 43 | ``` 44 | -------------------------------------------------------------------------------- /cheatsheets/javascript/deno/ignoring-rules.md: -------------------------------------------------------------------------------- 1 | # Ignoring rules 2 | 3 | 4 | 5 | ## Ignore deno rule 6 | 7 | ```typescript 8 | // deno-lint-ignore no-undef 9 | document.getElementById('root') 10 | ``` 11 | 12 | 13 | ## Ignore TypeScript rule 14 | 15 | See [Ignoring rules][] in the TypeScript section of Dev Cheatsheets. 16 | 17 | [Ignoring rules]: {% link cheatsheets/typescript/ignoring-rules.md %} 18 | 19 | 20 | ## Semantic checking 21 | 22 | Must be at the top of a file. 23 | 24 | Enable: 25 | 26 | ```typescript 27 | // @ts-check 28 | ``` 29 | 30 | Disable: 31 | 32 | ```typescript 33 | // @ts-no-check 34 | ``` 35 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/react/refs.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Refs 3 | description: Used to access DOM nodes or React elements created in the render method 4 | --- 5 | 6 | See [Refs and the DOM][] doc. 7 | 8 | [Refs and the DOM]: https://reactjs.org/docs/refs-and-the-dom.html 9 | 10 | ## Use-cases 11 | 12 | - Managing focus, text selection, or media playback. 13 | - Triggering imperative animations. 14 | - Integrating with third-party DOM libraries. 15 | 16 | Avoid using refs for anything that can be done declaratively. 17 | 18 | 19 | ## Access refs 20 | 21 | ```javascript 22 | const node = this.myRef.current; 23 | ``` 24 | -------------------------------------------------------------------------------- /cheatsheets/other/share-code.md: -------------------------------------------------------------------------------- 1 | # Share code 2 | 3 | 4 | 5 | - [pastebin.com/](https://pastebin.com/) 6 | - [sourceb.in](https://sourceb.in) 7 | - See also [sourcebin](https://www.npmjs.com/package/sourcebin) NPM package. 8 | > This wrapper is designed to easily create and get bins from sourcebin. You are also able to shorten the sourcebin links. 9 | - [hastebin.com](https://hastebin.com) 10 | 11 | See this [article](https://www.makeuseof.com/tag/4-alternatives-that-may-be-better-than-pastebin/) about some of these kind of tools. 12 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/grep/resources.md: -------------------------------------------------------------------------------- 1 | # Resources 2 | 3 | ## Homepage 4 | 5 | - [Grep](https://www.gnu.org/software/grep/) on the GNU site. 6 | 7 | 8 | ## Man page 9 | 10 | - Linux: [ss64.com/bash/grep.html](https://ss64.com/bash/grep.html) 11 | 12 | 13 | ## Tutorials 14 | 15 | - [Grep](https://www.tutorialspoint.com/unix_commands/grep.htm) on TutorialsPoint. 16 | - [Linux grep command](https://www.computerhope.com/unix/ugrep.htm) 🔗 17 | - [Linux egrep command](https://www.computerhope.com/unix/uegrep.htm) 🔗 18 | - [Grep command in Linux Unix](https://www.journaldev.com/24271/grep-command-in-linux-unix) 🔗 19 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/react/hooks/callback.md: -------------------------------------------------------------------------------- 1 | # Callback hook 2 | 3 | > Returns a memoized callback. 4 | 5 | > Pass an inline callback and an array of dependencies. 6 | > 7 | > `useCallback` will return a memoized version of the callback that only changes if one of the dependencies has changed. 8 | > 9 | > This is useful when passing callbacks to optimized child components that rely on reference equality to prevent unnecessary renders (e.g. shouldComponentUpdate). 10 | 11 | Compare with `useMemo` - these are equivalent: 12 | 13 | ```javascript 14 | useCallback(fn, deps) 15 | 16 | useMemo(() => fn, deps) 17 | ``` 18 | -------------------------------------------------------------------------------- /cheatsheets/web/html/clickable.md: -------------------------------------------------------------------------------- 1 | # Clickable 2 | 3 | If you want to make any element appear that it is clickable like a button or anchor tag. 4 | 5 | Set the cursor on that object to `pointer`. Note that you do **not** need the `:hover` modifier for this work. 6 | 7 | Here the hover behavior is set to change the text color on hover. 8 | 9 | - HTML: 10 | ```html 11 |

My text

12 | ``` 13 | - CSS: 14 | ```css 15 | .my-class { 16 | cursor: pointer; 17 | color: blue; 18 | } 19 | 20 | .my-class:hover { 21 | color: purple; 22 | } 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/dataviz/apex-charts/logarithm.md: -------------------------------------------------------------------------------- 1 | # Logarithm 2 | 3 | From [Multiple Y-axis scales](https://apexcharts.com/docs/chart-types/multiple-yaxis-scales/). 4 | 5 | ```javascript 6 | { 7 | series: [ 8 | { 9 | name: 'Linear', 10 | data: [1, 20, 14, 45, 15, 28, 38, 46] 11 | }, 12 | { 13 | name: 'Logarithmic', 14 | data: [10000, 124400, 244223, 3665232, 73452344, 875230623] 15 | } 16 | ], 17 | yaxis: [ 18 | { 19 | seriesName: 'Linear', 20 | }, 21 | { 22 | seriesName: 'Logarithmic', 23 | logarithmic: true 24 | } 25 | ], 26 | } 27 | ``` 28 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/express/index.md: -------------------------------------------------------------------------------- 1 | # Express 2 | 3 | Express is a Node web application framwork, which can be used for serving static assets, building APIs and integratng with middlewares. 4 | 5 | ### Resources 6 | 7 | - [expressjs.com](https://expressjs.com/) homepage. 8 | - [express](https://www.npmjs.com/package/express) package on NPM. 9 | 10 | See also project - [MichaelCurrin/express-js-rest-quickstart](https://github.com/MichaelCurrin/express-js-rest-quickstart). Including the notes in the docs. 11 | 12 | 13 | ## Install 14 | 15 | Install Express. 16 | 17 | ```sh 18 | $ npm install express 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /cheatsheets/python/libraries/ipython.md: -------------------------------------------------------------------------------- 1 | # IPython 2 | 3 | ## Markdown 4 | 5 | Useful if you have result from a function call and you want to display it with formatting. 6 | 7 | ```python 8 | from IPython.display import Markdown 9 | 10 | Markdown(value) 11 | ``` 12 | 13 | 14 | ## HTML 15 | 16 | ```python 17 | from IPython.display import HTML 18 | 19 | html = HTML(image_html) 20 | ``` 21 | 22 | Render the HTML: 23 | 24 | ```python 25 | from IPython.display import display 26 | 27 | display(html) 28 | ``` 29 | 30 | ## Image 31 | 32 | ```python 33 | from IPython.display import Image 34 | 35 | Image(filename=image_path) 36 | ``` 37 | -------------------------------------------------------------------------------- /cheatsheets/data/toml/sample.md: -------------------------------------------------------------------------------- 1 | # Sample 2 | 3 | - `sample.toml` 4 | ```toml 5 | # This is a TOML document 6 | 7 | title = "TOML Example" 8 | 9 | [owner] 10 | name = "Tom Preston-Werner" 11 | dob = 1979-05-27T07:32:00-08:00 12 | 13 | [database] 14 | enabled = true 15 | ports = [ 8000, 8001, 8002 ] 16 | data = [ ["delta", "phi"], [3.14] ] 17 | temp_targets = { cpu = 79.5, case = 72.0 } 18 | 19 | [servers] 20 | 21 | [servers.alpha] 22 | ip = "10.0.0.1" 23 | role = "frontend" 24 | 25 | [servers.beta] 26 | ip = "10.0.0.2" 27 | role = "backend" 28 | ``` 29 | 30 | 31 | -------------------------------------------------------------------------------- /cheatsheets/javascript/format-and-lint/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Formatting and linting JavaScript files 3 | --- 4 | # Format and lint 5 | 6 | See also [Format and lint](https://michaelcurrin.github.io/code-cookbook/recipes/javascript/format-and-lint/) section of my Cookbook. 7 | 8 | 9 | ### Ignore summary 10 | 11 | ### ES Lint 12 | 13 | Ignore linting rule on same line. 14 | 15 | ```javascript 16 | console.log("Hello, World"); // eslint-disable-line no-console 17 | ``` 18 | 19 | ### Prettier 20 | 21 | Ignore formatting rule on next line. 22 | 23 | ```javascript 24 | // prettier-ignore 25 | console.log("Hello, World") 26 | ``` 27 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/react/setup.md: -------------------------------------------------------------------------------- 1 | # Set up index script 2 | 3 | 4 | How to set up the index module of your React app. This is the entrypoint which loads your `App.jsx` file. 5 | 6 | With `render` method and strict mode: 7 | 8 | - `index.jsx` 9 | ```jsx 10 | ReactDOM.render( 11 | 12 | 13 | , 14 | document.getElementById("root"), 15 | ); 16 | ``` 17 | 18 | Or with `hydrate` method: 19 | 20 | - `index.jsx` 21 | ```jsx 22 | ReactDOM.hydrate( 23 | , 24 | document.getElementById('root') 25 | ); 26 | ``` 27 | -------------------------------------------------------------------------------- /cheatsheets/other/vscode-extensions/workflows/publish.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: How to publish your extension to the VS Code extension marketplace 3 | --- 4 | # Publish 5 | 6 | 7 | I haven't gone through that flow yet but the VS Code docs will help you out. See the [Publishing extensions](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) help guide if you want more info. 8 | 9 | Some other steps are needed first like `login` and `create-publisher`. 10 | 11 | When you are ready, run this this command: 12 | 13 | ```sh 14 | $ vsce publish 15 | # .myExtension published to VS Code MarketPlace 16 | ``` 17 | -------------------------------------------------------------------------------- /cheatsheets/python/libraries/queue-messaging/zmq.md: -------------------------------------------------------------------------------- 1 | # ZeroMQ (ZMQ) 2 | 3 | ZeroMQ is a high-performance asynchronous messaging library. 4 | 5 | ## Key Features 6 | - Supports various messaging patterns (pub/sub, request/reply, etc.) 7 | - No central broker, can be used for direct inter-process communication 8 | - Very fast and lightweight 9 | 10 | ## Basic Usage 11 | 12 | ```python 13 | import zmq 14 | 15 | context = zmq.Context() 16 | socket = context.socket(zmq.REP) 17 | socket.bind("tcp://*:5555") 18 | 19 | while True: 20 | message = socket.recv() 21 | print(f"Received request: {message}") 22 | socket.send(b"World") 23 | ``` -------------------------------------------------------------------------------- /cheatsheets/javascript/browser/network.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Network 3 | description: Get info about the user's network connection 4 | --- 5 | 6 | 7 | How to access: 8 | 9 | ```javascript 10 | navigator.connection 11 | ``` 12 | 13 | Attributes: 14 | 15 | - `.downloadlink` - bandwith speed in megabits/s. 16 | - `.effectiveType` - effective type such as `"3f"`. 17 | - `.rtt` - effective round-trip time. 18 | 19 | ## Resources 20 | 21 | - [Navigator.connection](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/connection) in Mozilla docs. 22 | - [Value](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation) that you get. 23 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/liquid/paths.md: -------------------------------------------------------------------------------- 1 | # Paths 2 | 3 | {% raw %} 4 | 5 | 6 | ## Split path 7 | 8 | ```liquid 9 | {% assign crumbs = page.url | split: '/' %} 10 | ``` 11 | 12 | For page with URL `/demo/python/pypi.html`: 13 | 14 | ```liquid 15 | {{ crumbs | inspect }} 16 | ``` 17 | 18 | ```json 19 | ["", "demo", "python", "pypi.html"] 20 | ``` 21 | 22 | Recombine: 23 | 24 | ```liquid 25 | {{ crumbs | join: '/' }} 26 | ``` 27 | ``` 28 | /demo/python/pypi.html 29 | ``` 30 | 31 | Use just a portion of the URL: 32 | 33 | ```liquid 34 | {{ crumbs | slice: 0, 3 | join: '/' }} 35 | ``` 36 | 37 | ``` 38 | /demo/python 39 | ``` 40 | 41 | {% endraw %} 42 | -------------------------------------------------------------------------------- /cheatsheets/make/variables/current-directory.md: -------------------------------------------------------------------------------- 1 | # Current directory 2 | 3 | From [SO](https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile). 4 | 5 | ## Basic 6 | 7 | ```mk 8 | current_dir = $(shell pwd) 9 | ``` 10 | 11 | ## Absolute path 12 | 13 | ```mk 14 | current_dir = $(notdir $(shell pwd)) 15 | ``` 16 | 17 | ## Flexible 18 | 19 | Or if invoking `Makefile` from any directory, such as using includes to load a Makefile in another directory. 20 | 21 | ```mk 22 | mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) 23 | current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path)))) 24 | ``` 25 | -------------------------------------------------------------------------------- /cheatsheets/python/strings/regex.md: -------------------------------------------------------------------------------- 1 | # Regex 2 | 3 | 4 | ## Import 5 | 6 | ```python 7 | import re 8 | ``` 9 | 10 | ## Pattern 11 | 12 | Compile a pattern and then use it later. This is more efficient if the pattern is reused as it just has to be compiled once. 13 | 14 | ```python 15 | PATTERN = re.compile(r"REGEX_PATTERN") 16 | ``` 17 | 18 | 19 | ## Match 20 | 21 | Using `.search` for anywhere in the string or `.match` for the start. 22 | 23 | ```python 24 | result = PATTERN.search(my_str) 25 | result = PATTERN.match(my_str) 26 | ``` 27 | 28 | Or using `re` directly. 29 | 30 | ```python 31 | result = re.search(pattern, my_str) 32 | ``` 33 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/committing/ci.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: CI 3 | description: How to commit and push with CI 4 | --- 5 | 6 | 7 | {% raw %} 8 | 9 | See [GH Actions Commit](https://michaelcurrin.github.io/code-cookbook/recipes/ci-cd/github-actions/workflows/commit.html) recipes for more info. 10 | 11 | ```sh 12 | git config --global user.name 'Automated Publisher' 13 | git config --global user.email 'actions@users.noreply.github.com' 14 | git commit -am "Commit message..." 15 | 16 | git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" 17 | git push 18 | ``` 19 | 20 | {% endraw %} 21 | -------------------------------------------------------------------------------- /cheatsheets/web/css/pseudo-selectors/overview.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | 4 | - [Pseudo-classes and pseudo-elements](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Pseudo-classes_and_pseudo-elements) 5 | - [Pseudo-classes](https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes) 6 | - [Pseudo-elements](https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements) 7 | 8 | Selectors target some bit of your document that is in a certain state, behaving as if you had added a class into your HTML. 9 | 10 | 11 | ## Syntax 12 | 13 | ```css 14 | selector::pseudo-element { 15 | property: value; 16 | } 17 | ``` 18 | 19 | -------------------------------------------------------------------------------- /cheatsheets/containers/kubernetes/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Kubernetes 3 | description: The tool that lets you manage and deploy pods of containers at scale 4 | logo: kubernetes 5 | --- 6 | 7 | Also known as "k8s" for short (since the name is 8 letters long). 8 | 9 | Example values for commands below. 10 | 11 | - `SERVICE_NAME` and `DEPLOYMENT_NAME` - `foobar` 12 | - `PODNAME` - `foo-0f4988689-l5hfa` 13 | 14 | 15 | ### Resources 16 | 17 | - [Kubernetes](https://michaelcurrin.github.io/dev-resources/resources/containers/kubernetes.html) on Dev Resources. 18 | - [Cheatsheet](https://kubernetes.io/docs/reference/kubectl/cheatsheet/) on Kubernetes site. 19 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/data-structures/iterables.md: -------------------------------------------------------------------------------- 1 | # Iterables 2 | 3 | From [Iteration protocols][]: 4 | 5 | > `String`, `Array`, `TypedArray`, `Map`, and `Set` are all built-in iterables, because each of their prototype objects implements an `@@iterator` method. 6 | 7 | [Iteration protocols]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols 8 | 9 | 10 | ## Make an iterator 11 | 12 | ```javascript 13 | const myIterable = {}; 14 | 15 | myIterable[Symbol.iterator] = function* () { 16 | yield 1; 17 | yield 2; 18 | yield 3; 19 | }; 20 | 21 | console.log([...myIterable]); // [1, 2, 3] 22 | ``` 23 | -------------------------------------------------------------------------------- /cheatsheets/python/type-checks/install-and-run-mypy.md: -------------------------------------------------------------------------------- 1 | 2 | # Install and run Mypy 3 | 4 | - Install Mypy. 5 | - Install directly. 6 | ```sh 7 | $ pip install mypy 8 | ``` 9 | - Or install from requirements (make sure to add `mypy` to your file first). 10 | ```sh 11 | $ pip install -r requirements-dev.txt 12 | ``` 13 | - Run Mypy. 14 | - All. 15 | ```sh 16 | $ mypy . 17 | Success: no issues found in 4 source files 18 | ``` 19 | - Targeted 20 | ```sh 21 | $ mypy my_app tests 22 | Success: no issues found in 4 source files 23 | ``` 24 | -------------------------------------------------------------------------------- /cheatsheets/ci-cd/netlify/functions/response-type.md: -------------------------------------------------------------------------------- 1 | # Response type 2 | 3 | 4 | ## Text 5 | 6 | ```javascript 7 | exports.handler = function (event) { 8 | const text= "Hello, World!" 9 | 10 | return { 11 | statusCode: 200, 12 | body: text, 13 | } 14 | } 15 | ``` 16 | 17 | 18 | ## JSON 19 | 20 | Convert an object to a JSON-formatted string. 21 | 22 | ```javascript 23 | exports.handler = function (event) { 24 | const respData = { 25 | message: "Hello World" 26 | eventData: event 27 | } 28 | 29 | return { 30 | statusCode: 200, 31 | body: JSON.stringify(respData) 32 | }; 33 | } 34 | ``` 35 | 36 | -------------------------------------------------------------------------------- /cheatsheets/graphql/spread.md: -------------------------------------------------------------------------------- 1 | # On type 2 | 3 | 4 | When there are multiples types available, you need to use `... on TYPE`. Some options here from the explorer are `Commit`, `Tree`, `Blob` and `Tag`. 5 | 6 | Example: 7 | 8 | ```graphql 9 | { 10 | repository(owner: "michaelcurrin", name: "aggre-git") { 11 | defaultBranchRef { 12 | target { 13 | ... on Commit { 14 | history(first: 3) { 15 | edges { 16 | node { 17 | committedDate 18 | } 19 | } 20 | } 21 | } 22 | } 23 | } 24 | } 25 | } 26 | ``` 27 | 28 | See also the Fragments page. 29 | -------------------------------------------------------------------------------- /cheatsheets/make/variables/access.md: -------------------------------------------------------------------------------- 1 | ## Access 2 | 3 | ### Make variable 4 | 5 | Use as a Make variable: 6 | 7 | - `Makefile` 8 | ```Makefile 9 | FOO = a 10 | BAR = 1 11 | 12 | test: 13 | echo "$(FOO) $(BAR)" 14 | ``` 15 | 16 | ```sh 17 | $ make test 18 | echo "a 1" 19 | a 1 20 | ``` 21 | 22 | The quotes are not strictly needed. 23 | 24 | Note that if you use single quotes, the variables will _still_ be evaluated. 25 | 26 | ### Shell variable 27 | 28 | Or use it as a Shell variable. NB. The `$` must be escaped as `$$`. 29 | 30 | ```Makefile 31 | FOO = a 32 | BAR = 1 33 | 34 | test: 35 | echo "$(FOO) $(BAR)" 36 | ``` 37 | -------------------------------------------------------------------------------- /cheatsheets/shell/scripting/sequence.md: -------------------------------------------------------------------------------- 1 | # Sequence 2 | 3 | ## Ascending numbers 4 | 5 | ```sh 6 | echo {0..10} 7 | ``` 8 | 9 | 10 | ## Descending numbers 11 | 12 | ```sh 13 | echo {10..0} 14 | ``` 15 | 16 | ## Every second number 17 | 18 | ```sh 19 | echo {0..10..2} 20 | ``` 21 | 22 | ## Letters 23 | 24 | ```sh 25 | echo {a..z} 26 | ``` 27 | 28 | 29 | ## Combine 30 | 31 | ```sh 32 | echo {0..2}{0..2} 33 | ``` 34 | ``` 35 | 00 01 02 10 11 12 20 21 22 36 | ``` 37 | 38 | 39 | Store as a variable. 40 | 41 | ```sh 42 | $ LETTER_COMBOS=({a..z}{a..z}) 43 | 44 | $ echo $LETTER_COMBOS 45 | aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ... 46 | ``` 47 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | logo: git 3 | description: | 4 | "the stupid content tracker" 5 | --- 6 | # Git 7 | 8 | See also [Git](https://github.com/MichaelCurrin/learn-to-code/tree/master/en/topics/version_control/Git) section of my Learn to Code project. 9 | 10 | If you're a more visual person, check out this visual [Git cheat sheet](https://www.git-tower.com/learn/cheat-sheets/git) available in multiple languages as well as light and dark modes. 11 | 12 | 13 | ### Quick reference 14 | 15 | Restore a file to match another branch. 16 | 17 | ```sh 18 | $ git checkout my-feature 19 | $ git checkout origin/master file.py 20 | ``` 21 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/style-console-log.md: -------------------------------------------------------------------------------- 1 | # Style the console log 2 | 3 | Supply CSS styling to `console.log`. Note use of `%c`. 4 | 5 | ## Single style 6 | 7 | ```javascript 8 | console.log('%cMy red text', 'color: red') 9 | ``` 10 | 11 | ## Combine styles 12 | 13 | ```javascript 14 | console.log('%cMy bold and red text', 'font-weight: bold; color: red') 15 | ``` 16 | 17 | ## Split styles 18 | 19 | ```javascript 20 | console.log('%cMy bold text %cMy red text', 'font-weight: bold', 'color: red') 21 | ``` 22 | 23 | This only seems to work in the browser and not in Node. You'll need come control characters or an NPM package to handle colors in Node. 24 | -------------------------------------------------------------------------------- /cheatsheets/shell/commands/fzf.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Fuzzy finder 3 | --- 4 | # fzf 5 | 6 | Interactive CLI tool for listing and finding files by a pattern using fuzzy search (rather than exact match or regex). 7 | 8 | See [fzf GitHub repo](https://github.com/junegunn/fzf). 9 | 10 | ## Installation 11 | 12 | See [Installation](https://github.com/junegunn/fzf?tab=readme-ov-file#installation) in the docs. 13 | 14 | ```sh 15 | $ sudo apt install fzf 16 | ``` 17 | 18 | 19 | ## Usage 20 | 21 | See [Usage](https://github.com/junegunn/fzf?tab=readme-ov-file#usage) in the docs. 22 | 23 | Start interactive mode. No arguments: 24 | 25 | ```sh 26 | $ fzf 27 | ``` 28 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/commands/whatchanged.md: -------------------------------------------------------------------------------- 1 | # whatchanged 2 | 3 | ```sh 4 | $ git whatchanged 5 | ``` 6 | 7 | Sample output: 8 | 9 | ``` 10 | commit 7ddd611... 11 | Author: ... 12 | Date: Sun Feb 21 17:26:22 2021 +0200 13 | 14 | fix: Update CSS url 15 | 16 | :100644 100644 a5d799b 352c472 M src/App.tsx 17 | 18 | commit f3f702d... 19 | Author: ... 20 | Date: Sun Feb 21 17:23:00 2021 +0200 21 | 22 | docs: Update docs 23 | 24 | :100644 100644 be0071a 587c61a M docs/deploy.md 25 | :100644 100644 be1d2bc f1ae092 M docs/template-notes/limitations.md 26 | :100644 100644 5503d92 20dd56b M docs/usage.md 27 | ``` 28 | -------------------------------------------------------------------------------- /cheatsheets/containers/podman/cli.md: -------------------------------------------------------------------------------- 1 | # CLI 2 | 3 | ## Start 4 | 5 | ```sh 6 | podman machine start 7 | ``` 8 | 9 | ## Stop 10 | 11 | ```sh 12 | podman machine stop 13 | ``` 14 | 15 | ## Run Docker commands 16 | 17 | Remember - if you are using Podman as a drop-in replacement for Docker, you can use `docker` commands instead of these. 18 | 19 | ### Registry 20 | 21 | ```sh 22 | podman login REGISTRY 23 | ``` 24 | 25 | ### Images 26 | ```sh 27 | podman pull xxx/yyy:latest 28 | ``` 29 | 30 | ### Containers 31 | 32 | ```sh 33 | podman run -it -p 8080:8080 34 | ``` 35 | 36 | If you configure `DOCKER_HOST` you can run Docker CLI commands without referecing podman. 37 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/esbuild/formats.md: -------------------------------------------------------------------------------- 1 | # Formats 2 | 3 | 4 | ## JS 5 | 6 | Plain JS. 7 | 8 | ```sh 9 | $ esbuild --outfile=dist/main.js src/index.js 10 | ``` 11 | 12 | 13 | ## JSX 14 | 15 | It can handle `.jsx` for React apps. 16 | 17 | ```sh 18 | $ esbuild --outfile=dist/main.js src/index.jsx 19 | ``` 20 | 21 | 22 | ## TypeScript 23 | 24 | It can handle `.ts` and `.tsx` files. Even without TypeScript installed. 25 | 26 | It will not evaluate your types though. You'll need to install and run TypeScript for that. 27 | 28 | ```sh 29 | $ esbuild --outfile=dist/main.js src/index.ts 30 | 31 | $ esbuild --outfile=dist/main.js src/index.tsx 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /cheatsheets/jekyll/windows.md: -------------------------------------------------------------------------------- 1 | # Windows compatibility 2 | 3 | If you use Windows or you want developers on Windows to use your project, add this to your `Gemfile`. 4 | 5 | From the file created by `jekyll new` for Jekyll `4.1`. 6 | 7 | - `Gemfile` 8 | ```ruby 9 | # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem 10 | # and associated library. 11 | platforms :mingw, :x64_mingw, :mswin, :jruby do 12 | gem "tzinfo", "~> 1.2" 13 | gem "tzinfo-data" 14 | end 15 | 16 | # Performance-booster for watching directories on Windows 17 | gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin] 18 | ``` 19 | -------------------------------------------------------------------------------- /cheatsheets/terraform/cli-usage/console.md: -------------------------------------------------------------------------------- 1 | # Console command 2 | 3 | Start the interactive console 4 | 5 | ```sh 6 | $ tf console 7 | > 8 | ``` 9 | Checking the help. 10 | 11 | ``` 12 | > help 13 | The Terraform console allows you to experiment with Terraform interpolations. 14 | You may access resources in the state (if you have one) just as you would 15 | from a configuration. For example: "aws_instance.foo.id" would evaluate 16 | to the ID of "aws_instance.foo" if it exists in your state. 17 | 18 | Type in the interpolation to test and hit to see the result. 19 | 20 | To exit the console, type "exit" and hit , or use Control-C or 21 | Control-D. 22 | ``` 23 | -------------------------------------------------------------------------------- /cheatsheets/ci-cd/netlify/functions/function-params.md: -------------------------------------------------------------------------------- 1 | # Function params 2 | 3 | ## Event only 4 | 5 | ```javascript 6 | exports.handler = function (event) { 7 | return { 8 | statusCode: 200, 9 | body: "Hello, World!", 10 | } 11 | } 12 | ``` 13 | 14 | 15 | ## Context 16 | 17 | ```javascript 18 | exports.handler = function (event) { 19 | return { 20 | statusCode: 200, 21 | body: "Hello, World! ${JSON.stringify(context)}", 22 | } 23 | } 24 | ``` 25 | 26 | 27 | ## Callback 28 | 29 | ```javascript 30 | exports.handler = unction (event, context, callback) { 31 | callback(null, { 32 | statusCode: 200, 33 | body: "Hello, World!" 34 | }) 35 | } 36 | ``` 37 | -------------------------------------------------------------------------------- /cheatsheets/containers/docker/clean.md: -------------------------------------------------------------------------------- 1 | # Clean 2 | 3 | 4 | ## Prune 5 | 6 | ```sh 7 | $ docker system prune 8 | ``` 9 | 10 | This will remove: 11 | 12 | - all stopped containers 13 | - all networks not used by at least one container 14 | - all dangling images 15 | - all dangling build cache 16 | 17 | 18 | Help: 19 | 20 | ``` 21 | Usage: docker system prune [OPTIONS] 22 | 23 | Remove unused data 24 | 25 | Options: 26 | -a, --all Remove all unused images not just dangling ones 27 | --filter filter Provide filter values (e.g. 'label==') 28 | -f, --force Do not prompt for confirmation 29 | --volumes Prune volumes 30 | ``` 31 | -------------------------------------------------------------------------------- /cheatsheets/make/variables/defaults-file.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Default files 3 | description: Set up default values in another file 4 | --- 5 | 6 | Set defaults in a separate file to keep your other file lighter. Such as a some constants which may or may not need to be override by a user. 7 | 8 | I'm not sure if the curly brackets are right here. See also the other pages on conditionals and default values. 9 | 10 | - `defaults.mk` 11 | ```mk 12 | FIZZ = ${FIZZ} 13 | BUZZ = ${BUZZ} 14 | 15 | export 16 | ``` 17 | 18 | Then import the defaults. 19 | 20 | - `Makefile` 21 | ```make 22 | include defaults.mk 23 | 24 | foo: 25 | echo $(FIZZ) 26 | ``` 27 | -------------------------------------------------------------------------------- /cheatsheets/python/convert.md: -------------------------------------------------------------------------------- 1 | # Convert 2 | 3 | ## HTML to Markdown 4 | 5 | ```sh 6 | $ pip install markdown 7 | ``` 8 | 9 | ```python 10 | import markdown 11 | 12 | markdown_value 13 | html_value = markdown.markdown(markdown_value) 14 | ``` 15 | 16 | ```python 17 | import markdown 18 | 19 | markdown.markdownFromFile(input="in.md", output='out.html') 20 | ``` 21 | 22 | ## Render Markdown 23 | 24 | Markdown to HTML. 25 | 26 | ```sh 27 | $ pip install markdownify 28 | ``` 29 | ```python 30 | from markdownify import ATX, markdownify as md 31 | 32 | 33 | BULLETS = "-*+" 34 | 35 | html_value = "..." 36 | 37 | md_value = md(html_value, heading_style=ATX, bullets=BULLETS) 38 | ``` 39 | -------------------------------------------------------------------------------- /cheatsheets/javascript/format-and-lint/eslint/rules/format.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Format 3 | description: Guide to writing rules for ESLint with fields and levels 4 | --- 5 | 6 | See also [Common rules][] page. 7 | 8 | [Common Rules]: {% link cheatsheets/javascript/format-and-lint/eslint/rules/common.md %} 9 | 10 | Each rule has its own allowed fields. 11 | 12 | For level, you can use: 13 | 14 | - `2` or `"error"` 15 | - `1` or `"warn"` 16 | - `0` or `"off"` 17 | 18 | Example: 19 | 20 | ```js 21 | { 22 | rules: { 23 | semi: [2, "always"], 24 | // OR 25 | semi: ["error", "always"], 26 | 27 | "no-console": "warn" 28 | // OR 29 | "no-console": 1 30 | } 31 | } 32 | ``` 33 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/http/index.md: -------------------------------------------------------------------------------- 1 | # http 2 | 3 | How to use the built-in `http` library - from [tutorial](https://www.w3schools.com/nodejs/nodejs_http.asp). 4 | 5 | See also my [gist](https://gist.github.com/MichaelCurrin/1a6116a4e0918c8468dc7e1a701a5f95). 6 | 7 | This is very low-level. You probably want to use Express or something at an even higher-level. 8 | 9 | Make a script. 10 | 11 | - `index.js` 12 | ```js 13 | const http = require('http'); 14 | 15 | http.createServer(function (req, res) { 16 | res.write('Hello World!'); 17 | res.end(); 18 | }).listen(8080); 19 | ``` 20 | 21 | Then run it: 22 | 23 | ```sh 24 | node index.js 25 | ``` 26 | -------------------------------------------------------------------------------- /cheatsheets/make/command-modifiers.md: -------------------------------------------------------------------------------- 1 | # Command modifiers 2 | 3 | ## Silent 4 | 5 | Add `@` to prevent the line from being shown in the CLI. This is useful for `echo` commands, to avoid duplicating output. 6 | 7 | ```Makefile 8 | greet: 9 | @echo 'Printing output' 10 | 11 | echo 'This line will appear twice' 12 | ``` 13 | 14 | ```console 15 | $ make greet 16 | Printing output 17 | echo 'This line will appear twice' 18 | This line will appear twice 19 | ``` 20 | 21 | 22 | ## No run 23 | 24 | Add `:` to show the line and do not execute it. 25 | 26 | ```Makefile 27 | name ?= foo 28 | 29 | greet: 30 | : $(name) 31 | ``` 32 | 33 | ```console 34 | $ make greet 35 | : foo 36 | ``` 37 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/ruby/bundler/upgrade.md: -------------------------------------------------------------------------------- 1 | # Upgrade 2 | 3 | 4 | ## `update` 5 | 6 | > Update the current environment 7 | 8 | ```sh 9 | $ bundle update [OPTIONS] 10 | ``` 11 | 12 | If you've made changes to your `Gemfile`, then you `Gemfile.lock` file will not match. 13 | 14 | If you run `bundle install`, you'll get an error about a mismatch. 15 | 16 | Therefore you can do: 17 | 18 | ```sh 19 | $ bundle update 20 | ``` 21 | 22 | You can also do that if there no changes in `Gemfile` and you just want to get newer gems. 23 | 24 | 25 | ## `outdated` 26 | 27 | > List installed gems with newer versions available. 28 | 29 | ```sh 30 | $ bundle outdated GEM [OPTIONS] 31 | ``` 32 | -------------------------------------------------------------------------------- /cheatsheets/python/libraries/queue-messaging/amazon-sqs.md: -------------------------------------------------------------------------------- 1 | # Amazon SQS / boto3 2 | 3 | Amazon Simple Queue Service (SQS) is a fully managed message queuing service. 4 | 5 | ## Key Features 6 | 7 | - Scalable and fully managed by AWS 8 | - Supports standard and FIFO queues 9 | - Integrates well with other AWS services 10 | 11 | ## Basic Usage with boto3 12 | 13 | ```python 14 | import boto3 15 | 16 | 17 | sqs = boto3.client('sqs') 18 | 19 | queue_url = 'https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue' 20 | 21 | response = sqs.send_message( 22 | QueueUrl=queue_url, 23 | MessageBody='Hello, SQS!' 24 | ) 25 | 26 | print(f"Message sent. ID: {response['MessageId']}") 27 | ``` -------------------------------------------------------------------------------- /cheatsheets/web/css/boxes.md: -------------------------------------------------------------------------------- 1 | # Boxes 2 | 3 | 4 | ## Box sizing 5 | 6 | - [box-sizing](https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing) on MDN docs. 7 | > The `box-sizing` CSS property sets how the total width and height of an element is calculated. 8 | 9 | ```css 10 | box-sizing: content-box; 11 | width: 100%; 12 | ``` 13 | 14 | Add border, but element goes outside of the parent. 15 | 16 | ```css 17 | box-sizing: content-box; 18 | width: 100%; 19 | border: solid #5B6DCD 10px; 20 | padding: 5px; 21 | ``` 22 | 23 | Keep element inside parent. 24 | 25 | ```css 26 | box-sizing: border-box; 27 | width: 100%; 28 | border: solid #5B6DCD 10px; 29 | padding: 5px; 30 | ``` 31 | 32 | -------------------------------------------------------------------------------- /cheatsheets/containers/docker-cli/manage-volumes.md: -------------------------------------------------------------------------------- 1 | # Manage volumes 2 | 3 | 4 | ## Related 5 | 6 | - [Prune][] for deleting volumes. 7 | 8 | [Prune]: {% link cheatsheets/containers/docker-cli/prune.md %} 9 | 10 | 11 | ## List 12 | 13 | ### Show all 14 | 15 | ```sh 16 | $ docker volume ls 17 | ``` 18 | 19 | Just the IDs - using quiet. 20 | 21 | ```sh 22 | $ docker volume ls -q 23 | ``` 24 | 25 | ### Dangling volumes 26 | 27 | Using filter: 28 | 29 | - `-f, --filter filter` Provide filter values (e.g. 'dangling=true') 30 | 31 | ```sh 32 | $ docker volume ls -qf dangling=true 33 | ``` 34 | 35 | 36 | ## Remove 37 | 38 | ```sh 39 | $ docker volume rm $(docker volume ls -q) 40 | ``` 41 | -------------------------------------------------------------------------------- /cheatsheets/other/cli/interface.md: -------------------------------------------------------------------------------- 1 | # Writing a CLI 2 | 3 | Cross-language guide for writing a command-line interface - focussing on the interface and help messaging. 4 | 5 | 6 | ## Arguments 7 | 8 | ### Subcommands 9 | 10 | ``` 11 | Subcommands: 12 | foo 13 | bar 14 | baz, b Baz all the bugs. 15 | ``` 16 | 17 | 18 | ## Options 19 | 20 | #### One argument 21 | 22 | ``` 23 | -f, --foo FOO 24 | ``` 25 | 26 | #### Optional argument 27 | 28 | ``` 29 | -f, --foo [FOO] Your foo value. (defaults to bar) 30 | ``` 31 | 32 | 33 | #### One or more arguments 34 | 35 | ``` 36 | --foo FOO[,FOO2,...] 37 | ``` 38 | 39 | #### Short and long flag 40 | 41 | ``` 42 | -f, --FOO FOO 43 | ``` 44 | -------------------------------------------------------------------------------- /cheatsheets/version-control/git/restore/undo.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Step back one commit 3 | --- 4 | # Undo 5 | 6 | ## Undo commit 7 | 8 | Undo latest commit and drop all changes. Warning - any other changes files will also be reset. 9 | 10 | ```sh 11 | $ git reset --hard HEAD~ 12 | ``` 13 | 14 | Safer: 15 | 16 | ```sh 17 | [[ -z $(git status --porcelain) ]] && git reset --hard HEAD~ || echo 'Unstaged changes!' 18 | ``` 19 | 20 | Then run: 21 | 22 | ```sh 23 | $ git stash --include-untracked 24 | ``` 25 | 26 | Then try again. 27 | 28 | 29 | ## Restore local to match remote 30 | 31 | This will get rid of any unpushed commits. 32 | 33 | ```sh 34 | $ git checkout origin/master . 35 | ``` 36 | -------------------------------------------------------------------------------- /cheatsheets/web/css/cursor.md: -------------------------------------------------------------------------------- 1 | # Cursor 2 | 3 | Set the appearance of the mouse pointer. 4 | 5 | 6 | ## Syntax 7 | 8 | ```css 9 | selector { 10 | cursor: VALUE; 11 | } 12 | ``` 13 | 14 | 15 | ## Values 16 | 17 | Some recommended values: 18 | 19 | - `pointer` for a link. This is already built-in for `a` tags but you might want to add this for buttons. 20 | - `help` 21 | - `default` 22 | - `wait` or `wait` 23 | - `not-allowed` or `no-drop` 24 | 25 | 26 | ## Resources 27 | 28 | - [W3 Schools](https://www.w3schools.com/csSref/pr_class_cursor.asp) - including definitions in a table. 29 | - [Mozilla dev docs](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor) - includes an interactive demo. 30 | -------------------------------------------------------------------------------- /cheatsheets/javascript/browser/styles.md: -------------------------------------------------------------------------------- 1 | # Styles 2 | 3 | 4 | ### Get styles 5 | 6 | ```javascript 7 | el.style 8 | ``` 9 | 10 | Or 11 | 12 | ```javascript 13 | el.getAttribute("style") 14 | // "left: 321px; top: 69px; visibility: hidden;" 15 | ``` 16 | 17 | 18 | ## Get style 19 | 20 | ```javascript 21 | el.style.left 22 | ``` 23 | 24 | Or 25 | 26 | ```javascript 27 | el.getStyle('left') 28 | // "321px" 29 | ``` 30 | 31 | 32 | ## Set style 33 | 34 | From [setProperty](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/setProperty) docs MDN. 35 | 36 | ```javascript 37 | el.style.setProperty('color', 'red') 38 | ``` 39 | 40 | I could not get `el.setStyle('color', 'red')` to work. 41 | -------------------------------------------------------------------------------- /cheatsheets/javascript/general/printing.md: -------------------------------------------------------------------------------- 1 | # Printing 2 | 3 | - `console.log` - Displays the `toString` representation of any object passed to it. This can be very limited on nested objects - the value will be `Object`. 4 | - `console.dir` - Displays interactive list of the properties of the object. The output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects. 5 | - `console.error` 6 | - `console.debug` - Useful for messages you only want to show when running the app in a more verbose debug mode. 7 | 8 | 9 | ## Timing 10 | 11 | ```javascript 12 | console.time("My label") 13 | 14 | // do stuff... 15 | 16 | console.timeEnd("My label") 17 | ``` 18 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/javascript/yarn/commands/npm-vs-yarn.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: NPM vs Yarn 3 | --- 4 | 5 | Based on [Yarn cheatsheet](https://devhints.io/yarn). 6 | 7 | NPM | Yarn 8 | --- | --- 9 | `npm install gulp` |`yarn add gulp` 10 | `npm install -D gulp` | `yarn add -D gulp` 11 | `npm install gulp --save-dev` | `yarn add gulp --dev` 12 | `npm install -g gulp` | `yarn global add gulp` 13 | `npm update` | `yarn upgrade` 14 | `npm run build` | `yarn build` 15 | `./node_modules/.bin/gulp` | `yarn run gulp` 16 | 17 | Note that while NPM supports aliases like `install` / `add` and `update` / `upgrade`, Yarn is strict and gives errors. Weirdly, Yarn uses NPM's aliases, rather than the main commands. 18 | -------------------------------------------------------------------------------- /cheatsheets/package-managers/os/homebrew/services.md: -------------------------------------------------------------------------------- 1 | # Services 2 | 3 | Set up a service to start now and then start up whenever you boot the machine. This uses `launchd`. 4 | 5 | ## Run 6 | 7 | > Run the service formula without registering to launch at login (or boot). 8 | 9 | ```sh 10 | brew services run SERVICE 11 | ``` 12 | 13 | ## Start 14 | 15 | > Start the service formula immediately and register it to launch at login (or boot). 16 | 17 | ```sh 18 | brew services start SERVICE 19 | ``` 20 | 21 | 22 | ## Stop 23 | 24 | > Stop the service formula immediately and unregister it from launching at login (or boot), unless --keep is specified. 25 | 26 | ```sh 27 | brew services stop SERVICE 28 | ``` 29 | -------------------------------------------------------------------------------- /cheatsheets/python/browser.md: -------------------------------------------------------------------------------- 1 | # Browser 2 | 3 | Open a URL in the browser. 4 | 5 | ```python 6 | url = "http://example.com" 7 | ``` 8 | 9 | 10 | ## webbrowser 11 | 12 | - [webbrowser](https://docs.python.org/3/library/webbrowser.html) standard library in the docs. 13 | > The webbrowser module provides a high-level interface to allow displaying web-based documents to users. 14 | > Under most circumstances, simply calling the `open()` function from this module will do the right thing. 15 | 16 | ```python 17 | import webbrowser 18 | 19 | webbrowser.open(url) 20 | ``` 21 | 22 | 23 | ## urllib 24 | 25 | ```python 26 | import urllib.request 27 | 28 | resp = urllib.request.urlopen(url) 29 | ``` 30 | -------------------------------------------------------------------------------- /cheatsheets/typescript/type-assertions.md: -------------------------------------------------------------------------------- 1 | # Type assertions 2 | 3 | Based on the [Type assertions](https://www.typescriptlang.org/docs/handbook/basic-types.html#type-assertions) part of the docs 4 | 5 | Below we convert or cast from a string to a number. 6 | 7 | This is useful when a value could have multiple types and you tell the compiler which one is in use here. 8 | 9 | 10 | ## The as syntax 11 | 12 | ```typescript 13 | const foo = "this is a string"; 14 | const len = (foo as string).length; 15 | ``` 16 | 17 | 18 | ## Angle-bracket syntax 19 | 20 | Same as above but not work with JSX syntax. 21 | 22 | ```typescript 23 | const foo = "this is a string"; 24 | const len = ( foo).length; 25 | ``` 26 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/dataviz/apex-charts/basic.md: -------------------------------------------------------------------------------- 1 | # Basic 2 | 3 | Based on [Creating Your First JavaScript Chart][] in the docs. 4 | 5 | 6 | ```javascript 7 | const data = [30, 40, 35, 50, 49, 60, 70, 91, 125] 8 | const categories = [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999] 9 | 10 | const options = { 11 | chart: { 12 | type: 'line' 13 | }, 14 | series: [{ 15 | name: 'sales', 16 | data 17 | }], 18 | xaxis: { 19 | categories 20 | } 21 | } 22 | 23 | const chart = new ApexCharts(document.querySelector("#chart"), options); 24 | 25 | chart.render(); 26 | ``` 27 | 28 | [Creating Your First JavaScript Chart]: https://apexcharts.com/docs/creating-first-javascript-chart/ 29 | -------------------------------------------------------------------------------- /cheatsheets/javascript/packages/react/basics/component-lifecycle.md: -------------------------------------------------------------------------------- 1 | # Component lifecycle 2 | 3 | See this [Lifecycle diagram](https://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/) which the React docs recommend as a cheatsheet. 4 | 5 | ## Class component methods 6 | 7 | The methods below make sense for class component - I don't know about for a functional component. 8 | 9 | ### Mounting 10 | 11 | 1. `constructor()` 12 | 1. `static getDerivedStateFromProps()` 13 | 1. `render()` 14 | 1. `componentDidMount()` 15 | 16 | ### Updating 17 | 18 | 1. `static getDerivedStateFromProps()` 19 | 1. `shouldComponentUpdate()` 20 | 1. `render()` 21 | 1. `getSnapshotBeforeUpdate()` 22 | 1. `componentDidUpdate()` 23 | 24 | -------------------------------------------------------------------------------- /cheatsheets/python/configs/setup-cfg.md: -------------------------------------------------------------------------------- 1 | # setup.cfg 2 | 3 | See [setuptools docs](https://setuptools.pypa.io/en/latest/userguide/declarative_config.html). 4 | 5 | e.g. 6 | 7 | ```ini 8 | [metadata] 9 | name = my_package 10 | version = attr: my_package.VERSION 11 | description = My package description 12 | long_description = file: README.rst, CHANGELOG.rst, LICENSE.rst 13 | keywords = one, two 14 | license = BSD 3-Clause License 15 | classifiers = 16 | Framework :: Django 17 | Programming Language :: Python :: 3 18 | 19 | [options] 20 | zip_safe = False 21 | include_package_data = True 22 | packages = find: 23 | install_requires = 24 | requests 25 | importlib-metadata; python_version<"3.8" 26 | ``` 27 | -------------------------------------------------------------------------------- /cheatsheets/javascript/node/install.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Install 3 | description: How to install Node, NPM and Yarn 4 | --- 5 | 6 | 7 | ## Install Node and NPM 8 | 9 | 10 | 11 | 12 | ## Install Yarn and Node 13 | 14 | 15 | 16 | 17 | ## Use NVM 18 | 19 | ### Install NVM 20 | 21 | 22 | 23 | 24 | ### Install Node using NVM 25 | 26 | 27 | --------------------------------------------------------------------------------