Pro Wireless Controller for Switch, STOGA PC Controller Compatible with Nintendo Switch Pro Game Controller for Windows PC

Pro Wireless Controller for Switch, STOGA PC Controller Compatible with Nintendo Switch Pro Game Controller for Windows PC

4.8 out of 5 stars137Red&Blue$29.99$29.99More Buying Choices
$22.11 (2 used & new offers)

What is the difference between process.nextTick() and setImmediate() ?

The difference between process.nextTick() and setImmediate() is that process.nextTick() defers the execution of action till the next pass around the event loop or it simply calls the callback function once the ongoing execution of the event loop is finished whereas setImmediate() executes a callback on the next cycle of the event loop and it gives back to the event loop for executing any I/O operations.

🔗Source: codingdefined.com

What are LTS releases of Node.js? why should you care?

LTS(Long Term Support)

An LTS(Long Term Support) version of Node.js receives all the critical bug fixes, security updates and performance improvements.

LTS versions of Node.js are supported for at least 18 months and are indicated by even version numbers (e.g. 4, 6, 8). They’re best for production since the LTS release line is focussed on stability and security, whereas the Current release line has a shorter lifespan and more frequent updates to the code. Changes to LTS versions are limited to bug fixes for stability, security updates, possible npm updates, documentation updates and certain performance improvements that can be demonstrated to not break existing applications.

🔗Source: github.com/i0natan/nodebestpractices

Mixpanel cheatsheet

Identify

mixpanel.identify('284')
mixpanel.people.set({ $email: 'hi@gmail.com' })
// Set common properties
mixpanel.register({ age: 28, gender: 'male' })

Track events

mixpanel.track('Login success')
mixpanel.track('Search', { query: 'cheese' })

References

Analytics libraries cheatsheet

Mixpanel

mixpanel.identify('284');
mixpanel.people.set({ $email: 'hi@gmail.com' });
mixpanel.register({ age: 28, gender: 'male' }); /* set common properties */

Google Analytics’s analytics.js

ga('create', 'UA-XXXX-Y', 'auto');
ga('create', 'UA-XXXX-Y', { userId: 'USER_ID' });
ga('send', 'pageview');
ga('send', 'pageview', { 'dimension15': 'My custom dimension' });

Google Analytics’s analytics.js cheatsheet

Google Analytics’s Analytics.js is deprecated.

Page view

ga('create', 'UA-XXXX-Y', 'auto')
ga('create', 'UA-XXXX-Y', { userId: 'USER_ID' })
ga('send', 'pageview')
ga('send', 'pageview', { 'dimension15': 'My custom dimension' })

Events

ga('send', 'event', 'button',  'click', {color: 'red'});
ga('send', 'event', 'button',  'click', 'nav buttons',  4);
/*                  ^category  ^action  ^label          ^value */

Exceptions

ga('send', 'exception', {
  exDescription: 'DatabaseError',
  exFatal: false,
  appName: 'myapp',
  appVersion: '0.1.2'
})

docker-compose cheatsheet

Basic example

# docker-compose.yml
version: '2'

services:
  web:
    build: .
    # build from Dockerfile
    context: ./Path
    dockerfile: Dockerfile
    ports:
     - "5000:5000"
    volumes:
     - .:/code
  redis:
    image: redis

Commands

docker-compose start
docker-compose stop
docker-compose pause
docker-compose unpause
docker-compose ps
docker-compose up
docker-compose down

Reference

Building

web:
  # build from Dockerfile
  build: .
  args:     # Add build arguments
    APP_HOME: app
  # build from custom Dockerfile
  build:
    context: ./dir
    dockerfile: Dockerfile.dev
  # build from image
  image: ubuntu
  image: ubuntu:14.04
  image: tutum/influxdb
  image: example-registry:4000/postgresql
  image: a4bc65fd

Ports

  ports:
    - "3000"
    - "8000:80"  # guest:host
  # expose ports to linked services (not to host)
  expose: ["3000"]

Commands

  # command to execute
  command: bundle exec thin -p 3000
  command: [bundle, exec, thin, -p, 3000]
  # override the entrypoint
  entrypoint: /app/start.sh
  entrypoint: [php, -d, vendor/bin/phpunit]

