From a54791651fc6b7c12ddf3ea39ca76955c3184beb Mon Sep 17 00:00:00 2001 From: Sherry Yang Date: Tue, 5 Mar 2019 15:25:54 +0100 Subject: [PATCH 001/215] XML cheat sheet Add first part of XML cheat sheet to the repository --- languages/XML.md | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 languages/XML.md diff --git a/languages/XML.md b/languages/XML.md new file mode 100644 index 0000000..adbac30 --- /dev/null +++ b/languages/XML.md @@ -0,0 +1,62 @@ +> announcement: this doc is a quiz-, interview-oriented cheatsheet, which desigend for those who want to have an overview of XML, when preparing for interviews. + +# What is XML +XML stands for eXtensible Markup Language, XML was designed to store and transport data. XML is often used for distributing data over the Internet(especial in web development). + +# Then how can XML store data +XML uses a DTD to describe the data. + +# The relation with HTML +* XML: is used to store or transport data. + So the XML is a **Complement** to HTML. +* HTML: is used to format and display the same data. + + +XML does not carry any information about how to be displayed. The same XML data can be used in many different presentation scenarios. +Because of this, with XML, there is a full separation between data and presentation. + +# What is XML Schema/DTD +The purpose of a DTD is to define the structure of an XML document. It defines the structure with a list of legal elements: + + +# When Not to Use a XML DTD/Sschema +XML does not require a DTD/Schema. + +When you are experimenting with XML, or when you are working with small XML files, creating DTDs may be a waste of time. + +If you develop applications, wait until the specification is stable before you add a document definition. Otherwise, your software might stop working because of validation errors. + + +# XML Syntax +The XML language has no predefined tags, but the syntax is rather logic and easy to learn. XML documents must contain one root element that is the parent of all other elements. + +``` + + + Harry Potter + J K. Rowling + 2005 + 29.99 + + + Learning XML + Erik T. Ray + 2003 + 39.95 + + +``` + +1. XML Tags are Case Sensitive +2. All XML Elements Must Have a Closeing Tag + +``` +

This is a paragraph.

