1
1
mirror of https://github.com/namibia/awesome-cheatsheets.git synced 2024-06-04 13:40:46 +00:00

Merge branch 'master' of github.com:LeCoupa/awesome-cheatsheets

This commit is contained in:
Julien Le Coupanec 2019-10-11 18:28:26 +02:00
commit 926b0cb279
6 changed files with 501 additions and 7 deletions

View File

@ -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,6 +100,7 @@ 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)
</details>
## 🙌🏼 How to Contribute?

View File

@ -43,10 +43,34 @@
# *****************************************************************************
django-admin startproject <ProjectName> # create a new project directory structure
django-admin startapp <Appname> # 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 check # Checks the entire django project for potential problems
django-admin changepassword <username> # Allows changing a users 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.
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 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.
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 startapp <Appname> # create a new django application with the specified name
django-admin startproject <ProjectName> # 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

View File

@ -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;
}

178
tools/gcp.md Normal file
View File

@ -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://<bucket-name>
- `Download file`: gsutil cp gs://<bucket-name>/<dir-path>/package-1.1.tgz .
- `Upload file`: gsutil cp <filename> gs://<bucket-name>/<directory>/
- `Cat file`: gsutil cat gs://<bucket-name>/<filepath>/
- `Delete file`: gsutil rm gs://<bucket-name>/<filepath>
- `Move file`: gsutil mv <src-filepath> gs://<bucket-name>/<directory>/<dest-filepath>
- `Copy folder`: gsutil cp -r ./conf gs://<bucket-name>/
- `Show disk usage`: gsutil du -h gs://<bucket-name>/<directory>/
- `Create bucket`: gsutil mb gs://<bucket-name>
- `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 <project-id>
## GKE
- `Display a list of credentialed accounts `: gcloud auth list
- `Set the active account `: gcloud config set account <ACCOUNT>
- `Set kubectl context `: gcloud container clusters get-credentials <cluster-name>
- `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 <key-file>
- `Display a list of credentialed accounts `: gcloud auth list
- `Set the active account `: gcloud config set account <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 <application-default> revoke
## BUCKET SECURITY
- `Make all files readable `: gsutil -m acl set -R -a public-read gs://<bucket-name>/
- `Config auth `: gsutil config -a
- `Grant bucket access `: gsutil iam ch user:denny@gmail.com:objectCreator,objectViewer gs://<bucket-name>
- `Remove bucket access `: gsutil iam ch -d user:denny@gmail.com:objectCreator,objectViewer gs://<bucket-name>
## VM
- `List all instances `: gcloud compute instances list, gcloud compute instance-templates list
- `Show instance info `: gcloud compute instances describe "<instance-name>" --project "<project-name>" --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 "<zone>" --machine-type f1-micro
- `SSH to instance `: gcloud compute ssh --project "<project-name>" --zone "<zone-name>" "<instance-name>"
- `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 <diskname> --snapshotname <name1> --zone $zone
## NETWORK
- `List all networks `: gcloud compute networks list
- `Detail of one network `: gcloud compute networks describe <network-name> --format json
- `Create network `: gcloud compute networks create <network-name>
- `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 <ip-name> --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 <rule-name>
- `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 <cluster-name>
## 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

114
tools/heroku.sh Normal file
View File

@ -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

141
tools/sublime_text.md Normal file
View File

@ -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
- `<open 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`