### Setup Block for React Class Source: https://devhints.io/cheatsheet-styles Another example of a setup block, this time for a React class component. ```javascript class Hello extends React.Component { render () { return Hello } } ``` -------------------------------- ### Ansible Playbook Example Source: https://devhints.io/ansible-guide A sample playbook that installs and configures Nginx, installs bundler, and performs a shell command. ```yaml - hosts: 127.0.0.1 user: root tasks: - name: install nginx apt: pkg=nginx state=present - name: start nginx every bootup service: name=nginx state=started enabled=yes - name: do something in the shell shell: echo hello > /tmp/abc.txt - name: install bundler gem: name=bundler state=latest ``` -------------------------------- ### Apt Package Installation Source: https://devhints.io/travis Install system packages using `apt-get` before the build starts. Requires `sudo` privileges. ```yaml before_install: - sudo apt-get update -q - sudo apt-get install gcc-4.8 -y ``` -------------------------------- ### Examples and Epilog Source: https://devhints.io/yargs Adds examples and epilog text to the help output. ```APIDOC ## Examples and Epilog Add examples and epilog to help messages. ```javascript // more help .example('...') .epilog('copyright 2015') .command('start', 'start a server') ``` ``` -------------------------------- ### Simulate Composer Installation Source: https://devhints.io/composer Simulates the installation process without making any changes to the project files. Useful for checking dependency compatibility before a real installation. ```bash composer install --dry-run ``` -------------------------------- ### Yarn Install Options Source: https://devhints.io/yarn Lists available options for the `yarn install` command. Use these to control the installation process, such as disabling lockfiles or installing offline. ```bash --no-lockfile ``` ```bash --pure-lockfile ``` ```bash --frozen-lockfile ``` ```bash --silent ``` ```bash --offline ``` ```bash --update-checksums ``` ```bash --check-files ``` ```bash --flat ``` ```bash --force ``` ```bash --ignore-scripts ``` ```bash --modules-folder ``` ```bash --production[=true|false] ``` -------------------------------- ### Install a Package Source: https://devhints.io/yum Install a specific package, such as 'vsftpd', from the configured repositories. ```bash yum install vsftpd ``` -------------------------------- ### Using Setup Data in Test Source: https://devhints.io/exunit Tests can access data returned from a `setup/0` block via the context map. The example shows accessing the `name` key provided by the setup block. ```elixir test "it works", %{name: name} do assert name == "John" end ``` -------------------------------- ### Instantiate Dispatcher and Stores Source: https://devhints.io/flux Basic setup for a Flux application, showing the instantiation of a Dispatcher and a simple Store. This is the starting point for managing application state. ```javascript d = new Dispatcher(); TabStore = { tab: 'home' }; ``` -------------------------------- ### Install Chef on a Server Source: https://devhints.io/chef Installs Chef using a script downloaded via curl. Ensure curl is installed first. ```bash $ sudo apt-get install curl ``` ```bash $ curl -L https://omnitruck.chef.io/install.sh | sudo bash Thank you for installing Chef! ``` ```bash $ chef-solo -v ... Chef: 14.5.33 ``` -------------------------------- ### Vim Help File Header Example Source: https://devhints.io/vim-help A file header in a Vim help file typically starts with the filename in asterisks, followed by a description. ```vim *potion.txt* functionality for the potion programming language ``` -------------------------------- ### Install a Package with Homebrew Source: https://devhints.io/homebrew Use this command to install any available package from Homebrew. ```bash brew install git ``` -------------------------------- ### Install Devise Source: https://devhints.io/devise Run the Devise installation generator to set up initial configuration files. ```bash $ rails generate devise:install ``` -------------------------------- ### Vim Help File Heading Example Source: https://devhints.io/vim-help Headings in Vim help files start with all capital letters and end with a tag in asterisks. ```vim ============================================================================== CONTENTS *potion-contents* ``` -------------------------------- ### Install Phoenix Framework Source: https://devhints.io/phoenix Installs the Phoenix Framework archive using Hex. Ensure Erlang and Elixir are installed first. ```bash # Install Phoenix mix local.hex mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez ``` -------------------------------- ### Add Examples and Epilog Source: https://devhints.io/yargs Include example usage and epilog text for help messages. Commands can also be defined to structure sub-commands. ```javascript // more help .example('...') .epilog('copyright 2015') .command('start', 'start a server') ``` -------------------------------- ### Install Packages with NPM Source: https://devhints.io/npm Use `npm install` to install all dependencies listed in `package.json`. Use `--production` to exclude devDependencies. ```bash npm i ``` ```bash npm install ``` ```bash npm install --production ``` -------------------------------- ### Install Expect.js Source: https://devhints.io/expectjs Install Expect.js as a dev dependency using npm. ```bash npm install --save-dev expect ``` -------------------------------- ### Yarn Create React App Source: https://devhints.io/yarn Initializes a new React application using the `create-react-app` package via Yarn. This command installs the necessary scaffolding and runs the application setup. ```bash yarn create react-app hello ``` -------------------------------- ### Setup Block for React Component Source: https://devhints.io/cheatsheet-styles Use the `.-setup` class for blocks that represent setup or boilerplate code, like React imports. ```javascript import React from 'react' ``` -------------------------------- ### Authentication Example Source: https://devhints.io/rest-api Shows an example of how to authenticate API requests using a token. ```APIDOC ## Authentication ### Request Example ```bash curl -is https://$TOKEN@api.example.com/ ``` ``` -------------------------------- ### Install Webpack Source: https://devhints.io/webpack Installs Webpack as a development dependency. ```bash npm install --save-dev webpack ``` -------------------------------- ### List Available and Installed Packages Source: https://devhints.io/yum List all available packages, installed packages, or specific package types like kernels. ```bash yum list available ``` ```bash yum list installed ``` ```bash yum list kernel ``` -------------------------------- ### Basic Table Example Source: https://devhints.io/cheatsheet-styles A simple table with two columns, 'Example' and 'Output', used for demonstrating date formatting. ```markdown Example | Output ---|--- `%m/%d/%Y` | `06/05/2013` `%A, %B %e, %Y` | `Sunday, June 5, 2013` `%b %e %a` | `Jun 5 Sun` ``` -------------------------------- ### Install Enzyme and adapter Source: https://devhints.io/enzyme Install Enzyme and the appropriate adapter for your React version using npm. ```bash npm install --save-dev enzyme \ enzyme-adapter-react-16 \ react-test-renderer ``` -------------------------------- ### Install Webpack Dev Server Source: https://devhints.io/webpack Installs webpack-dev-server as a development dependency. ```bash npm install --save-dev \ webpack-dev-server ``` -------------------------------- ### Install a Specific Ruby Version Source: https://devhints.io/rbenv Install a particular Ruby version, for example, 2.2.1. ```bash rbenv install 2.2.1 ``` -------------------------------- ### Vim Help File Example with Usage Instructions Source: https://devhints.io/vim-help This snippet shows a typical Vim help file structure, including a plugin description, usage instructions with a command, and a filetype setting. ```vim *ack.txt* Plugin that integrates ack with Vim ============================================================================== USAGE INSTRUCTIONS *ack-usage* :Ack[!] {pattern} *:Ack* Search recursively for {pattern}. See |:AckAdd|. Also see http://beyondgrep.com for more information. vim:tw=78:ts=8:ft=help:norl: ``` -------------------------------- ### GraphQL over HTTP - GET Source: https://devhints.io/graphql Example of sending a GraphQL query using an HTTP GET request. ```APIDOC ## Over HTTP #### GET ```javascript fetch('http://myapi/graphql?query={ me { name } }') ``` ``` -------------------------------- ### Install Jekyll and Bundler Source: https://devhints.io/jekyll Installs the necessary gems for Jekyll development. ```bash gem install jekyll bundler ``` -------------------------------- ### Install Zuul Source: https://devhints.io/saucelabs Install the Zuul command-line tool globally using npm. ```bash npm i -g zuul ``` -------------------------------- ### Install Blanket.js Source: https://devhints.io/mocha-blanket Install Blanket.js as a development dependency using npm. ```bash npm i --save-dev blanket ``` -------------------------------- ### Start Phoenix Application Source: https://devhints.io/phoenix Starts the Phoenix development server. This command compiles and runs your application. ```bash # Start the application mix phx.server ``` -------------------------------- ### Ansible Handlers Example Source: https://devhints.io/ansible Defines handlers that are triggered by tasks. This example shows starting the apache2 service. ```yaml handlers: - name: start apache2 action: service name=apache2 state=started tasks: - name: install apache action: apt pkg=apache2 state=latest notify: - start apache2 ``` -------------------------------- ### Configure Help and Version Source: https://devhints.io/yargs Set up version and help flags, including aliases and custom messages. `showHelpOnFail` controls behavior when options are invalid. ```javascript var argv = require('yargs') // version .alias('v', 'version') .version(function() { return require('../package').version; }) .describe('v', 'show version information') // help text .alias('h', 'help') .help('help') .usage('Usage: $0 -x [num]') .showHelpOnFail(false, "Specify --help for available options") ``` -------------------------------- ### Hello World with Fastify Source: https://devhints.io/fastify Create a basic HTTP server that listens on port 3000 and responds with 'hello: world' to requests on the root path. ```javascript const fastify = require('fastify')() fastify.get('/', (req, reply) => { reply.send({ hello: 'world' }) }) fastify.listen(3000, err => { if (err) throw err const port = fastify.server.address().port console.log(`server listening on ${port}`) }) ``` -------------------------------- ### Start and connect to a Vagrant machine Source: https://devhints.io/vagrant Use these commands to bring up your virtual machine and then connect to it via SSH. ```bash vagrant up vagrant ssh ``` -------------------------------- ### Start Camp Server Source: https://devhints.io/camp Initializes a new Camp server instance on a specified port. Camp serves files in the 'web/' directory by default. ```javascript const Camp = require('camp') const camp = Camp.start({ port: 1234 }) ``` -------------------------------- ### Get Nested Property Source: https://devhints.io/101 Example of retrieving a deeply nested property using `pluck`. ```javascript pluck(state, 'user.profile.name') ``` -------------------------------- ### Install Packages from Various Sources with NPM Source: https://devhints.io/npm Install packages by name, version, tag, from GitHub, GitLab, local paths, or tarballs via HTTP. ```bash npm i sax ``` ```bash npm i sax@latest ``` ```bash npm i sax@3.0.0 ``` ```bash npm i sax@">=1 <2.0" ``` ```bash npm i @org/sax ``` ```bash npm i user/repo ``` ```bash npm i user/repo#master ``` ```bash npm i github:user/repo ``` ```bash npm i gitlab:user/repo ``` ```bash npm i /path/to/repo ``` ```bash npm i ./archive.tgz ``` ```bash npm i https://site.com/archive.tgz ``` -------------------------------- ### Query Syntax Examples Source: https://devhints.io/hledger Examples of how to construct queries for filtering transactions by account, amount, description, code, tag, and currency. ```plaintext Assets # An account (regex) acct:Assets # same ^Assets # Starting with Assets (eg, not 'Expenses:Assets') acctonly:A # no subaccounts amt:2000 # amount (in absolute value) amt:<200 # amount comparison (in absolute value) amt:<+200 # amount comparison # also: <=, >, >= desc:REGEX # description code:REGEX # transaction code (check number?) tag:REGEX cur:'\$' real: # real posts real:0 # virtual posts depth:N # --depth 2 not:... ``` -------------------------------- ### ExUnit Setup with Hooks Source: https://devhints.io/exunit Define private functions (`defp`) as setup hooks. These hooks are invoked before each test in a `describe` block and their results are merged into the test context. ```elixir defp my_hook(_context) do # Invoked in every block in "a block" {:ok, name: "John", age: 54} end describe "a block" do setup [:my_hook] test "John's age", context do assert context[:name] == "John" assert context[:age] == 54 end end ``` -------------------------------- ### Configure Enzyme adapter Source: https://devhints.io/enzyme Configure Enzyme with the installed adapter in your test setup file. ```javascript import Enzyme from 'enzyme' import Adapter from 'enzyme-adapter-react-16' Enzyme.configure({ adapter: new Adapter() }) ``` -------------------------------- ### Start BrowserSync Server Source: https://devhints.io/browser-sync Start a static server in the specified directory and watch for changes in HTML and CSS files, automatically reloading the browser. ```bash browser-sync start --server --files='**/*.html, **/*.css' ``` -------------------------------- ### Wildcard Domain Mapping Example Source: https://devhints.io/heroku Example configuration for mapping a wildcard domain to your Heroku app. ```bash *.yourdomain.com => heroku.com ``` -------------------------------- ### Install Tig on Ubuntu Source: https://devhints.io/tig Installs Tig using the apt package manager on Ubuntu. ```bash # Ubuntu $ sudo apt install tig ``` -------------------------------- ### Get Security Update Information Source: https://devhints.io/yum Retrieve information about available security updates for installed packages. ```bash yum updateinfo security ``` -------------------------------- ### Start and Connect to ZNC Server Source: https://devhints.io/znc Use these commands to add a server to your ZNC configuration and establish a connection. Ensure the server address and port are correct. ```bash /msg *status addserver irc.undernet.org [6667] ``` ```bash /msg *status connect ``` -------------------------------- ### Diagnose Homebrew Issues Source: https://devhints.io/homebrew Run this command to check for common problems with your Homebrew installation and get suggestions for fixes. ```bash brew doctor ``` -------------------------------- ### Initialize Knexfile.js Source: https://devhints.io/knex Command to generate the default Knex configuration file. ```bash ./node_modules/.bin/knex init ``` -------------------------------- ### Polyfill.io with Extra Features (e.g., Fetch) Source: https://devhints.io/polyfill.io This example demonstrates how to include specific polyfill features, such as `window.fetch()`, in addition to the default set. It checks for the existence of `fetch` and other modern features before loading the polyfills. ```javascript if(!(window.fetch&&window.Promise&&[].includes&&Object.assign&&window.Map)){document.write('