+
+``` +3. XML Attribute Values Must Always be Quoted +4. Pay attention to the name rules. + +# Reference +1. (W3School) [https://www.w3schools.com/xml/] +2. [cheat sheet in German](https://www.i-d-e.de/wp-content/uploads/2015/02/ide-xml-kurzreferenz.pdf) From 432c2c8becca35bb644468d35bfd80079ab673eb Mon Sep 17 00:00:00 2001 From: David Luecke Date: Wed, 28 Aug 2019 08:57:12 -0700 Subject: [PATCH 002/215] Update FeathersJS cheatsheet to Feathers v4 --- backend/feathers.js | 320 +++++++++++++++----------------------------- 1 file changed, 106 insertions(+), 214 deletions(-) diff --git a/backend/feathers.js b/backend/feathers.js index c1cd63e..2a574b6 100644 --- a/backend/feathers.js +++ b/backend/feathers.js @@ -113,13 +113,13 @@ app.service('my-service').hooks({ before: { all: [ // Use normal functions - function(context) { console.log('before all hook ran'); } + async function(context) { console.log('before all hook ran'); } ], find: [ // Use ES6 arrow functions context => console.log('before find hook 1 ran'), - context => console.log('before find hook 2 ran') + async context => console.log('before find hook 2 ran') ], async create (context) { @@ -177,7 +177,8 @@ service.publish([event,] fn) // registers a publishing function for a specific app.publish([event,] fn) // registers an event publishing callback app.on('connection', connection => {}) // fired every time a new real-time connection is established -app.on('login', (payload, info) => {}) // sent by the authentication module and also contains the connection in the info object that is passed as the second parameter +app.on('disconnection', connection => {}) +app.on('login', (authenticationResult, params, context) => {}) // sent by the authentication module and also contains the connection in the info object that is passed as the second parameter /* ******************************************************************************************* @@ -233,13 +234,6 @@ app.configure(socketio(callback)) // sets up the Socket.io t app.configure(socketio(options [, callback])) // sets up the Socket.io transport with the given Socket.io options object and optionally calls the callback app.configure(socketio(port, [options], [callback])) // creates a new Socket.io server on a separate port. Options and a callback are optional -// The options can also be used to initialize uWebSocket which is a WebSocket server -// implementation that provides better performace and reduced latency. -// npm install uws --save -app.configure(socketio({ - wsEngine: 'uws' -})); - // --> PRIMUS <-- // https://docs.feathersjs.com/api/client/primus.html @@ -306,55 +300,65 @@ npm install @feathersjs/authentication --save # Wraps the passport-local authentication strategy (username and password) npm install @feathersjs/authentication-local --save -# Wraps the passport-jwt authentication strategy (JSON Web Token access token) -npm install @feathersjs/authentication-jwt --save - -# Allows you to use any Passport OAuth1 authentication strategy (most notably Twitter) -npm install @feathersjs/authentication-oauth1 --save - -# Allows you to use any Passport OAuth2 authentication strategy (FB, Instagram, Github, Google...) -npm install @feathersjs/authentication-oauth2 --save +# Allows to use 180+ oAuth providers (Facebook, Google, Twitter etc.) +npm install @feathersjs/authentication-oauth --save ``` // --> SERVER <-- // https://docs.feathersjs.com/api/authentication/server.html const options = { - path: '/authentication', // the authentication service path - header: 'Authorization', // the header to use when using JWT auth - entity: 'user', // the entity that will be added to the request, socket, and context.params. (ie. req.user, socket.user, context.params.user) - service: 'users', // the service to look up the entity - passReqToCallback: true, // whether the request object should be passed to the strategies `verify` function - session: false, // whether to use sessions - cookie: { - enabled: false, // whether cookie creation is enabled - name: 'feathers-jwt', // the cookie name - httpOnly: false, // when enabled, prevents the client from reading the cookie. - secure: true // whether cookies should only be available over HTTPS - }, - jwt: { - header: { typ: 'access' }, // by default is an access token but can be any type - audience: 'https://yourdomain.com', // The resource server where the token is processed - subject: 'anonymous', // Typically the entity id associated with the JWT - issuer: 'feathers', // The issuing server, application or resource - algorithm: 'HS256', // the algorithm to use - expiresIn: '1d' // the access token expiry + "authentication": { + "secret": "CHANGE_ME", // The token signing secret + "entity": "user", // the entity that will be added to the request, socket, and context.params. (ie. req.user, socket.user, context.params.user) + "service": "users", // the service to look up the entity + "authStrategies": [ "jwt", "local" ], // The authentication strategies to allow to create a token + "jwtOptions": { + "header": { "typ": "access" }, // by default is an access token but can be any type + "audience": "https://yourdomain.com", // The resource server where the token is processed + "issuer": "feathers", // The issuing server, application or resource + "algorithm": "HS256", // the algorithm to use + "expiresIn": "1d" // the access token expiry + } } } -app.configure(auth(options)) // configure the authentication plugin with the given options +const { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication'); -service = app.service('authentication') // service for creating JWT (implements only the create and remove methods) +let authService = new AuthenticationService(app); -service.create(data) // creates a JWT based on the jwt options configured on the plugin -service.remove(data) // removes the JWT token (mostly exists for the logout process) -service.hooks({ before }) // registers hooks for this service -service.hooks({ after }) // registers hooks for this service +service.register('jwt', new JWTStrategy()); -app.passport.createJWT(payload, options) // used by the authentication service to generate JSON Web Tokens -app.passport.verifyJWT(token, options) // verifies the signature and payload of the passed in JWT token using the options +app.use('/authentication', authService); +app.configure(expressOauth()); + +app.get('defaultAuthentication') // The name of the default authentication service + +authService = app.service('authentication') // service for creating JWT (implements only the create and remove methods) + +authService.hooks({ before }) // registers hooks for this service +authService.hooks({ after }) // registers hooks for this service + +new AuthenticationService(app) // Create a new authentication service + +class MyAuthenticationService extends AuthenticationService {} // Customize the authentication service + +authService.authenticate(data, params, ...strategies) // Authenticate with strategies +authService.create(data, params) // Authenticate with data and params +authService.create({ // Authenticate and create a JWT using the local strategy email/password + strategy: 'local', + email: 'hello@feathersjs.com', + password: 'supersecret' +}); +authService.remove(id, params) // removes the JWT token (mostly exists for the logout process) +authService.configuration // The current configuration +authService.register(name, strategy) // Register a new authentication strategy +authService.createAccessToken(payload) // Create a new access token with payload +authService.verifyAccessToken(accessToken) // Verify an existing access token +authService.getTokenOptions(authResult, params) // Get the options for a token +authService.getPayload(authResult, params) // Return the payload for an authentication result +authService.parse(req, res, ...strategies) // Parse an HTTP request and response with using a list of strategies -auth.hooks.authenticate(strategies) // registers an array of authentication strategies on a service method app.on('login', callback)) // emits an event whenever a client successfully authenticates app.on('logout', callback)) // emits an event whenever a client successfully logout @@ -363,198 +367,77 @@ app.on('logout', callback)) // emits an event whenever a client successfully lo // https://docs.feathersjs.com/api/authentication/client.html const options = { - path: '/authentication', // the server-side authentication service path - header: 'Authorization', // the default authorization header for REST - jwtStrategy: 'jwt', // the name of the JWT authentication strategy - entity: 'user', // the entity you are authenticating (ie. a users) - service: 'users', // the service to look up the entity - cookie: 'feathers-jwt', // the name of the cookie to parse the JWT from when cookies are enabled server side - storageKey: 'feathers-jwt', // the key to store the accessToken in localstorage or AsyncStorage on React Native - storage: undefined // Passing a WebStorage-compatible object to enable automatic storage on the client. + storage: window.localStorage, // The storage to store the access token + path: '/authentication', // The path of the authentication service + locationKey: 'access_token', // The name of the window hash parameter to parse for an access token from the window.location. Usually used by the oAuth flow. + locationErrorKey: 'error', // The name of the window hash parameter to parse for authentication errors. Usually used by the oAuth flow. + jwtStrategy: 'jwt', // The access token authentication strategy + storageKey: 'feathers-jwt', // Key for storing the token in e.g. localStorage + header: 'Authorization', // Name of the accessToken header + scheme: 'Bearer', // The HTTP header scheme + Authentication: AuthenticationClient // Allows to provide a customized authentication client class } app.configure(auth(options)) // configure the authentication plugin with the given options -app.authenticate() // authenticates using the JWT from the storage +app.reAuthenticate() // authenticates using the JWT from the storage app.authenticate(options) // authenticate with a Feathers server by passing a strategy and other properties as credentials app.logout() // removes the JWT accessToken from storage on the client -app.passport.getJWT() // pulls the JWT from storage or the cookie -app.passport.verifyJWT(token) // verifies that a JWT is not expired and decode it to get the payload -app.passport.payloadIsValid(token) // synchronously verify that a token has not expired +const authenticationInfo = await app.get('authentication'); // The authenticatoin information (like the user) -app.on('authenticated', callback)) // emits an event whenever the client successfully authenticates -app.on('logout', callback)) // emits an event whenever the client successfully authenticates -app.on('reauthentication-error', errorHandler) // will automatically handle attempting to re-authenticate the socket when the client regains connectivity with the server +app.on('login', callback) // emits an event whenever the client successfully authenticates +app.on('logout', callback) // emits an event whenever the client successfully authenticates // --> LOCAL (EMAIL & PASSWORD) <-- // https://docs.feathersjs.com/api/authentication/local.html -const feathers = require('@feathersjs/feathers'); -const authentication = require('@feathersjs/authentication'); -const local = require('@feathersjs/authentication-local'); -const app = feathers(); +const { LocalStrategy } = require('@feathersjs/authentication-local'); const options = { - name: 'local', // the name to use when invoking the authentication Strategy - entity: 'user', // the entity that you're comparing username/password against - service: 'users', // the service to look up the entity - usernameField: 'email', // key name of username field - passwordField: 'password', // key name of password field - passReqToCallback: true, // whether the request object should be passed to `verify` - session: false, // whether to use sessions - Verifier: Verifier // A Verifier class. Defaults to the built-in one but can be a custom one + usernameField: 'email', // Name of the username field in the (e.g. 'email') + passwordField: 'password', // Name of the password field (e.g. 'password') + hashSize: 10, // The BCrypt hash size + errorMessage: 'Invalid login', // The error message to return on errors + entityUsernameField: usernameField, // Name of the username field on the entity if authentication request data and entity field names are different + entityPasswordField: passwordField // Name of the password field on the entity if authentication request data and entity field names are different } -app.configure(authentication(options)); -app.configure(local()); - -// Setup a hook to only allow valid JWTs or successful -// local auth to authenticate and get new JWT access tokens -app.service('authentication').hooks({ - before: { - create: [ - authentication.hooks.authenticate(['local', 'jwt']) - ] - } -}); +authService.register('local', new LocalStrategy()); local.hooks.hashPassword() // hashes plain text passwords before they are saved to the database local.hooks.protect('password') // makes sure that protected fields don't get sent to a client -// --> JWT <-- -// https://docs.feathersjs.com/api/authentication/jwt.html +// --> OAUTH <-- +// https://docs.feathersjs.com/api/authentication/oauth.html +const { expressOauth, OAuthStrategy } = require('@feathersjs/authentication-oauth'); -const feathers = require('@feathersjs/feathers'); -const authentication = require('@feathersjs/authentication'); -const jwt = require('@feathersjs/authentication-jwt'); -const app = feathers(); +class GitHubStrategy extends OAuthStrategy { + async getEntityData(profile) { + const baseData = await super.getEntityData(profile); -const options = { - name: 'jwt', // the name to use when invoking the authentication Strategy - entity: 'user', // the entity that you pull from if an 'id' is present in the payload - service: 'users', // the service to look up the entity - passReqToCallback: true, // whether the request object should be passed to `verify` - jwtFromRequest: [ // a passport-jwt option determining where to parse the JWT - ExtractJwt.fromHeader, // From "Authorization" header - ExtractJwt.fromAuthHeaderWithScheme('Bearer'), // Allowing "Bearer" prefix - ExtractJwt.fromBodyField('body') // from request body - ], - secretOrKey: auth.secret, // Your main secret provided to passport-jwt - session: false, // whether to use sessions, - Verifier: Verifier // A Verifier class. Defaults to the built-in one but can be a custom one. See below for details. + return { + ...baseData, + email: profile.email + }; + } } -app.configure(authentication(options)); -app.configure(jwt()); - -// Setup a hook to only allow valid JWTs to authenticate -// and get new JWT access tokens -app.service('authentication').hooks({ - before: { - create: [ - authentication.hooks.authenticate(['jwt']) - ] - } -}); - -// --> OAUTH1 <-- -// https://docs.feathersjs.com/api/authentication/oauth1.html - -const feathers = require('@feathersjs/feathers'); -const authentication = require('@feathersjs/authentication'); -const jwt = require('@feathersjs/authentication-jwt'); -const oauth1 = require('@feathersjs/authentication-oauth1'); - -const session = require('express-session'); -const TwitterStrategy = require('passport-twitter').Strategy; -const app = feathers(); - -// Setup in memory session -app.use(session({ - secret: 'super secret', - resave: true, - saveUninitialized: true -})); +authService.register('github', new MyGitHubStrategy()); const options = { - idField: 'Id', // The field to look up the entity by when logging in with the provider. Defaults to 'Id' (ie. 'twitterId'). - path: '/auth/', // The route to register the middleware - callbackURL: 'http(s)://hostame[:port]/auth//callback', // The callback url. Will automatically take into account your host and port and whether you are in production based on your app environment to construct the url. (ie. in development http://localhost:3030/auth/twitter/callback) - entity: 'user', // the entity that you are looking up - service: 'users', // the service to look up the entity - passReqToCallback: true, // whether the request object should be passed to `verify` - session: true, // whether to use sessions, - handler: fn, // Express middleware for handling the oauth callback. Defaults to the built in middleware. - formatter: fn, // The response formatter. Defaults the the built in feathers-rest formatter, which returns JSON. - Verifier: Verifier // A Verifier class. Defaults to the built-in one but can be a custom one. See below for details. + authentication: { + oauth: { + redirect: '/', // The redirect after a successful login + github: { // The per-strategy configuration + key: '', + secret: '' + } + } + } } -// Setup authentication -app.configure(authentication(options)); -app.configure(jwt()); -app.configure(oauth1({ - name: 'twitter', - Strategy: TwitterStrategy, - consumerKey: '', - consumerSecret: '' -})); - -// Setup a hook to only allow valid JWTs to authenticate -// and get new JWT access tokens -app.service('authentication').hooks({ - before: { - create: [ - authentication.hooks.authenticate(['jwt']) - ] - } -}); - -// --> OAUTH 2 <-- -// https://docs.feathersjs.com/api/authentication/oauth2.html - -const feathers = require('@feathersjs/feathers'); -const authentication = require('@feathersjs/authentication'); -const jwt = require('@feathersjs/authentication-jwt'); -const oauth2 = require('@feathersjs/authentication-oauth2'); -const FacebookStrategy = require('passport-facebook').Strategy; -const app = feathers(); - -const options = { - idField: 'Id', // The field to look up the entity by when logging in with the provider. Defaults to 'Id' (ie. 'facebookId'). - path: '/auth/', // The route to register the middleware - callbackURL: 'http(s)://hostname[:port]/auth//callback', // The callback url. Will automatically take into account your host and port and whether you are in production based on your app environment to construct the url. (ie. in development http://localhost:3030/auth/facebook/callback) - successRedirect: undefined, - failureRedirect: undefined, - entity: 'user', // the entity that you are looking up - service: 'users', // the service to look up the entity - passReqToCallback: true, // whether the request object should be passed to `verify` - session: false, // whether to use sessions, - handler: fn, // Express middleware for handling the oauth callback. Defaults to the built in middleware. - formatter: fn, // The response formatter. Defaults the the built in feathers-rest formatter, which returns JSON. - Verifier: Verifier // A Verifier class. Defaults to the built-in one but can be a custom one. See below for details. -} - -// Setup authentication -app.configure(authentication({ secret: 'super secret' })); -app.configure(jwt()); -app.configure(oauth2({ - name: 'facebook', - Strategy: FacebookStrategy, - clientID: '', - clientSecret: '', - scope: ['public_profile', 'email'] -})); - -// Setup a hook to only allow valid JWTs to authenticate -// and get new JWT access tokens -app.service('authentication').hooks({ - before: { - create: [ - authentication.hooks.authenticate(['jwt']) - ] - } -}); +app.configure(expressOauth(options)); /* ******************************************************************************************* @@ -602,7 +485,9 @@ app.use('/messages', service({ paginate: { // (optional) a pagination object containing a default and max page size default: undefined, // sets the default number of items when $limit is not set max: undefined // sets the maximum allowed number of items per page (even if the $limit query parameter is set higher) - } + }, + whitelist: [], // A list of additional non-standard query parameters to allow (e.g [ '$regex', '$populate' ]) + multi: true // Allow create with arrays and update and remove with id null to change multiple items })); adapter.find() // returns a list of all records matching the query in params.query using the common querying mechanism @@ -612,6 +497,14 @@ adapter.update(id, data, params) // completely replaces a single record identif adapter.patch(id, data, params) // merges a record identified by id with data. id can be null to allow replacing multiple records (all records that match params.query the same as in .find). id can not be changed adapter.remove(id, params) // removes a record identified by id. id can be null to allow removing multiple records (all records that match params.query the same as in .find) +// Hook-less +adapter._find() +adapter._get(id, params) +adapter._create(data, params) +adapter._update(id, data, params) +adapter._patch(id, data, params) +adapter._remove(id, params) + // --> QUERYING <-- // https://docs.feathersjs.com/api/databases/querying.html @@ -673,14 +566,13 @@ app.service('messages').find({ // │ │ └── ... // │ ├── services/ # contains our services // │ │ └── ... -// │ ├── tests/ # contains Mocha test files for the app, hooks and services -// │ │ └── ... // │ │ // │ ├── index.js # is used to load and start the application // │ ├── app.js # configures our Feathers application // │ ├── app.hooks.js # contains hooks which that run for all services // │ └── channels.js # set up Feathers event channels -// │ +// ├── tests/ # contains Mocha test files for the app, hooks and services +// │ └── ... // ├── .editorconfig # helps developers define and maintain consistent coding styles // ├── .eslintrc.json # eslint configuration // └── package.json # express server for production From 75058411bbcbe901eb6f1a840d6e69834570bf98 Mon Sep 17 00:00:00 2001 From: Sudhakar R Date: Thu, 29 Aug 2019 15:50:13 +0530 Subject: [PATCH 003/215] Fixing a missed spacing --- languages/C.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/C.txt b/languages/C.txt index 5ed3de5..ca721f5 100644 --- a/languages/C.txt +++ b/languages/C.txt @@ -45,7 +45,7 @@ break used to exit loop and used to exit switch case choice in a switch char basic declaration of a type character const prefix declaration meaning variable can not be changed -continuego to bottom of loop in for, while and do loops +continue go to bottom of loop in for, while and do loops default optional last case of a switch do executable statement, do-while loop double basic declaration double precision floating point From 7d7afdd2180209d8af4efa1252ed3a7fcbe76c91 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Thu, 5 Sep 2019 12:57:22 +0200 Subject: [PATCH 004/215] docs(laravel): add valet commands --- backend/laravel.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/backend/laravel.php b/backend/laravel.php index 70d128a..98c4952 100644 --- a/backend/laravel.php +++ b/backend/laravel.php @@ -379,3 +379,27 @@ $this->assertGuest($guard = null); // Assert t $this->assertAuthenticatedAs($user, $guard = null); // Assert that the given user is authenticated. $this->assertCredentials(array $credentials, $guard = null); // $this->assertCredentials(array $credentials, $guard = null). $this->assertInvalidCredentials(array $credentials, $guard = null); // Assert that the given credentials are invalid. + +/******************************************************************************************** + * 14. LARAVEL VALET COMMANDS + * https://laravel.com/docs/6.0/valet + ********************************************************************************************/ + +valet install // Install the Valet daemon. +valet uninstall // Uninstall the Valet daemon. +valet use php@7.2 // Allows you to switch between php versions. + +valet restart // Restart the Valet daemon. +valet start // Start the Valet daemon. +valet stop // Stop the Valet daemon. + +valet park // Register your current working directory as a path which Valet should search for sites. +valet forget // Run this command from a "parked" directory to remove it from the parked directory list. +valet paths // View all of your "parked" paths. +valet link // Link a single site in the current directory and not the entire directory. +valet unlink // Unlink a single site in the current directory +valet secure // Serve site into https +valet unsecure // Revert back to http + +valet log // View a list of logs which are written by Valet's services. +valet trust // Add sudoers files for Brew and Valet to allow Valet commands to be run without prompting for passwords. From 68933acade160ba9db8132202b155b5184b4dda5 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Thu, 5 Sep 2019 13:39:35 +0200 Subject: [PATCH 005/215] docs(laravel): update Valet commands --- backend/laravel.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/backend/laravel.php b/backend/laravel.php index 98c4952..a383ab5 100644 --- a/backend/laravel.php +++ b/backend/laravel.php @@ -389,17 +389,22 @@ valet install // Install the Valet daemon. valet uninstall // Uninstall the Valet daemon. valet use php@7.2 // Allows you to switch between php versions. -valet restart // Restart the Valet daemon. valet start // Start the Valet daemon. valet stop // Stop the Valet daemon. +valet restart // Restart the Valet daemon. valet park // Register your current working directory as a path which Valet should search for sites. valet forget // Run this command from a "parked" directory to remove it from the parked directory list. valet paths // View all of your "parked" paths. -valet link // Link a single site in the current directory and not the entire directory. -valet unlink // Unlink a single site in the current directory + +valet link // Link a single site in the current directory and not the entire directory. +valet unlink // Unlink a single site in the current directory +valet links // View all of your "linked" paths. + valet secure // Serve site into https valet unsecure // Revert back to http -valet log // View a list of logs which are written by Valet's services. -valet trust // Add sudoers files for Brew and Valet to allow Valet commands to be run without prompting for passwords. +valet log // View a list of logs which are written by Valet's services. +valet trust // Add sudoers files for Brew and Valet to allow Valet commands to be run without prompting for passwords. +valet tld // Update tld for your domains (default to test). +valet share // Share your site with the world. From d9eee18d872fb785078e064fb32eea06680f76b6 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sat, 7 Sep 2019 16:32:05 +0200 Subject: [PATCH 006/215] docs(vscode): add XML Format plugin --- tools/vscode.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/vscode.md b/tools/vscode.md index 5f51625..02853bf 100644 --- a/tools/vscode.md +++ b/tools/vscode.md @@ -12,6 +12,8 @@ - `SCSS IntelliSense`: Advanced autocompletion and refactoring support for SCSS. +- `XML Format`: Format XML documents. + ### JavaScript, Node & NPM - `Import Cost`: This extension will display inline in the editor the size of the imported package. From 12e5e7747eecd74313bbfc51dbb5fc75569c5146 Mon Sep 17 00:00:00 2001 From: Arkadius Jonczek Date: Fri, 13 Sep 2019 23:26:53 +0200 Subject: [PATCH 007/215] add trait example to php language --- languages/php.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/languages/php.php b/languages/php.php index 78a565f..572cf93 100644 --- a/languages/php.php +++ b/languages/php.php @@ -303,3 +303,39 @@ abstract class AbstractClassName abstract function abstractFunction(Type $var = null): Type; } + + +/** + * Basic Implementation of LoggerAwareInterface. + * @see https://github.com/php-fig/log/blob/master/Psr/Log/LoggerAwareTrait.php + */ +trait LoggerAwareTrait +{ + /** + * The logger instance. + * + * @var LoggerInterface + */ + protected $logger; + /** + * Sets a logger. + * + * @param LoggerInterface $logger + */ + public function setLogger(LoggerInterface $logger) + { + $this->logger = $logger; + } +} + + +/** + * Example with use of LoggerAwareTrait. + */ +class ClassWithLogger +{ + /** + * Use the LoggerAwareTrait in this class. + */ + use LoggerAwareTrait; +} \ No newline at end of file From dfe3d9c173b308dc77b52f4b2918a84531a7888b Mon Sep 17 00:00:00 2001 From: Manoj Tyagi <38884133+neo-0224@users.noreply.github.com> Date: Tue, 24 Sep 2019 00:38:07 +0530 Subject: [PATCH 008/215] Created basic cheatsheet for Heroku CLI I have created a cheat sheet on Heroku CLI where I have included all the basic commands with basic deployment methods needed to deploy and manage the application on the Heroku platform --- tools/heroku.sh | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 tools/heroku.sh diff --git a/tools/heroku.sh b/tools/heroku.sh new file mode 100644 index 0000000..d6c1c00 --- /dev/null +++ b/tools/heroku.sh @@ -0,0 +1,114 @@ +# ############################################################################## +##### HEROKU TOOLBELT COMPLETE GUIDE ########################################### +################################################################################ + + + +# Installing Heroku toolbelt using command line + +# For MacOS... +brew tap heroku/brew && brew install heroku + +# For Ubuntu... +sudo snap install --classic heroku + +# Other installation methods are + +curl https://cli-assets.heroku.com/install.sh | sh # only for unix based systems, windows incompatible as it needs sudo + +curl https://cli-assets.heroku.com/install-ubuntu.sh | sh # Ubuntu/Debian apt-get + +yay -S heroku-cli # Arch linux, Note: This package is community maintained not by heroku + +npm install -g heroku # This installation method is required for users on ARM and BSD... + + +############ + +# Verifying your installation + +heroku --version + + +# Let's get started with heroku + +heroku login # To login into the heroku toolbelt with your heroku account, this will open browser for you. + +heroku login -i # If you prefer to stay in the command line environment, then you can execute this command + + +# Now navigate to your desired directory and create a blank heroku application + +cd ~/myapp +heorku create + + +# If you are facing login issues, try to execute the following command + +mv ~/.netrc ~/.netrc.backup +heroku login + + +# Uninstalling the heroku CLI + +# For macOS +rm -rf /usr/local/heroku /usr/local/lib/heroku /usr/local/bin/heroku ~/.local/share/heroku ~/Library/Caches/heroku + +# or you can try the below command also on macOS +brew uninstall heroku +rm -rf ~/.local/share/heroku ~/Library/Caches/heroku + +# For Linux (Standalone installs) +rm /usr/local/bin/heroku +rm -rf /usr/local/lib/heroku /usr/local/heroku +rm -rf ~/.local/share/heroku ~/.cache/heroku + +# For Linux (Debian and Ubuntu installs) +sudo apt-get remove heroku heroku-toolbelt +sudo rm /etc/apt/sources.list.d/heroku.list + + + + +##################################################################################################### +### Managing and deploying applications on Heroku (Using Git) ################################### +##################################################################################################### + + +cd myapp # Changing into the project directory +git init # Initializing the project into a git repository +git add . # Adding all the contents of the project into the repository excluding .gitignore content +git commit -m "My first commit" # Commiting the content to the repository + +heroku create # Creating a new empty application on Heroku +git remote -v # verifying that the remote is set to the heroku + +heroku git:remote -a thawing-inlet-61413 # For an existing heroku app, you can add remote to the application +git remote rename heroku heroku-staging # renaming remotes + +git push heroku master # Deploying code to the heroku application +git push heroku testbranch:master # Deploying code from a non-master branch to the heroku application + +heroku create --ssh-git # ssh git transport for the application instead of https +git config --global url.ssh://git@heroku.com/.insteadOf https://git.heroku.com/ # For using ssh always +git config --global --remove-section url.ssh://git@heroku.com/ # To remove this rewrite setting run the command + + + + +##################################################################################################### +### Managing and deploying applications on Heroku (Using Docker) ################################### +##################################################################################################### + + +heroku container:login # Login to the container resistry +git clone https://github.com/heroku/alpinehelloworld.git # Get sample code by cloning into the following repository +heroku create # Creating a blank heroku application + +heroku container:push web # Build the image and push to Container Registry +heroku container:push --recursive # Pushing from the root directory of the project in recursive manner +heroku container:push web worker --recursive # Building the image and pushing to container resistry in recursive manner +heroku container:release web # Releasing the image to your application + +heroku open # Open the application in the browser + From a38e14178901632c313077c47f70734112c6e005 Mon Sep 17 00:00:00 2001 From: Manoj Tyagi <38884133+neo-0224@users.noreply.github.com> Date: Tue, 24 Sep 2019 01:30:10 +0530 Subject: [PATCH 009/215] Some more django-admin commands added I have added some more useful and some advanced django-admin commands with there use and description in a proper format. --- backend/django.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/backend/django.py b/backend/django.py index 3cc384c..34bf4f6 100644 --- a/backend/django.py +++ b/backend/django.py @@ -50,3 +50,28 @@ django-admin makemigrations # create new migrations to the database django-admin runserver # start the development webserver at 127.0.0.1 with the port 8000 django-admin help # display usage information and a list of the commands provided by each application django-admin version # display the current django version + + +# ****************************************************************************** +# Other useful or advanced django-admin commands +# ****************************************************************************** + + +django-admin check # Checks the entire django project for potential problems +django-admin compilemessages # Compiles .po files to .mo files for use with builtin gettext support +django-admin createcachetable # Creates the tables needed to use the SQL cache backend. +django-admin dbshell # Runs the command-line client for specified database, or the default database if none is provided. +django-admin diffsettings # Displays differences between the current settings.py and Django's default settings. +django-admin dumpdata # Output the contents of the database as a fixture of the given format (using each model's default manager unless --all is specified). +django-admin flush # Removes ALL DATA from the database, including data added during migrations. Does not achieve a "fresh install" state. +django-admin inspectdb # Introspects the database tables in the given database and outputs a Django model module. +django-admin loaddata # Installs the named fixture(s) in the database. +django-admin makemessages # Runs over the entire source tree of the current directory and pulls out all strings marked for translation. It creates (or updates) a message file in the conf/locale (in the django tree) or locale (for projects and applications) directory. You must run this command with one of either the --locale, --exclude, or --all options. +django-admin sendtestemail # Sends a test email to the email addresses specified as arguments. +django-admin shell # Runs a Python interactive interpreter. Tries to use IPython or bpython, if one of them is available. Any standard input is executed as code. +django-admin showmigrations # Shows all available migrations for the current project. +django-admin sqlflush # Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed. +django-admin sqlmigrate # Prints the SQL statements for the named migration. +django-admin sqlsequencereset # Prints the SQL statements for resetting sequences for the given app name(s). +django-admin squashmigrations # Squashes an existing set of migrations (from first until specified) into a single new one. +django-admin testserver # Runs a development server with data from the given fixture(s). From 841dc6ce33be9192fad704097b16dc31cfbd5725 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Tue, 24 Sep 2019 09:26:33 +0200 Subject: [PATCH 010/215] docs(django): update --- backend/django.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/backend/django.py b/backend/django.py index 34bf4f6..a30a9b4 100644 --- a/backend/django.py +++ b/backend/django.py @@ -51,12 +51,6 @@ django-admin runserver # start the development webserver at 12 django-admin help # display usage information and a list of the commands provided by each application django-admin version # display the current django version - -# ****************************************************************************** -# Other useful or advanced django-admin commands -# ****************************************************************************** - - django-admin check # Checks the entire django project for potential problems django-admin compilemessages # Compiles .po files to .mo files for use with builtin gettext support django-admin createcachetable # Creates the tables needed to use the SQL cache backend. From c3861473e8410520d4bae62d38dbc42ab3da734c Mon Sep 17 00:00:00 2001 From: Manoj Tyagi <38884133+neo-0224@users.noreply.github.com> Date: Mon, 30 Sep 2019 13:59:16 +0530 Subject: [PATCH 011/215] Added Heroku CLI in tools subsection --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 896e4cb..6e2aabd 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## 🤔 Why Awesome-Cheatsheets? -I usually make a cheatsheet when I want to improve my skills on a programming language, a framework or a development tool. [I started doing these kind of things a long time ago on Gist](https://gist.github.com/LeCoupa). To better keep track of the history and to let people contribute, I reorganized all of them into this single repository. Most of the content is coming from official documentations and some books I have read. +I usually make a cheat sheet when I want to improve my skills in a programming language, a framework or a development tool. [I started doing these kinds of things a long time ago on Gist](https://gist.github.com/LeCoupa). To better keep track of the history and to let people contribute, I reorganized all of them into this single repository. Most of the content is coming from official documentation and some books I have read. Feel free to take a look. You might learn new things. They have been designed to provide a quick way to assess your knowledge and to save you time. @@ -100,8 +100,9 @@ Feel free to take a look. You might learn new things. They have been designed to - [Kubernetes](tools/kubernetes.sh) - [Nanobox Boxfile](tools/nanobox_boxfile.yml) - [Nanobox CLI](tools/nanobox_cli.sh) +- [Heroku CLI](tools/heroku.sh) ## 🙌🏼 How to Contribute? -You are more than welcome to contribute and build your own cheatsheet for your favorite programming language, framework or development tool. Just submit changes via pull request and I will review them before merging. +You are more than welcome to contribute and build your own cheat sheet for your favorite programming language, framework or development tool. Just submit changes via pull request and I will review them before merging. From 4042809cde1a5e507ec9cc09c4d4ddb13e64745e Mon Sep 17 00:00:00 2001 From: Manoj Tyagi <38884133+neo-0224@users.noreply.github.com> Date: Mon, 30 Sep 2019 21:53:37 +0530 Subject: [PATCH 012/215] Google Cloud Platform Cheat sheet in Tools section I have added Most used Google Cloud Platform Cheat Sheet in the Tools section of the repository --- tools/gcp.md | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 tools/gcp.md diff --git a/tools/gcp.md b/tools/gcp.md new file mode 100644 index 0000000..dba1226 --- /dev/null +++ b/tools/gcp.md @@ -0,0 +1,178 @@ +# GCLOUD SDK AND TOOLBELT CHEATSHEET + +## GCP BASICS + +- `Check Version and Settings`: gcloud version, gcloud info, gcloud components list + +- `Init Profile`: gcloud init This will ask you to open an OpenID URL + +- `List all zones`: gcloud compute zones list + +- `Upgrade local SDK`: gcloud components update, gcloud components update --version 219.0.1 + + +## BUCKET BASICS + +- `List all buckets and files`: gsutil ls, gsutil ls -lh gs:// + +- `Download file`: gsutil cp gs:////package-1.1.tgz . + +- `Upload file`: gsutil cp gs://// + +- `Cat file`: gsutil cat gs://// + +- `Delete file`: gsutil rm gs:/// + +- `Move file`: gsutil mv gs://// + +- `Copy folder`: gsutil cp -r ./conf gs:/// + +- `Show disk usage`: gsutil du -h gs://// + +- `Create bucket`: gsutil mb gs:// + +- `Caculate file sha1sum`: gsha1sum syslog-migration-10.0.2.tgz, shasum syslog-migration-10.0.2.tgz + +- `Gsutil help`: gsutil help, gsutil help cp, gsutil help options + + +## GCP PROJECT + +- `List projects `: gcloud config list, gcloud config list project + +- `Show project info `: gcloud compute project-info describe + +- `Switch project `: gcloud config set project + + +## GKE + +- `Display a list of credentialed accounts `: gcloud auth list + +- `Set the active account `: gcloud config set account + +- `Set kubectl context `: gcloud container clusters get-credentials + +- `Change region `: gcloud config set compute/region us-west + +- `Change zone `: gcloud config set compute/zone us-west1-b + +- `List all container clusters `: gcloud container clusters list + + +## IAM + +- `Authenticate client `: gcloud auth activate-service-account --key-file + +- `Display a list of credentialed accounts `: gcloud auth list + +- `Set the active account `: gcloud config set account + +- `Auth to GCP Container Registry `: gcloud auth configure-docker + +- `Print token for active account `: gcloud auth print-access-token, gcloud auth print-refresh-token + +- `Revoke previous generated credential `: gcloud auth revoke + + +## BUCKET SECURITY + +- `Make all files readable `: gsutil -m acl set -R -a public-read gs:/// + +- `Config auth `: gsutil config -a + +- `Grant bucket access `: gsutil iam ch user:denny@gmail.com:objectCreator,objectViewer gs:// + +- `Remove bucket access `: gsutil iam ch -d user:denny@gmail.com:objectCreator,objectViewer gs:// + + +## VM + +- `List all instances `: gcloud compute instances list, gcloud compute instance-templates list + +- `Show instance info `: gcloud compute instances describe "" --project "" --zone "us-west2-a" + +- `Stop an instance `: gcloud compute instances stop instance-2 + +- `Start an instance `: gcloud compute instances start instance-2 + +- `Create an instance `: gcloud compute instances create vm1 --image image-1 --tags test --zone "" --machine-type f1-micro + +- `SSH to instance `: gcloud compute ssh --project "" --zone "" "" + +- `Download files `: gcloud compute copy-files example-instance:~/REMOTE-DIR ~/LOCAL-DIR --zone us-central1-a + +- `Upload files `: gcloud compute copy-files ~/LOCAL-FILE-1 example-instance:~/REMOTE-DIR --zone us-central1-a + + +## DISKS & VOLUMES + +- `List all disks `: gcloud compute disks list + +- `List all disk types `: gcloud compute disk-types list + +- `List all snapshots `: gcloud compute snapshots list + +- `Create snapshot `: gcloud compute disks snapshot --snapshotname --zone $zone + + +## NETWORK + +- `List all networks `: gcloud compute networks list + +- `Detail of one network `: gcloud compute networks describe --format json + +- `Create network `: gcloud compute networks create + +- `Create subnet `: gcloud compute networks subnets create subnet1 --network net1 --range 10.5.4.0/24 + +- `Get a static ip `: gcloud compute addresses create --region us-west2-a vpn-1-static-ip + +- `List all ip addresses `: gcloud compute addresses list + +- `Describe ip address `: gcloud compute addresses describe --region us-central1 + +- `List all routes `: gcloud compute routes list + + +## DNS + +- `List of all record-sets in my zone `: gcloud dns record-sets list --zone my_zone + +- `List first 10 DNS records `: gcloud dns record-sets list --zone my_zone --limit=10 + + +## FIREWALL + +- `List all firewall rules `: gcloud compute firewall-rules list + +- `List all forwarding rules `: gcloud compute forwarding-rules list + +- `Describe one firewall rule `: gcloud compute firewall-rules describe + +- `Create one firewall rule `: gcloud compute firewall-rules create my-rule --network default --allow tcp:9200 tcp:3306 + +- `Update one firewall rule `: gcloud compute firewall-rules update default --network default --allow tcp:9200 tcp:9300 + + +## IMAGES & CONTAINERS + +- `List all images `: gcloud compute images list + +- `List all container clusters `: gcloud container clusters list + +- `Set kubectl context `: gcloud container clusters get-credentials + + +## RDS + +- `List all sql instances `: gcloud sql instances list + + +## SERVICES + +- `List my backend services `: gcloud compute backend-services list + +- `List all my health check endpoints `: gcloud compute http-health-checks list + +- `List all URL maps `: gcloud compute url-maps list From 70e7886997c84026342ea50c9bb7c323f3e5eccd Mon Sep 17 00:00:00 2001 From: Manoj Tyagi <38884133+neo-0224@users.noreply.github.com> Date: Mon, 30 Sep 2019 22:35:29 +0530 Subject: [PATCH 013/215] Cheat sheet added for Sublime Text 3 A well-described cheat sheet for Sublime Text 3 added for tools section. --- tools/sublime_text.md | 141 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 tools/sublime_text.md diff --git a/tools/sublime_text.md b/tools/sublime_text.md new file mode 100644 index 0000000..8ba2cf8 --- /dev/null +++ b/tools/sublime_text.md @@ -0,0 +1,141 @@ +# SUBLIME TEXT 3 CHEATSHEET + +## Access every command with the command palette + +- `shift + cmd + P `: Command palette + + +## Goto anything + +- `cmd + P `: Goto file + +- `ctrl + G `: Goto line + +- `cmd + P and # `: Fuzzy search + +- `cmd + R `: Goto symbol + + +## Quick selections + +- `cmd + D `: Select word + +- `cmd + K D `: Skip and add next + +- `cmd + U `: Undo quick select + +- `cmd + L `: Select line + +- `ctrl + cmd + G `: Select all in file + +- `shift + cmd + space `: Expand selection to scope + +- `shift + cmd + L `: Split into lines + + +## Edit code + +- `cmd + J `: Join 2 lines + +- `cmd + shift + D `: Duplicate line + +- `cmd + shift + R `: Reindent + +- `cmd + shift + K `: Delete line + +- `ctrl + cmd + up/down `: Move line/selection up/down + +- `alt + cmd + V `: Paste from history + +- `shift + cmd + / `: Comment/uncomment line + +- `alt + backspace `: Delete word by word + +- `alt + fn + backspace `: Forward delete word by word + +- `cmd + shift + enter `: Insert line before + +- `cmd + enter `: Insert line after + + +## Searching + +- `cmd + F `: Search in file + +- `shift + cmd + F `: Search in all files + +- ` `: where filter + + +## Miscelaneous + +- `alt + cmd + right/left `: Switch open tab + +- `Indent selection `: Indent selection + +- `Unindent selection `: Unindent selection + +- `Go to previous cursor position `: Go to previous cursor position + +- `Go to next previous cursor position `: Go to next previous cursor position + +- `Build and execute file `: Build and execute file + + +## Must have packages + +`A file icon, BracketHighlighter, Color Highlighter, Comment-Snippets, DevDocs, EditorConfig, Emmet, File Rename, Git, Git blame, GitGutter, HTML-CSS-JS Prettify, JavaScript Completions, JavaScript Patterns, JavaScript Snippets, LESS, Nodejs, Package Control, Pretty JSON, SideBarEnhancements, SublimeLinter, SublimeLinter-contrib-eslint, Terminal` + + +## Preferences + +```javascript +{ +"color_scheme": "Packages/User/Color Highlighter/themes/Boxy Ocean.tmTheme", +"detect_indentation": false, +"folder_exclude_patterns": +[ +"node_modules", +".svn", +".git", +".meteor/local" +], +"ignored_packages": +[ +"Vintage" +], +"show_definitions": true, +"theme": "Adaptive.sublime-theme" +} +``` + +## Keymap + +```javascript +[ +{ "keys": ["super+v"], "command": "paste_and_indent" }, +{ "keys": ["super+shift+v"], "command": "paste" }, +{ "keys": ["super+shift+r"], "command": "reindent" }, +{ "keys": ["super+h"], "command": "dev_docs_search_selection" } +] + +``` + +## Syncing settings with iCloud + +- `cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages` + +- `mkdir -p ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/WebDev/ST3/Plugins` + +- `mv User ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/WebDev/ST3/Plugins` + +- `ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/WebDev/ST3/Plugins/User` + + +## Restore settings from iCloud + +- `cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages` + +- `rm -rf User` + +- `ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/WebDev/ST3/Plugins/User` From 166ca58ac37dd641bbdad3a0cbf29fc0dc279f36 Mon Sep 17 00:00:00 2001 From: Manoj Tyagi <38884133+thewolfcommander@users.noreply.github.com> Date: Thu, 10 Oct 2019 23:45:55 +0530 Subject: [PATCH 014/215] Four more django-admin commands added I have added four more app-related django-admin commands. --- backend/django.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/django.py b/backend/django.py index a30a9b4..dd50a37 100644 --- a/backend/django.py +++ b/backend/django.py @@ -69,3 +69,15 @@ django-admin sqlmigrate # Prints the SQL statements for the nam django-admin sqlsequencereset # Prints the SQL statements for resetting sequences for the given app name(s). django-admin squashmigrations # Squashes an existing set of migrations (from first until specified) into a single new one. django-admin testserver # Runs a development server with data from the given fixture(s). + + + +################################################################################### +# App related commands ####################################################### +################################################################################### + +django-admin changepassword # Allows changing a user’s password. It prompts you to enter a new password twice for the given user. +django-admin createsuperuser # Creates a superuser account (a user who has all permissions). +django-admin remove_stale_contenttypes # Deletes stale content types (from deleted models) in your database. +django-admin clearsessions # Can be run as a cron job or directly to clean out expired sessions. +django-admin collectstatic # Helps to collect all the static files in the one mentioned directory. From d309cb8546d7b9df9f4e9a7781097d59adb93908 Mon Sep 17 00:00:00 2001 From: Manoj Tyagi <38884133+thewolfcommander@users.noreply.github.com> Date: Fri, 11 Oct 2019 00:17:27 +0530 Subject: [PATCH 015/215] Reordered the commands alphabetically --- backend/django.py | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/backend/django.py b/backend/django.py index dd50a37..12a33ee 100644 --- a/backend/django.py +++ b/backend/django.py @@ -43,15 +43,11 @@ # ***************************************************************************** -django-admin startproject # create a new project directory structure -django-admin startapp # create a new django application with the specified name -django-admin migrate # synchronize the database state with your current state project models and migrations -django-admin makemigrations # create new migrations to the database based on the changes detected in the models -django-admin runserver # start the development webserver at 127.0.0.1 with the port 8000 -django-admin help # display usage information and a list of the commands provided by each application -django-admin version # display the current django version - django-admin check # Checks the entire django project for potential problems +django-admin changepassword # Allows changing a user’s password. It prompts you to enter a new password twice for the given user. +django-admin clearsessions # Can be run as a cron job or directly to clean out expired sessions. +django-admin collectstatic # Helps to collect all the static files in the one mentioned director +django-admin createsuperuser # Creates a superuser account (a user who has all permissions). django-admin compilemessages # Compiles .po files to .mo files for use with builtin gettext support django-admin createcachetable # Creates the tables needed to use the SQL cache backend. django-admin dbshell # Runs the command-line client for specified database, or the default database if none is provided. @@ -61,6 +57,11 @@ django-admin flush # Removes ALL DATA from the database, i django-admin inspectdb # Introspects the database tables in the given database and outputs a Django model module. django-admin loaddata # Installs the named fixture(s) in the database. django-admin makemessages # Runs over the entire source tree of the current directory and pulls out all strings marked for translation. It creates (or updates) a message file in the conf/locale (in the django tree) or locale (for projects and applications) directory. You must run this command with one of either the --locale, --exclude, or --all options. +django-admin help # display usage information and a list of the commands provided by each application +django-admin makemigrations # create new migrations to the database based on the changes detected in the models +django-admin migrate # synchronize the database state with your current state project models and migrations +django-admin remove_stale_contenttypes # Deletes stale content types (from deleted models) in your database.y. +django-admin runserver # start the development webserver at 127.0.0.1 with the port 8000 django-admin sendtestemail # Sends a test email to the email addresses specified as arguments. django-admin shell # Runs a Python interactive interpreter. Tries to use IPython or bpython, if one of them is available. Any standard input is executed as code. django-admin showmigrations # Shows all available migrations for the current project. @@ -68,16 +69,8 @@ django-admin sqlflush # Returns a list of the SQL statements django-admin sqlmigrate # Prints the SQL statements for the named migration. django-admin sqlsequencereset # Prints the SQL statements for resetting sequences for the given app name(s). django-admin squashmigrations # Squashes an existing set of migrations (from first until specified) into a single new one. +django-admin startapp # create a new django application with the specified name +django-admin startproject # create a new project directory structure django-admin testserver # Runs a development server with data from the given fixture(s). +django-admin version # display the current django version - - -################################################################################### -# App related commands ####################################################### -################################################################################### - -django-admin changepassword # Allows changing a user’s password. It prompts you to enter a new password twice for the given user. -django-admin createsuperuser # Creates a superuser account (a user who has all permissions). -django-admin remove_stale_contenttypes # Deletes stale content types (from deleted models) in your database. -django-admin clearsessions # Can be run as a cron job or directly to clean out expired sessions. -django-admin collectstatic # Helps to collect all the static files in the one mentioned directory. From 56d8d41136ada9d5aecbc012a2b3a87bb615e76d Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Fri, 11 Oct 2019 18:28:24 +0200 Subject: [PATCH 016/215] docs(vscode): add better comments --- tools/vscode.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/vscode.md b/tools/vscode.md index 02853bf..da185c8 100644 --- a/tools/vscode.md +++ b/tools/vscode.md @@ -54,6 +54,8 @@ ### Handy +- `Better comments`: Improve your code commenting by annotating with alert, informational, TODOs, and more! + - `Debugger for Chrome`: Debug your JavaScript code in the Chrome browser. - `EditorConfig for VS Code`: EditorConfig Support for Visual Studio Code. From a552f052d1bccf538681fba5fa9e19b7768d0ab1 Mon Sep 17 00:00:00 2001 From: Amaury Souza Date: Fri, 11 Oct 2019 22:12:09 -0300 Subject: [PATCH 017/215] Update bash.sh --- languages/bash.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/languages/bash.sh b/languages/bash.sh index 866968b..64d6420 100644 --- a/languages/bash.sh +++ b/languages/bash.sh @@ -359,6 +359,8 @@ fg %?string # brings job whose command contains string kill -l # returns a list of all signals on the system, by name and number kill PID # terminates process with specified PID +kill -s SIGKILL 4500 # sends a signal to force or terminate the process +kill -15 913 # Ending PID 913 process with signal 15 (TERM) ps # prints a line of information about the current running login shell and any processes running under it ps -a # selects all processes with a tty except session leaders From 03581585cfef3bf872dba009b8885278226c9bf8 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sat, 12 Oct 2019 12:42:32 +0200 Subject: [PATCH 018/215] docs(bash): align comments --- languages/bash.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/languages/bash.sh b/languages/bash.sh index 64d6420..0fe147c 100644 --- a/languages/bash.sh +++ b/languages/bash.sh @@ -357,10 +357,10 @@ fg %N # brings job number N fg %string # brings job whose command begins with string fg %?string # brings job whose command contains string -kill -l # returns a list of all signals on the system, by name and number -kill PID # terminates process with specified PID -kill -s SIGKILL 4500 # sends a signal to force or terminate the process -kill -15 913 # Ending PID 913 process with signal 15 (TERM) +kill -l # returns a list of all signals on the system, by name and number +kill PID # terminates process with specified PID +kill -s SIGKILL 4500 # sends a signal to force or terminate the process +kill -15 913 # Ending PID 913 process with signal 15 (TERM) ps # prints a line of information about the current running login shell and any processes running under it ps -a # selects all processes with a tty except session leaders From 32a915da584b3b87f50b1590a7efd0ca0b4f8284 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sat, 12 Oct 2019 20:58:43 +0200 Subject: [PATCH 019/215] docs(readme): updates --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e2aabd..ebdaa9a 100644 --- a/README.md +++ b/README.md @@ -91,16 +91,18 @@ Feel free to take a look. You might learn new things. They have been designed to #### Development +- [Sublime Text](tools/sublime_text.md) - [VIM](tools/vim.txt) +- [Visual Studio Code](tools/vscode.md) - [Xcode](tools/xcode.txt) #### Infrastructure - [Docker](tools/docker.sh) +- [Heroku CLI](tools/heroku.sh) - [Kubernetes](tools/kubernetes.sh) - [Nanobox Boxfile](tools/nanobox_boxfile.yml) - [Nanobox CLI](tools/nanobox_cli.sh) -- [Heroku CLI](tools/heroku.sh) ## 🙌🏼 How to Contribute? From c946fe9b67aba7682b1749dab4a711a34c0482bf Mon Sep 17 00:00:00 2001 From: XVR147 Date: Wed, 16 Oct 2019 20:39:29 +0200 Subject: [PATCH 020/215] Fix small errors in HTML cheatsheet Just some casing and misspelling fixes. --- frontend/html5.html | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/frontend/html5.html b/frontend/html5.html index e40173c..5072fb1 100644 --- a/frontend/html5.html +++ b/frontend/html5.html @@ -28,7 +28,7 @@