Environment variables

  # environment vars
  environment:
    RACK_ENV: development
  environment:
    - RACK_ENV=development
  # environment vars from file
  env_file: .env
  env_file: [.env, .development.env]

Dependencies

  # makes the `db` service available as the hostname `database`
  # (implies depends_on)
  links:
    - db:database
    - redis
  # make sure `db` is alive before starting
  depends_on:
    - db

Other options

  # make this service extend another
  extends:
    file: common.yml  # optional
    service: webapp
  volumes:
    - /var/lib/mysql
    - ./_data:/var/lib/mysql

Advanced features

Labels

services:
  web:
    labels:
      com.example.description: "Accounting web app"

DNS servers

services:
  web:
    dns: 8.8.8.8
    dns:
      - 8.8.8.8
      - 8.8.4.4

Devices

services:
  web:
    devices:
    - "/dev/ttyUSB0:/dev/ttyUSB0"
services:
  web:
    external_links:
      - redis_1
      - project_db_1:mysql

Hosts

services:
  web:
    extra_hosts:
      - "somehost:192.168.1.100"

Network

# creates a custom network called `frontend`
networks:
  frontend:

External network

# join a pre-existing network
networks:
  default:
    external:
      name: frontend

Semver cheatsheet

Semver

Given a version number MAJOR.MINOR.PATCH:

MAJORincompatible API changes
MINORadd functionality (backwards-compatible)
PATCHbug fixes (backwards-compatible)

Simple ranges

  1.2.3
 =1.2.3
 >1.2.3
 <1.2.3
>=1.2.3

Note that suffixed versions (1.2.3-rc1) are not matched.

Ranges

~1.2.3is >=1.2.3 <1.3.0 
^1.2.3is >=1.2.3 <2.0.0 
^0.2.3is >=0.2.3 <0.3.0(0.x.x is special)
^0.0.1is =0.0.1(0.0.x is special)
^1.2is >=1.2.0 <2.0.0(like ^1.2.0)
~1.2is >=1.2.0 <1.3.0(like ~1.2.0)
^1is >=1.0.0 <2.0.0 
~1same 
1.xsame 
1.*same 
1same 
*any version 
xsame 

Hyphenated ranges

1.2.3 - 2.3.0is >=1.2.3 <=2.3.4

Partial right

1.2.3 - 2.3is >=1.2.3 <2.4.0
1.2.3 - 2is >=1.2.3 <3.0.0

Partial left

1.2 - 2.3.0is 1.2.0 - 2.3.0

When the right is partial (eg, 2.3), missing pieces are assumed to be x (eg, 2.3.x).

When the left is partial (eg, 1.2), missing pieces are assumed to be 0 (eg, 1.2.0).

Combining ranges

>=0.14 <16And (space-separated)
0.14.x || 15.x.xOr (pipe-separated)

Pre-releases

1.2.3-prerelease+build

Explanation

^means “compatible with”
~means “reasonably close to”
0.x.xis for “initial development”
1.x.xmeans public API is defined

References

Bulma cheatsheet

Screen sizes

         768         1024                1216         1408
'     '     '     '     '     '     '     '     '     '     '     '
<---------^------------^------------------^-------------^------------->
  mobile      tablet         desktop         widescreen      fullhd

Columns

.container

Wrap as many .column’s’ as you like in a .columns wrapper

<div class="columns">
    <div class="column"></div>
    <div class="column"></div>
    <div class="column"></div>
    <div class="column"></div>
    <div class="column"></div>
</div>

Modifiers

The following CSS classes affect the colour.

.is-primary
.is-link
.is-info
.is-success
.is-warning
.is-danger

The following classes modify the size.

.is-small
.is-medium
.is-large

The following classes modify the state.

.is-outlined
.is-loading

Typography Helpers

The following classes modify the font-size

.is-size-13rem
.is-size-22.5rem
.is-size-32rem
.is-size-41.5rem
.is-size-51.25rem
.is-size-61rem
.is-size-70.75rem

The following classes align the text

.has-text-centeredMakes the text centered
.has-text-justifiedMakes the text justified
.has-text-left.Makes the text align to the left
.has-text-rightMakes the text align to the right

The following classes transform the text

.is-capitalizedTransforms the first character of each word to uppercase
.is-lowercaseTransforms all characters to lowercase
.is-uppercaseTransforms all characters to uppercase

WYSIWYG Content

