From ba3551ccf14b3484b470f5b9516d0632ebdb60c3 Mon Sep 17 00:00:00 2001 From: WH Date: Tue, 6 Feb 2018 12:32:07 +0500 Subject: [PATCH 01/32] Added Array.prototype in languages/javascript.js --- languages/javascript.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/languages/javascript.js b/languages/javascript.js index b0eab0a..fa7a5e2 100644 --- a/languages/javascript.js +++ b/languages/javascript.js @@ -5,7 +5,8 @@ // Global object: properties -Array.length // Reflects the number of elements in an array +Array.length // Reflects the number of elements in an array. +Array.prototype // Represents the prototype for the Array constructor and allows to add new properties and methods to all Array objects. // Global object: methods Array.from(arrayLike[, mapFn[, thisArg]]) // Creates a new Array instance from an array-like or iterable object. From 04226615849b7ff64979bf35e50a178cddf8bcb7 Mon Sep 17 00:00:00 2001 From: shrivatsahosabettu Date: Tue, 6 Feb 2018 14:45:44 +0530 Subject: [PATCH 02/32] django-admin Added the django-admin commands --- backend/django.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/backend/django.py b/backend/django.py index 3676b5c..464a1a1 100644 --- a/backend/django.py +++ b/backend/django.py @@ -36,3 +36,20 @@ # Use underscores in URL pattern names rather than dashes. + + +# ***************************************************************************** +# Django to begin django-admin +# ***************************************************************************** +# Note: When working with single Django Project its easy to use manage.py instead of django-admin +# These two options can be intechangeble +django-admin startproject # To create Project Directory structure + # https://docs.djangoproject.com/en/2.0/ref/django-admin/#startproject +django-admin startapp # To create Django Application Name + # https://docs.djangoproject.com/en/2.0/ref/django-admin/#startapp +django-admin migrate # To Synchronize the database state with your current state project models and migrations + # https://docs.djangoproject.com/en/2.0/ref/django-admin/#migrate +django-admin makemigrations # To create new migrations to the database based on the changes detected in the models + # https://docs.djangoproject.com/en/2.0/ref/django-admin/#makemigrations +django-admin runserver # To start the development webserver at 127.0.0.1 with the port 8000 + # https://docs.djangoproject.com/en/2.0/ref/django-admin/#runserver From 1b9a0ce80c8bad5b97f452fa4c54e2b2870b83f2 Mon Sep 17 00:00:00 2001 From: Cristi Jora Date: Tue, 6 Feb 2018 12:50:57 +0200 Subject: [PATCH 03/32] Make readme more appealing Tackle first point of #7 Inspired by [30 seconds of code reamde](https://github.com/Chalarangelo/30-seconds-of-code) --- README.md | 75 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 7c50647..8c995c6 100644 --- a/README.md +++ b/README.md @@ -14,51 +14,60 @@ Feel free to browse each file to learn new things and to keep them at hand when **If you want to follow this mindset for your favorite programming language, framework or development tool, you are more than welcome to contribute. Just submit changes via pull request and I will review it.** -## Table of Contents +## 📚 Table of Contents + +## 📃 Languages +
+View contents -- [Languages](#languages) +* [Bash](languages/bash.sh) -- [Backend](#backend) +* [JavaScript](languages/javascript.js) -- [Frontend](#frontend) +
-- [Databases](#databases) +## 📦 Backend +
+View contents -- [Tools](#tools) +### Python + * [Django](backend/django.py) +### Javascript + + * [Feathers.js](backend/feathers.js) -## Languages + * [Node.js](backend/node.js) + +
-- [Bash](languages/bash.sh) +## 🌐 Frontend +
+View contents + +### Frameworks + * [Vue.js](frontend/vue.js) + +
-- [JavaScript](languages/javascript.js) +## 🗃️ Databases +
+View contents + +* [Redis](databases/redis.sh) +
-## Backend +## 🔧 Tools +
+View contents + +* [Docker](tools/docker.sh) -- [Django](backend/django.py) +* [Nanobox Boxfile](tools/nanobox_boxfile.yml) -- [Feathers.js](backend/feathers.js) +* [Nanobox CLI](tools/nanobox_cli.sh) -- [Node.js](backend/node.js) +* [VIM](tools/vim.txt) +
- -## Frontend - -- [Vue.js](frontend/vue.js) - - -## Databases - -- [Redis](databases/redis.sh) - - -## Tools - -- [Docker](tools/docker.sh) - -- [Nanobox Boxfile](tools/nanobox_boxfile.yml) - -- [Nanobox CLI](tools/nanobox_cli.sh) - -- [VIM](tools/vim.txt) From 528b6d3e93ad5963949c5a63f1d90868fa813ab7 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Wed, 7 Feb 2018 00:21:06 +0000 Subject: [PATCH 04/32] Update README.md with companies who contributed --- README.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7c50647..816ae95 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -![AWESOME CHEATSHEETS LOgO](_images/awesome_cheatsheets_logo@2x.png) +![AWESOME CHEATSHEETS LOGO](_images/awesome_cheatsheets_logo@2x.png) > 📚 Awesome cheatsheets for popular programming languages, frameworks and development tools. They include everything you should know in one single file. -> ❤️ **If you love this repository, [you can click here to make it spread](https://ctt.ec/PHba4).** +> ❤️ **If you like this repository, [you can click here to make it spread](https://ctt.ec/PHba4).** ## Why Awesome Cheatsheets? @@ -62,3 +62,27 @@ Feel free to browse each file to learn new things and to keep them at hand when - [Nanobox CLI](tools/nanobox_cli.sh) - [VIM](tools/vim.txt) + + +## Companies who contributed + + + + + + + + + + + + + + +
+ +
Anyleads
+ +
Crisp
+ +> 👋 Do you want your company to be listed there? Contribute with a cheatsheet for your favorite programming language, framework or development tool. From ad661bbb3d0540933fdf7fad24ec89ac8334f7a6 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Wed, 7 Feb 2018 00:24:20 +0000 Subject: [PATCH 05/32] Update README.md --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index 816ae95..781291a 100644 --- a/README.md +++ b/README.md @@ -71,18 +71,10 @@ Feel free to browse each file to learn new things and to keep them at hand when - - - Anyleads - - - - Crisp - > 👋 Do you want your company to be listed there? Contribute with a cheatsheet for your favorite programming language, framework or development tool. From 5791c29ab62b768e284b302bc0593cbde208812d Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Wed, 7 Feb 2018 00:29:34 +0000 Subject: [PATCH 06/32] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 781291a..9a27f2f 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Feel free to browse each file to learn new things and to keep them at hand when - [VIM](tools/vim.txt) -## Companies who contributed +## Contribution From ef808c91de965a3d8f1eea44caba40befabb1f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Farr=C3=A9s?= Date: Wed, 7 Feb 2018 18:01:27 +0100 Subject: [PATCH 07/32] Use C instead of c$ to change to end of the line --- tools/vim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/vim.txt b/tools/vim.txt index cac6e7c..41e5a7d 100644 --- a/tools/vim.txt +++ b/tools/vim.txt @@ -86,7 +86,7 @@ R enter Insert mode, replacing characters rather than insertin J join line below to the current one cc change (replace) an entire line cw change (replace) to the end of word -c$ change (replace) to the end of line +C change (replace) to the end of line s delete character at cursor and substitute text S delete line at cursor and substitute text (same as cc) xp transpose two letters (delete and paste, technically) From 928f739577066ffaebe07858efa76dc0923e3bfa Mon Sep 17 00:00:00 2001 From: Kobus Date: Wed, 7 Feb 2018 22:53:08 +0100 Subject: [PATCH 08/32] php oop --- languages/php.php | 252 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 languages/php.php diff --git a/languages/php.php b/languages/php.php new file mode 100644 index 0000000..c4871a7 --- /dev/null +++ b/languages/php.php @@ -0,0 +1,252 @@ + Date: Sat, 10 Feb 2018 01:11:11 +0100 Subject: [PATCH 09/32] Update README.md --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9a27f2f..7249178 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,19 @@ > 📚 Awesome cheatsheets for popular programming languages, frameworks and development tools. They include everything you should know in one single file. -> ❤️ **If you like this repository, [you can click here to make it spread](https://ctt.ec/PHba4).** +> ❤️ **If you like this repository, [you can click here to tweet it and make it spread](https://ctt.ec/PHba4).** -## Why Awesome Cheatsheets? +## Why Awesome-Cheatsheets? -I always 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) but as it is easier to keep track of the history, I reorganized everything into a single repository. Most of the content is coming from official documentations or some books I have read. +I always 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 to them, I reorganized everything into this single repository. Most of the content is coming from official documentations and some books I have read. -Feel free to browse each file to learn new things and to keep them at hand when you forgot about something. They have been designed to save you time when you are building great things and to provide a quick way to assess your knowledge. +Feel free to browse each cheatsheet to learn new things and to keep them at hand when you forgot about one command. They have been designed to provide a quick way to assess your knowledge and to save you time. -**If you want to follow this mindset for your favorite programming language, framework or development tool, you are more than welcome to contribute. Just submit changes via pull request and I will review it.** + +## 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. ## Table of Contents @@ -68,11 +71,11 @@ Feel free to browse each file to learn new things and to keep them at hand when
-
- + + - +
From ba0c6df3c127dc2eda9114228ebf9447b781086b Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sat, 10 Feb 2018 01:12:29 +0100 Subject: [PATCH 10/32] FeathersJS - Updates --- backend/feathers.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/backend/feathers.js b/backend/feathers.js index 559b2f6..4cdbc08 100644 --- a/backend/feathers.js +++ b/backend/feathers.js @@ -159,7 +159,7 @@ channel.connections // contains a list of all connections in this channel channel.length // returns the total number of connections in this channel service.publish([event,] fn) // registers a publishing function for a specific service for a specific event or all events if no event name was given -app.publish([event,] fn) +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 @@ -182,6 +182,26 @@ npm install @feathersjs/socketio --save npm install @feathersjs/primus --save ``` +const feathers = require('@feathersjs/feathers'); +const express = require('@feathersjs/express'); + +// Create an app that is a Feathers AND Express application +const app = express(feathers()); + +// Register a service +app.use('/todos', { + get(id) { + return Promise.resolve({ id }); + } +}); + +// Register an Express middleware +app.use('/test', (req, res) => { + res.json({ + message: 'Hello world from Express middleware' + }); +}); + /* ******************************************************************************************* * 3. CLIENT: More details on how to use Feathers on the client. From 48390e96fef5b03590f23327455935a18e575c28 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sat, 10 Feb 2018 01:26:12 +0100 Subject: [PATCH 11/32] Add awesome badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7249178..31db452 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ > ❤️ **If you like this repository, [you can click here to tweet it and make it spread](https://ctt.ec/PHba4).** +[![Awesome](https://awesome.re/badge.svg)](https://awesome.re) + ## Why Awesome-Cheatsheets? From 12fbb4bdce522c7e28997aad88b4755daec4c411 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sat, 10 Feb 2018 01:27:00 +0100 Subject: [PATCH 12/32] Change badge position --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 31db452..8fcdce6 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ ![AWESOME CHEATSHEETS LOGO](_images/awesome_cheatsheets_logo@2x.png) +[![Awesome](https://awesome.re/badge.svg)](https://awesome.re) + > 📚 Awesome cheatsheets for popular programming languages, frameworks and development tools. They include everything you should know in one single file. > ❤️ **If you like this repository, [you can click here to tweet it and make it spread](https://ctt.ec/PHba4).** -[![Awesome](https://awesome.re/badge.svg)](https://awesome.re) - ## Why Awesome-Cheatsheets? From 1564a59aa2ee87ed8e18732f3abac8de2a1a7014 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sat, 10 Feb 2018 03:08:55 +0100 Subject: [PATCH 13/32] Feathers: Express transport --- backend/feathers.js | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/backend/feathers.js b/backend/feathers.js index 4cdbc08..eec7f24 100644 --- a/backend/feathers.js +++ b/backend/feathers.js @@ -81,6 +81,9 @@ class MyService { setup(app, path) {} } +params.query // contains the URL query parameters sent from the client +params.provider // for any service method call made through REST params.provider will be set to rest + app.use('/my-service', new MyService()); // Important: Always use the service returned by app.service(path) @@ -182,25 +185,36 @@ npm install @feathersjs/socketio --save npm install @feathersjs/primus --save ``` +// --> EXPRESS <-- + const feathers = require('@feathersjs/feathers'); const express = require('@feathersjs/express'); // Create an app that is a Feathers AND Express application const app = express(feathers()); -// Register a service -app.use('/todos', { - get(id) { - return Promise.resolve({ id }); - } -}); +// If no Feathers application is passed, express() returns a plain Express application +// just like a normal call to Express would +const app = express(); + +app.use(path, service|mw) // registers either a service object or an Express middleware on the given path +app.listen(port) // will first call Express app.listen and then internally also call the Feathers app.setup(server) +app.setup(server) // usually called internally by app.listen but in the cases described below needs to be called explicitly + +express.rest() // registers a Feathers transport mechanism that allows you to expose and consume services through a RESTful API. +app.configure(express.rest()) // configures the transport provider with a standard formatter sending JSON response via res.json + +express.notFound() // returns middleware that returns a NotFound (404) Feathers error +express.errorHandler() // middleware that formats any error response to a REST call as JSON and sets the appropriate error code +app.use(express.errorHandler()) // set up the error handler with the default configuration + +// --> SOCKET.IO <-- + + + + +// --> PRIMUS <-- -// Register an Express middleware -app.use('/test', (req, res) => { - res.json({ - message: 'Hello world from Express middleware' - }); -}); /* ******************************************************************************************* From 4e4d66405d240d3a88b0a6b8684eeda668a00ee5 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sat, 10 Feb 2018 03:24:42 +0100 Subject: [PATCH 14/32] Feathers: Socket.io transport --- backend/feathers.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/feathers.js b/backend/feathers.js index eec7f24..4d109d3 100644 --- a/backend/feathers.js +++ b/backend/feathers.js @@ -210,8 +210,22 @@ app.use(express.errorHandler()) // set up the error handler with the default co // --> SOCKET.IO <-- +const feathers = require('@feathersjs/feathers'); +const socketio = require('@feathersjs/socketio'); +const app = feathers(); +app.configure(socketio()); // sets up the Socket.io transport with the default configuration using either the server provided by app.listen or passed in app.setup(server) +app.configure(socketio(callback)) // sets up the Socket.io transport with the default configuration and call callback with the Socket.io server object +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 <-- From 387787300289538be3d0d55aa06e18509a6a8ee3 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sat, 10 Feb 2018 03:32:51 +0100 Subject: [PATCH 15/32] Feathers - Primus transport --- backend/feathers.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/feathers.js b/backend/feathers.js index 4d109d3..0e883f6 100644 --- a/backend/feathers.js +++ b/backend/feathers.js @@ -168,7 +168,6 @@ app.on('connection', connection => {}) // fired every time a new real-time conn 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 - /* ******************************************************************************************* * 2. TRANSPORT: Expose a Feathers application as an API server. * ******************************************************************************************* */ @@ -229,6 +228,9 @@ app.configure(socketio({ // --> PRIMUS <-- +app.configure(primus(options)) // sets up the Primus transport with the given Primus options +app.configure(primus(options, callback)) // sets up the Primus transport with the given Primus options and calls the callback with the Primus server instance + /* ******************************************************************************************* From 71645edf5f6086121f7e0bee29f66048a8f03d77 Mon Sep 17 00:00:00 2001 From: congnd Date: Sun, 11 Feb 2018 01:37:40 +0900 Subject: [PATCH 16/32] [ADD] Xcode Cheat Sheet --- README.md | 2 + tools/xcode.txt | 97 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 tools/xcode.txt diff --git a/README.md b/README.md index 8fcdce6..504f291 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ You are more than welcome to contribute and build your own cheatsheet for your f - [VIM](tools/vim.txt) +- [XCode](tools/xcode.txt) + ## Contribution diff --git a/tools/xcode.txt b/tools/xcode.txt new file mode 100644 index 0000000..f22ce17 --- /dev/null +++ b/tools/xcode.txt @@ -0,0 +1,97 @@ +############################################################################## +# XCODE CHEAT SHEET +############################################################################## + + + +############################################################################## +# SEARCH +############################################################################## + +Cmd + F Find in File +Cmd + Option + F Find & Replace in File +Cmd + Shift + F Find in Project +Cmd + Option + Shift + F Find & Replace in Project + + +############################################################################## +# TABS +############################################################################## + +Cmd + T New Tab +Cmd + } Previous Tab +Cmd + { Next Tab + + +############################################################################## +# NAVIGATION +############################################################################## + +Cmd + Shift + O Quick Open +Cmd + J Focus to Editor +Cmd + Ctrl + UP Next Counterpart +Cmd + Ctrl + DOWN Previous Counterpart +Cmd + Ctrl + RIGHT Next Recent File +Cmd + Ctrl + LEFT Previous Recent File +Cmd + click Defination of Symbol +Cmd + L Go to Line +Cmd + Option + LEFT Fold Section +Cmd + Option + RIGHT Unfold Section + + +############################################################################## +# EDITING +############################################################################## + +Cmd + Option + ENTER Show Assitant Editor +Cmd + ENTER Hide Assitant Editor +Ctrl + SPACE or ESC Toggle Completions +Cmd + ] Indent Section +Cmd + [ Outdent Section +Ctrl + i Fix Indentation +Cmd + / Comment / Uncomment +Cmd + Option + [ Move Line Up +Cmd + Option + ] Move Line Down + + +############################################################################## +# NAVIGATOR (Left Panel) +############################################################################## + +Cmd + 0 Show /Hide +Cmd + 1-8 Switch tabs +Option + click Open Assistant Editor +Shift + Option + click Decide where to Open +double click Open in New Window + + +############################################################################## +# DEBUGGING +############################################################################## + +Cmd + Shift + Y Toggle Debug Area +Cmd + ' Next Issue +Cmd + " Previous Issue +Cmd + \ Add / Remove Breakpoint +Cmd + Y Active / Deactive Breakpoints +Cmd + K Clear Console + + +############################################################################## +# UTILITIES (Right Panel) +############################################################################## + +Cmd + Option + 0 Show / Hide +Cmd + Option + 1-9 Go to Tab + + +############################################################################## +# DUBGE & RUN +############################################################################## + +Cmd + B Build +Cmd + R Run +Cmd + . Stop +Cmd + Shift + B Analyze +Cmd + U Test +Cmd + Shift + K Clean \ No newline at end of file From 9a04ba0ef4a5cc06859d7f89e4aaa8ab2c152d29 Mon Sep 17 00:00:00 2001 From: Michael Pierce Date: Sat, 10 Feb 2018 12:22:42 -0800 Subject: [PATCH 17/32] bash.sh: array(val val val) -> array=(val val val) --- languages/bash.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/bash.sh b/languages/bash.sh index ac55bca..60fcd98 100644 --- a/languages/bash.sh +++ b/languages/bash.sh @@ -147,7 +147,7 @@ array[0]=val # several ways to define an array array[1]=val array[2]=val array=([2]=val [0]=val [1]=val) -array(val val val) +array=(val val val) ${array[i]} # displays array's value for this index. If no index is supplied, array element 0 is assumed ${#array[i]} # to find out the length of any element in the array From 90ee1fbdf7091d99f1eaefe63725edb4b4795e1b Mon Sep 17 00:00:00 2001 From: Amir Arsalan Date: Sun, 11 Feb 2018 02:30:08 +0330 Subject: [PATCH 18/32] update docker-compose and add docker service command --- tools/docker.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/docker.sh b/tools/docker.sh index 10bece1..38ce835 100644 --- a/tools/docker.sh +++ b/tools/docker.sh @@ -31,8 +31,26 @@ docker-compose up docker-compose up -d docker-compose down docker-compose logs +docker-compose restart # Restart all service +docker-compose pull # Pull all image service +docker-compose build # Build all image service +docker-compose config # Validate and view the Compose file +docker-compose scale = # Scale special service(s) +docker-compose top # Display the running processes +############################################################################## +# DOCKER SERVICES +############################################################################## + + +docker service create # Create new service +docker service inspect --pretty # Display detailed information Service(s) +docker service ls # List Services +docker service ps # List the tasks of Services +docker service scale = # Scale special service(s) +docker service update # Update Service options + ############################################################################## # DOCKER STACK ############################################################################## From a538a5dfddfdba74465f17eeefe43545c1d5d957 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sun, 11 Feb 2018 00:27:03 +0100 Subject: [PATCH 19/32] Feathers: Client methods --- backend/feathers.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/backend/feathers.js b/backend/feathers.js index 0e883f6..a8b7dbf 100644 --- a/backend/feathers.js +++ b/backend/feathers.js @@ -232,13 +232,16 @@ app.configure(primus(options)) // sets up the Primus transport with t app.configure(primus(options, callback)) // sets up the Primus transport with the given Primus options and calls the callback with the Primus server instance - /* ******************************************************************************************* * 3. CLIENT: More details on how to use Feathers on the client. * ******************************************************************************************* */ ```bash +# Bundles the separate Feathers client side modules into one providing the code as ES5 (compatible with modern browsers) +# You do not have to install or load any of the other modules listed below +npm install @feathersjs/client --save + # Allows to connect to services through REST HTTP npm install @feathersjs/rest-client --save @@ -252,6 +255,26 @@ npm install @feathersjs/primus-client --save npm install @feathersjs/authentication-client --save ``` +// --> REST CLIENT <-- + +rest([baseUrl]) // Initialize a client object with a base URL + +app.configure(restClient.jquery(window.jQuery)); // connect to a service using jQuery +app.configure(restClient.request(requestClient)); // connect to a service using request +app.configure(restClient.superagent(superagent)); // connect to a service using Superagent +app.configure(restClient.axios(axios)); // connect to a service using Axion +app.configure(restClient.fetch(window.fetch)); // connect to a service using Fetch + +// --> SOCKET.IO <-- + +socketio(socket) // initialize the Socket.io client using a given socket and the default options +socketio(socket, options) // initialize the Socket.io client using a given socket and the given options + +// --> PRISMUS <-- + +primus(socket) // initialize the Primus client using a given socket and the default options +primus(socket, options) // initialize the Primus client using a given socket and the given options + /* ******************************************************************************************* * 4. AUTHENTICATION: Feathers authentication mechanism. From b370cc04008804c3af83b06d17cc7a24a020b70d Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sun, 11 Feb 2018 19:02:39 +0100 Subject: [PATCH 20/32] Django: update django-admin --- backend/django.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/backend/django.py b/backend/django.py index 464a1a1..42895ed 100644 --- a/backend/django.py +++ b/backend/django.py @@ -39,17 +39,12 @@ # ***************************************************************************** -# Django to begin django-admin +# DJANGO-ADMIN # ***************************************************************************** -# Note: When working with single Django Project its easy to use manage.py instead of django-admin -# These two options can be intechangeble -django-admin startproject # To create Project Directory structure - # https://docs.djangoproject.com/en/2.0/ref/django-admin/#startproject -django-admin startapp # To create Django Application Name - # https://docs.djangoproject.com/en/2.0/ref/django-admin/#startapp -django-admin migrate # To Synchronize the database state with your current state project models and migrations - # https://docs.djangoproject.com/en/2.0/ref/django-admin/#migrate -django-admin makemigrations # To create new migrations to the database based on the changes detected in the models - # https://docs.djangoproject.com/en/2.0/ref/django-admin/#makemigrations -django-admin runserver # To start the development webserver at 127.0.0.1 with the port 8000 - # https://docs.djangoproject.com/en/2.0/ref/django-admin/#runserver + + +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 From 945738c9927f6bfccfc63955ced9fcef82ee6eef Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sun, 11 Feb 2018 19:09:22 +0100 Subject: [PATCH 21/32] Update README.md --- README.md | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 626efc0..4e5dc69 100644 --- a/README.md +++ b/README.md @@ -20,64 +20,65 @@ You are more than welcome to contribute and build your own cheatsheet for your f ## 📚 Table of Contents - -## 📃 Languages + +### 📃 Languages +
View contents * [Bash](languages/bash.sh) - * [JavaScript](languages/javascript.js) -
-## 📦 Backend + +### 📦 Backend +
View contents -### Python - * [Django](backend/django.py) +#### Python -### Javascript - - * [Feathers.js](backend/feathers.js) +* [Django](backend/django.py) - * [Node.js](backend/node.js) +#### Javascript +* [Feathers.js](backend/feathers.js) +* [Node.js](backend/node.js)
-## 🌐 Frontend + +### 🌐 Frontend +
View contents -### Frameworks - * [Vue.js](frontend/vue.js) - +#### Frameworks + +* [Vue.js](frontend/vue.js)
-## 🗃️ Databases + +### 🗃️ Databases +
View contents * [Redis](databases/redis.sh) -
+ ## 🔧 Tools +
View contents - + * [Docker](tools/docker.sh) - * [Nanobox Boxfile](tools/nanobox_boxfile.yml) - * [Nanobox CLI](tools/nanobox_cli.sh) - * [VIM](tools/vim.txt)
- ## Contribution From dca4f0d99a4213139be201e0dac0961a6bea827a Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sun, 11 Feb 2018 19:12:10 +0100 Subject: [PATCH 22/32] Update README.md --- README.md | 4 ++-- backend/feathers.js | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4e5dc69..bba8a15 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,14 @@ > ❤️ **If you like this repository, [you can click here to tweet it and make it spread](https://ctt.ec/PHba4).** -## Why Awesome-Cheatsheets? +## 🎩 Why Awesome-Cheatsheets? I always 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 to them, I reorganized everything into this single repository. Most of the content is coming from official documentations and some books I have read. Feel free to browse each cheatsheet to learn new things and to keep them at hand when you forgot about one command. They have been designed to provide a quick way to assess your knowledge and to save you time. -## How to Contribute? +## 🙌🏼 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. diff --git a/backend/feathers.js b/backend/feathers.js index a8b7dbf..5e59096 100644 --- a/backend/feathers.js +++ b/backend/feathers.js @@ -298,6 +298,33 @@ npm install @feathersjs/authentication-oauth1 --save npm install @feathersjs/authentication-oauth2 --save ``` +app.configure(auth(options)) // configure the authentication plugin with the given options + +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 + } +} + +app.service('authentication') // + /* ******************************************************************************************* * 5. DATABASE: Feathers common database adapter API and querying mechanism. From 394f046e77b748fc9beef256277f34849ad49436 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sun, 11 Feb 2018 19:17:56 +0100 Subject: [PATCH 23/32] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bba8a15..a5990d2 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ You are more than welcome to contribute and build your own cheatsheet for your f -## 🔧 Tools +### 🔧 Tools
View contents From 08179d5961d21d5a06af85160c3389c6e4e6c827 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sun, 11 Feb 2018 19:25:19 +0100 Subject: [PATCH 24/32] Update README.md --- README.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e4de6b1..0a640e3 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,12 @@ You are more than welcome to contribute and build your own cheatsheet for your f
View contents +#### Command line interface + * [Bash](languages/bash.sh) + +#### Functional + * [JavaScript](languages/javascript.js)
@@ -62,7 +67,9 @@ You are more than welcome to contribute and build your own cheatsheet for your f
View contents - + +#### NoSQL + * [Redis](databases/redis.sh)
@@ -72,14 +79,18 @@ You are more than welcome to contribute and build your own cheatsheet for your f
View contents +#### Development + +* [VIM](tools/vim.txt) +* [XCode](tools/xcode.txt) + +#### Infrastructure + * [Docker](tools/docker.sh) * [Nanobox Boxfile](tools/nanobox_boxfile.yml) * [Nanobox CLI](tools/nanobox_cli.sh) -* [VIM](tools/vim.txt)
-- [XCode](tools/xcode.txt) - ## Contribution From 97f4043e86e50add421d20f8f9e5853c62a39cb8 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sun, 11 Feb 2018 19:29:21 +0100 Subject: [PATCH 25/32] Xcode: improve formatting --- tools/xcode.txt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/xcode.txt b/tools/xcode.txt index f22ce17..a26dcc9 100644 --- a/tools/xcode.txt +++ b/tools/xcode.txt @@ -1,13 +1,15 @@ ############################################################################## # XCODE CHEAT SHEET +# WEBSITE: https://developer.apple.com/xcode/ +# DOCUMENTATION: https://developer.apple.com/documentation/xcodekit ############################################################################## - ############################################################################## # SEARCH ############################################################################## + Cmd + F Find in File Cmd + Option + F Find & Replace in File Cmd + Shift + F Find in Project @@ -18,6 +20,7 @@ Cmd + Option + Shift + F Find & Replace in Project # TABS ############################################################################## + Cmd + T New Tab Cmd + } Previous Tab Cmd + { Next Tab @@ -27,6 +30,7 @@ Cmd + { Next Tab # NAVIGATION ############################################################################## + Cmd + Shift + O Quick Open Cmd + J Focus to Editor Cmd + Ctrl + UP Next Counterpart @@ -43,6 +47,7 @@ Cmd + Option + RIGHT Unfold Section # EDITING ############################################################################## + Cmd + Option + ENTER Show Assitant Editor Cmd + ENTER Hide Assitant Editor Ctrl + SPACE or ESC Toggle Completions @@ -55,9 +60,10 @@ Cmd + Option + ] Move Line Down ############################################################################## -# NAVIGATOR (Left Panel) +# NAVIGATOR (LEFT PANEL) ############################################################################## + Cmd + 0 Show /Hide Cmd + 1-8 Switch tabs Option + click Open Assistant Editor @@ -69,6 +75,7 @@ double click Open in New Window # DEBUGGING ############################################################################## + Cmd + Shift + Y Toggle Debug Area Cmd + ' Next Issue Cmd + " Previous Issue @@ -78,20 +85,22 @@ Cmd + K Clear Console ############################################################################## -# UTILITIES (Right Panel) +# UTILITIES (RIGHT PANEL) ############################################################################## + Cmd + Option + 0 Show / Hide Cmd + Option + 1-9 Go to Tab ############################################################################## -# DUBGE & RUN +# DUBUGGING & RUN ############################################################################## + Cmd + B Build Cmd + R Run Cmd + . Stop Cmd + Shift + B Analyze Cmd + U Test -Cmd + Shift + K Clean \ No newline at end of file +Cmd + Shift + K Clean From 1dcb38b8839b18d6ca503bd1752da34a4480fed0 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sun, 11 Feb 2018 19:32:13 +0100 Subject: [PATCH 26/32] Docker: improve formating --- tools/docker.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/docker.sh b/tools/docker.sh index 38ce835..18b2948 100644 --- a/tools/docker.sh +++ b/tools/docker.sh @@ -51,6 +51,7 @@ docker service ps # List the tasks of Services docker service scale = # Scale special service(s) docker service update # Update Service options + ############################################################################## # DOCKER STACK ############################################################################## From 889cd60ac1f5dd512d9ea4a478021e0becbd2df3 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sun, 11 Feb 2018 19:33:47 +0100 Subject: [PATCH 27/32] Docker: add comments for docker-compose methods --- tools/docker.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/docker.sh b/tools/docker.sh index 18b2948..3b87fca 100644 --- a/tools/docker.sh +++ b/tools/docker.sh @@ -27,10 +27,10 @@ docker run username/repository:tag # Run image from a registry ############################################################################## -docker-compose up -docker-compose up -d -docker-compose down -docker-compose logs +docker-compose up # Create and start containers +docker-compose up -d # Create and start containers in detached mode +docker-compose down # Stop and remove containers, networks, images, and volumes +docker-compose logs # View output from containers docker-compose restart # Restart all service docker-compose pull # Pull all image service docker-compose build # Build all image service From 9a6984369d10a671cef64b2616d866205da0b35c Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sun, 11 Feb 2018 19:39:44 +0100 Subject: [PATCH 28/32] PHP: improve formating --- languages/php.php | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/languages/php.php b/languages/php.php index c4871a7..4c8d311 100644 --- a/languages/php.php +++ b/languages/php.php @@ -6,9 +6,10 @@ */ class NormalClass extends AbstractClassName implements InterfaceName { + use TraitName; - // Property types + // --> PROPERTY TYPES <-- /** * Public property, everyone can access this property. @@ -34,7 +35,7 @@ class NormalClass extends AbstractClassName implements InterfaceName */ static $property; - // Function Types + // --> FUNCTION TYPES <-- /** * Public function, everyone can access this function. @@ -43,7 +44,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public function publicFunction(Type $var = null): Type { - # code... } /** @@ -53,7 +53,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ private function privateFunction(Type $var = null): Type { - # code... } /** @@ -63,7 +62,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ protected function protectedFunction(Type $var = null): Type { - # code... } /** @@ -73,10 +71,9 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public static function staticFunction(Type $var = null): Type { - # code... } - // Magic methods + // --> MAGIC METHODS <-- /** * Gets triggered on creating a new class instance @@ -86,7 +83,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public function __construct(Type $var = null) { - # code... } /** @@ -96,7 +92,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public function __destruct() { - # code... } /** @@ -108,7 +103,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public function __set(string $name , mixed $value) { - # code... } /** @@ -119,7 +113,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public function __get(string $name) { - # code... } /** @@ -130,7 +123,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public function __isset(string $name) { - # code... } /** @@ -141,7 +133,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public function __unset(string $name) { - # code... } /** @@ -153,7 +144,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public function __call(string $name, array $arguments) { - # code... } /** @@ -165,7 +155,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public static function __callStatic(string $name, array $arguments) { - # code... } /** @@ -174,7 +163,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public function __sleep() { - # code... } /** @@ -183,7 +171,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public function __wakeup() { - # code... } /** @@ -192,7 +179,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public function __toString() { - # code... } /** @@ -202,7 +188,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public function __invoke(Type $var = null) { - # code... } /** @@ -212,7 +197,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public static function __set_state(array $properties) { - # code... } /** @@ -221,7 +205,6 @@ class NormalClass extends AbstractClassName implements InterfaceName */ public function __debugInfo() { - # code... } } From 7399f975c812e379dea04d929bc0d22f37f7ed30 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sun, 11 Feb 2018 19:41:42 +0100 Subject: [PATCH 29/32] README: add PHP cheatsheet --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a640e3..ad1ad78 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,10 @@ You are more than welcome to contribute and build your own cheatsheet for your f * [Bash](languages/bash.sh) +### Imperative + +* [JavaScript](languages/php.php) + #### Functional * [JavaScript](languages/javascript.js) @@ -56,7 +60,7 @@ You are more than welcome to contribute and build your own cheatsheet for your f
View contents - + #### Frameworks * [Vue.js](frontend/vue.js) From 514d5a18230f3e7da2226c3d4cdfc7301fc0f396 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sun, 11 Feb 2018 19:42:04 +0100 Subject: [PATCH 30/32] README.md: fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad1ad78..954e66c 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ You are more than welcome to contribute and build your own cheatsheet for your f * [Bash](languages/bash.sh) -### Imperative +#### Imperative * [JavaScript](languages/php.php) From 3e7c4408537adb9e1af567e76ab7feaed2f10d4c Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Sun, 11 Feb 2018 19:42:30 +0100 Subject: [PATCH 31/32] README: Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 954e66c..98cc045 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ You are more than welcome to contribute and build your own cheatsheet for your f #### Imperative -* [JavaScript](languages/php.php) +* [PHP](languages/php.php) #### Functional From 2ef26d3c396453db806cb6a09604f9af62083571 Mon Sep 17 00:00:00 2001 From: Vitaly Bagno <5454420+veber88@users.noreply.github.com> Date: Sun, 11 Feb 2018 21:02:37 +0200 Subject: [PATCH 32/32] Update bash.sh --- languages/bash.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/bash.sh b/languages/bash.sh index 60fcd98..10d4d7d 100644 --- a/languages/bash.sh +++ b/languages/bash.sh @@ -400,7 +400,7 @@ function errtrap { echo "ERROR line $1: Command exited with status $es." } -trap 'errtrap $LINENO' ERR # is run whenever a command in the surrounding script or function exists with non-zero status +trap 'errtrap $LINENO' ERR # is run whenever a command in the surrounding script or function exits with non-zero status function dbgtrap { echo "badvar is $badvar"