...

-
+


@@ -39,7 +39,7 @@ and and - +
                                       
 
@@ -54,13 +54,13 @@ - + -text +text @@ -70,7 +70,7 @@
  • -
    +
    @@ -85,7 +85,7 @@ enctype="" novalidate accept-charset="" -target="" +target=""
    @@ -105,16 +105,16 @@ step="" - + name="" size="" multiple required -autofocus +autofocus - + @@ -136,7 +136,7 @@ autofocus - + type="" @@ -146,7 +146,7 @@ usemap="" -scr="" +src="" width="" @@ -155,7 +155,7 @@ width=""
    -
    +
    @@ -177,7 +177,7 @@ width="" - + " " Quotation Marks - " From 1eec2b0273532dd2176e8f58723d76429ce2a2c9 Mon Sep 17 00:00:00 2001 From: XVR147 Date: Wed, 16 Oct 2019 20:39:29 +0200 Subject: [PATCH 021/215] Fix small errors in HTML cheatsheet Just some casing, spacing and misspelling fixes. --- frontend/html5.html | 52 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/frontend/html5.html b/frontend/html5.html index e40173c..c9a0154 100644 --- a/frontend/html5.html +++ b/frontend/html5.html @@ -10,28 +10,28 @@ - + - - - + + + -

    ...
    -

    -
    - -
    -
    +

    ...
    +

    +
    + +
    +
    @@ -39,10 +39,10 @@ and and - +
                                           
     
    - +
    @@ -54,13 +54,13 @@ - + -text +text @@ -70,7 +70,7 @@
    • -
      +
      @@ -80,12 +80,12 @@
      -method="somefunction()" +method="somefunction()" enctype="" autocomplete="" novalidate accept-charset="" -target="" +target=""
      @@ -105,16 +105,16 @@ step="" - + name="" -size="" +size="" multiple required -autofocus +autofocus - + @@ -136,17 +136,17 @@ autofocus - + type="" -height="" +height="" width="" usemap="" -scr="" +src="" width="" @@ -155,7 +155,7 @@ width=""
      -
      +
      @@ -177,7 +177,7 @@ width="" - + " " Quotation Marks - " From f0fae838f811faed8d06ab08c5e671ba8f68821a Mon Sep 17 00:00:00 2001 From: Alexound Date: Thu, 24 Oct 2019 11:21:36 +0400 Subject: [PATCH 022/215] Added match '*.swp' to work with Vim in 'gitgnore'. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 54166b9..83f1989 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ # Editors .vscode/ + +# Vim +*.swp From d2c01dccd4fb326b5f03302db1913a5060f8acce Mon Sep 17 00:00:00 2001 From: Alexound Date: Thu, 24 Oct 2019 11:41:37 +0400 Subject: [PATCH 023/215] Fixed and improved SHORTCUTS module. Now it's 'SHORTCUTS and HISTORY'. --- languages/bash.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/languages/bash.sh b/languages/bash.sh index 0fe147c..d738b2c 100644 --- a/languages/bash.sh +++ b/languages/bash.sh @@ -1,9 +1,8 @@ #!/bin/bash ############################################################################## -# SHORTCUTS +# SHORTCUTS and HISTORY ############################################################################## - CTRL+A # move to beginning of line CTRL+B # moves backward one character CTRL+C # halts the current command @@ -11,6 +10,7 @@ CTRL+D # deletes one character backward or logs out of current session, similar CTRL+E # moves to end of line CTRL+F # moves forward one character CTRL+G # aborts the current editing command and ring the terminal bell +CTRL+H # deletes one character under cursor (same as DELETE) CTRL+J # same as RETURN CTRL+K # deletes (kill) forward to end of line CTRL+L # clears screen and redisplay the line @@ -31,10 +31,17 @@ CTRL+Z # stops the current command, resume with fg in the foreground or bg in t ALT+B # moves backward one word ALT+D # deletes next word ALT+F # moves forward one word +ALT+H # deletes one character backward -DELETE # deletes one character backward -!! # repeats the last command -exit # logs out of current session +BACKSPACE # deletes one character backward +DELETE # deletes one character under cursor + +history # shows command line history +!! # repeats the last command +! # refers to command line 'n' +! # refers to command starting with 'string' + +exit # logs out of current session ############################################################################## From aa8b4efb860c9863ae8c117f53f600392ab6023e Mon Sep 17 00:00:00 2001 From: Alexound Date: Thu, 24 Oct 2019 11:52:27 +0400 Subject: [PATCH 024/215] Fixed tabs and spaces. --- languages/bash.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/languages/bash.sh b/languages/bash.sh index d738b2c..774ef51 100644 --- a/languages/bash.sh +++ b/languages/bash.sh @@ -10,7 +10,7 @@ CTRL+D # deletes one character backward or logs out of current session, similar CTRL+E # moves to end of line CTRL+F # moves forward one character CTRL+G # aborts the current editing command and ring the terminal bell -CTRL+H # deletes one character under cursor (same as DELETE) +CTRL+H # deletes one character under cursor (same as DELETE) CTRL+J # same as RETURN CTRL+K # deletes (kill) forward to end of line CTRL+L # clears screen and redisplay the line @@ -31,14 +31,14 @@ CTRL+Z # stops the current command, resume with fg in the foreground or bg in t ALT+B # moves backward one word ALT+D # deletes next word ALT+F # moves forward one word -ALT+H # deletes one character backward +ALT+H # deletes one character backward BACKSPACE # deletes one character backward DELETE # deletes one character under cursor history # shows command line history !! # repeats the last command -! # refers to command line 'n' +! # refers to command line 'n' ! # refers to command starting with 'string' exit # logs out of current session From 6fe0435c7777df8de98b5d9f3536820c6a39c431 Mon Sep 17 00:00:00 2001 From: Alexound Date: Thu, 24 Oct 2019 12:02:15 +0400 Subject: [PATCH 025/215] Keep working on 'bash' cheetsheet. Minor corrections. --- languages/bash.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/bash.sh b/languages/bash.sh index 774ef51..780e98c 100644 --- a/languages/bash.sh +++ b/languages/bash.sh @@ -54,7 +54,7 @@ echo $SHELL # displays the shell you're using echo $BASH_VERSION # displays bash version bash # if you want to use bash (type exit to go back to your previously opened shell) -whereis bash # finds out where bash is on your system +whereis bash # locates the binary, source and manual-page for a command which bash # finds out which program is executed as 'bash' (default: /bin/bash, can change across environments) clear # clears content on window (hide displayed lines) From de864ea195efc883675a2e91834d3f9f39659389 Mon Sep 17 00:00:00 2001 From: Alexound Date: Fri, 25 Oct 2019 01:37:20 +0400 Subject: [PATCH 026/215] Updated VIM cheatsheet a bit. Ignore case while searching: on and off command. Run command in multiple buffers with 'bufdo'. --- tools/vim.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/vim.txt b/tools/vim.txt index 5efe85e..5832df3 100644 --- a/tools/vim.txt +++ b/tools/vim.txt @@ -232,6 +232,8 @@ n repeat search in same direction N repeat search in opposite direction * search forward, word under cursor # search backward, word under cursor +set ic ignore case: turn on +set noic ignore case: turn off :%s/old/new/g replace all old with new throughout file :%s/old/new/gc replace all old with new throughout file with confirmation :argdo %s/old/new/gc | wq open multiple files and run this command to replace old @@ -251,6 +253,7 @@ N repeat search in opposite direction :bd delete a buffer (close a file) :b1 show buffer 1 :b vimrc show buffer whose filename begins with "vimrc" +:bufdo run 'command(s)' in all buffers ############################################################################## From c3ad4a15ab9d24ad72534d9eacf940bb8ee71a94 Mon Sep 17 00:00:00 2001 From: Alexound Date: Fri, 25 Oct 2019 01:41:59 +0400 Subject: [PATCH 027/215] Minor additions. --- tools/vim.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/vim.txt b/tools/vim.txt index 5832df3..2a55240 100644 --- a/tools/vim.txt +++ b/tools/vim.txt @@ -254,6 +254,7 @@ set noic ignore case: turn off :b1 show buffer 1 :b vimrc show buffer whose filename begins with "vimrc" :bufdo run 'command(s)' in all buffers +:[range]bufdo run 'command(s)' for buffers in 'range' ############################################################################## From d9ff0ab37984971a83e60d7934dad665ef7d5a5f Mon Sep 17 00:00:00 2001 From: JenniferStamm Date: Fri, 1 Nov 2019 12:41:06 +0100 Subject: [PATCH 028/215] update redis cheatsheet HLEN had the same description as HKEYS. Fixed it to say that it gets the number of fields instead of the fields themselves. --- databases/redis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/databases/redis.sh b/databases/redis.sh index 5665af4..9fbce26 100644 --- a/databases/redis.sh +++ b/databases/redis.sh @@ -115,7 +115,7 @@ HINCRBY key field increment # increment value in hash by X HDEL key field [field ...] # delete one or more hash fields HEXISTS key field # determine if a hash field exists HKEYS key # get all the fields in a hash -HLEN key # get all the fields in a hash +HLEN key # get the number of fields in a hash HSTRLEN key field # get the length of the value of a hash field HVALS key # get all the values in a hash From b7a5aa284c0cd19d847d9ac7c04a16a6471f7ac9 Mon Sep 17 00:00:00 2001 From: pfeinsondev <58021443+pfeinsondev@users.noreply.github.com> Date: Wed, 20 Nov 2019 21:37:39 -0800 Subject: [PATCH 029/215] Update django.py Ammend runserver with optional port parameter. Useful if 8000 is unavailable. --- backend/django.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/django.py b/backend/django.py index 12a33ee..f9347ea 100644 --- a/backend/django.py +++ b/backend/django.py @@ -61,7 +61,7 @@ django-admin help # display usage information and a list django-admin makemigrations # create new migrations to the database based on the changes detected in the models django-admin migrate # synchronize the database state with your current state project models and migrations django-admin remove_stale_contenttypes # Deletes stale content types (from deleted models) in your database.y. -django-admin runserver # start the development webserver at 127.0.0.1 with the port 8000 +django-admin runserver # start the development webserver at 127.0.0.1 with the port default 8000 django-admin sendtestemail # Sends a test email to the email addresses specified as arguments. django-admin shell # Runs a Python interactive interpreter. Tries to use IPython or bpython, if one of them is available. Any standard input is executed as code. django-admin showmigrations # Shows all available migrations for the current project. From 12e8b98f331cee116073c30c74f5dc378e94426e Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Fri, 6 Dec 2019 14:06:33 +0100 Subject: [PATCH 030/215] docs(laravel): add validation fields --- backend/laravel.php | 65 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/backend/laravel.php b/backend/laravel.php index a383ab5..4e3fd5d 100644 --- a/backend/laravel.php +++ b/backend/laravel.php @@ -192,7 +192,70 @@ php artisan view:clear // Clear all compiled view files * https://laravel.com/docs/5.8/validation ********************************************************************************************/ - +accepted // The field under validation must be yes, on, 1, or true. +active_url // The field under validation must have a valid A or AAAA record according to the dns_get_record PHP function. +after:date // The field under validation must be a value after a given date. +after_or_equal:date // The field under validation must be a value after or equal to the given date. +alpha // The field under validation must be entirely alphabetic characters. +alpha_dash // The field under validation may have alpha-numeric characters, as well as dashes and underscores. +alpha_num // The field under validation must be entirely alpha-numeric characters. +array // The field under validation must be a PHP array. +bail // Stop running validation rules after the first validation failure. +before:date // The field under validation must be a value preceding the given date. +before_or_equal:date // The field under validation must be a value preceding or equal to the given date. +between:min,max // The field under validation must have a size between the given min and max. +boolean // The field under validation must be able to be cast as a boolean. Accepted input are true, false, 1, 0, "1", and "0". +confirmed // The field under validation must have a matching field of foo_confirmation. +date // The field under validation must be a valid, non-relative date according to the strtotime PHP function. +date_equals:date // The field under validation must be equal to the given date. +date_format:format // The field under validation must match the given format. +different:field // The field under validation must have a different value than field. +digits:value // The field under validation must be numeric and must have an exact length of value. +digits_between:min,max // The field under validation must have a length between the given min and max. +dimensions // The file under validation must be an image meeting the dimension constraints as specified by the rule's parameters. +distinct // When working with arrays, the field under validation must not have any duplicate values. +email // The field under validation must be formatted as an e-mail address. +ends_with:foo,bar,... // The field under validation must end with one of the given values. +exists:table,column // The field under validation must exist on a given database table. +file // The field under validation must be a successfully uploaded file. +filled // The field under validation must not be empty when it is present. +gt:field // The field under validation must be greater than the given field. +gte:field // The field under validation must be greater than or equal to the given field. +image // The file under validation must be an image (jpeg, png, bmp, gif, svg, or webp) +in:foo,bar,... // The field under validation must be included in the given list of values. +in_array:anotherfield.* // The field under validation must exist in anotherfield's values. +integer // The field under validation must be an integer. +ip // The field under validation must be an IP address. +ipv4 // The field under validation must be an IPv4 address. +ipv6 // The field under validation must be an IPv6 address. +json // The field under validation must be a valid JSON string. +lt:field // The field under validation must be less than the given field. +lte:field // The field under validation must be less than or equal to the given field. +max:value // The field under validation must be less than or equal to a maximum value. +mimetypes:text/plain,... // The file under validation must match one of the given MIME types: +mimes:foo,bar,... // The file under validation must have a MIME type corresponding to one of the listed extensions. +min:value // The field under validation must have a minimum value. +not_in:foo,bar,... // The field under validation must not be included in the given list of values. +not_regex:pattern // The field under validation must not match the given regular expression. +nullable // The field under validation may be null. +numeric // The field under validation must be numeric. +present // The field under validation must be present in the input data but can be empty. +regex:pattern // The field under validation must match the given regular expression. +required // The field under validation must be present in the input data and not empty. +required_if:anotherfield,value,... // The field under validation must be present and not empty if the anotherfield field is equal to any value. +required_unless:anotherfield,value,... // The field under validation must be present and not empty unless the anotherfield field is equal to any value. +required_with:foo,bar,... // The field under validation must be present and not empty only if any of the other specified fields are present. +required_with_all:foo,bar,... // The field under validation must be present and not empty only if all of the other specified fields are present. +required_without:foo,bar,... // The field under validation must be present and not empty only when any of the other specified fields are not present. +required_without_all:foo,bar,... // The field under validation must be present and not empty only when all of the other specified fields are not present. +same:field // The given field must match the field under validation. +size:value // The field under validation must have a size matching the given value. +starts_with:foo,bar,... // The field under validation must start with one of the given values. +string // The field under validation must be a string. +timezone // The field under validation must be a valid timezone identifier according to the timezone_identifiers_list PHP function. +unique:table,column,except,idColumn // The field under validation must not exist within the given database table. +url // The field under validation must be a valid URL. +uuid // The field under validation must be a valid RFC 4122 (version 1, 3, 4, or 5) universally unique identifier (UUID). /******************************************************************************************** * 10. ERROR HANDLING From 394910144d8027ff73424b1a7de16518938731b0 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Fri, 6 Dec 2019 14:15:34 +0100 Subject: [PATCH 031/215] style(laravel): remove empty spaces --- backend/laravel.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/backend/laravel.php b/backend/laravel.php index 4e3fd5d..45a64ba 100644 --- a/backend/laravel.php +++ b/backend/laravel.php @@ -275,7 +275,6 @@ uuid // The field under validation must be a v * https://laravel.com/docs/5.7/collections ********************************************************************************************/ - all average avg @@ -384,13 +383,11 @@ whereNotInStrict wrap zip - /******************************************************************************************** * 13. HTTP TESTS * https://laravel.com/docs/5.7/http-tests ********************************************************************************************/ - $response->assertStatus($code); // Assert that the response has a given code. $response->assertForbidden(); // Assert that the response has a forbidden status code. $response->assertNotFound(); // Assert that the response has a not found status code. From 66c417155a9719258bf7214386987bf5dd1ebaa1 Mon Sep 17 00:00:00 2001 From: qiisziilbash Date: Sun, 8 Dec 2019 16:52:57 -0700 Subject: [PATCH 032/215] git cheatsheet is added --- tools/git.txt | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tools/git.txt diff --git a/tools/git.txt b/tools/git.txt new file mode 100644 index 0000000..eb0c1a7 --- /dev/null +++ b/tools/git.txt @@ -0,0 +1,55 @@ +git init >> initiates git in the current directory +git clone
      >> creates a git repo from given address (get the address from your git-server) +=== +git add file.txt >> adds(stages) file.txt to the git +git add * >> adds(stages) all new modifications, deletions, creations to the git +git reset file.txt >> Removes file.txt from the stage +git rm file.txt >> removes file.txt both from git and file system +git status >> shows the modifications and stuff that are not staged yet +=== +git branch >> shows all the branches (current branch is shown with a star) +git branch my-branch >> creates my-branch +git branch -d my-branch >> deletes my-branch +git checkout my-bracnch >> switches to my-branch +git merge my-branch >> merges my-branch to current branch +=== +git remote >> shows the remotes +git remote -v >> shows the remote for pull and push +git remote add my-remote
      >> creates a remote (get the address from your git-server) +=== +git log >> shows the log of commits +git commit -m 'msg' >> commit changes with a msg +git push my-remote my-branch >> pushes the commits to the my-remote in my-branch (does not push the tags) +=== +git tag >> shows all the tags +git tag -a v1.0 -m 'msg' >> creates an annotated tag +git show v1.0 >> shows the description of version-1.0 tag +git tag --delete v1.0 >> deletes the tag in local directory +git push --delete my-remote v1.0 >> deletes the tag in my-remote (be carefore to not delete a branch) +git push my-remote my-branch v1.0 >> push v1.0 tag to my-remote in my-branch +git fetch --tags >> pulls the tags from remote +=== +git pull my-remote my-branch >> pulls and tries to merge my-branch from my-remote to the current branch +=== +git stash >> stashes the staged and unstaged changes (git status will be clean after it) +git stash -u >> stash everything including new untracked files (but not .gitignore) +git stash save 'msg' >> stash with a msg +git stash list >> list all stashes +git stash pop >> delete the recent stash and applies it +git stash stach@{2} >> delete the {2} stash and applies it +git stash show >> shows the description of stash +git stash apply >> keep the stash and applies it to the git +git stash branch my-branch stash@{1} >> creates a branch from your stash +git stash drop stash@{1} >> deletes the {1} stash +git stash clear >> clears all the stash +=== +.gitignore + >> is a file including names of stuff that you don't want to be staged or tracked. + >> You usually keep your local files like database, media, and etc here. + >> You can find good resources online about ignoring specific files in your project files. + >> .gitignore is also get ignored +.git + >> is a hiiden directory in repo directory including git files. It is created after "git init". + + + From 5b2794a35e441ea0b9a248458c0da70a5d31aa14 Mon Sep 17 00:00:00 2001 From: qiisziilbash Date: Sun, 8 Dec 2019 17:50:49 -0700 Subject: [PATCH 033/215] Django start project and deployment steps were added --- backend/django.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/backend/django.py b/backend/django.py index f9347ea..df659f1 100644 --- a/backend/django.py +++ b/backend/django.py @@ -38,6 +38,25 @@ # Use underscores in URL pattern names rather than dashes. +# ***************************************************************************** +# Deployment +# ***************************************************************************** + + +# add your media, database, venv, __pycache__ to the .gitignore (there is a compelete list that you can find here: https://github.com/jpadilla/django-project-template/blob/master/.gitignore) +# keep migration files in the git (you will need to migrate them in target server) +# don't run "makemigrations" in the target server (you will need to just run "migrate") +# $ pip freeze > requirements.txt +# make appropriate changes in your project settings.py file (change DEBUG to False and etc) +# push your code to your git-server +# pull your code in your target server +# give right permissions to the web-server (e.g. $ chown www-data:www-data -R /var/www/myproject) +# make a new venv in the target server and activate it +# $ sudo pip install -r requirements.txt +# sudo ./venv/bin/python3 manage.py migrate +# restart your web-server (in case of apache: $ sudo service apache2 restart) + + # ***************************************************************************** # DJANGO-ADMIN # ***************************************************************************** @@ -74,3 +93,22 @@ django-admin startproject # create a new project directory struct django-admin testserver # Runs a development server with data from the given fixture(s). django-admin version # display the current django version + +# ***************************************************************************** +# Starting a django project in python3 +# ***************************************************************************** + + +# 1. $ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py; python3 get-pip.py +# 2. $ pip install django +# 3. $ pip install virtualenv +# 4. $ mkdir django-projects +# 5. $ cd django-projects +# 6. $ virtualenv venv +# 7. $ source venv/bin/activate +# 8. $ django-admin startproject myproject +# 9. $ python manage.py runserver + + + + From 65f7f7fda314d242f1c7d883942747ff03edeff1 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Mon, 9 Dec 2019 11:48:40 +0100 Subject: [PATCH 034/215] style(git): rework --- README.md | 1 + tools/git.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ tools/git.txt | 55 --------------------------------------------------- 3 files changed, 56 insertions(+), 55 deletions(-) create mode 100644 tools/git.sh delete mode 100644 tools/git.txt diff --git a/README.md b/README.md index ebdaa9a..0dded65 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ Feel free to take a look. You might learn new things. They have been designed to #### Development +- [Git](tools/git.sh) - [Sublime Text](tools/sublime_text.md) - [VIM](tools/vim.txt) - [Visual Studio Code](tools/vscode.md) diff --git a/tools/git.sh b/tools/git.sh new file mode 100644 index 0000000..c097771 --- /dev/null +++ b/tools/git.sh @@ -0,0 +1,55 @@ +git init # initiates git in the current directory +git clone
      # creates a git repo from given address (get the address from your git-server) + +git add file.txt # adds(stages) file.txt to the git +git add * # adds(stages) all new modifications, deletions, creations to the git +git reset file.txt # Removes file.txt from the stage +git rm file.txt # removes file.txt both from git and file system +git status # shows the modifications and stuff that are not staged yet + +git branch # shows all the branches (current branch is shown with a star) +git branch my-branch # creates my-branch +git branch -d my-branch # deletes my-branch +git checkout my-bracnch # switches to my-branch +git merge my-branch # merges my-branch to current branch + +git remote # shows the remotes +git remote -v # shows the remote for pull and push +git remote add my-remote
      # creates a remote (get the address from your git-server) + +git log # shows the log of commits +git commit -m "msg" # commit changes with a msg +git push my-remote my-branch # pushes the commits to the my-remote in my-branch (does not push the tags) + +git tag # shows all the tags +git tag -a v1.0 -m "msg" # creates an annotated tag +git show v1.0 # shows the description of version-1.0 tag +git tag --delete v1.0 # deletes the tag in local directory +git push --delete my-remote v1.0 # deletes the tag in my-remote (be carefore to not delete a branch) +git push my-remote my-branch v1.0 # push v1.0 tag to my-remote in my-branch +git fetch --tags # pulls the tags from remote + +git pull my-remote my-branch# pulls and tries to merge my-branch from my-remote to the current branch + +git stash # stashes the staged and unstaged changes (git status will be clean after it) +git stash -u # stash everything including new untracked files (but not .gitignore) +git stash save "msg" # stash with a msg +git stash list # list all stashes +git stash pop # delete the recent stash and applies it +git stash stach@{2} # delete the {2} stash and applies it +git stash show # shows the description of stash +git stash apply # keep the stash and applies it to the git +git stash branch my-branch stash@{1} # creates a branch from your stash +git stash drop stash@{1} # deletes the {1} stash +git stash clear # clears all the stash + +.gitignore +# is a file including names of stuff that you don"t want to be staged or tracked. +# You usually keep your local files like database, media, and etc here. +# You can find good resources online about ignoring specific files in your project files. +# .gitignore is also get ignored +.git +# is a hidden directory in repo directory including git files. It is created after "git init". + + + diff --git a/tools/git.txt b/tools/git.txt deleted file mode 100644 index eb0c1a7..0000000 --- a/tools/git.txt +++ /dev/null @@ -1,55 +0,0 @@ -git init >> initiates git in the current directory -git clone
      >> creates a git repo from given address (get the address from your git-server) -=== -git add file.txt >> adds(stages) file.txt to the git -git add * >> adds(stages) all new modifications, deletions, creations to the git -git reset file.txt >> Removes file.txt from the stage -git rm file.txt >> removes file.txt both from git and file system -git status >> shows the modifications and stuff that are not staged yet -=== -git branch >> shows all the branches (current branch is shown with a star) -git branch my-branch >> creates my-branch -git branch -d my-branch >> deletes my-branch -git checkout my-bracnch >> switches to my-branch -git merge my-branch >> merges my-branch to current branch -=== -git remote >> shows the remotes -git remote -v >> shows the remote for pull and push -git remote add my-remote
      >> creates a remote (get the address from your git-server) -=== -git log >> shows the log of commits -git commit -m 'msg' >> commit changes with a msg -git push my-remote my-branch >> pushes the commits to the my-remote in my-branch (does not push the tags) -=== -git tag >> shows all the tags -git tag -a v1.0 -m 'msg' >> creates an annotated tag -git show v1.0 >> shows the description of version-1.0 tag -git tag --delete v1.0 >> deletes the tag in local directory -git push --delete my-remote v1.0 >> deletes the tag in my-remote (be carefore to not delete a branch) -git push my-remote my-branch v1.0 >> push v1.0 tag to my-remote in my-branch -git fetch --tags >> pulls the tags from remote -=== -git pull my-remote my-branch >> pulls and tries to merge my-branch from my-remote to the current branch -=== -git stash >> stashes the staged and unstaged changes (git status will be clean after it) -git stash -u >> stash everything including new untracked files (but not .gitignore) -git stash save 'msg' >> stash with a msg -git stash list >> list all stashes -git stash pop >> delete the recent stash and applies it -git stash stach@{2} >> delete the {2} stash and applies it -git stash show >> shows the description of stash -git stash apply >> keep the stash and applies it to the git -git stash branch my-branch stash@{1} >> creates a branch from your stash -git stash drop stash@{1} >> deletes the {1} stash -git stash clear >> clears all the stash -=== -.gitignore - >> is a file including names of stuff that you don't want to be staged or tracked. - >> You usually keep your local files like database, media, and etc here. - >> You can find good resources online about ignoring specific files in your project files. - >> .gitignore is also get ignored -.git - >> is a hiiden directory in repo directory including git files. It is created after "git init". - - - From 5f0b94b7c2a3d29ce359436b929fc868ee708c25 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Mon, 9 Dec 2019 11:51:16 +0100 Subject: [PATCH 035/215] style(django): remove empty lines --- backend/django.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/backend/django.py b/backend/django.py index df659f1..ccb74eb 100644 --- a/backend/django.py +++ b/backend/django.py @@ -108,7 +108,3 @@ django-admin version # display the current django version # 7. $ source venv/bin/activate # 8. $ django-admin startproject myproject # 9. $ python manage.py runserver - - - - From 3f4277fafe7a6b95358d7d627659e9fc23e7b15d Mon Sep 17 00:00:00 2001 From: qiisziilbash Date: Tue, 10 Dec 2019 12:13:04 -0700 Subject: [PATCH 036/215] django start project steps reordered, in order to install django in venv instead of /usr --- backend/django.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/django.py b/backend/django.py index ccb74eb..b485c1e 100644 --- a/backend/django.py +++ b/backend/django.py @@ -99,12 +99,12 @@ django-admin version # display the current django version # ***************************************************************************** -# 1. $ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py; python3 get-pip.py -# 2. $ pip install django -# 3. $ pip install virtualenv -# 4. $ mkdir django-projects -# 5. $ cd django-projects -# 6. $ virtualenv venv -# 7. $ source venv/bin/activate +# 1. $ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py; python3 get-pip.py +# 2. $ pip install virtualenv +# 3. $ mkdir django-projects +# 4. $ cd django-projects +# 5. $ virtualenv venv +# 6. $ source venv/bin/activate +# 7. $ pip install django # 8. $ django-admin startproject myproject # 9. $ python manage.py runserver From a0aa12efa7682727aa2414f8074918e79af78fc9 Mon Sep 17 00:00:00 2001 From: Kerollos Magdy Date: Thu, 12 Dec 2019 13:13:15 +0200 Subject: [PATCH 037/215] Fix a typo --- tools/vscode.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/vscode.md b/tools/vscode.md index da185c8..d68a786 100644 --- a/tools/vscode.md +++ b/tools/vscode.md @@ -4,7 +4,7 @@ ### HTML & CSS -- `CSScomb`: Codeing style formatter for CSS, Less, SCSS and Saas. +- `CSScomb`: Coding style formatter for CSS, Less, SCSS and Saas. - `Puglint`: Linter and style checker for pug. From e28a4a9cec370f30dd22e850b7c36d380f1907c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20St=C3=BCmmel?= <7893682+janstuemmel@users.noreply.github.com> Date: Tue, 21 Jan 2020 18:57:12 +0100 Subject: [PATCH 038/215] Fix php cheatsheet, for loop iterates over all values, not just n-1 values --- languages/php.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/languages/php.php b/languages/php.php index 572cf93..beb1291 100644 --- a/languages/php.php +++ b/languages/php.php @@ -24,7 +24,7 @@ foreach($arr as $key => $value) { } // For -for($i = 0; $i < count($arr) - 1; $i++) { +for($i = 0; $i < count($arr); $i++) { $key = $i; $value = $arr[$i]; } @@ -338,4 +338,4 @@ class ClassWithLogger * Use the LoggerAwareTrait in this class. */ use LoggerAwareTrait; -} \ No newline at end of file +} From b3444b6a31ab7d2f310d640cd99c27e451388a90 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Mon, 16 Mar 2020 15:26:48 +0100 Subject: [PATCH 039/215] docs(puppeteer): initialize cheatsheet --- tools/puppeteer.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tools/puppeteer.js diff --git a/tools/puppeteer.js b/tools/puppeteer.js new file mode 100644 index 0000000..b8034ce --- /dev/null +++ b/tools/puppeteer.js @@ -0,0 +1,14 @@ +/* ******************************************************************************************* + * PUPPETEER + * https://pptr.dev/ + * ******************************************************************************************* */ + + +// When you install Puppeteer, it downloads a recent version of Chromium (~170MB Mac, ~282MB Linux, ~280MB Win) +// that is guaranteed to work with the API. +npm install puppeteer; + +// A lightweight version of Puppeteer for launching an existing browser installation or for connecting to a remote one. +// Be sure that the version of puppeteer-core you install is compatible with the browser you intend to connect to. +npm install puppeteer-core; + From b525056ac8732772d2558aafdffad6e7034d2c5b Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Mon, 16 Mar 2020 15:27:33 +0100 Subject: [PATCH 040/215] docs(readme): add pupeeteer --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0dded65..94394cb 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ Feel free to take a look. You might learn new things. They have been designed to #### Development - [Git](tools/git.sh) +- [Puppeteer](tools/puppeteer.js) - [Sublime Text](tools/sublime_text.md) - [VIM](tools/vim.txt) - [Visual Studio Code](tools/vscode.md) From 0a88f6209fdb0b0f23c01c337f7e50a8102b9554 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Mon, 16 Mar 2020 16:28:02 +0100 Subject: [PATCH 041/215] docs(puppeteer): wip --- tools/puppeteer.js | 444 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 442 insertions(+), 2 deletions(-) diff --git a/tools/puppeteer.js b/tools/puppeteer.js index b8034ce..9af134f 100644 --- a/tools/puppeteer.js +++ b/tools/puppeteer.js @@ -6,9 +6,449 @@ // When you install Puppeteer, it downloads a recent version of Chromium (~170MB Mac, ~282MB Linux, ~280MB Win) // that is guaranteed to work with the API. -npm install puppeteer; +npm install puppeteer // A lightweight version of Puppeteer for launching an existing browser installation or for connecting to a remote one. // Be sure that the version of puppeteer-core you install is compatible with the browser you intend to connect to. -npm install puppeteer-core; +// More about the difference between puppeteer vs puppeteer-core +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-puppeteer-vs-puppeteer-core +npm install puppeteer-core + +/* ******************************************************************************************* + * ENVIRONMENT VARIABLES + * ******************************************************************************************* */ + +HTTP_PROXY // Defines HTTP proxy settings that are used to download and run Chromium. +HTTPS_PROXY // Defines HTTP proxy settings that are used to download and run Chromium. +NO_PROXY // Defines HTTP proxy settings that are used to download and run Chromium. + +PUPPETEER_SKIP_CHROMIUM_DOWNLOAD // Do not download bundled Chromium during installation step. +PUPPETEER_DOWNLOAD_HOST // Overwrite URL prefix that is used to download Chromium. Note: this includes protocol and might even include path prefix. Defaults to https://storage.googleapis.com. +PUPPETEER_CHROMIUM_REVISION // Specify a certain version of Chromium you'd like Puppeteer to use. See puppeteer.launch([options]) on how executable path is inferred. BEWARE: Puppeteer is only guaranteed to work with the bundled Chromium, use at your own risk. +PUPPETEER_EXECUTABLE_PATH // Specify an executable path to be used in puppeteer.launch. See puppeteer.launch([options]) on how the executable path is inferred. BEWARE: Puppeteer is only guaranteed to work with the bundled Chromium, use at your own risk. +PUPPETEER_PRODUCT // Specify which browser you'd like Puppeteer to use. Must be one of chrome or firefox. Setting product programmatically in puppeteer.launch([options]) supercedes this environment variable. The product is exposed in puppeteer.product + +/* ******************************************************************************************* + * API + * ******************************************************************************************* */ + + +// PUPPETEER +// Puppeteer module provides a method to launch a Chromium instance. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-puppeteer + +const puppeteer = require('puppeteer'); + +puppeteer.devices; +puppeteer.errors; +puppeteer.product; + +puppeteer.connect(options); +puppeteer.createBrowserFetcher([options]); +puppeteer.defaultArgs([options]); +puppeteer.executablePath(); +puppeteer.launch([options]); + +// BROWSER FETCHER +// BrowserFetcher can download and manage different versions of Chromium. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-browserfetcher + +const browserFetcher = puppeteer.createBrowserFetcher(); + +browserFetcher.canDownload(revision) +browserFetcher.download(revision[, progressCallback]) +browserFetcher.localRevisions() +browserFetcher.platform() +browserFetcher.remove(revision) +browserFetcher.revisionInfo(revision) + +// BROWSER +// A Browser is created when Puppeteer connects to a Chromium instance, either through puppeteer.launch or puppeteer.connect. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-browser + +const browser = await puppeteer.launch(); + +browser.on('disconnected') +browser.on('targetchanged') +browser.on('targetcreated') +browser.on('targetdestroyed') + +browser.browserContexts() +browser.close() +browser.createIncognitoBrowserContext() +browser.defaultBrowserContext() +browser.disconnect() +browser.isConnected() +browser.newPage() +browser.pages() +browser.process() +browser.target() +browser.targets() +browser.userAgent() +browser.version() +browser.waitForTarget(predicate[, options]) +browser.wsEndpoint() + +// BROWSER CONTEXT +// BrowserContexts provide a way to operate multiple independent browser sessions +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-browsercontext + +const context = await browser.createIncognitoBrowserContext(); + +browserContext.on('targetchanged') +browserContext.on('targetcreated') +browserContext.on('targetdestroyed') + +browserContext.browser() +browserContext.clearPermissionOverrides() +browserContext.close() +browserContext.isIncognito() +browserContext.newPage() +browserContext.overridePermissions(origin, permissions) +browserContext.pages() +browserContext.targets() +browserContext.waitForTarget(predicate[, options]) + +// PAGE +// Page provides methods to interact with a single tab or extension background page in Chromium. +// One Browser instance might have multiple Page instances. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-page + +const page = await browser.newPage(); + +page.on('close') +page.on('console') +page.on('dialog') +page.on('domcontentloaded') +page.on('error') +page.on('frameattached') +page.on('framedetached') +page.on('framenavigated') +page.on('load') +page.on('metrics') +page.on('pageerror') +page.on('popup') +page.on('request') +page.on('requestfailed') +page.on('requestfinished') +page.on('response') +page.on('workercreated') +page.on('workerdestroyed') + +page.accessibility +page.coverage +page.keyboard +page.mouse +page.touchscreen +page.tracing + +page.$(selector) +page.$$(selector) +page.$$eval(selector, pageFunction[, ...args]) +page.$eval(selector, pageFunction[, ...args]) +page.$x(expression) +page.addScriptTag(options) +page.addStyleTag(options) +page.authenticate(credentials) +page.bringToFront() +page.browser() +page.browserContext() +page.click(selector[, options]) +page.close([options]) +page.content() +page.cookies([...urls]) +page.deleteCookie(...cookies) +page.emulate(options) +page.emulateMedia(type) +page.emulateMediaFeatures(features) +page.emulateMediaType(type) +page.emulateTimezone(timezoneId) +page.evaluate(pageFunction[, ...args]) +page.evaluateHandle(pageFunction[, ...args]) +page.evaluateOnNewDocument(pageFunction[, ...args]) +page.exposeFunction(name, puppeteerFunction) +page.focus(selector) +page.frames() +page.goBack([options]) +page.goForward([options]) +page.goto(url[, options]) +page.hover(selector) +page.isClosed() +page.mainFrame() +page.metrics() +page.pdf([options]) +page.queryObjects(prototypeHandle) +page.reload([options]) +page.screenshot([options]) +page.select(selector, ...values) +page.setBypassCSP(enabled) +page.setCacheEnabled([enabled]) +page.setContent(html[, options]) +page.setCookie(...cookies) +page.setDefaultNavigationTimeout(timeout) +page.setDefaultTimeout(timeout) +page.setExtraHTTPHeaders(headers) +page.setGeolocation(options) +page.setJavaScriptEnabled(enabled) +page.setOfflineMode(enabled) +page.setRequestInterception(value) +page.setUserAgent(userAgent) +page.setViewport(viewport) +page.tap(selector) +page.target() +page.title() +page.type(selector, text[, options]) +page.url() +page.viewport() +page.waitFor(selectorOrFunctionOrTimeout[, options[, ...args]]) +page.waitForFileChooser([options]) +page.waitForFunction(pageFunction[, options[, ...args]]) +page.waitForNavigation([options]) +page.waitForRequest(urlOrPredicate[, options]) +page.waitForResponse(urlOrPredicate[, options]) +page.waitForSelector(selector[, options]) +page.waitForXPath(xpath[, options]) +page.workers() + +// WORKER +// The Worker class represents a WebWorker. +// The events workercreated and workerdestroyed are emitted on the page object to signal the worker lifecycle. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-worker + +worker.evaluate(pageFunction[, ...args]) +worker.evaluateHandle(pageFunction[, ...args]) +worker.executionContext() +worker.url() + +// ACCESSIBILITY +// The Accessibility class provides methods for inspecting Chromium's accessibility tree. +// The accessibility tree is used by assistive technology such as screen readers or switches. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-accessibility + +accessibility.snapshot([options]) + +// KEYBOARD +// Keyboard provides an api for managing a virtual keyboard. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-keyboard + +keyboard.down(key[, options]) +keyboard.press(key[, options]) +keyboard.sendCharacter(char) +keyboard.type(text[, options]) +keyboard.up(key) + +// MOUSE +// The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-mouse + +mouse.click(x, y[, options]) +mouse.down([options]) +mouse.move(x, y[, options]) +mouse.up([options]) + +// TOUCHSCREEN +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-touchscreen + +touchscreen.tap(x, y) + +// TRACING +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-tracing + +tracing.start([options]) +tracing.stop() + +// FILE CHOOSER +// FileChooser objects are returned via the 'page.waitForFileChooser' method. +// File choosers let you react to the page requesting for a file. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-filechooser + +fileChooser.accept(filePaths) +fileChooser.cancel() +fileChooser.isMultiple() + +// DIALOG +// Dialog objects are dispatched by page via the 'dialog' event. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-dialog + +dialog.accept([promptText]) +dialog.defaultValue() +dialog.dismiss() +dialog.message() +dialog.type() + +// CONSOLE MESSAGE +// ConsoleMessage objects are dispatched by page via the 'console' event. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-consolemessage + +consoleMessage.args() +consoleMessage.location() +consoleMessage.text() +consoleMessage.type() + +// FRAME +// At every point of time, page exposes its current frame tree via the page.mainFrame() and frame.childFrames() methods. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-frame + +frame.$(selector) +frame.$$(selector) +frame.$$eval(selector, pageFunction[, ...args]) +frame.$eval(selector, pageFunction[, ...args]) +frame.$x(expression) +frame.addScriptTag(options) +frame.addStyleTag(options) +frame.childFrames() +frame.click(selector[, options]) +frame.content() +frame.evaluate(pageFunction[, ...args]) +frame.evaluateHandle(pageFunction[, ...args]) +frame.executionContext() +frame.focus(selector) +frame.goto(url[, options]) +frame.hover(selector) +frame.isDetached() +frame.name() +frame.parentFrame() +frame.select(selector, ...values) +frame.setContent(html[, options]) +frame.tap(selector) +frame.title() +frame.type(selector, text[, options]) +frame.url() +frame.waitFor(selectorOrFunctionOrTimeout[, options[, ...args]]) +frame.waitForFunction(pageFunction[, options[, ...args]]) +frame.waitForNavigation([options]) +frame.waitForSelector(selector[, options]) +frame.waitForXPath(xpath[, options]) + +// EXECUTION CONTEXT +// The class represents a context for JavaScript execution. +// Besides pages, execution contexts can be found in workers. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-executioncontext + +executionContext.evaluate(pageFunction[, ...args]) +executionContext.evaluateHandle(pageFunction[, ...args]) +executionContext.frame() +executionContext.queryObjects(prototypeHandle) + +// JSHANDLE +// JSHandle represents an in-page JavaScript object. +// JSHandles can be created with the page.evaluateHandle method. +// const windowHandle = await page.evaluateHandle(() => window); + +jsHandle.asElement() +jsHandle.dispose() +jsHandle.evaluate(pageFunction[, ...args]) +jsHandle.evaluateHandle(pageFunction[, ...args]) +jsHandle.executionContext() +jsHandle.getProperties() +jsHandle.getProperty(propertyName) +jsHandle.jsonValue() + +// ELEMENTHANDLE +// ElementHandle represents an in-page DOM element. +// ElementHandles can be created with the page.$ method. +// const hrefElement = await page.$('a'); + +elementHandle.$(selector) +elementHandle.$$(selector) +elementHandle.$$eval(selector, pageFunction[, ...args]) +elementHandle.$eval(selector, pageFunction[, ...args]) +elementHandle.$x(expression) +elementHandle.asElement() +elementHandle.boundingBox() +elementHandle.boxModel() +elementHandle.click([options]) +elementHandle.contentFrame() +elementHandle.dispose() +elementHandle.evaluate(pageFunction[, ...args]) +elementHandle.evaluateHandle(pageFunction[, ...args]) +elementHandle.executionContext() +elementHandle.focus() +elementHandle.getProperties() +elementHandle.getProperty(propertyName) +elementHandle.hover() +elementHandle.isIntersectingViewport() +elementHandle.jsonValue() +elementHandle.press(key[, options]) +elementHandle.screenshot([options]) +elementHandle.select(...values) +elementHandle.tap() +elementHandle.toString() +elementHandle.type(text[, options]) +elementHandle.uploadFile(...filePaths) + +// REQUEST +// Represents a request which are sent by a page. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-request + +request.abort([errorCode]) +request.continue([overrides]) +request.failure() +request.frame() +request.headers() +request.isNavigationRequest() +request.method() +request.postData() +request.redirectChain() +request.resourceType() +request.respond(response) +request.response() +request.url() + +// RESPONSE +// Response class represents responses which are received by page. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-response + +response.buffer() +response.frame() +response.fromCache() +response.fromServiceWorker() +response.headers() +response.json() +response.ok() +response.remoteAddress() +response.request() +response.securityDetails() +response.status() +response.statusText() +response.text() +response.url() + +// SECURITY DETAILS +// SecurityDetails class represents the security details when response was received over the secure connection. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-securitydetails + +securityDetails.issuer() +securityDetails.protocol() +securityDetails.subjectName() +securityDetails.validFrom() +securityDetails.validTo() + +// TARGET +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-target + +target.browser() +target.browserContext() +target.createCDPSession() +target.opener() +target.page() +target.type() +target.url() +target.worker() + +// CDPSESSION +// The CDPSession instances are used to talk raw Chrome Devtools Protocol +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-cdpsession + +cdpSession.detach() +cdpSession.send(method[, params]) + +// COVERAGE +// Coverage gathers information about parts of JavaScript and CSS that were used by the page. +// https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-coverage + +coverage.startCSSCoverage([options]) +coverage.startJSCoverage([options]) +coverage.stopCSSCoverage() +coverage.stopJSCoverage() From c882af50b703982d21ea630cf4b37c0525287766 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Tue, 17 Mar 2020 13:14:24 +0100 Subject: [PATCH 042/215] feat(puppeteer): add puppeeter and browserfetcher --- tools/puppeteer.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tools/puppeteer.js b/tools/puppeteer.js index 9af134f..f3c7540 100644 --- a/tools/puppeteer.js +++ b/tools/puppeteer.js @@ -40,15 +40,15 @@ PUPPETEER_PRODUCT // Specify which browser you'd like Puppeteer t const puppeteer = require('puppeteer'); -puppeteer.devices; -puppeteer.errors; -puppeteer.product; +puppeteer.devices; // Returns a list of devices to be used with page.emulate(options) +puppeteer.errors; // Returns the specific error classes +puppeteer.product; // Returns the name of the browser that is under automation ("chrome" or "firefox") -puppeteer.connect(options); -puppeteer.createBrowserFetcher([options]); -puppeteer.defaultArgs([options]); -puppeteer.executablePath(); -puppeteer.launch([options]); +puppeteer.connect(options); // Attaches Puppeteer to an existing Chromium instance. +puppeteer.createBrowserFetcher([options]); // Create a brower fetcher instance +puppeteer.defaultArgs([options]); // The default flags that Chromium will be launched with. +puppeteer.executablePath(); // Returns a path where Puppeteer expects to find bundled Chromium. +puppeteer.launch([options]); // Launch a browser instance // BROWSER FETCHER // BrowserFetcher can download and manage different versions of Chromium. @@ -56,12 +56,12 @@ puppeteer.launch([options]); const browserFetcher = puppeteer.createBrowserFetcher(); -browserFetcher.canDownload(revision) -browserFetcher.download(revision[, progressCallback]) -browserFetcher.localRevisions() -browserFetcher.platform() -browserFetcher.remove(revision) -browserFetcher.revisionInfo(revision) +browserFetcher.canDownload(revision) // Initiates a HEAD request to check if the revision is available. +browserFetcher.download(revision[, progressCallback]) // Initiates a GET request to download the revision from the host. +browserFetcher.localRevisions() // Returns a list of all revisions available locally on disk. +browserFetcher.platform() // Returns one of mac, linux, win32 or win64. +browserFetcher.remove(revision) // Resolves when the revision has been removed. +browserFetcher.revisionInfo(revision) // Returns all the information on the revision. // BROWSER // A Browser is created when Puppeteer connects to a Chromium instance, either through puppeteer.launch or puppeteer.connect. @@ -69,10 +69,10 @@ browserFetcher.revisionInfo(revision) const browser = await puppeteer.launch(); -browser.on('disconnected') -browser.on('targetchanged') -browser.on('targetcreated') -browser.on('targetdestroyed') +browser.on('disconnected') // +browser.on('targetchanged') // +browser.on('targetcreated') // +browser.on('targetdestroyed') // browser.browserContexts() browser.close() From c5faec60ef0d3275a45962ac784d8a1c0ac07c55 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Tue, 17 Mar 2020 14:13:45 +0100 Subject: [PATCH 043/215] feat(puppeteer): add comments --- tools/puppeteer.js | 532 ++++++++++++++++++++++----------------------- 1 file changed, 266 insertions(+), 266 deletions(-) diff --git a/tools/puppeteer.js b/tools/puppeteer.js index f3c7540..45f914f 100644 --- a/tools/puppeteer.js +++ b/tools/puppeteer.js @@ -69,26 +69,26 @@ browserFetcher.revisionInfo(revision) // Returns all the informa const browser = await puppeteer.launch(); -browser.on('disconnected') // -browser.on('targetchanged') // -browser.on('targetcreated') // -browser.on('targetdestroyed') // +browser.on('disconnected') // Emitted when Puppeteer gets disconnected from the Chromium instance. +browser.on('targetchanged') // Emitted when the url of a target changes. +browser.on('targetcreated') // Emitted when a target is created, for example when a new page is opened by window.open or browser.newPage. +browser.on('targetdestroyed') // Emitted when a target is destroyed, for example when a page is closed. -browser.browserContexts() -browser.close() -browser.createIncognitoBrowserContext() -browser.defaultBrowserContext() -browser.disconnect() -browser.isConnected() -browser.newPage() -browser.pages() -browser.process() -browser.target() -browser.targets() -browser.userAgent() -browser.version() -browser.waitForTarget(predicate[, options]) -browser.wsEndpoint() +browser.browserContexts() // +browser.close() // +browser.createIncognitoBrowserContext() // +browser.defaultBrowserContext() // +browser.disconnect() // +browser.isConnected() // +browser.newPage() // +browser.pages() // +browser.process() // +browser.target() // +browser.targets() // +browser.userAgent() // +browser.version() // +browser.waitForTarget(predicate[, options]) // +browser.wsEndpoint() // // BROWSER CONTEXT // BrowserContexts provide a way to operate multiple independent browser sessions @@ -96,19 +96,19 @@ browser.wsEndpoint() const context = await browser.createIncognitoBrowserContext(); -browserContext.on('targetchanged') -browserContext.on('targetcreated') -browserContext.on('targetdestroyed') +browserContext.on('targetchanged') // +browserContext.on('targetcreated') // +browserContext.on('targetdestroyed') // -browserContext.browser() -browserContext.clearPermissionOverrides() -browserContext.close() -browserContext.isIncognito() -browserContext.newPage() -browserContext.overridePermissions(origin, permissions) -browserContext.pages() -browserContext.targets() -browserContext.waitForTarget(predicate[, options]) +browserContext.browser() // +browserContext.clearPermissionOverrides() // +browserContext.close() // +browserContext.isIncognito() // +browserContext.newPage() // +browserContext.overridePermissions(origin, permissions) // +browserContext.pages() // +browserContext.targets() // +browserContext.waitForTarget(predicate[, options]) // // PAGE // Page provides methods to interact with a single tab or extension background page in Chromium. @@ -117,338 +117,338 @@ browserContext.waitForTarget(predicate[, options]) const page = await browser.newPage(); -page.on('close') -page.on('console') -page.on('dialog') -page.on('domcontentloaded') -page.on('error') -page.on('frameattached') -page.on('framedetached') -page.on('framenavigated') -page.on('load') -page.on('metrics') -page.on('pageerror') -page.on('popup') -page.on('request') -page.on('requestfailed') -page.on('requestfinished') -page.on('response') -page.on('workercreated') -page.on('workerdestroyed') +page.on('close') // +page.on('console') // +page.on('dialog') // +page.on('domcontentloaded') // +page.on('error') // +page.on('frameattached') // +page.on('framedetached') // +page.on('framenavigated') // +page.on('load') // +page.on('metrics') // +page.on('pageerror') // +page.on('popup') // +page.on('request') // +page.on('requestfailed') // +page.on('requestfinished') // +page.on('response') // +page.on('workercreated') // +page.on('workerdestroyed') // -page.accessibility -page.coverage -page.keyboard -page.mouse -page.touchscreen -page.tracing +page.accessibility // +page.coverage // +page.keyboard // +page.mouse // +page.touchscreen // +page.tracing // -page.$(selector) -page.$$(selector) -page.$$eval(selector, pageFunction[, ...args]) -page.$eval(selector, pageFunction[, ...args]) -page.$x(expression) -page.addScriptTag(options) -page.addStyleTag(options) -page.authenticate(credentials) -page.bringToFront() -page.browser() -page.browserContext() -page.click(selector[, options]) -page.close([options]) -page.content() -page.cookies([...urls]) -page.deleteCookie(...cookies) -page.emulate(options) -page.emulateMedia(type) -page.emulateMediaFeatures(features) -page.emulateMediaType(type) -page.emulateTimezone(timezoneId) -page.evaluate(pageFunction[, ...args]) -page.evaluateHandle(pageFunction[, ...args]) -page.evaluateOnNewDocument(pageFunction[, ...args]) -page.exposeFunction(name, puppeteerFunction) -page.focus(selector) -page.frames() -page.goBack([options]) -page.goForward([options]) -page.goto(url[, options]) -page.hover(selector) -page.isClosed() -page.mainFrame() -page.metrics() -page.pdf([options]) -page.queryObjects(prototypeHandle) -page.reload([options]) -page.screenshot([options]) -page.select(selector, ...values) -page.setBypassCSP(enabled) -page.setCacheEnabled([enabled]) -page.setContent(html[, options]) -page.setCookie(...cookies) -page.setDefaultNavigationTimeout(timeout) -page.setDefaultTimeout(timeout) -page.setExtraHTTPHeaders(headers) -page.setGeolocation(options) -page.setJavaScriptEnabled(enabled) -page.setOfflineMode(enabled) -page.setRequestInterception(value) -page.setUserAgent(userAgent) -page.setViewport(viewport) -page.tap(selector) -page.target() -page.title() -page.type(selector, text[, options]) -page.url() -page.viewport() -page.waitFor(selectorOrFunctionOrTimeout[, options[, ...args]]) -page.waitForFileChooser([options]) -page.waitForFunction(pageFunction[, options[, ...args]]) -page.waitForNavigation([options]) -page.waitForRequest(urlOrPredicate[, options]) -page.waitForResponse(urlOrPredicate[, options]) -page.waitForSelector(selector[, options]) -page.waitForXPath(xpath[, options]) -page.workers() +page.$(selector) // +page.$$(selector) // +page.$$eval(selector, pageFunction[, ...args]) // +page.$eval(selector, pageFunction[, ...args]) // +page.$x(expression) // +page.addScriptTag(options) // +page.addStyleTag(options) // +page.authenticate(credentials) // +page.bringToFront() // +page.browser() // +page.browserContext( // +page.click(selector[, options]) // +page.close([options]) // +page.content() // +page.cookies([...urls]) // +page.deleteCookie(...cookies) // +page.emulate(options) // +page.emulateMedia(type) // +page.emulateMediaFeatures(features) // +page.emulateMediaType(type) // +page.emulateTimezone(timezoneId) // +page.evaluate(pageFunction[, ...args]) // +page.evaluateHandle(pageFunction[, ...args]) // +page.evaluateOnNewDocument(pageFunction[, ...args]) // +page.exposeFunction(name, puppeteerFunction) // +page.focus(selector) // +page.frames() // +page.goBack([options]) // +page.goForward([options]) // +page.goto(url[, options]) // +page.hover(selector) // +page.isClosed() // +page.mainFrame() // +page.metrics() // +page.pdf([options]) // +page.queryObjects(prototypeHandle) // +page.reload([options]) // +page.screenshot([options]) // +page.select(selector, ...values) // +page.setBypassCSP(enabled) // +page.setCacheEnabled([enabled]) // +page.setContent(html[, options]) // +page.setCookie(...cookies) // +page.setDefaultNavigationTimeout(timeout) // +page.setDefaultTimeout(timeout) // +page.setExtraHTTPHeaders(headers) // +page.setGeolocation(options) // +page.setJavaScriptEnabled(enabled) // +page.setOfflineMode(enabled) // +page.setRequestInterception(value) // +page.setUserAgent(userAgent) // +page.setViewport(viewport) // +page.tap(selector) // +page.target() // +page.title() // +page.type(selector, text[, options]) // +page.url() // +page.viewport() // +page.waitFor(selectorOrFunctionOrTimeout[, options[, ...args]]) // +page.waitForFileChooser([options]) // +page.waitForFunction(pageFunction[, options[, ...args]]) // +page.waitForNavigation([options]) // +page.waitForRequest(urlOrPredicate[, options]) // +page.waitForResponse(urlOrPredicate[, options]) // +page.waitForSelector(selector[, options]) // +page.waitForXPath(xpath[, options]) // +page.workers() // // WORKER // The Worker class represents a WebWorker. // The events workercreated and workerdestroyed are emitted on the page object to signal the worker lifecycle. // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-worker -worker.evaluate(pageFunction[, ...args]) -worker.evaluateHandle(pageFunction[, ...args]) -worker.executionContext() -worker.url() +worker.evaluate(pageFunction[, ...args]) // +worker.evaluateHandle(pageFunction[, ...args]) // +worker.executionContext() // +worker.url() // // ACCESSIBILITY // The Accessibility class provides methods for inspecting Chromium's accessibility tree. // The accessibility tree is used by assistive technology such as screen readers or switches. // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-accessibility -accessibility.snapshot([options]) +accessibility.snapshot([options]) // // KEYBOARD // Keyboard provides an api for managing a virtual keyboard. // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-keyboard -keyboard.down(key[, options]) -keyboard.press(key[, options]) -keyboard.sendCharacter(char) -keyboard.type(text[, options]) -keyboard.up(key) +keyboard.down(key[, options]) // +keyboard.press(key[, options]) // +keyboard.sendCharacter(char) // +keyboard.type(text[, options]) // +keyboard.up(key) // // MOUSE // The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport. // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-mouse -mouse.click(x, y[, options]) -mouse.down([options]) -mouse.move(x, y[, options]) -mouse.up([options]) +mouse.click(x, y[, options]) // +mouse.down([options]) // +mouse.move(x, y[, options]) // +mouse.up([options]) // // TOUCHSCREEN // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-touchscreen -touchscreen.tap(x, y) +touchscreen.tap(x, y) // // TRACING // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-tracing -tracing.start([options]) -tracing.stop() +tracing.start([options]) // +tracing.stop() // // FILE CHOOSER // FileChooser objects are returned via the 'page.waitForFileChooser' method. // File choosers let you react to the page requesting for a file. // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-filechooser -fileChooser.accept(filePaths) -fileChooser.cancel() -fileChooser.isMultiple() +fileChooser.accept(filePaths) // +fileChooser.cancel() // +fileChooser.isMultiple() // // DIALOG // Dialog objects are dispatched by page via the 'dialog' event. // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-dialog -dialog.accept([promptText]) -dialog.defaultValue() -dialog.dismiss() -dialog.message() -dialog.type() +dialog.accept([promptText]) // +dialog.defaultValue() // +dialog.dismiss() // +dialog.message() // +dialog.type() // // CONSOLE MESSAGE // ConsoleMessage objects are dispatched by page via the 'console' event. // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-consolemessage -consoleMessage.args() -consoleMessage.location() -consoleMessage.text() -consoleMessage.type() +consoleMessage.args() // +consoleMessage.location() // +consoleMessage.text() // +consoleMessage.type() // // FRAME // At every point of time, page exposes its current frame tree via the page.mainFrame() and frame.childFrames() methods. // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-frame -frame.$(selector) -frame.$$(selector) -frame.$$eval(selector, pageFunction[, ...args]) -frame.$eval(selector, pageFunction[, ...args]) -frame.$x(expression) -frame.addScriptTag(options) -frame.addStyleTag(options) -frame.childFrames() -frame.click(selector[, options]) -frame.content() -frame.evaluate(pageFunction[, ...args]) -frame.evaluateHandle(pageFunction[, ...args]) -frame.executionContext() -frame.focus(selector) -frame.goto(url[, options]) -frame.hover(selector) -frame.isDetached() -frame.name() -frame.parentFrame() -frame.select(selector, ...values) -frame.setContent(html[, options]) -frame.tap(selector) -frame.title() -frame.type(selector, text[, options]) -frame.url() -frame.waitFor(selectorOrFunctionOrTimeout[, options[, ...args]]) -frame.waitForFunction(pageFunction[, options[, ...args]]) -frame.waitForNavigation([options]) -frame.waitForSelector(selector[, options]) -frame.waitForXPath(xpath[, options]) +frame.$(selector) // +frame.$$(selector) // +frame.$$eval(selector, pageFunction[, ...args]) // +frame.$eval(selector, pageFunction[, ...args]) // +frame.$x(expression) // +frame.addScriptTag(options) // +frame.addStyleTag(options) // +frame.childFrames() // +frame.click(selector[, options]) // +frame.content() // +frame.evaluate(pageFunction[, ...args]) // +frame.evaluateHandle(pageFunction[, ...args]) // +frame.executionContext() // +frame.focus(selector) // +frame.goto(url[, options]) // +frame.hover(selector) // +frame.isDetached() // +frame.name() // +frame.parentFrame() // +frame.select(selector, ...values) // +frame.setContent(html[, options]) // +frame.tap(selector) // +frame.title() // +frame.type(selector, text[, options]) // +frame.url() // +frame.waitFor(selectorOrFunctionOrTimeout[, options[, ...args]]) // +frame.waitForFunction(pageFunction[, options[, ...args]]) // +frame.waitForNavigation([options]) // +frame.waitForSelector(selector[, options]) // +frame.waitForXPath(xpath[, options]) // // EXECUTION CONTEXT // The class represents a context for JavaScript execution. // Besides pages, execution contexts can be found in workers. // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-executioncontext -executionContext.evaluate(pageFunction[, ...args]) -executionContext.evaluateHandle(pageFunction[, ...args]) -executionContext.frame() -executionContext.queryObjects(prototypeHandle) +executionContext.evaluate(pageFunction[, ...args]) // +executionContext.evaluateHandle(pageFunction[, ...args]) // +executionContext.frame() // +executionContext.queryObjects(prototypeHandle) // // JSHANDLE // JSHandle represents an in-page JavaScript object. // JSHandles can be created with the page.evaluateHandle method. // const windowHandle = await page.evaluateHandle(() => window); -jsHandle.asElement() -jsHandle.dispose() -jsHandle.evaluate(pageFunction[, ...args]) -jsHandle.evaluateHandle(pageFunction[, ...args]) -jsHandle.executionContext() -jsHandle.getProperties() -jsHandle.getProperty(propertyName) -jsHandle.jsonValue() +jsHandle.asElement() // +jsHandle.dispose() // +jsHandle.evaluate(pageFunction[, ...args]) // +jsHandle.evaluateHandle(pageFunction[, ...args]) // +jsHandle.executionContext() // +jsHandle.getProperties() // +jsHandle.getProperty(propertyName) // +jsHandle.jsonValue() // // ELEMENTHANDLE // ElementHandle represents an in-page DOM element. // ElementHandles can be created with the page.$ method. // const hrefElement = await page.$('a'); -elementHandle.$(selector) -elementHandle.$$(selector) -elementHandle.$$eval(selector, pageFunction[, ...args]) -elementHandle.$eval(selector, pageFunction[, ...args]) -elementHandle.$x(expression) -elementHandle.asElement() -elementHandle.boundingBox() -elementHandle.boxModel() -elementHandle.click([options]) -elementHandle.contentFrame() -elementHandle.dispose() -elementHandle.evaluate(pageFunction[, ...args]) -elementHandle.evaluateHandle(pageFunction[, ...args]) -elementHandle.executionContext() -elementHandle.focus() -elementHandle.getProperties() -elementHandle.getProperty(propertyName) -elementHandle.hover() -elementHandle.isIntersectingViewport() -elementHandle.jsonValue() -elementHandle.press(key[, options]) -elementHandle.screenshot([options]) -elementHandle.select(...values) -elementHandle.tap() -elementHandle.toString() -elementHandle.type(text[, options]) -elementHandle.uploadFile(...filePaths) +elementHandle.$(selector) // +elementHandle.$$(selector) // +elementHandle.$$eval(selector, pageFunction[, ...args]) // +elementHandle.$eval(selector, pageFunction[, ...args]) // +elementHandle.$x(expression) // +elementHandle.asElement() // +elementHandle.boundingBox() // +elementHandle.boxModel() // +elementHandle.click([options]) // +elementHandle.contentFrame() // +elementHandle.dispose() // +elementHandle.evaluate(pageFunction[, ...args]) // +elementHandle.evaluateHandle(pageFunction[, ...args]) // +elementHandle.executionContext() // +elementHandle.focus() // +elementHandle.getProperties() // +elementHandle.getProperty(propertyName) // +elementHandle.hover() // +elementHandle.isIntersectingViewport() // +elementHandle.jsonValue() // +elementHandle.press(key[, options]) // +elementHandle.screenshot([options]) // +elementHandle.select(...values) // +elementHandle.tap() // +elementHandle.toString() // +elementHandle.type(text[, options]) // +elementHandle.uploadFile(...filePaths) // // REQUEST // Represents a request which are sent by a page. // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-request -request.abort([errorCode]) -request.continue([overrides]) -request.failure() -request.frame() -request.headers() -request.isNavigationRequest() -request.method() -request.postData() -request.redirectChain() -request.resourceType() -request.respond(response) -request.response() -request.url() +request.abort([errorCode]) // +request.continue([overrides]) // +request.failure() // +request.frame() // +request.headers() // +request.isNavigationRequest() // +request.method() // +request.postData() // +request.redirectChain() // +request.resourceType() // +request.respond(response) // +request.response() // +request.url() // // RESPONSE // Response class represents responses which are received by page. // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-response -response.buffer() -response.frame() -response.fromCache() -response.fromServiceWorker() -response.headers() -response.json() -response.ok() -response.remoteAddress() -response.request() -response.securityDetails() -response.status() -response.statusText() -response.text() -response.url() +response.buffer() // +response.frame() // +response.fromCache() // +response.fromServiceWorker() // +response.headers() // +response.json() // +response.ok() // +response.remoteAddress() // +response.request() // +response.securityDetails() // +response.status() // +response.statusText() // +response.text() // +response.url() // // SECURITY DETAILS // SecurityDetails class represents the security details when response was received over the secure connection. // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-securitydetails -securityDetails.issuer() -securityDetails.protocol() -securityDetails.subjectName() -securityDetails.validFrom() -securityDetails.validTo() +securityDetails.issuer() // +securityDetails.protocol() // +securityDetails.subjectName() // +securityDetails.validFrom() // +securityDetails.validTo() // // TARGET // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-target -target.browser() -target.browserContext() -target.createCDPSession() -target.opener() -target.page() -target.type() -target.url() -target.worker() +target.browser() // +target.browserContext() // +target.createCDPSession() // +target.opener() // +target.page() // +target.type() // +target.url() // +target.worker() // // CDPSESSION // The CDPSession instances are used to talk raw Chrome Devtools Protocol // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-cdpsession -cdpSession.detach() -cdpSession.send(method[, params]) +cdpSession.detach() // +cdpSession.send(method[, params]) // // COVERAGE // Coverage gathers information about parts of JavaScript and CSS that were used by the page. // https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-coverage -coverage.startCSSCoverage([options]) -coverage.startJSCoverage([options]) -coverage.stopCSSCoverage() -coverage.stopJSCoverage() +coverage.startCSSCoverage([options]) // +coverage.startJSCoverage([options]) // +coverage.stopCSSCoverage() // +coverage.stopJSCoverage() // From c7ad1bf57459747a40e0491554099cbd514bf2d2 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Tue, 17 Mar 2020 15:10:34 +0100 Subject: [PATCH 044/215] docs(puppeteer): add browser functions --- tools/puppeteer.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/puppeteer.js b/tools/puppeteer.js index 45f914f..58bd214 100644 --- a/tools/puppeteer.js +++ b/tools/puppeteer.js @@ -74,21 +74,21 @@ browser.on('targetchanged') // Emitted when the url of a target changes. browser.on('targetcreated') // Emitted when a target is created, for example when a new page is opened by window.open or browser.newPage. browser.on('targetdestroyed') // Emitted when a target is destroyed, for example when a page is closed. -browser.browserContexts() // -browser.close() // -browser.createIncognitoBrowserContext() // -browser.defaultBrowserContext() // -browser.disconnect() // -browser.isConnected() // -browser.newPage() // -browser.pages() // -browser.process() // -browser.target() // -browser.targets() // -browser.userAgent() // -browser.version() // -browser.waitForTarget(predicate[, options]) // -browser.wsEndpoint() // +browser.browserContexts() // Returns an array of all open browser contexts. +browser.close() // Closes Chromium and all of its pages (if any were opened). +browser.createIncognitoBrowserContext() // Creates a new incognito browser context. +browser.defaultBrowserContext() // Returns the default browser context. +browser.disconnect() // Disconnects Puppeteer from the browser, but leaves the Chromium process running. +browser.isConnected() // Indicates that the browser is connected. +browser.newPage() // Promise which resolves to a new Page object. +browser.pages() // An array of all pages inside the Browser. +browser.process() // Returns Spawned browser process. +browser.target() // A target associated with the browser. +browser.targets() // An array of all active targets inside the Browser. +browser.userAgent() // Promise which resolves to the browser's original user agent. +browser.version() // Returns the browser version (e.g. Chrome/61.0.3153.0) +browser.waitForTarget(predicate[, options]) // Promise which resolves to the first target found that matches the predicate function. +browser.wsEndpoint() // Returns the browser websocket url. // BROWSER CONTEXT // BrowserContexts provide a way to operate multiple independent browser sessions From 7937ffea53469debfe0ecb4a3e945ab445f2a9f9 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Tue, 17 Mar 2020 15:23:55 +0100 Subject: [PATCH 045/215] docs(puppeteer): browser functions --- tools/puppeteer.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/puppeteer.js b/tools/puppeteer.js index 58bd214..bb6c7d5 100644 --- a/tools/puppeteer.js +++ b/tools/puppeteer.js @@ -96,19 +96,19 @@ browser.wsEndpoint() // Returns the browser websocket url const context = await browser.createIncognitoBrowserContext(); -browserContext.on('targetchanged') // -browserContext.on('targetcreated') // -browserContext.on('targetdestroyed') // +browserContext.on('targetchanged') // Emitted when the url of a target inside the browser context changes. +browserContext.on('targetcreated') // Emitted when a new target is created inside the browser context. +browserContext.on('targetdestroyed') // Emitted when a target inside the browser context is destroyed, for example when a page is closed. -browserContext.browser() // -browserContext.clearPermissionOverrides() // -browserContext.close() // -browserContext.isIncognito() // -browserContext.newPage() // -browserContext.overridePermissions(origin, permissions) // -browserContext.pages() // -browserContext.targets() // -browserContext.waitForTarget(predicate[, options]) // +browserContext.browser() // The browser this browser context belongs to. +browserContext.clearPermissionOverrides() // Clears all permission overrides for the browser context. +browserContext.close() // Closes the browser context. All the targets that belong to the browser context will be closed. +browserContext.isIncognito() // Returns whether BrowserContext is incognito. +browserContext.newPage() // Creates a new page in the browser context. +browserContext.overridePermissions(origin, permissions) // Overrides permissions to grant. +browserContext.pages() // An array of all pages inside the browser context. +browserContext.targets() // An array of all active targets inside the browser context. +browserContext.waitForTarget(predicate[, options]) // Promise which resolves to the first target found that matches the predicate function. // PAGE // Page provides methods to interact with a single tab or extension background page in Chromium. From 1716f3f5755fefcf04ad7a50527f17ab32128494 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Tue, 17 Mar 2020 22:07:34 +0100 Subject: [PATCH 046/215] feat(puppeteer): add page functions --- tools/puppeteer.js | 467 ++++++++++++++++++++++----------------------- 1 file changed, 233 insertions(+), 234 deletions(-) diff --git a/tools/puppeteer.js b/tools/puppeteer.js index bb6c7d5..3c2f936 100644 --- a/tools/puppeteer.js +++ b/tools/puppeteer.js @@ -117,135 +117,134 @@ browserContext.waitForTarget(predicate[, options]) // Promise which resolve const page = await browser.newPage(); -page.on('close') // -page.on('console') // -page.on('dialog') // -page.on('domcontentloaded') // -page.on('error') // -page.on('frameattached') // -page.on('framedetached') // -page.on('framenavigated') // -page.on('load') // -page.on('metrics') // -page.on('pageerror') // -page.on('popup') // -page.on('request') // -page.on('requestfailed') // -page.on('requestfinished') // -page.on('response') // -page.on('workercreated') // -page.on('workerdestroyed') // +page.on('close') // Emitted when the page closes. +page.on('console') // Emitted when JavaScript within the page calls one of console API methods. +page.on('dialog') // Emitted when a JavaScript dialog appears, such as alert, prompt, confirm or beforeunload. +page.on('domcontentloaded') // Emitted when the JavaScript DOMContentLoaded event is dispatched. +page.on('error') // Emitted when the page crashes. +page.on('frameattached') // Emitted when a frame is attached. +page.on('framedetached') // Emitted when a frame is detached. +page.on('framenavigated') // Emitted when a frame is navigated to a new url. +page.on('load') // Emitted when the JavaScript load event is dispatched. +page.on('metrics') // Emitted when the JavaScript code makes a call to console.timeStamp. +page.on('pageerror') // Emitted when an uncaught exception happens within the page. +page.on('popup') // Emitted when the page opens a new tab or window. +page.on('request') // Emitted when a page issues a request. +page.on('requestfailed') // Emitted when a request fails, for example by timing out. +page.on('requestfinished') // Emitted when a request finishes successfully. +page.on('response') // Emitted when a response is received. +page.on('workercreated') // Emitted when a dedicated WebWorker is spawned by the page. +page.on('workerdestroyed') // Emitted when a dedicated WebWorker is terminated. -page.accessibility // -page.coverage // -page.keyboard // -page.mouse // -page.touchscreen // -page.tracing // +page.accessibility // returns Accessibility +page.coverage // returns Coverage +page.keyboard // returns Keyboard +page.mouse // returns Mouse +page.touchscreen // returns Touchscreen +page.tracing // returns Tracing -page.$(selector) // -page.$$(selector) // -page.$$eval(selector, pageFunction[, ...args]) // -page.$eval(selector, pageFunction[, ...args]) // -page.$x(expression) // -page.addScriptTag(options) // -page.addStyleTag(options) // -page.authenticate(credentials) // -page.bringToFront() // -page.browser() // -page.browserContext( // -page.click(selector[, options]) // -page.close([options]) // -page.content() // -page.cookies([...urls]) // -page.deleteCookie(...cookies) // -page.emulate(options) // -page.emulateMedia(type) // -page.emulateMediaFeatures(features) // -page.emulateMediaType(type) // -page.emulateTimezone(timezoneId) // -page.evaluate(pageFunction[, ...args]) // -page.evaluateHandle(pageFunction[, ...args]) // -page.evaluateOnNewDocument(pageFunction[, ...args]) // -page.exposeFunction(name, puppeteerFunction) // -page.focus(selector) // -page.frames() // -page.goBack([options]) // -page.goForward([options]) // -page.goto(url[, options]) // -page.hover(selector) // -page.isClosed() // -page.mainFrame() // -page.metrics() // -page.pdf([options]) // -page.queryObjects(prototypeHandle) // -page.reload([options]) // -page.screenshot([options]) // -page.select(selector, ...values) // -page.setBypassCSP(enabled) // -page.setCacheEnabled([enabled]) // -page.setContent(html[, options]) // -page.setCookie(...cookies) // -page.setDefaultNavigationTimeout(timeout) // -page.setDefaultTimeout(timeout) // -page.setExtraHTTPHeaders(headers) // -page.setGeolocation(options) // -page.setJavaScriptEnabled(enabled) // -page.setOfflineMode(enabled) // -page.setRequestInterception(value) // -page.setUserAgent(userAgent) // -page.setViewport(viewport) // -page.tap(selector) // -page.target() // -page.title() // -page.type(selector, text[, options]) // -page.url() // -page.viewport() // -page.waitFor(selectorOrFunctionOrTimeout[, options[, ...args]]) // -page.waitForFileChooser([options]) // -page.waitForFunction(pageFunction[, options[, ...args]]) // -page.waitForNavigation([options]) // -page.waitForRequest(urlOrPredicate[, options]) // -page.waitForResponse(urlOrPredicate[, options]) // -page.waitForSelector(selector[, options]) // -page.waitForXPath(xpath[, options]) // -page.workers() // +page.$(selector) // The method runs document.querySelector within the page. If no element matches the selector, the return value resolves to null. +page.$$(selector) // The method runs document.querySelectorAll within the page. If no elements match the selector, the return value resolves to []. +page.$$eval(selector, pageFunction[, ...args]) // This method runs Array.from(document.querySelectorAll(selector)) within the page and passes it as the first argument to pageFunction. +page.$eval(selector, pageFunction[, ...args]) // This method runs document.querySelector within the page and passes it as the first argument to pageFunction. If there's no element matching selector, the method throws an error. +page.$x(expression) // The method evaluates the XPath expression. +page.addScriptTag(options) // Adds a