<div class="content">
  <!-- start WYSIWYG contents -->
  <h1>Heading</h1>
  <p>Paragraph</p>

  <ul>
    <li>Item 1</li>
    <li>Item 2</li>
  </ul>
  <!-- end WYSIWYG contents -->
</div>

To provide default stylings for commonly generated WYSIWYG contents, use the .content class.

CSS Grid cheatsheet

Container

.grid-container {
  /* Display properties */
  display: grid;
  display: inline-grid;
  display: subgrid;
  /* Columns and rows */
  grid-template-columns: 1rem 2rem 1rem; /* Measurement units */
  grid-template-columns: 25% 50% 25%; /* Percentage units */
  grid-template-columns: 1rem auto 1rem 2fr; /* Fill remaining widths with auto or fr units */
  grid-template-columns: repeat(12, 1fr); /* Repeat columns without needing to write them */
  
  grid-template-rows: 1rem 10% auto repeat(5, 10px); /* Mix any group, same rules work for rows */
  /* Automatic columns and rows */

  grid-auto-columns: 10px; /* No matter how many columns of content end up in the grid, each column will be this same width */
  grid-auto-rows: 1rem; /* No matter how many rows of content end up in the grid, each row will be this same height */
  /* Areas */
  grid-template-areas:
    "header header"
    "main aside"
    "footer footer"; /* Grid-style */

  grid-template-areas: "header header" "main aside" "footer footer"; /* Inline-style */
  /* Template shorthand */
  grid-template:
    "header header" auto
    "main aside" 100vh
    "footer footer" 10rem
    / 80% 20%;

  /* The above is the same as below long-hand */
  grid-template-columns: 80% 20%;
  grid-template-rows: auto 100vh 10rem;
  grid-template-areas:
    "header header"
    "main aside"
    "footer footer";
  /* Gaps */
  grid-row-gap: 1rem;
  grid-column-gap: 0.5rem; /* Define values separately */

  grid-gap: 1rem 0.5rem; /* Short-hand for row / column */
  grid-gap: 1rem; /* Gap in both dimensions */
  /* Item justification (horizontal or column alignment) */
  justify-items: start; /* Align items to the left */
  justify-items: center; /* Align items centered within its column */
  justify-items: end; /* Align items to the right */
  justify-items: stretch; /* (default) Fills available area (horizontally) */
  /* Item alignment (vertical or row alignment) */
  align-items: start; /* Align items to the top */
  align-items: center; /* Align items centered within its row */
  align-items: end; /* Align items to the bottom */
  align-items: stretch; /* (default) Fills available area (vertically) */
  /* Place item shorthand */
  place-items: start stretch;

  /* The above is the same as below long-hand */
  align-items: start;
  justify-items: stretch;
  /* Content justification (horizontal or column alignment) */
  justify-content: start; /* Align content to the left */
  justify-content: center; /* Align content centered horizontally within the grid */
  justify-content: end; /* Align content to the right */
  justify-content: stretch; /* (default) Fills available area (horizontally) */

  justify-content: space-around; /* Chooses a space for both sides of the columns like a left and right margin */
  justify-content: space-between; /* Chooses a space to go between columns, no margins on outside of content */
  justify-content: space-evenly; /* Chooses a space that goes between all columns and edges consistently */
  /* Content alignment (horizontal or column alignment) */
  align-content: start; /* Align content to the top */
  align-content: center; /* Align content centered vertically within the grid */
  align-content: end; /* Align content to the bottom */
  align-content: stretch; /* (default) Fills available area (vertically) */

  align-content: space-around; /* Chooses a space for the top and bottom of the rows like a top and bottom margin */
  align-content: space-between; /* Chooses a space to go between rows, no margins on outside of content */
  align-content: space-evenly; /* Chooses a space that goes between all rows and edges consistently */
  /* Place item shorthand */
  place-content: center start;

  /* The above is the same as below long-hand */
  align-content: center;
  justify-content: start;
  /* Automatic grid positioning */

  grid-auto-flow: row; /* Left-to-right rows, then top-to-bottom*/
  grid-auto-flow: column; /* Top-to-bottom columns, then left-to-right */
  grid-auto-flow: dense; /* Responds with best-guess on left-to-right, top-to-bottom order with advanced layouts */
  /* There is one final shorthand for all container properties in one */

  /* Explicit grid columns, rows, and areas */
  grid:
    "header header" auto
    "main aside" 100vh
    "footer footer" 10rem
    / 80% 20%; /* You can include a template as the only value, which is equivalent to below */
  grid-template:
    "header header" auto
    "main aside" 100vh
    "footer footer" 10rem
    / 80% 20%; /* Which is again equivalent to below */
  grid-template-columns: 80% 20%;
  grid-template-rows: auto 100vh 10rem;
  grid-template-areas:
    "header header"
    "main aside"
    "footer footer";

  /* Automatic grid flows */
  grid: 1rem / auto-flow dense 1fr; /* You can include rows, a flow, and automatic columns, which is equivalent to below */
  grid-template-rows: 1rem;
  grid-auto-flow: dense;
  grid-auto-columns: 1fr;

  grid: auto-flow dense 1rem / repeat(10, 10%); /* Conversely, you can do the same thing with automatic rows, and defined columns */
  grid-auto-flow: dense;
  grid-auto-rows: 1rem;
  grid-template-columns: repeat(10, 10%);
}

