From a67d270791aad7c08ff67b0f8e4c0359df7fee1a Mon Sep 17 00:00:00 2001 From: FireIsGood Date: Sat, 12 Oct 2024 00:54:10 -0700 Subject: [PATCH 01/13] fix: small C inconsistencies Adds more newlines and removes small inconsistencies. Some newlines were not added in places where the intent was to show printf format specifiers. --- source/_posts/c.md | 82 +++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/source/_posts/c.md b/source/_posts/c.md index 9eedac5..cbd23a5 100644 --- a/source/_posts/c.md +++ b/source/_posts/c.md @@ -78,7 +78,7 @@ const int BIRTHYEAR = 1980; ```c // this is a comment -printf("Hello World!"); // Can comment anywhere in file +printf("Hello World!\n"); // Can comment anywhere in file /*Multi-line comment, print Hello World! to the screen, it's awesome */ @@ -87,12 +87,12 @@ to the screen, it's awesome */ ### Print text ```c -printf("I am learning C."); +printf("I am learning C.\n"); int testInteger = 5; -printf("Number = %d", testInteger); +printf("Number = %d\n", testInteger); float f = 5.99; // floating point number -printf("Value = %f", f); +printf("Value = %f\n", f); short a = 0b1010110; // binary number int b = 02713; // octal number @@ -183,7 +183,7 @@ printf("%s", greetings); ``` **NOTE**: String literals might be stored in read-only section of memory. Modifying a string literal invokes undefined -behavior. You can't modify it.! +behavior. You can't modify it! `C` **does not** have a String type, use `char` type and create an `array` of characters @@ -192,18 +192,18 @@ behavior. You can't modify it.! ```c int time = 20; if (time < 18) { - printf("Goodbye!"); + printf("Goodbye!\n"); } else { - printf("Good evening!"); + printf("Good evening!\n"); } // Output -> "Good evening!" int time = 22; if (time < 10) { - printf("Good morning!"); + printf("Good morning!\n"); } else if (time < 20) { - printf("Goodbye!"); + printf("Goodbye!\n"); } else { - printf("Good evening!"); + printf("Good evening!\n"); } // Output -> "Good evening!" ``` @@ -212,7 +212,7 @@ if (time < 10) { ```c int age = 20; -(age > 19) ? printf("Adult") : printf("Teenager"); +(age > 19) ? printf("Adult\n") : printf("Teenager\n"); ``` ### Switch @@ -221,10 +221,10 @@ int age = 20; int day = 4; switch (day) { - case 3: printf("Wednesday"); break; - case 4: printf("Thursday"); break; + case 3: printf("Wednesday\n"); break; + case 4: printf("Thursday\n"); break; default: - printf("Weekend!"); + printf("Weekend!\n"); } // output -> "Thursday" (day 4) ``` @@ -403,13 +403,13 @@ switch(day) { int myNum; // Ask the user to enter a number -printf("Please enter a number: \n"); +printf("Enter a number: "); // Get and save the number entered by the user scanf("%d", &myNum); // Output the number entered by the user -printf("The number you entered: %d", myNum); +printf("The number you entered: %d\n", myNum); ``` ### User input string @@ -418,11 +418,11 @@ printf("The number you entered: %d", myNum); // create a string char firstName[30]; // Ask the user to enter some text -printf("Enter your name: \n"); +printf("Enter your name: "); // get and save the text scanf("%s", &firstName); // output text -printf("Hello %s.", firstName); +printf("Hello %s.\n", firstName); ``` ### memory address @@ -442,10 +442,10 @@ To access it, use the reference operator (`&`) ```c int myAge = 43; // an int variable -printf("%d", myAge); // output the value of myAge(43) +printf("%d\n", myAge); // output the value of myAge(43) // Output the memory address of myAge (0x7ffe5367e044) -printf("%p", &myAge); +printf("%p\n", &myAge); ``` ### pointer variable {.col-span-2} @@ -716,12 +716,12 @@ printf("%c\n", myLetter); ```c #include -int main() { - printf("File :%s\n", __FILE__); - printf("Date :%s\n", __DATE__); - printf("Time :%s\n", __TIME__); - printf("Line :%d\n", __LINE__); - printf("ANSI :%d\n", __STDC__); +int main(void) { + printf("File: %s\n", __FILE__); + printf("Date: %s\n", __DATE__); + printf("Time: %s\n", __TIME__); + printf("Line: %d\n", __LINE__); + printf("ANSI: %d\n", __STDC__); } ``` @@ -764,7 +764,7 @@ When you need to convert a macro parameter to a string constant, use the string ```c #include -#define tokenpaster(n) printf ("token" #n " = %d", token##n) +#define tokenpaster(n) printf ("Token " #n " = %d\n", token##n) int main(void) { int token34 = 40; @@ -823,7 +823,7 @@ int main(void) { ```c int main(void) { - printf("Hello World!"); + printf("Hello World!\n"); return 0; } @@ -855,7 +855,7 @@ int main() { } void myFunction() {// Function definition - printf("Good evening!"); + printf("Good evening!\n"); } ``` @@ -864,7 +864,7 @@ void myFunction() {// Function definition ```c // create function void myFunction() { - printf("Good evening!"); + printf("Good evening!\n"); } int main() { @@ -918,7 +918,7 @@ int myFunction(int x) { } int main() { - printf("Result: %d", myFunction(3)); + printf("Result: %d\n", myFunction(3)); return 0; } // output 8 (5 + 3) @@ -932,10 +932,10 @@ int myFunction(int x, int y) { } int main() { - printf("Result: %d", myFunction(5, 3)); + printf("Result: %d\n", myFunction(5, 3)); // store the result in a variable int result = myFunction(5, 3); - printf("Result = %d", result); + printf("Result = %d\n", result); return 0; } @@ -950,7 +950,7 @@ int sum(int k); int main() { int result = sum(10); - printf("%d", result); + printf("%d\n", result); return 0; } @@ -970,10 +970,10 @@ int sum(int k) { #include void main(void) { - printf("%f", sqrt(16)); // square root - printf("%f", ceil(1.4)); // round up (round) - printf("%f", floor(1.4)); // round down (round) - printf("%f", pow(4, 3)); // x(4) to the power of y(3) + printf("%f\n", sqrt(16)); // square root + printf("%f\n", ceil(1.4)); // round up (round) + printf("%f\n", floor(1.4)); // round down (round) + printf("%f\n", pow(4, 3)); // x(4) to the power of y(3) } ``` @@ -1028,13 +1028,13 @@ int main() { struct myStructure s1; strcpy(s1. myString, "Some text"); // print value - printf("my string: %s", s1.myString); + printf("My string: %s\n", s1.myString); return 0; } ``` -Assigning values ​​to strings using the `strcpy` function +Assigning values to strings using the `strcpy` function ### Accessing structure members {.row-span-2} @@ -1100,7 +1100,7 @@ struct myStructure s1 = { s1.myNum = 30; s1.myLetter = 'C'; // print value -printf("%d %c %s", +printf("%d %c", s1.myNum, s1.myLetter); ``` From 9d95e528f0fd79edac1a46b424086016870cbefa Mon Sep 17 00:00:00 2001 From: Fechin Date: Thu, 17 Oct 2024 17:59:26 +0800 Subject: [PATCH 02/13] feat: change order --- themes/coo/layout/index.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/coo/layout/index.ejs b/themes/coo/layout/index.ejs index b4d9c63..62d6ad1 100644 --- a/themes/coo/layout/index.ejs +++ b/themes/coo/layout/index.ejs @@ -9,7 +9,7 @@
- <% site.categories.findOne({name: category}).posts.sort('-date').map(function(post){ %> + <% site.categories.findOne({name: category}).posts.sort('date').map(function(post){ %> <%- partial('_partial/index/card', { url: url_for(post.path), title: post.title, From 1e2042b70bc4db543f259b70b021b934d66cfe5e Mon Sep 17 00:00:00 2001 From: TheCreator69 <16518527+TheCreator69@users.noreply.github.com> Date: Thu, 24 Oct 2024 22:59:06 +0200 Subject: [PATCH 03/13] Added unreal-engine.md --- source/_posts/unreal-engine.md | 192 +++++++++++++++++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 source/_posts/unreal-engine.md diff --git a/source/_posts/unreal-engine.md b/source/_posts/unreal-engine.md new file mode 100644 index 0000000..6078c6d --- /dev/null +++ b/source/_posts/unreal-engine.md @@ -0,0 +1,192 @@ +--- +title: Unreal Engine +date: 2024-10-24 21:12:26 +tags: + - unreal + - engine +categories: +- Keyboard Shortcuts +intro: + A visual cheat-sheet for many keyboard shortcuts found in Unreal Engine 5 +--- + +## Level Editor + +### Viewport Transformation + +| Shortcut | Action | +| --------------------- | --------------------------- | +| `W` | Translate | +| `E` | Rotate | +| `R` | Scale | +| `Space Bar` | Toggle Transform Mode | +| `[` | Decrease Position Grid Size | +| `]` | Increase Position Grid Size | +| `Shift` `[` | Decrease Rotation Grid Size | +| `Shift` `]` | Increase Rotation Grid Size | + +{.shortcuts} + +### View Modes + +| Shortcut | Action | +| --------------------- | --------------------- | +| `Alt` `2` | Wireframe | +| `Alt` `3` | Unlit | +| `Alt` `4` | Lit | +| `Alt` `5` | Detail Lighting | +| `Alt` `6` | Lighting Only | +| `Alt` `7` | Light Complexity | +| `Alt` `8` | Shader Complexity | +| `Alt` `0` | Lightmap Density | + +{.shortcuts} + +### Level Editor General {.row-span-2} + +| Shortcut | Action | +| --------------------- | ---------------------------- | +| `Esc` | Deselect All | +| `H` | Hide Selected | +| `Ctrl` `H` | Unhide All | +| `F` | Focus on Actor | +| `F9` | Screenshot | +| `F11` | Immersive Mode | +| `G` | Game View | +| `T` | Toggle Translucent Selection | +| `(right click)` | Asset Menu | +| `Ctrl` `E` | Edit Selected Asset | +| `Ctrl` `P` | Open Asset | +| `P` | Toggle Navmesh | +| `Ctrl` `Shift` `,` | Profile GPU | +| `Ctrl` `Shift` `H` | Toggle FPS | +| `~` | Command Console | + +{.shortcuts} + +### Camera Navigation + +| Shortcut | Action | +| --------------------- | --------------------- | +| `Alt` `G` | Perspective View | +| `Alt` `H` | Front View | +| `Alt` `J` | Top View | +| `Alt` `K` | Side View | +| `Ctrl` `0-9` | Set Bookmark | +| `0-9` | Jump to Bookmark | + +{.shortcuts} + +### Editing Modes + +| Shortcut | Action | +| --------------------- | --------------------- | +| `Shift` `1` | Selection Mode | +| `Shift` `2` | Landscape Mode | +| `Shift` `3` | Foliage Mode | +| `Shift` `4` | Modeling Mode | +| `Shift` `5` | Brush Editing Mode | +| `Shift` `6` | Animation Mode | + +{.shortcuts} + +### Snapping + +| Shortcut | Action | +| --------------------- | --------------------- | +| `End` | Snap to Floor | +| `Alt` `End` | Snap Pivot to Floor | +| `Shift` `End` | Snap Bounds to Floor | +| `Ctrl` `End` | Snap to World Grid | + +{.shortcuts} + +### Play in Editor (PIE) + +| Shortcut | Action | +| --------------------- | --------------------- | +| `Alt` `P` | Start PIE Session | +| `Pause` | Pause | +| `F8 ` | Eject from Player | +| `Esc` | Stop PIE Session | + +{.shortcuts} + +### Content Browser + +Note: You need to select assets first for these shortcuts to work + +| Shortcut | Action | +| --------------------- | --------------------- | +| `Alt` `Shift` `A` | Audit Assets | +| `Alt` `Shift` `R` | Reference Viewer | +| `Alt` `Shift` `M` | Size Map | + +{.shortcuts} + +## Asset Editors + +### Blueprints {.row-span-2} + +| Shortcut | Action | +| --------------------- | ------------------------------- | +| `B` | Add Branch | +| `S` | Add Sequence | +| `D` | Add Delay | +| `F` | Add For Each Loop | +| `G` | Add Gate | +| `M` | Add Multi Gate | +| `O` | Add Do Once | +| `N` | Add Do N | +| `C` | Add Comment | +| `F7` | Compile Blueprint | +| `F9` | Add Breakpoint to selected node | +| `Ctrl` `Shift` `F9` | Remove all Breakpoints | +| `Home` | Zoom to selected node | + +{.shortcuts} + +### Asset Editor Viewports + +Used in the viewport for the Mesh Editor, Material Editor, Blueprint Editor, etc. + +| Shortcut | Action | +| --------------------- | ---------------------- | +| `I` | Toggle Environment | +| `O` | Toggle Floor | +| `P` | Toggle Post Processing | + +{.shortcuts} + +### Static Meshes + +| Shortcut | Action | +| --------------------- | ------------------------- | +| `Ctrl` `N` | Show Nanite Fallback Mesh | +| `Alt` `N` | Toggle Normals | +| `Alt` `S` | Toggle Sockets | + +{.shortcuts} + +## Your own Shortcuts + +### Shortcut Settings + +- Click on the `Edit` Menu + +- Open `Editor Preferences` + +- Under "General" (the first section), find `Editor Shortcuts` + +- Here you can modify all of the above shortcuts, as well as many more! + +## Also see + +- [Unreal Engine Blog: Designer's Guide to Shortcuts](https://www.unrealengine.com/en-US/tech-blog/designer-s-guide-to-unreal-engine-keyboard-shortcuts) + _(www.unrealengine.com)_ +- [Unreal Developer Community: Unexplored Shortcuts](https://dev.epicgames.com/community/learning/tutorials/yp8j/the-unexplored-unreal-engine-keyboard-shortucts) + _(dev.epicgames.com)_ +- [Unreal Engine Editor Hotkey Cheat Sheet](https://uecasts.com/resources/unreal-engine-5-editor-hotkeys-cheat-sheet) + _(uecasts.com)_ +- [Unreal Engine Actor Snapping Shortcuts](https://unrealdirective.com/tips/actor-snapping-shortcuts) + _(unrealdirective.com)_ \ No newline at end of file From 65ff2e32a4f56a73b3ad10d96e96b4b67265b3ef Mon Sep 17 00:00:00 2001 From: Danilo Maia Florenzano Date: Mon, 28 Oct 2024 09:42:52 -0300 Subject: [PATCH 04/13] update firefox.md --- source/_posts/firefox.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/_posts/firefox.md b/source/_posts/firefox.md index 2d3aecb..3260e9b 100644 --- a/source/_posts/firefox.md +++ b/source/_posts/firefox.md @@ -89,8 +89,8 @@ intro: | | `Ctrl` `Shift` `W` | Close Window | | `Ctrl` `Tab` | Cycle through Tabs in Recently Used Order | | `Ctrl` `Q` | Quit | -| `Ctrl` `Alt` `Left` | Go one Tab to the Left | -| `Ctrl` `Alt` `Right` | Go one Tab to the Right | +| `Ctrl` `PgUp` | Go one Tab to the Left | +| `Ctrl` `PgDown` | Go one Tab to the Right | | `Ctrl` `Shift` `PgUp` | Move Tab Left | | `Ctrl` `Shift` `PgDown` | Move Tab Right | | `Ctrl` `Shift` `Home` | Move Tab in focus to start | From b88c4f4750a081608cea70ca6a6bb8e93317a5ea Mon Sep 17 00:00:00 2001 From: Saeid Javadi Date: Tue, 29 Oct 2024 20:15:24 +0330 Subject: [PATCH 05/13] Updating the Django template section and completing another section --- source/_posts/django.md | 99 ++++++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 22 deletions(-) diff --git a/source/_posts/django.md b/source/_posts/django.md index 5f48843..58a0229 100644 --- a/source/_posts/django.md +++ b/source/_posts/django.md @@ -110,8 +110,12 @@ Migrate: Will read the migrations files and create the actual database and table ## Project config {.cols-1} ### Configuration settings - - +##### Project base templates directory and Apps templates directory: + - create folder project/templates + - create folder appfolder/templates/appname +##### Create Static folder in base root and separate for apps: +- project_name\static\root +- app_name\static\app_name ```python # Add app to settings.py @@ -120,27 +124,18 @@ INSTALLED_APPS = [ 'app_name.apps.App_nameConfig', ] -# App templates folder -create folder appfolder/templates/appname - -# Project templates folder: -create folder projectname/templates - -# settings.py template config +# template directory config Project templates settings.py: TEMPLATES = [ { … 'DIRS': [BASE_DIR / 'templates'], … } -# Create Static folder: -project_name\static\ - -# Static folder (settings.py): +# Static folder: STATIC_URL = '/static/' STATICFILES_DIRS = [ BASE_DIR / 'static' ] STATIC_ROOT = 'static_root' -# Media folder (settings.py): +# Media folder: MEDIA_URL = '/media/' STATICFILES_DIRS = ( (BASE_DIR / 'static'), @@ -529,15 +524,20 @@ Templates are store in `project_folder/templates` or in your app_folder/te ```python +# Extend from another template +# can use the same parts of your HTML for different template {% extends 'base.html' %} -{% block content %} -{% endblock %} +# A part of the parent template that is defined and is replaced by a part in the child template +{% block contents %} +{% endblock contents %} + +# include template {% include 'partials/header.html' %} - # include template with One or More Parameters {% include 'body.html' with key1=value1 key2=value2 %} +# If statement in template {% if user.username = 'Mike' %}

Hello Admin

{% elif user.username = 'john' %} @@ -546,15 +546,20 @@ Templates are store in `project_folder/templates` or in your app_folder/te

Hello User

{% endif %} +# for loop in template {% for product in products %} -

product number: {{ forloop.counter0 }}

-

The product name is {{ product }}

+

row: + {{ forloop.counter }} # starting index 1 + {{ forloop.counter0 }} # starting index 0 +

+

The product name is {{ product.name }}

+

The product name is {{ product.price }}

{% endfor %} # Access to the variable in the template {{ var_name }} -# Template variables formatting +# Template variables formating {{ title | lower }} {{ blog.post | truncatwords:50 }} {{ order.date | date:"D M Y" }} @@ -577,6 +582,53 @@ Templates are store in `project_folder/templates` or in your app_folder/te

Hello {{ name }}!
{% endwith %} + +# Template translate text +{% load i18n %} +{% trans "This is the title." %} +# Use variable translate in the template +{% trans object.title %} + +# Define the list in the template + + +# Safely Pass Data to JavaScript in a Django Template: +#+ Use data attributes for simple values + + +#+ Separate script files: can use document.currentScript for separate script files + + +#+ Case conversion + +# Read it in JavaScript as fullName: +const data = document.currentScript.dataset; +const fullName = data.fullName; + +#+ Non-string types + +# parseInt() to convert this value from a string: +const data = document.currentScript.dataset; +const followerCount = parseInt(data.followerCount, 10); + +#+ There’s no limit: A ``` ### Custom Template Tags and Filters @@ -857,12 +909,15 @@ messages.error(request, 'Login error') # Message tags # debug, info, success, warning and error - -# Display flash in template +``` +```django +# Display flash messages in template {% if messages %} {% for message in messages %} {% message %} {% message.tags %} + {% endfor %} +{% endif %} ``` ## User Model From 44f81d8155ac3424e8f720cf863e29f947d7239c Mon Sep 17 00:00:00 2001 From: Saeid Javadi Date: Wed, 13 Nov 2024 20:52:54 +0330 Subject: [PATCH 06/13] Add new content for Django --- source/_posts/django.md | 337 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 325 insertions(+), 12 deletions(-) diff --git a/source/_posts/django.md b/source/_posts/django.md index 58a0229..0085307 100644 --- a/source/_posts/django.md +++ b/source/_posts/django.md @@ -523,7 +523,7 @@ Templates are store in `project_folder/templates` or in your app_folder/te -```python +```django # Extend from another template # can use the same parts of your HTML for different template {% extends 'base.html' %} @@ -851,7 +851,8 @@ class ArticleForm(ModelForm): 'name': 'Enter Your First Name', } - +``` +```django # Render form in template
{% csrf_token %} @@ -863,14 +864,17 @@ class ArticleForm(ModelForm): {% load crispy_forms_tags %} {{ form|crispy }} {{ form.email|as_crispy_field }} - +``` +```bash # crispy-tailwind pip install crispy-tailwind - +``` +```python # settings.py CRISPY_ALLOWED_TEMPLATE_PACKS = 'tailwind' CRISPY_TEMPLATE_PACK = 'tailwind' - +``` +```django # template usage {% load tailwind_filters %} {{ form|crispy}} @@ -953,7 +957,8 @@ from django.contrib.auth.views import LoginView path('login/', LoginView.as_view(), name='login') # By default the LoginView will try to open a template name 'registration/login.html' and send a login form with it. - +``` +```django # Create a template under registration/login.html {% extends "base.html" %} {% block content %} @@ -998,8 +1003,8 @@ class SignupView(CreateView): def get_success_url(self): return reverse("login") - - +``` +```django # Create template: registration/signup.html {% extends "base.html" %} {% block content %} @@ -1009,12 +1014,14 @@ class SignupView(CreateView):
{% endblock content %} - +``` +```python # Add a url to reach that view from posts.views import SignupView path('signup/', SignupView.as_view(), name='signup') - +``` +```python # Optional: Customize the UserCreationForm # (forms.py) from django.contrib.auth import get_user_model @@ -1038,7 +1045,7 @@ urlpatterns += path('', include('django.contrib.auth.urls')) #### Template Authentication helpers -```python +```django # Authentication links Login Signup @@ -1107,7 +1114,8 @@ user.set_password('raw password') ```python # Add accounts app to settings.py INSTALLED_APPS = [ … , - 'accounts.apps.AccountsConfi', ] + 'accounts.apps.AccountsConfig', + ] . . . @@ -1806,3 +1814,308 @@ command. We can also take a look at the program output with the `tail` command. ```bash ~$ supervisor> quit ``` + +## Deployment Django in Server + +### Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu server + +#### Step 1 — Installing the Packages from the Ubuntu Repositories + +```bash +sudo apt update +sudo apt install python3-venv python3-dev libpq-dev postgresql postgresql-contrib nginx curl +``` + +#### Step 2 — Creating the PostgreSQL Database and User + +```bash +sudo -u postgres psql +``` + +- First, create a database for your project: + +```bash +postgres=# CREATE DATABASE myproject; +``` + +- Next, create a database user for our project. Make sure to select a secure password: + +```bash +postgres=# CREATE USER myprojectuser WITH PASSWORD 'password'; +``` + +- Afterwards, you’ll modify a few of the connection parameters for the user that you just created + +```bash +postgres=# ALTER ROLE myprojectuser SET client_encoding TO 'utf8'; +postgres=# ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed'; +postgres=# ALTER ROLE myprojectuser SET timezone TO 'UTC'; +``` + +- Now, you can give the new user access to administer the new database: + +```bash +postgres=# GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser; +``` + +- When you are finished, exit out of the PostgreSQL prompt by typing: + +```bash +postgres=# \q +``` + +#### Step 3 — Creating a Python Virtual Environment for your Project + +- thin the project directory, create a Python virtual environment by typing: + +```bash +mkdir ~/myprojectdir +cd ~/myprojectdir +``` + +- Within the project directory, create a Python virtual environment by typing: + +```bash +python3 -m venv myprojectenv +``` + +- Before installing your project’s Python requirements, you will need to activate the virtual environment. You can do that by typing: + +```bash +source myprojectenv/bin/activate +``` + +- With your virtual environment active, install Django, Gunicorn, and the psycopg2 PostgreSQL adaptor with the local instance of pip + +```bash +(myprojectenv)$ pip install django gunicorn psycopg2-binary +``` + +#### Step 4 — Creating and Configuring a New Django Project + +- With your Python components installed, you can now create the actual Django project files. + +```bash +(myprojectenv)$ django-admin startproject myproject ~/myprojectdir +``` + +- The first thing you should do with your newly created project files is adjust the settings. Open the settings file in your text editor: + +```bash +(myprojectenv)$ nano ~/myprojectdir/myproject/settings.py +``` + +- Start by locating the ALLOWED_HOSTS directive. + +```py ~/myprojectdir/myproject/settings.py +ALLOWED_HOSTS = ['your_server_domain_or_IP', 'second_domain_or_IP', . . ., 'localhost'] +``` + +- Next, find the section that configures database access. It will start with DATABASES. The configuration in the file is for a SQLite database. + +```py +. . . +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'myproject', + 'USER': 'myprojectuser', + 'PASSWORD': 'password', + 'HOST': 'localhost', + 'PORT': '', + } +} +. . . +``` + +- Next, move down to the bottom of the file and add a setting indicating where the static files should be placed. + +```py +. . . +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +import os +STATIC_ROOT = os.path.join(BASE_DIR, 'static/') +``` + +#### Step 5 — Completing Initial Project Setup + +- Now, you can migrate the initial database schema to our PostgreSQL database using the management script: + +```bash +(myprojectenv)$ ~/myprojectdir/manage.py makemigrations +(myprojectenv)$ ~/myprojectdir/manage.py migrate +``` + +- Create an administrative user for the project by typing: + +```bash +(myprojectenv)$ ~/myprojectdir/manage.py createsuperuser +``` + +- You can collect all of the static content into the directory location that you configured by typing: + +```bash +(myprojectenv)$ ~/myprojectdir/manage.py collectstatic +``` + +#### Step 6 — Testing Gunicorn’s Ability to Serve the Project + +```bash +(myprojectenv)$ cd ~/myprojectdir +(myprojectenv)$ gunicorn --bind 0.0.0.0:8000 myproject.wsgi +``` + +- You’re now finished configuring your Django application. You can back out of our virtual environment by typing: + +```bash +(myprojectenv)$ deactivate +``` + +#### Step 7 — Creating systemd Socket and Service Files for Gunicorn You have tested tha + +```bash +sudo nano /etc/systemd/system/gunicorn.socket +``` + +- Inside, you will create a `[Unit]` section to describe the socket, a `[Socket]` section to define the socket location, and an `[Install]` section to make sure the socket is created at the right time: + +```bash /etc/systemd/system/gunicorn.socket +[Unit] +Description=gunicorn socket + +[Socket] +ListenStream=/run/gunicorn.sock + +[Install] +WantedBy=sockets.target +``` + +- Save and close the file when you are finished. +- Next, create and open a systemd service file for Gunicorn with sudo privileges in your text editor. The service filename should match the socket filename with the exception of the extension: + +```bash +sudo nano /etc/systemd/system/gunicorn.service +``` +```bash +[Unit] +Description=gunicorn daemon +Requires=gunicorn.socket +After=network.target + +[Service] +User=sammy +Group=www-data +WorkingDirectory=/home/sammy/myprojectdir +ExecStart=/home/sammy/myprojectdir/myprojectenv/bin/gunicorn \ + --access-logfile - \ + --workers 3 \ + --bind unix:/run/gunicorn.sock \ + myproject.wsgi:application + +[Install] +WantedBy=multi-user.target +``` +- You can now start and enable the Gunicorn socket. This will create the socket file at /run/gunicorn.sock now and at boot. When a connection is made to that socket, systemd will automatically start the gunicorn.service to handle it +```bash +sudo systemctl start gunicorn.socket +sudo systemctl enable gunicorn.socket +``` +#### Step 8 — Checking for the Gunicorn Socket File +- Check the status of the process to find out whether it was able to start: + +```bash +sudo systemctl status gunicorn.socket +``` +- Next, check for the existence of the gunicorn.sock file within the /run directory: +```bash +file /run/gunicorn.sock +``` +#### Step 9 — Testing Socket Activation +```bash +sudo systemctl status gunicorn +``` +- To test the socket activation mechanism, you can send a connection to the socket through curl by typing: +```bash +curl --unix-socket /run/gunicorn.sock localhost +``` +- You should receive the HTML output from your application in the terminal. This indicates that Gunicorn was started and was able to serve your Django application. You can verify that the Gunicorn service is running by typing: +```bash +sudo systemctl status gunicorn +``` +- Check your /etc/systemd/system/gunicorn.service file for problems. If you make changes to the /etc/systemd/system/gunicorn.service file, reload the daemon to reread the service definition and restart the Gunicorn process by typing +```bash +sudo systemctl daemon-reload +sudo systemctl restart gunicorn +``` +#### Step 10 — Configure Nginx to Proxy Pass to Gunicorn +- Start by creating and opening a new server block in Nginx’s sites-available directory: +```bash +sudo nano /etc/nginx/sites-available/myproject +``` +```bash +server { + listen 80; + server_name server_domain_or_IP; + + location = /favicon.ico { access_log off; log_not_found off; } + location /static/ { + alias /home/sammy/myprojectdir/staticfiles/; + } + + location /media { + autoindex on; + alias /home/sammy/myprojectdir/media/; + } + + location / { + include proxy_params; + proxy_pass http://unix:/run/gunicorn.sock; + } +} +``` +- Save and close the file when you are finished. Now, you can enable the file by linking it to the sites-enabled directory: +```bash +sudo ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled +``` +- Test your Nginx configuration for syntax errors by typing: +```bash +sudo nginx -t +``` +- If no errors are reported, go ahead and restart Nginx by typing: +```bash +sudo systemctl restart nginx +``` +- you need to open up your firewall to normal traffic on port 80 +```bash +sudo ufw allow 'Nginx Full' +``` +You should now be able to go to your server’s domain or IP address to view your application. +#### Step 11 — Troubleshooting Nginx and Gunicorn +- Nginx Is Showing the Default Page Instead of the Django Application +```bash +sudo tail -F /var/log/nginx/error.log +``` +- Django Is Displaying: “could not connect to server: Connection refused” +```bash +sudo systemctl status postgresql +``` +- If it is not, you can start it and enable it to start automatically at boot (if it is not already configured to do so) by typing: +```bash +sudo systemctl start postgresql +sudo systemctl enable postgresql +``` +If you change Gunicorn socket or service files, reload the daemon and restart the process by typing: +```bash +sudo systemctl daemon-reload +sudo systemctl restart gunicorn.socket gunicorn.service +``` +If you change the Nginx server block configuration, test the configuration and then Nginx by typing: +```bash +sudo nginx -t && sudo systemctl restart nginx +``` \ No newline at end of file From 8b2fbce9cb4e4882054c95af1752bc300a6f84fc Mon Sep 17 00:00:00 2001 From: Saeid Javadi Date: Wed, 13 Nov 2024 21:26:40 +0330 Subject: [PATCH 07/13] Best Windows Shortcuts --- source/_posts/windows-shortcuts.md | 458 +++++++++++++++++++++++++++++ 1 file changed, 458 insertions(+) create mode 100644 source/_posts/windows-shortcuts.md diff --git a/source/_posts/windows-shortcuts.md b/source/_posts/windows-shortcuts.md new file mode 100644 index 0000000..ab404f9 --- /dev/null +++ b/source/_posts/windows-shortcuts.md @@ -0,0 +1,458 @@ +# Best Windows Shortcuts on Your Keyboard + + Copy selected content (Ctrl + C can also abort commands): + +``` +Ctrl + C +``` + + Paste copied content: + +``` +Ctrl + V +``` + + Paste unformatted content: + +``` +Ctrl + Shift + V +``` + + Delete and copy selected content (good for moving text, files, etc.): + +``` +Ctrl + X +``` + + Select all available content in focus: + +``` +Ctrl + A +``` + + Undo the previous action: + +``` +Ctrl + Z +``` + + Redo the previous action: + +``` +Ctrl + Y +``` + + Save what you're working on: + +``` +Ctrl + S +``` + + Open a new file: + +``` +Ctrl + O +``` + + Open the print dialog box: + +``` +Ctrl + P +``` + + Open the search tool to find something on the page: + +``` +Ctrl + F +``` + + Refresh the contents on the screen (only F5 works in some cases): + +``` +Ctrl + R +``` + + Close the active program: + +``` +Alt + F4 +``` + + Enter full-screen mode: + +``` +F11 +``` + + Stop or close a prompt or process: + +``` +Esc +``` + +# Keyboard Shortcuts for Navigating Windows + + Lock your user account: + +``` +Win + L +``` + + Open File Explorer: + +``` +Win + E +``` + + Open Windows Settings: + +``` +Win + i +``` + + Move focus to the navigation bar to edit or copy the folder path: + +``` +Alt + D +``` + + Go to the folder the current folder is stored in: + +``` +Alt + Up +``` + + Show your password on the sign-in screen: + +``` +Alt + F8 +``` + + Open Task Manager (Ctrl + Alt + Del works, too): + +``` +Ctrl + Shift + Esc +``` + + Open the Run dialog box to run commands: + +``` +Win + R +``` + + Quickly switch to the desktop: + +``` +Win + D +``` + + Open the selected item's Properties window: + +``` +Alt + [Enter or double-click] +``` + + Add a Virtual Desktop: + +``` +Win + Ctrl + D +``` + + Switch to the virtual desktop on the left or right: + +``` +Win + Ctrl + [Left or Right] +``` + + Show All Open Desktops: + +``` +WIN + Tab +``` + + Close Current Virtual Desktop: + +``` +WIN + Ctrl + F4 +``` + + Select noncontiguous items (like files or folders): + +``` +Ctrl + Click +``` + + A possible fix for when your screen is black: + +``` +Win + Ctrl + Shift + B +``` + + Select every item between the first and last select items: + +``` +Shift + Click +``` + + Permanently delete a file or folder (it skips the Recycle Bin): + +``` +Shift + Del +``` + + Switch to the last used window: + +``` +Alt + Tab +``` + + Snap the active window to one side of the screen: + +``` +Win + [Arrow] +``` + + Rename the selected file or folder: + +``` +F2 +``` + + Open the Power User Menu: + +``` +Win + X +``` + + Open a new instance of that app: + +``` +Shift + Click Taskbar Icon +``` + + Launch that item from the taskbar: + +``` +Win + [number] +``` + + Make a new folder: + +``` +Ctrl + Shift + N +``` + + Open the Windows About page: + +``` +Win + Pause +``` + +# Keyboard Shortcuts for Screenshots + + Screenshot just the active window: + +``` +Alt + PrtScn +``` + + Auto-save full-screen screenshot to Pictures > Screenshots: + +``` +Win + PrtScn +``` + + Choose a part of the screen to make a screenshot: + +``` +Win + Shift + S +``` + +# Keyboard Shortcuts for Text Manipulation + + Bold the selected text: + +``` +Ctrl + B +``` + + Italicize the selected text: + +``` +Ctrl + i +``` + + Underline the selected text: + +``` +Ctrl + U +``` + + Insert a hyperlink into the selected text: + +``` +Ctrl + K +``` + + Open the Find and Replace tool (confirmed in MS Word and Google Docs): + +``` +Ctrl + H +``` + + Pick an arrow key with this shortcut to quickly highlight a whole word or paragraph: + +``` +Shift + Ctrl + [Arrow] +``` + + Highlight everything from the cursor to the beginning or end of the line: + +``` +Shift + [Home or End] +``` + + Delete the word to the right of the cursor: + +``` +Ctrl + Del +``` + +# Keyboard Shortcuts for Web Browsers + + Open a new tab: + +``` +Ctrl + T +``` + + Reopen the most recently closed tab: + +``` +Ctrl + Shift + T +``` + + Close the active tab: + +``` +Ctrl + W +``` + + Open the link in a new tab: + +``` +Ctrl + [Link] +``` + + View your web browsing history: + +``` +Ctrl + H +``` + + View recent or active downloads: + +``` +Ctrl + J +``` + + Start a search using the default search engine: + +``` +Ctrl + E +``` + + Jump to the tab in that position from the left (e.g., Ctrl + 4): + +``` +Ctrl + [number] +``` + + Open the options to delete browsing data: + +``` +Ctrl + Shift + Del +``` + + Go back or forward a page: + +``` +Alt + [Left or Right] +``` + + Adjust the size of the text (scroll up with the mouse to increase the size): + +``` +Ctrl + [Zoom] +``` + + Add .com to the end of the text in the address bar, and then visit the page: + +``` +Ctrl + Enter +``` + + Refresh the page, but skip the cache: + +``` +Ctrl + F5 +``` + + Open LinkedIn (or Teams, Word Online): + +``` +Ctrl + Shift + Alt + Win + L +``` +# Windows Shortcuts in Run Command +* The quickest way to access the Run command window is to use the keyboard shortcut `Windows + R` + +| Command | Description | +| ---- | ---- | +|sysdm.cpl| Windows Propertes| +|compmgmt.msc| Component Managment| +|winver| Windows Version| +|appwiz.cpl| Programs And Fuatchers| +|resmon|The Resource Monitor window will open, displaying real-time performance data| +|taskmgr| Task Manager| +|explorer| Windows Explorer| +|ncpa.cpl| Network Connection| +|Firewall.cpl| Firewall | +|wf.msc| Windows Firewall Advanced| +|intl.cpl| Time And Date Options| +|timedate.cpl| Time And Date Settings| +|mstsc| Remote Desktop| +|osk| Keybord Virtual| +|charmap| Character Map | +|devmgmt.msc| Device Managment| +|desk.cpl| Desktop Resuliation| +|dfrgui| program for configuring the scheduled task for disk defragmentation| +|diskmgmt.msc| Disk Managare| +|fsmgmt.msc| Show Folders Share| +|inetcpl.cpl| Internet Explorer options| +|logoff| Log Off| +|magnify| Show Magnifier | +|mmsys.cpl| Sound settings| +|msconfig| System settings| +|msinfo32| Show system all info| +|systeminfo | Show system info| +|netplwiz| System Users info| +|perfmon.msc| Start Windows Reliability and Performance Monitor in a specific standalone mode| +|powercfg.cpl| Power options| +|services.msc| Services| +|shrpubw| Shared Folder Wizard| +|write| WordPad| +|control| Control Panel| +|Control Printers| Device And Printers| +|dxdiag| Show System Information Hardware| +|tracert| Trace Route | +|printui /s /t2 |Print Server Properties| +|printui /s|Show Printer Drivers| +|PrintManagement.msc| Printers Management , show all printers with drivers| +|shell:appsfolder| Show App Folder| +|shutdown /r /t 5|Restart the system after 5 seconds| +|shutdown /s /t 5|System shutdown after 5 seconds| +|shutdown /r /fw|Bios Login from windows| + +# Create God Mode Folder +create a new folder on your desktop with this exact name (copy and paste it): `GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}` +* The folder icon will change to a Control Panel-style icon, and you will be able to jump in and change all kinds of settings \ No newline at end of file From c9e38d87aa2b69bf87d23a5a75b780e7b1b980f0 Mon Sep 17 00:00:00 2001 From: Saeid Javadi Date: Thu, 14 Nov 2024 07:39:45 +0330 Subject: [PATCH 08/13] Update windows-shortcuts.md --- source/_posts/windows-shortcuts.md | 237 +++++++++++++++-------------- 1 file changed, 121 insertions(+), 116 deletions(-) diff --git a/source/_posts/windows-shortcuts.md b/source/_posts/windows-shortcuts.md index ab404f9..50a2e62 100644 --- a/source/_posts/windows-shortcuts.md +++ b/source/_posts/windows-shortcuts.md @@ -1,90 +1,90 @@ # Best Windows Shortcuts on Your Keyboard - Copy selected content (Ctrl + C can also abort commands): +Copy selected content (Ctrl + C can also abort commands): ``` Ctrl + C ``` - Paste copied content: +Paste copied content: ``` Ctrl + V ``` - Paste unformatted content: +Paste unformatted content: ``` Ctrl + Shift + V ``` - Delete and copy selected content (good for moving text, files, etc.): +Delete and copy selected content (good for moving text, files, etc.): ``` Ctrl + X ``` - Select all available content in focus: +Select all available content in focus: ``` Ctrl + A ``` - Undo the previous action: +Undo the previous action: ``` Ctrl + Z ``` - Redo the previous action: +Redo the previous action: ``` Ctrl + Y ``` - Save what you're working on: +Save what you're working on: ``` Ctrl + S ``` - Open a new file: +Open a new file: ``` Ctrl + O ``` - Open the print dialog box: +Open the print dialog box: ``` Ctrl + P ``` - Open the search tool to find something on the page: +Open the search tool to find something on the page: ``` Ctrl + F ``` - Refresh the contents on the screen (only F5 works in some cases): +Refresh the contents on the screen (only F5 works in some cases): ``` Ctrl + R ``` - Close the active program: +Close the active program: ``` Alt + F4 ``` - Enter full-screen mode: +Enter full-screen mode: ``` F11 ``` - Stop or close a prompt or process: +Stop or close a prompt or process: ``` Esc @@ -92,157 +92,157 @@ Esc # Keyboard Shortcuts for Navigating Windows - Lock your user account: +Lock your user account: ``` Win + L ``` - Open File Explorer: +Open File Explorer: ``` Win + E ``` - Open Windows Settings: +Open Windows Settings: ``` Win + i ``` - Move focus to the navigation bar to edit or copy the folder path: +Move focus to the navigation bar to edit or copy the folder path: ``` Alt + D ``` - Go to the folder the current folder is stored in: +Go to the folder the current folder is stored in: ``` Alt + Up ``` - Show your password on the sign-in screen: +Show your password on the sign-in screen: ``` Alt + F8 ``` - Open Task Manager (Ctrl + Alt + Del works, too): +Open Task Manager (Ctrl + Alt + Del works, too): ``` Ctrl + Shift + Esc ``` - Open the Run dialog box to run commands: +Open the Run dialog box to run commands: ``` Win + R ``` - Quickly switch to the desktop: +Quickly switch to the desktop: ``` Win + D ``` - Open the selected item's Properties window: +Open the selected item's Properties window: ``` Alt + [Enter or double-click] ``` - Add a Virtual Desktop: +Add a Virtual Desktop: ``` Win + Ctrl + D ``` - Switch to the virtual desktop on the left or right: +Switch to the virtual desktop on the left or right: ``` Win + Ctrl + [Left or Right] ``` - Show All Open Desktops: +Show All Open Desktops: ``` WIN + Tab ``` - Close Current Virtual Desktop: +Close Current Virtual Desktop: ``` WIN + Ctrl + F4 ``` - Select noncontiguous items (like files or folders): +Select noncontiguous items (like files or folders): ``` Ctrl + Click ``` - A possible fix for when your screen is black: +A possible fix for when your screen is black: ``` Win + Ctrl + Shift + B ``` - Select every item between the first and last select items: +Select every item between the first and last select items: ``` Shift + Click ``` - Permanently delete a file or folder (it skips the Recycle Bin): +Permanently delete a file or folder (it skips the Recycle Bin): ``` Shift + Del ``` - Switch to the last used window: +Switch to the last used window: ``` Alt + Tab ``` - Snap the active window to one side of the screen: +Snap the active window to one side of the screen: ``` Win + [Arrow] ``` - Rename the selected file or folder: +Rename the selected file or folder: ``` F2 ``` - Open the Power User Menu: +Open the Power User Menu: ``` Win + X ``` - Open a new instance of that app: +Open a new instance of that app: ``` Shift + Click Taskbar Icon ``` - Launch that item from the taskbar: +Launch that item from the taskbar: ``` Win + [number] ``` - Make a new folder: +Make a new folder: ``` Ctrl + Shift + N ``` - Open the Windows About page: +Open the Windows About page: ``` Win + Pause @@ -250,19 +250,19 @@ Win + Pause # Keyboard Shortcuts for Screenshots - Screenshot just the active window: +Screenshot just the active window: ``` Alt + PrtScn ``` - Auto-save full-screen screenshot to Pictures > Screenshots: +Auto-save full-screen screenshot to Pictures > Screenshots: ``` Win + PrtScn ``` - Choose a part of the screen to make a screenshot: +Choose a part of the screen to make a screenshot: ``` Win + Shift + S @@ -270,49 +270,49 @@ Win + Shift + S # Keyboard Shortcuts for Text Manipulation - Bold the selected text: +Bold the selected text: ``` Ctrl + B ``` - Italicize the selected text: +Italicize the selected text: ``` Ctrl + i ``` - Underline the selected text: +Underline the selected text: ``` Ctrl + U ``` - Insert a hyperlink into the selected text: +Insert a hyperlink into the selected text: ``` Ctrl + K ``` - Open the Find and Replace tool (confirmed in MS Word and Google Docs): +Open the Find and Replace tool (confirmed in MS Word and Google Docs): ``` Ctrl + H ``` - Pick an arrow key with this shortcut to quickly highlight a whole word or paragraph: +Pick an arrow key with this shortcut to quickly highlight a whole word or paragraph: ``` Shift + Ctrl + [Arrow] ``` - Highlight everything from the cursor to the beginning or end of the line: +Highlight everything from the cursor to the beginning or end of the line: ``` Shift + [Home or End] ``` - Delete the word to the right of the cursor: +Delete the word to the right of the cursor: ``` Ctrl + Del @@ -320,139 +320,144 @@ Ctrl + Del # Keyboard Shortcuts for Web Browsers - Open a new tab: +Open a new tab: ``` Ctrl + T ``` - Reopen the most recently closed tab: +Reopen the most recently closed tab: ``` Ctrl + Shift + T ``` - Close the active tab: +Close the active tab: ``` Ctrl + W ``` - Open the link in a new tab: +Open the link in a new tab: ``` Ctrl + [Link] ``` - View your web browsing history: +View your web browsing history: ``` Ctrl + H ``` - View recent or active downloads: +View recent or active downloads: ``` Ctrl + J ``` - Start a search using the default search engine: +Start a search using the default search engine: ``` Ctrl + E ``` - Jump to the tab in that position from the left (e.g., Ctrl + 4): +Jump to the tab in that position from the left (e.g., Ctrl + 4): ``` Ctrl + [number] ``` - Open the options to delete browsing data: +Open the options to delete browsing data: ``` Ctrl + Shift + Del ``` - Go back or forward a page: +Go back or forward a page: ``` Alt + [Left or Right] ``` - Adjust the size of the text (scroll up with the mouse to increase the size): +Adjust the size of the text (scroll up with the mouse to increase the size): ``` Ctrl + [Zoom] ``` - Add .com to the end of the text in the address bar, and then visit the page: +Add .com to the end of the text in the address bar, and then visit the page: ``` Ctrl + Enter ``` - Refresh the page, but skip the cache: +Refresh the page, but skip the cache: ``` Ctrl + F5 ``` - Open LinkedIn (or Teams, Word Online): +Open LinkedIn (or Teams, Word Online): ``` Ctrl + Shift + Alt + Win + L ``` -# Windows Shortcuts in Run Command -* The quickest way to access the Run command window is to use the keyboard shortcut `Windows + R` -| Command | Description | -| ---- | ---- | -|sysdm.cpl| Windows Propertes| -|compmgmt.msc| Component Managment| -|winver| Windows Version| -|appwiz.cpl| Programs And Fuatchers| -|resmon|The Resource Monitor window will open, displaying real-time performance data| -|taskmgr| Task Manager| -|explorer| Windows Explorer| -|ncpa.cpl| Network Connection| -|Firewall.cpl| Firewall | -|wf.msc| Windows Firewall Advanced| -|intl.cpl| Time And Date Options| -|timedate.cpl| Time And Date Settings| -|mstsc| Remote Desktop| -|osk| Keybord Virtual| -|charmap| Character Map | -|devmgmt.msc| Device Managment| -|desk.cpl| Desktop Resuliation| -|dfrgui| program for configuring the scheduled task for disk defragmentation| -|diskmgmt.msc| Disk Managare| -|fsmgmt.msc| Show Folders Share| -|inetcpl.cpl| Internet Explorer options| -|logoff| Log Off| -|magnify| Show Magnifier | -|mmsys.cpl| Sound settings| -|msconfig| System settings| -|msinfo32| Show system all info| -|systeminfo | Show system info| -|netplwiz| System Users info| -|perfmon.msc| Start Windows Reliability and Performance Monitor in a specific standalone mode| -|powercfg.cpl| Power options| -|services.msc| Services| -|shrpubw| Shared Folder Wizard| -|write| WordPad| -|control| Control Panel| -|Control Printers| Device And Printers| -|dxdiag| Show System Information Hardware| -|tracert| Trace Route | -|printui /s /t2 |Print Server Properties| -|printui /s|Show Printer Drivers| -|PrintManagement.msc| Printers Management , show all printers with drivers| -|shell:appsfolder| Show App Folder| -|shutdown /r /t 5|Restart the system after 5 seconds| -|shutdown /s /t 5|System shutdown after 5 seconds| -|shutdown /r /fw|Bios Login from windows| +# Windows Shortcuts in Run Command + +- The quickest way to access the Run command window is to use the keyboard shortcut `Windows + R` + +| Command | Description | +| --------------------- | -------------------------------------------------------------------------------- | +| `sysdm.cpl` | Windows Propertes | +| `compmgmt.msc` | Component Managment | +| `winver` | Windows Version | +| `appwiz.cpl` | Programs And Fuatchers | +| `resmon` | The Resource Monitor window will open, displaying real-time performance d`ata | +| `taskmgr` | Task Manager | +| `explorer` | Windows Explorer | +| `ncpa.cpl` | Network Connection | +| `Firewall.cpl` | Firewall | +| `wf.msc` | Windows Firewall Advanced | +| `intl.cpl` | Time And Date Options | +| `timedate.cpl` | Time And Date Settings | +| `mstsc` | Remote Desktop | +| `osk` | Keybord Virtual | +| `charmap` | Character Map | +| `devmgmt.msc` | Device Managment | +| `desk.cpl` | Desktop Resuliation | +| `dfrgui` | program for configuring the scheduled task for disk defragmentation | +| `diskmgmt.msc` | Disk Managare | +| `fsmgmt.msc` | Show Folders Share | +| `inetcpl.cpl` | Internet Explorer options | +| `logoff` | Log Off | +| `magnify` | Show Magnifier | +| `mmsys.cpl` | Sound settings | +| `msconfig` | System settings | +| `msinfo32` | Show system all info | +| `systeminfo` | Show system info | +| `netplwiz` | System Users info | +| `perfmon.msc` | Start Windows Reliability and Performance Monitor in a specific s`tandalone mode | +| `powercfg.cpl` | Power options | +| `services.msc` | Services | +| `shrpubw` | Shared Folder Wizard | +| `write` | WordPad | +| `control` | Control Panel | +| `Control Printers` | Device And Printers | +| `dxdiag` | Show System Information Hardware | +| `tracert` | Trace Route | +| `printui /s /t2` | Print Server Properties | +| `printui /s` | Show Printer Drivers | +| `PrintManagement.msc` | Printers Management , show all printers with drivers | +| `shell:appsfolder` | Show App Folder | +| `shutdown /r /t 5` | Restart the system after 5 seconds | +| `shutdown /s /t 5` | System shutdown after 5 seconds | +| `shutdown /r /fw` | Bios Login from windows | # Create God Mode Folder -create a new folder on your desktop with this exact name (copy and paste it): `GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}` -* The folder icon will change to a Control Panel-style icon, and you will be able to jump in and change all kinds of settings \ No newline at end of file + +create a new folder on your desktop with this exact name (copy and paste it): +`GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}` + +- The folder icon will change to a Control Panel-style icon, and you will be able to jump in and change all kinds of settings From 20a0a3c7e3ab87a10fa2e777eb2c08e7a35057dc Mon Sep 17 00:00:00 2001 From: Saeid Javadi Date: Mon, 18 Nov 2024 20:39:38 +0330 Subject: [PATCH 09/13] Update some content and tag issues --- source/_posts/django.md | 262 ++++++++++++++++++----------- source/_posts/windows-shortcuts.md | 4 +- 2 files changed, 165 insertions(+), 101 deletions(-) diff --git a/source/_posts/django.md b/source/_posts/django.md index 0085307..f42e807 100644 --- a/source/_posts/django.md +++ b/source/_posts/django.md @@ -110,10 +110,14 @@ Migrate: Will read the migrations files and create the actual database and table ## Project config {.cols-1} ### Configuration settings + ##### Project base templates directory and Apps templates directory: - - create folder project/templates - - create folder appfolder/templates/appname + +- create folder project/templates +- create folder appfolder/templates/appname + ##### Create Static folder in base root and separate for apps: + - project_name\static\root - app_name\static\app_name @@ -521,23 +525,21 @@ path('/update/', PostsUpdateView.as_view(), name='post-update') Templates are store in `project_folder/templates` or in your app_folder/templates/app_name/\*.html - - -```django -# Extend from another template -# can use the same parts of your HTML for different template +```html + + {% extends 'base.html' %} -# A part of the parent template that is defined and is replaced by a part in the child template + {% block contents %} {% endblock contents %} -# include template + {% include 'partials/header.html' %} -# include template with One or More Parameters + {% include 'body.html' with key1=value1 key2=value2 %} -# If statement in template + {% if user.username = 'Mike' %}

Hello Admin

{% elif user.username = 'john' %} @@ -546,7 +548,7 @@ Templates are store in `project_folder/templates` or in your app_folder/te

Hello User

{% endif %} -# for loop in template + {% for product in products %}

row: {{ forloop.counter }} # starting index 1 @@ -556,40 +558,40 @@ Templates are store in `project_folder/templates` or in your app_folder/te

The product name is {{ product.price }}

{% endfor %} -# Access to the variable in the template + {{ var_name }} -# Template variables formating + {{ title | lower }} {{ blog.post | truncatwords:50 }} {{ order.date | date:"D M Y" }} {{ list_items | slice:":3" }} {{ total | default:"nil" }} -# Current path (ex. posts/1/show) + {{ request.path }} -# URL by name with param + {% url 'posts.delete' id=post.id %} -# Use static in template: + {% load static %} {% static 'css/main.css' %} -# Define the variable in the template + {% with name="World" %}

Hello {{ name }}!
{% endwith %} -# Template translate text + {% load i18n %} {% trans "This is the title." %} -# Use variable translate in the template + {% trans object.title %} -# Define the list in the template + app_folder/te step="1" {% endif %}> -# Safely Pass Data to JavaScript in a Django Template: -#+ Use data attributes for simple values + + -#+ Separate script files: can use document.currentScript for separate script files + -#+ Case conversion + -# Read it in JavaScript as fullName: -const data = document.currentScript.dataset; -const fullName = data.fullName; + + -#+ Non-string types + -# parseInt() to convert this value from a string: -const data = document.currentScript.dataset; -const followerCount = parseInt(data.followerCount, 10); -#+ There’s no limit: A + + + - - + + - - - - + + + - - + + - - + - - + + +

``` ### Custom Template Tags and Filters @@ -732,7 +751,7 @@ def site_email(request): 'OPTIONS': { 'context_processors': [ … - 'app_name.context_processors.site_email', + 'app_name.context_processors.site_email', # New context processor here … ], @@ -866,8 +885,16 @@ class ArticleForm(ModelForm): {% csrf_token %} {{ form }} +``` -{% load crispy_forms_tags %} {{ form|crispy }} {{ form.email|as_crispy_field }} +- NOTE: If the form contains a file field, your form MUST contain `enctype="multipart/form-data"`, eg: + +```django +
+ {% csrf_token %} + {{ form.as_p }} + +
``` ##### A Tailwind CSS template pack for the wonderful django-crispy-forms. @@ -918,7 +945,6 @@ def clean(self): ### Displaying messages - ```python # Message tags # debug, info, success, warning and error @@ -929,11 +955,7 @@ messages.error(request, 'Login error') ```html -{% if messages %} - {% for message in messages %} - {% message %} {% message.tags %} - {% endfor %} -{% endif %} +{% if messages %} {% for message in messages %} {% message %} {% message.tags %} {% endfor %} {% endif %} ``` ## User Model @@ -2180,4 +2202,4 @@ If you change the Nginx server block configuration, test the configuration and t ```bash sudo nginx -t && sudo systemctl restart nginx -``` +``` \ No newline at end of file From 543a2936003d7ceb1c6af2a1b401c7f875cfeba7 Mon Sep 17 00:00:00 2001 From: Saeid Javadi Date: Mon, 25 Nov 2024 13:00:38 +0330 Subject: [PATCH 12/13] Update django.md --- source/_posts/django.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/_posts/django.md b/source/_posts/django.md index dc37c91..38841df 100644 --- a/source/_posts/django.md +++ b/source/_posts/django.md @@ -889,7 +889,7 @@ class ArticleForm(ModelForm): - NOTE: If the form contains a file field, your form MUST contain `enctype="multipart/form-data"`, eg: -```django +```html
{% csrf_token %} {{ form.as_p }} @@ -2202,4 +2202,4 @@ If you change the Nginx server block configuration, test the configuration and t ```bash sudo nginx -t && sudo systemctl restart nginx -``` \ No newline at end of file +``` From d8ec584c65f4f6d68600394f50a238d05555ce48 Mon Sep 17 00:00:00 2001 From: Fechin Date: Mon, 25 Nov 2024 20:31:36 +0800 Subject: [PATCH 13/13] health check --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 24a2b67..6322340 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,5 @@ RUN apk add --no-cache nginx && mkdir -p /run/nginx COPY --from=build /usr/share/nginx/html/ /usr/share/nginx/html/ COPY --from=build /etc/nginx/nginx.conf /etc/nginx/nginx.conf EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +HEALTHCHECK --interval=1s --timeout=3s CMD wget -q -O - http://localhost:80 || exit 1 +CMD ["nginx", "-g", "daemon off;"]