Child

.grid-child {
  /* Column position */
  grid-column-start: 1;
  grid-column-end: 2;

  grid-column: 1 / 2; /* Short hand */
  grid-column: 1 / span 2; /* Span 2 columns without explicitly defining an endpoint */
  grid-column: 1; /* Start in and occupy a single column */
  /* Row position */
  grid-row-start: 2;
  grid-row-end: 4;

  grid-row: 2 / 4; /* Short hand */
  grid-row: 2 / span 3;/* Span 3 rows without explicitly defining an endpoint */
  grid-row: 1; /* Start in and occupy a single row */
  /* Area positioning */
  grid-area: header; /* You can use a named grid area from the container */

  grid-area: 2 / 1 / 4 / 2; /* Or you can use positioning. This is equivalent to... */
  grid-row-start: 2;
  grid-column-start: 1;
  grid-row-end: 4;
  grid-column-end: 2;
  /* Self justification (horizontal or column alignment) */
  justify-self: start; /* Align item to the left */
  justify-self: center; /* Align item centered within its column */
  justify-self: end; /* Align item to the right */
  justify-self: stretch; /* (default) Fills available area (horizontally) */
  /* Self alignment (vertical or row alignment) */
  align-self: start; /* Align item to the top */
  align-self: center; /* Align item centered within its row */
  align-self: end; /* Align item to the bottom */
  align-self: stretch; /* (default) Fills available area (vertically) */
  /* Placement shorthand */
  place-self: start stretch;

  /* The above is the same as below long-hand */
  align-self: start;
  justify-self: stretch;
}

References

Bolt Quickstart cheatsheet

Install Bolt

# On MacOS
brew cask install puppetlabs/puppet/puppet-bolt
# On Windows
choco install puppet-bolt

Bolt is available as a package for most platforms. See installing bolt

Create a module with a task

mkdir -p ~/.puppetlabs/bolt/modules/mymodule/tasks
cp myscript.sh ~/.puppetlabs/bolt/modules/mymodule/tasks/

Tasks can be written in any language your targets can run. See writing tasks for more details.

Run Bolt

bolt task run mymodule::myscript -n node1.example.com,node2.example.com --private-key ~/.ssh/id_rsa-private

See bolt task run --help for more information and command line options.

RESTful API cheatsheet

Status codes

200 OKSuccessful get, patch (return a JSON object)
201 CreatedSuccessful post (return a JSON object)
202 AcceptedSuccessful post, delete, path – async
204 No contentSuccessful delete
206 Partial contentSuccessful get – async

Error status

401 UnauthorizedNot authenticated
403 ForbiddenAuthenticated, but no permissions
422 Unprocessable entityValidation

Errors

HTTP/1.1 401 Unauthorized
Content-Type: application/json
{
  'id': 'auth_failed',
  'message': "You're not logged in."
}

Here’s an example of a possible error reply.

Versioning

GET /api/foo
Accept: application/json; version=1

You can pass a version=x to the Accept request header. Info here

Authentication

curl -is https://$TOKEN@api.service.com/

Methods

GET /articles/1read, returns 200
PUT /articles/1edit (or path), returns 200
DELETE /articles/1delete, returns 200
POST /articlescreate, returns 201
GET /articleslist, returns 200

References