From f16f3db46cdbf3d0b779d609af8e2c5423480af0 Mon Sep 17 00:00:00 2001 From: OcelusPRO Date: Tue, 17 Jan 2023 20:42:55 +0100 Subject: [PATCH 01/10] Multi-table formatting to improve readability and finding information --- source/_posts/google-search.md | 224 ++++++++++++++++++++------------- 1 file changed, 135 insertions(+), 89 deletions(-) diff --git a/source/_posts/google-search.md b/source/_posts/google-search.md index a01fec8..3f0f9b1 100644 --- a/source/_posts/google-search.md +++ b/source/_posts/google-search.md @@ -9,101 +9,147 @@ intro: | This quick reference cheat sheet lists of Google advanced search operators. --- -Getting Started {.cols-1} +Getting Started {.cols-2} ---- ### Google Advanced Search Operators +| Operator | Description | Category | +|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------| +| `""` | Allows searching for a specific phrase - exact match search. Individual word prevents synonyms | Basic,Mail | +| `OR`/`AND` | Boolean search function for OR searches as Google defaults to AND between words - must be all caps | Basic,Mail | +| `\` | Implements OR | Basic | +| `()` | Allows grouping of operators and helps dictate order | Basic,Mail | +| `-` | Excludes a word from results | Basic,Mail | +| `*` | Acts as a wildcard and will match any word or phrase | Basic | +| `#..#` | # represents a number in this instance. Use to find numbers in a series. | Basic | +| `$` | Allows for search of USD | Basic | +| `€` | Allows for search of Euro | Basic | +| `in` | Allows searches for unit conversion (currency, unit or measure) | Basic | +| `~` | Prefix - Include synonyms (potentially defunct) | Basic | +| `+` | Prefix - Force exact match on single phrase | Basic,Mail | +| `AROUND(X)` | This is sandwiched between two words and the X declares how many words they must be mentioned between. I.e. if it’s (4) then the two keywords must be mentioned within 4 words of each other. | Advanced | +| `_` | Acts as wildcard for autocomplete | Advanced | - Operator | Operator | Category ----|---|--- - `""` | Allows searching for a specific phrase - exact match search. Individual word prevents synonyms | Basic,Mail - `OR` | Boolean search function for OR searches as Google defaults to AND between words - must be all caps | Basic,Mail - `\` | Implements OR | Basic - `()` | Allows grouping of operators and helps dictate order | Basic,Mail - `-` | Excludes a word from results | Basic,Mail - `*` | Acts as a wildcard and will match any word or phrase | Basic - `#..#` | # represents a number in this instance. Use to find numbers in a series. | Basic - `$` | Allows for search of USD | Basic - `€` | Allows for search of Euro | Basic - `in` | Allows searches for unit conversion (currency, unit or measure) | Basic - `~` | Prefix - Include synonyms (potentially defunct) | Basic - `+` | Prefix - Force exact match on single phrase | Basic,Mail - `daterange:` | Return results in a specified range (requires julian dates) | Advanced - `link:` | Find pages that link to the target domain | Advanced - `inanchor:` | Find pages linked to with the specified anchor text/ phrase. Data is heavily sampled. | Advanced - `allinanchor:` | Find pages with all individual terms after "inanchor:" in the inbound anchor text. | Advanced - `inposttile:` | Finds pages with keywords in their post titles (i.e. for researching blogs) |   - `define:` | Pulls a card response from Google displaying the dictionary definition of the word or phrase | Advanced - `cache:` | Returns the most up to date cache of an indexed web page | Advanced - `filetype:` | Returns only files of a particular type associated with the keyword searched | Advanced - `ext:` | As above, based on extension | Advanced - `site:` | Limit results to those from one site | Advanced - `related:` | Find similar domains to the queried domain | Advanced - `intitle:` | Returns pages based on the searched query appearing in their title | Advanced - `allintitle:` | Similar to intitle: but only returns titles where all the words in the title match | Advanced - `inurl:` | Only returns results where the queried keyword(s) is present in the URL | Advanced - `allinurl:` | As above but only containing all of the specified words in the URL | Advanced - `intext:` | Finds pages where the keyword(s) are mentioned within the page content. | Advanced - `allintext:` | Similar to “intext,” but only results containing all of the specified words somewhere on the page will be returned. | Advanced - `AROUND(X)` | This is sandwiched between two words and the X declares how many words they must be mentioned between. I.e. if it’s (4) then the two keywords must be mentioned within 4 words of each other. | Advanced - `weather:` | Brings up the featured snipped for weather for that location | Advanced - `stocks:` | Returns stock information for the specified ticker | Advanced - `map:` | Force google map results for a particular query | Advanced - `movie:` | Find information for the specified movie (particularly useful when that movie has an ambiguous name). If the movie is still in theatres it’ll also return screen times | Advanced - `source:` | Use in google news, returns results from the specified source | Advanced - `_` | Acts as wildcard for autocomplete | Advanced - `blogurl:` | Find blog URLs under a specific domain. This was used in Google blog search, but I’ve found it does return some results in regular search. | Advanced - `loc:` | Returns results for a specific location | Advanced - `location:` | As above but with Google news | Advanced - `info:` | Returns information rlated to a domain (pages with dmain text, similar on-site pages, cache etc) | Advanced - `near` | Part of the google maps lazy searches e.g. book shops near work | Maps - `Business` | type E.g. cafe, restaurant, bar etc will return a selection of appropriate businesses in the are | Maps - `Petrol/Charging` | Station EV near me or perol station near me returns | Maps - `type:` | Allows you to search drive by file type | Drive - `owner:` | Allows you to search drive by owner of file or folder | Drive - `after:` | Allows you to search drive or mail for files modified or mail sent/received anytime after a set date | Drive,Mail - `before:` | Allows you to search drive or mail for files modified or mail sent/received before a certain date | Drive,Mail - `to:` | Allows you to search drive for files shared with a specific person | Drive - `title:` | Searches drive for files with the keyword in their title alone | Drive - `source:domain` | Allows you to search for files or folders shared with everyone in your business | Drive - `is:trashed` | Searches for the item in the Drive bin | Drive - `is:starred` | Searches only items that have been starred in drive | Drive,Mail - `from:` | Specify the sender in google mail | Mail - `to:` | Specify the recipient in google mail | Mail - `cc:` | Search by a recipient that was copied into an email | Mail - `bcc:` | Search by a recipient that was blind copied into an email | Mail - `subject:` | Search by keywords featured in the subject line | Mail - `{}` | Use for OR in mail instead of the OR function | Mail - `AROUND` | Similar to the normal google search function, allows you to search for keywords near each other. | Mail - `label:` | Search for messages that have a certain label | Mail - `has:attachment` | Search for messages that have an item attached | Mail - `has:drive` | Search for messages with a google drive attached | Mail - `has:document` | Search for messages with a google doc attached | Mail - `Search` | for a message with a google sheet attached | Mail - `Search` | for a message with a google presentation attached | Mail - `has:youtube` | Search for a message containing a youtube video | Mail - `list:` | Search for all messages from a particular mailing list | Mail - `filename:` | Search for messages with a particular type of file attached, or the exact name of a file | Mail - `in:anywhere` | Includes all folders in your search, including spam and bin | Mail - `is:important` | Search for messages that have been marked as important | Mail - `label:important` | Same as is:important | Mail - `is:snoozed` | Searches for messages that have been snoozed | Mail - `is:unread` | Searches for unread messages | Mail - `is:read` | searches for read messages only | Mail - `has:yellow-star` | Searches for messages with coloured star icon | Mail - `has:blue-info` | Searches for messages with colourd icon | Mail - `older:` | Search for messages older than a certain date | Mail - `newer:` | Search for messages newer than a certain date | Mail - `is:chat` | Searches for messagse from chat | Mail - `deliveredto:` | Search by email address for delivered messages | Mail - `category:` | Searches by messages based on category. Follow the colon with the categoy name, i.e. category:primary | Mail - `size:` | Messages larger than a certain size in bytes | Mail - `larger:` | Messages larger than a certain size in bytes | Mail - `smaller:` | Messages smaller than a certain size in bytes | Mail - `has:userlabels` | Search for messages that have custom user labels | Mail - ` ` | Search for messages that have no custom user labels | Mail +### Search with url +| Operator | Description | Category | +|-------------|--------------------------------------------------------------------------------------------------------------------------------------------|----------| +| `inurl:` | Only returns results where the queried keyword(s) is present in the URL | Advanced | +| `allinurl:` | As above but only containing all of the specified words in the URL | Advanced | +| `blogurl:` | Find blog URLs under a specific domain. This was used in Google blog search, but I’ve found it does return some results in regular search. | Advanced | +| `site:` | Limit results to those from one site | Advanced | +| `related:` | Find similar domains to the queried domain | Advanced | + + +### Search with dates +| Operator | Description | Category | +|--------------|------------------------------------------------------------------------------------------------------|------------| +| `daterange:` | Return results in a specified range (requires julian dates) | Advanced | +| `after:` | Allows you to search drive or mail for files modified or mail sent/received anytime after a set date | Drive,Mail | +| `before:` | Allows you to search drive or mail for files modified or mail sent/received before a certain date | Drive,Mail | +| `older:` | Search for messages older than a certain date | Mail | +| `newer:` | Search for messages newer than a certain date | Mail | + + +### Search files +| Operator | Description | Category | +|-----------------|------------------------------------------------------------------------------------------------------|------------| +| `filename:` | Search for messages with a particular type of file attached, or the exact name of a file | Mail | +| `type:` | Allows you to search drive by file type | Drive | +| `owner:` | Allows you to search drive by owner of file or folder | Drive | +| `to:` | Allows you to search drive for files shared with a specific person | Drive | +| `title:` | Searches drive for files with the keyword in their title alone | Drive | +| `source:domain` | Allows you to search for files or folders shared with everyone in your business | Drive | +| `filetype:` | Returns only files of a particular type associated with the keyword searched | Advanced | +| `ext:` | As above, based on extension | Advanced | +| `after:` | Allows you to search drive or mail for files modified or mail sent/received anytime after a set date | Drive,Mail | +| `before:` | Allows you to search drive or mail for files modified or mail sent/received before a certain date | Drive,Mail | +| `is:trashed` | Searches for the item in the Drive bin | Drive | + + +### Search with page content +| Operator | Description | Category | +|----------------|---------------------------------------------------------------------------------------------------------------------|----------| +| `link:` | Find pages that link to the target domain | Advanced | +| `inanchor:` | Find pages linked to with the specified anchor text/ phrase. Data is heavily sampled. | Advanced | +| `allinanchor:` | Find pages with all individual terms after "inanchor:" in the inbound anchor text. | Advanced | +| `intitle:` | Returns pages based on the searched query appearing in their title | Advanced | +| `allintitle:` | Similar to intitle: but only returns titles where all the words in the title match | Advanced | +| `inposttile:` | Finds pages with keywords in their post titles (i.e. for researching blogs) |   | +| `intext:` | Finds pages where the keyword(s) are mentioned within the page content. | Advanced | +| `allintext:` | Similar to “intext,” but only results containing all of the specified words somewhere on the page will be returned. | Advanced | + + +### Keywords +| Operator | Description | Category | +|-------------------|--------------------------------------------------------------------------------------------------|----------| +| `Business` | type E.g. cafe, restaurant, bar etc will return a selection of appropriate businesses in the are | Maps | +| `Petrol/Charging` | Station EV near me or perol station near me returns | Maps | +| `Search` | for a message with a google sheet attached | Mail | +| `Search` | for a message with a google presentation attached | Mail | + + +### Search on emails +| Operator | Description | Category | +|-------------------|-------------------------------------------------------------------------------------------------------|------------| +| `+` | Prefix - Force exact match on single phrase | Basic,Mail | +| `()` | Allows grouping of operators and helps dictate order | Basic,Mail | +| `-` | Excludes a word from results | Basic,Mail | +| `""` | Allows searching for a specific phrase - exact match search. Individual word prevents synonyms | Basic,Mail | +| `OR`/`AND` | Boolean search function for OR searches as Google defaults to AND between words - must be all caps | Basic,Mail | +| `after:` | Allows you to search drive or mail for files modified or mail sent/received anytime after a set date | Drive,Mail | +| `before:` | Allows you to search drive or mail for files modified or mail sent/received before a certain date | Drive,Mail | +| `is:starred` | Searches only items that have been starred in drive | Drive,Mail | +| `from:` | Specify the sender in google mail | Mail | +| `to:` | Specify the recipient in google mail | Mail | +| `cc:` | Search by a recipient that was copied into an email | Mail | +| `bcc:` | Search by a recipient that was blind copied into an email | Mail | +| `older:` | Search for messages older than a certain date | Mail | +| `newer:` | Search for messages newer than a certain date | Mail | +| `Search` | for a message with a google sheet attached | Mail | +| `Search` | for a message with a google presentation attached | Mail | +| `AROUND` | Similar to the normal google search function, allows you to search for keywords near each other. | Mail | +| `subject:` | Search by keywords featured in the subject line | Mail | +| `{}` | Use for OR in mail instead of the OR function | Mail | +| `label:` | Search for messages that have a certain label | Mail | +| `has:attachment` | Search for messages that have an item attached | Mail | +| `has:drive` | Search for messages with a google drive attached | Mail | +| `has:document` | Search for messages with a google doc attached | Mail | +| `has:youtube` | Search for a message containing a youtube video | Mail | +| `list:` | Search for all messages from a particular mailing list | Mail | +| `in:anywhere` | Includes all folders in your search, including spam and bin | Mail | +| `is:important` | Search for messages that have been marked as important | Mail | +| `label:important` | Same as is:important | Mail | +| `is:snoozed` | Searches for messages that have been snoozed | Mail | +| `is:unread` | Searches for unread messages | Mail | +| `is:read` | searches for read messages only | Mail | +| `has:yellow-star` | Searches for messages with coloured star icon | Mail | +| `has:blue-info` | Searches for messages with colourd icon | Mail | +| `is:chat` | Searches for messagse from chat | Mail | +| `deliveredto:` | Search by email address for delivered messages | Mail | +| `category:` | Searches by messages based on category. Follow the colon with the categoy name, i.e. category:primary | Mail | +| `size:` | Messages larger than a certain size in bytes | Mail | +| `larger:` | Messages larger than a certain size in bytes | Mail | +| `smaller:` | Messages smaller than a certain size in bytes | Mail | +| `has:userlabels` | Search for messages that have custom user labels | Mail | +| ` ` | Search for messages that have no custom user labels | Mail | + + +### Some other useful search operators +| Operator | Description | Category | +|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------| +| `define:` | Pulls a card response from Google displaying the dictionary definition of the word or phrase | Advanced | +| `cache:` | Returns the most up to date cache of an indexed web page | Advanced | +| `weather:` | Brings up the featured snipped for weather for that location | Advanced | +| `stocks:` | Returns stock information for the specified ticker | Advanced | +| `map:` | Force google map results for a particular query | Advanced | +| `movie:` | Find information for the specified movie (particularly useful when that movie has an ambiguous name). If the movie is still in theatres it’ll also return screen times | Advanced | +| `source:` | Use in google news, returns results from the specified source | Advanced | +| `loc:` | Returns results for a specific location | Advanced | +| `location:` | As above but with Google news | Advanced | +| `info:` | Returns information related to a domain (pages with domain text, similar on-site pages, cache etc) | Advanced | +| `near` | Part of the google maps lazy searches e.g. book shops near work | Maps | From ae60257b3f749a44d748406e995b0773df64c5b8 Mon Sep 17 00:00:00 2001 From: Kebap Date: Thu, 19 Jan 2023 09:47:23 +0100 Subject: [PATCH 02/10] Fix typo --- source/_posts/quickref.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/_posts/quickref.md b/source/_posts/quickref.md index 72fe4e1..6536778 100644 --- a/source/_posts/quickref.md +++ b/source/_posts/quickref.md @@ -449,7 +449,7 @@ Table Variants |----------|------------------------| | `[abc]` | Match a, b or c | | `[^abc]` | Match except a, b or c | -| `[a-z]` | Match a tot z | +| `[a-z]` | Match a to z | #### ↓ Source Code @@ -928,4 +928,4 @@ Add `{.secondary}` to make the title yellow. ``` 5 -``` \ No newline at end of file +``` From f3f08869931d5992544f98476914967d75e9f15c Mon Sep 17 00:00:00 2001 From: Kebap Date: Thu, 19 Jan 2023 09:53:09 +0100 Subject: [PATCH 03/10] Fix more typos --- source/_posts/quickref.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/_posts/quickref.md b/source/_posts/quickref.md index 6536778..9de760e 100644 --- a/source/_posts/quickref.md +++ b/source/_posts/quickref.md @@ -449,7 +449,7 @@ Table Variants |----------|------------------------| | `[abc]` | Match a, b or c | | `[^abc]` | Match except a, b or c | -| `[a-z]` | Match a to z | +| `[a-z]` | Match a to z | #### ↓ Source Code @@ -458,7 +458,7 @@ Table Variants |----------|------------------------| | `[abc]` | Match a, b or c | | `[^abc]` | Match except a, b or c | -| `[a-z]` | Match a tot z | +| `[a-z]` | Match a to z | ``` @@ -491,7 +491,7 @@ Table Variants |----------|------------------------| | `[abc]` | Match a, b or c | | `[^abc]` | Match except a, b or c | -| `[a-z]` | Match a tot z | +| `[a-z]` | Match a to z | {.show-header} #### ↓ Source Code @@ -501,7 +501,7 @@ Table Variants |----------|------------------------| | `[abc]` | Match a, b or c | | `[^abc]` | Match except a, b or c | -| `[a-z]` | Match a tot z | +| `[a-z]` | Match a to z | {.show-header} ``` @@ -514,7 +514,7 @@ Table Variants |----------|------------------------| | `[abc]` | Match a, b or c | | `[^abc]` | Match except a, b or c | -| `[a-z]` | Match a tot z | +| `[a-z]` | Match a to z | {.left-text} #### ↓ Source Code @@ -524,7 +524,7 @@ Table Variants |----------|------------------------| | `[abc]` | Match a, b or c | | `[^abc]` | Match except a, b or c | -| `[a-z]` | Match a tot z | +| `[a-z]` | Match a to z | {.left-text} ``` @@ -537,7 +537,7 @@ Table Variants |----------|------------------------| | `[abc]` | Match a, b or c | | `[^abc]` | Match except a, b or c | -| `[a-z]` | Match a tot z | +| `[a-z]` | Match a to z | {.bold-first} #### ↓ Source Code @@ -547,7 +547,7 @@ Table Variants |----------|------------------------| | `[abc]` | Match a, b or c | | `[^abc]` | Match except a, b or c | -| `[a-z]` | Match a tot z | +| `[a-z]` | Match a to z | {.bold-first} ``` From 6442155bb6b9da86188989508ae17a7ba0ae558e Mon Sep 17 00:00:00 2001 From: Adeilton Santana Aguiar Filho <93356734+adeiltonsantanaa@users.noreply.github.com> Date: Wed, 25 Jan 2023 15:39:03 -0300 Subject: [PATCH 04/10] Creating a reference to some date functions adding some very used and important date functions --- source/_posts/postgres.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/_posts/postgres.md b/source/_posts/postgres.md index b5984a5..487771c 100644 --- a/source/_posts/postgres.md +++ b/source/_posts/postgres.md @@ -332,6 +332,26 @@ DROP SCHEMA IF EXISTS CASCADE; ``` +### Dates + +Show [current date](https://www.postgresql.org/docs/15/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT) YYYY-MM-DD +```sql {.wrap} +SELECT current_date; +``` +Calculate [age](https://www.postgresql.org/docs/15/functions-datetime.html#:~:text=age%20(%20timestamp%2C%20timestamp%20)%20%E2%86%92%20interval) between two dates +```sql {.wrap} +SELECT age(timestamp, timestamp); +``` +Show [current time](https://www.postgresql.org/docs/15/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT) with time zone +```sql {.wrap} +SELECT current_time; +``` +[Make](https://www.postgresql.org/docs/15/functions-datetime.html#:~:text=make_date%20(%20year%20int%2C%20month%20int%2C%20day%20int%20)%20%E2%86%92%20date) dates using integers +```sql {.wrap} +SELECT make_date(2021,03,25); +``` + + PostgreSQL Commands ----------- From 9b576634672e504484f3d6954a327f1160ae3aa5 Mon Sep 17 00:00:00 2001 From: Diamond Rivero Date: Thu, 26 Jan 2023 11:45:31 +0800 Subject: [PATCH 05/10] Improve readability --- source/_posts/c.md | 200 ++++++++++++++++++++++++++++----------------- 1 file changed, 125 insertions(+), 75 deletions(-) diff --git a/source/_posts/c.md b/source/_posts/c.md index 9f806e6..0910149 100644 --- a/source/_posts/c.md +++ b/source/_posts/c.md @@ -19,8 +19,9 @@ Getting Started ```c #include -int main() { - printf("Hello World!"); +int main(void) { + printf("Hello World!\n"); + return 0; } ``` @@ -28,7 +29,7 @@ int main() { Compile `hello.c` file with `gcc` ```bash -$ gcc -o hello hello.c +$ gcc hello.c -o hello ``` Run the compiled binary `hello` @@ -84,7 +85,7 @@ const int BIRTHYEAR = 1980; ```c // this is a comment -printf("Hello World!"); // comment +printf("Hello World!"); // Can comment anywhere in file /*Multi-line comment, print Hello World! to the screen, it's awesome */ @@ -128,10 +129,10 @@ printf("a=%hX, b=%X, c=%lX\n", a, b, c); ### Control the number of spaces ```c -int a1=20, a2=345, a3=700; -int b1=56720, b2=9999, b3=20098; -int c1=233, c2=205, c3=1; -int d1=34, d2=0, d3=23; +int a1 = 20, a2 = 345, a3 = 700; +int b1 = 56720, b2 = 9999, b3 = 20098; +int c1 = 233, c2 = 205, c3 = 1; +int d1 = 34, d2 = 0, d3 = 23; printf("%-9d %-9d %-9d\n", a1, a2, a3); printf("%-9d %-9d %-9d\n", b1, b2, b3); @@ -214,8 +215,8 @@ if (time < 10) { ### Ternary operator {.col-span-2} ```c -int time = 20; -(time < 18) ? printf("Goodbye!") : printf("Good evening!"); +int age = 20; +(age > 19) ? printf("Adult") : printf("Teenager"); ``` @@ -229,7 +230,7 @@ switch (day) { case 3: printf("Wednesday"); break; case 4: printf("Thursday"); break; default: - printf("Looking forward to the weekend"); + printf("Weekend!"); } // output -> "Thursday" (day 4) ``` @@ -267,9 +268,7 @@ do { ### For Loop ```c -int i; - -for (i = 0; i < 5; i++) { +for (int i = 0; i < 5; i++) { printf("%d\n", i); } ``` @@ -279,9 +278,7 @@ for (i = 0; i < 5; i++) { ### Break out of the loop Break/Continue {.row-span-2} ```c -int i; - -for (i = 0; i < 10; i++) { +for (int i = 0; i < 10; i++) { if (i == 4) { break; } @@ -292,8 +289,7 @@ for (i = 0; i < 10; i++) { break out of the loop when `i` is equal to `4` ```c -int i; -for (i = 0; i < 10; i++) { +for (int i = 0; i < 10; i++) { if (i == 4) { continue; } @@ -315,6 +311,7 @@ while (i < 10) { break; } printf("%d\n", i); + i++; } ``` @@ -328,6 +325,7 @@ int i = 0; while (i < 10) { i++; + if (i == 4) { continue; } @@ -341,6 +339,7 @@ while (i < 10) { ```c int myNumbers[] = {25, 50, 75, 100}; + printf("%d", myNumbers[0]); // output 25 ``` @@ -370,6 +369,7 @@ set array size ```c // Declare an array of four integers: int myNumbers[4]; + // add element myNumbers[0] = 25; myNumbers[1] = 50; @@ -410,11 +410,11 @@ enum week {Mon = 1, Tues, Wed, Thurs} day; scanf("%d", &day); -switch(day){ +switch(day) { case Mon: puts("Monday"); break; case Tues: puts("Tuesday"); break; case Wed: puts("Wednesday"); break; -case Thursday: puts("Thursday"); break; + case Thursday: puts("Thursday"); break; default: puts("Error!"); } ``` @@ -447,7 +447,7 @@ char firstName[30]; // Ask the user to enter some text printf("Enter your name: \n"); // get and save the text -scanf("%s", firstName); +scanf("%s", &firstName); // output text printf("Hello %s.", firstName); ``` @@ -508,7 +508,7 @@ printf("%p\n", ptr); printf("%d\n", *ptr); ``` -C Operator +Operators --- @@ -527,11 +527,11 @@ int sum3 = sum2 + sum2; // 800 (400 + 400) | Operator | Name | Example | |----------|-----------|---------| | `+` | Add | `x + y` | -| `-` | Subtract | `x -y` | -| `*` | Multiply | `x *y` | -| `/` | Divide | `x /y` | +| `-` | Subtract | `x - y` | +| `*` | Multiply | `x * y` | +| `/` | Divide | `x / y` | | `%` | Modulo | `x % y` | -| `++` | Increment | `++` | +| `++` | Increment | `++x` | | `--` | Decrement | `--x` | @@ -547,7 +547,7 @@ int sum3 = sum2 + sum2; // 800 (400 + 400) | x `/=` 3 | x `=` x `/` 3 | | x `%=` 3 | x `=` x `%` 3 | | x `&=` 3 | x `=` x `&` 3 | -| x `\|=` 3 | x `=` x `\|` 3 | +| x `|=` 3 | x `=` x `|` 3 | | x `^=` 3 | x `=` x `^` 3 | | x `>>=` 3 | x `=` x `>>` 3 | | x `<<=` 3 | x `=` x `<<` 3 | @@ -583,8 +583,8 @@ Comparison operators are used to compare two values | Symbol | Name | Description | Example | | --------| --------| --------| --------| -| `&&` | `and` logic | returns true if both statements are true | `x < 5 && x < 10` | -| `\|\|` | `or`logical | returns true if one of the statements is true | `x < 5 \|\| x < 4` | +| `&&` | `and` logical | returns true if both statements are true | `x < 5 && x < 10` | +| `||` | `or` logical | returns true if one of the statements is true | `x < 5 || x < 4` | | `!` | `not` logical | Invert result, return false if true | `!(x < 5 && x < 10)` | @@ -597,18 +597,18 @@ unsigned int b = 13; /*13 = 0000 1101 */ int c = 0; c = a & b; /*12 = 0000 1100 */ -printf("Line 1 -the value of c is %d\n", c ); +printf("Line 1 -the value of c is %d\n", c); c = a | b; /*61 = 0011 1101 */ -printf("Line 2 -the value of c is %d\n", c ); +printf("Line 2 -the value of c is %d\n", c); c = a ^ b; /*49 = 0011 0001 */ -printf("Line 3 -the value of c is %d\n", c ); +printf("Line 3 -the value of c is %d\n", c); c = ~a; /*-61 = 1100 0011 */ -printf("Line 4 -The value of c is %d\n", c ); +printf("Line 4 -The value of c is %d\n", c); c = a << 2; /*240 = 1111 0000 */ -printf("Line 5 -the value of c is %d\n", c ); +printf("Line 5 -the value of c is %d\n", c); c = a >> 2; /*15 = 0000 1111 */ -printf("Line 6 -The value of c is %d\n", c ); +printf("Line 6 -The value of c is %d\n", c); ``` @@ -618,13 +618,13 @@ printf("Line 6 -The value of c is %d\n", c ); operator | description | instance :-|:-|:- `&` | Bitwise AND operation, "AND" operation by binary digits | `(A & B)` will get `12` which is 0000 1100 -`\|` | Bitwise OR operator, "or" operation by binary digit | `(A \| B)` will get `61` which is 0011 1101 +`|` | Bitwise OR operator, "or" operation by binary digit | `(A | B)` will get `61` which is 0011 1101 `^` | XOR operator, perform "XOR" operation by binary digits | `(A ^ B)` will get `49` which is 0011 0001 `~` | Inversion operator, perform "inversion" operation by binary bit | `(~A)` will get `-61` which is 1100 0011 `<<` | binary left shift operator | `A << 2` will get `240` which is 1111 0000 `>>` | binary right shift operator | `A >> 2` will get `15` which is 0000 1111 -Data Types Data Types +Data Types --- @@ -645,9 +645,9 @@ Data Types Data Types | `long int` | 4 bytes | `-2,147,483,648` ~ `2,147,483,647` | | | `signed long int` | 4 bytes | `-2,147,483,648` ~ `2,147,483,647` | | | `unsigned long int` | 4 bytes | `0` ~ `4,294,967,295` | | -| `float` | 4 bytes | | | -| `double` | 8 bytes | | | -| `long double` | 10 bytes | | | +| `float` | 4 bytes | `3.4E-38` ~ `3.4E+38` | | +| `double` | 8 bytes | `1.7E-308` ~ `1.7E+308` | | +| `long double` | 10 bytes | `3.4E-4932` ~ `1.1E+4932` | | @@ -770,7 +770,7 @@ macro | description #include int main() { -printf("File :%s\n", __FILE__); + printf("File :%s\n", __FILE__); printf("Date :%s\n", __DATE__); printf("Time :%s\n", __TIME__); printf("Line :%d\n", __LINE__); @@ -803,6 +803,7 @@ If the macro is too long to fit on a single line, use the macro continuation ope int main(void) { message_for(Carole, Debra); + return 0; } ``` @@ -823,9 +824,10 @@ When you need to convert a macro parameter to a string constant, use the string #define tokenpaster(n) printf ("token" #n " = %d", token##n) -int main(void){ +int main(void) { int token34 = 40; tokenpaster(34); + return 0; } ``` @@ -843,6 +845,7 @@ int main(void){ int main(void) { printf("Here is the message: %s\n", MESSAGE); + return 0; } ``` @@ -853,25 +856,26 @@ int main(void) { ```c int square(int x) { -return x *x; + return x * x; } ``` The macro rewrites the above code as follows: ```c -#define square(x) ((x) *(x)) +#define square(x) ( (x) * (x) ) ``` No spaces are allowed between the macro name and the opening parenthesis ```c #include -#define MAX(x,y) ((x) > (y) ? (x) : (y)) +#define MAX(x,y) ( (x) > (y) ? (x) : (y) ) int main(void) { - printf("Max between 20 and 10 is %d\n", MAX(10, 20)); - return 0; + printf("Max between 20 and 10 is %d\n", MAX(10, 20)); + + return 0; } ``` @@ -883,8 +887,9 @@ C Function ### Function declaration and definition {.row-span-2} ```c -int main() { +int main(void) { printf("Hello World!"); + return 0; } ``` @@ -909,8 +914,10 @@ void myFunction(); // main method int main() { myFunction(); // --> call the function + return 0; } + void myFunction() {// Function definition printf("Good evening!"); } @@ -925,9 +932,11 @@ void myFunction() {// Function definition void myFunction() { printf("Good evening!"); } + int main() { myFunction(); // call the function myFunction(); // can be called multiple times + return 0; } // Output -> "Good evening!" @@ -942,9 +951,11 @@ int main() { void myFunction(char name[]) { printf("Hello %s\n", name); } + int main() { -myFunction("Liam"); + myFunction("Liam"); myFunction("Jenny"); + return 0; } // Hello Liam @@ -962,6 +973,7 @@ void myFunction(char name[], int age) { int main() { myFunction("Liam", 3); myFunction("Jenny", 14); + return 0; } // Hi Liam you are 3 years old. @@ -996,6 +1008,7 @@ int main() { // store the result in a variable int result = myFunction(5, 3); printf("Result = %d", result); + return 0; } // result: 8 (5 + 3) @@ -1008,9 +1021,11 @@ int main() { ```c int sum(int k); + int main() { int result = sum(10); printf("%d", result); + return 0; } @@ -1029,10 +1044,13 @@ int sum(int k) { ```c #include -printf("%f", sqrt(16)); // square root -printf("%f", ceil(1.4)); // round up (round) -printf("%f", floor(1.4)); // round up (round) -printf("%f", pow(4, 3)); // x(4) to the power of y(3) + +void main(void) { + printf("%f", sqrt(16)); // square root + printf("%f", ceil(1.4)); // round up (round) + printf("%f", floor(1.4)); // round up (round) + printf("%f", pow(4, 3)); // x(4) to the power of y(3) +} ``` ---- @@ -1071,6 +1089,7 @@ struct myStructure { int main() { struct myStructure s1; + return 0; } ``` @@ -1091,6 +1110,7 @@ int main() { strcpy(s1. myString, "Some text"); // print value printf("my string: %s", s1.myString); + return 0; } ``` @@ -1104,7 +1124,7 @@ Assigning values ​​to strings using the `strcpy` function ```c{11,12,16} // create a structure called myStructure struct myStructure { -int myNum; + int myNum; char myLetter; }; @@ -1121,6 +1141,7 @@ int main() { // print value printf("My number: %d\n", s1.myNum); printf("My letter: %c\n", s1.myLetter); + return 0; } ``` @@ -1220,15 +1241,16 @@ Mode Mode | Description Description ```c{6} #include -void main( ) { +void main() { FILE *fp; char ch; + fp = fopen("file_handle.c", "r"); while (1) { ch = fgetc(fp); if (ch == EOF) - break; + break; printf("%c", ch); } fclose(fp); @@ -1244,12 +1266,13 @@ After performing all operations on the file, the file must be closed with `fclos ```c{7} #include -main() { +void main() { FILE *fp; fp = fopen("file.txt", "w"); // open the file + // write data to file fprintf(fp, "Hello file for fprintf..\n"); -fclose(fp); // close the file + fclose(fp); // close the file } ``` @@ -1259,11 +1282,14 @@ fclose(fp); // close the file ```c{6} #include -main(){ + +void main() { FILE *fp; + char buff[255]; // Create a char array to store file data fp = fopen("file.txt", "r"); - while(fscanf(fp, "%s", buff)!=EOF) { + + while(fscanf(fp, "%s", buff) != EOF) { printf("%s ", buff); } fclose(fp); @@ -1277,7 +1303,7 @@ main(){ ```c{6} #include -main(){ +void main() { FILE *fp; fp = fopen("file1.txt", "w"); // open the file fputc('a',fp); // write a single character to the file @@ -1292,15 +1318,20 @@ main(){ ```c{8} #include #include + void main() { FILE *fp; char c; + clrscr(); - fp=fopen("myfile.txt", "r"); - while((c=fgetc(fp))!=EOF){ + + fp = fopen("myfile.txt", "r"); + + while( (c = fgetc(fp) ) != EOF) { printf("%c", c); } fclose(fp); + getch(); } ``` @@ -1313,12 +1344,15 @@ void main() { #include #include -void main(){ +void main() { FILE *fp; + clrscr(); + fp = fopen("myfile2.txt","w"); fputs("hello c programming",fp); fclose(fp); + getch(); } ``` @@ -1334,10 +1368,13 @@ void main(){ void main() { FILE *fp; char text[300]; + clrscr(); -fp=fopen("myfile2.txt", "r"); + + fp = fopen("myfile2.txt", "r"); printf("%s", fgets(text, 200, fp)); fclose(fp); + getch(); } ``` @@ -1348,13 +1385,16 @@ fp=fopen("myfile2.txt", "r"); ```c{8} #include -void main(){ + +void main(void) { FILE *fp; + fp = fopen("myfile.txt","w+"); fputs("This is Book", fp); - // Set the file pointer to the given position + // Set file pointer to the given position fseek(fp, 7, SEEK_SET); + fputs("Kenny Wong", fp); fclose(fp); } @@ -1369,19 +1409,26 @@ set the file pointer to the given position ```c{11} #include #include -void main(){ + +void main() { FILE *fp; char c; + clrscr(); - fp=fopen("file.txt", "r"); -while((c=fgetc(fp)) != EOF){ + + fp = fopen("file.txt", "r"); + + while( (c = fgetc(fp) ) != EOF) { printf("%c", c); } + rewind(fp); // move the file pointer to the beginning of the file - while((c=fgetc(fp)) != EOF){ + + while( (c = fgetc(fp) ) != EOF) { printf("%c", c); } fclose(fp); + getch(); } // output @@ -1396,17 +1443,20 @@ while((c=fgetc(fp)) != EOF){ #include #include -void main (){ +void main () { FILE *fp; int length; + clrscr(); + fp = fopen("file.txt", "r"); + fseek(fp, 0, SEEK_END); - length = ftell(fp); // return current position - fclose(fp); + printf("File size: %d bytes", length); + getch(); } // output From 8ec6c87e21a22aa48bf89315d64a0de8541a962e Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Tue, 31 Jan 2023 16:51:14 +0800 Subject: [PATCH 06/10] Correct the `--include` option `-include` is invalid, it is intercepted as `-i -n -c` and will create a file named `lude` under the current directory. --- source/_posts/curl.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/_posts/curl.md b/source/_posts/curl.md index 2a16c3b..cf6ce74 100644 --- a/source/_posts/curl.md +++ b/source/_posts/curl.md @@ -148,7 +148,7 @@ command | description ### Multiple file upload {.col-span-2} ```bash -$ curl -v -include \ +$ curl -v --include \ --form key1=value1 \ --form upload=@localfilename URL ``` @@ -324,4 +324,4 @@ curl -K file # read configuration from file curl --config file $HOME/.curlrc # default configuration file on UNIX-like systems -``` \ No newline at end of file +``` From 94157cda354901ebf57a78968ec8332a1e2716f2 Mon Sep 17 00:00:00 2001 From: Fechin Date: Thu, 9 Feb 2023 09:44:12 +0800 Subject: [PATCH 07/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 490f66d..aac89dd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Reference +# Reference Twitter Follow [![love](https://badgen.net/badge/make%20with/love/pink)](#) [![License](https://badgen.net/badge/license/MIT/blue)](https://github.com/Fechin/reference/blob/main/LICENSE) From aa6a4dce68a3686187deb8d0b67d1ae028b47f6e Mon Sep 17 00:00:00 2001 From: Fechin Date: Thu, 9 Feb 2023 09:46:01 +0800 Subject: [PATCH 08/10] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aac89dd..224191b 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,14 @@ -# Reference Twitter Follow +# Reference + [![love](https://badgen.net/badge/make%20with/love/pink)](#) [![License](https://badgen.net/badge/license/MIT/blue)](https://github.com/Fechin/reference/blob/main/LICENSE) [![contributors](https://badgen.net/github/contributors/Fechin/reference)](https://github.com/Fechin/reference/graphs/contributors) [![forks](https://badgen.net/github/forks/Fechin/reference)](https://github.com/Fechin/reference/network/members) [![starts](https://badgen.net/github/stars/Fechin/reference)](#) +[![Follow us on Twitter](https://img.shields.io/twitter/follow/FechinLi?style=social)](https://twitter.com/FechinLi) + + From 28fd59cfe3ca6d11ccd0a410548f4f713e7ac634 Mon Sep 17 00:00:00 2001 From: Fechin Date: Thu, 9 Feb 2023 09:46:46 +0800 Subject: [PATCH 09/10] Update README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 224191b..b9cb527 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,6 @@ [![love](https://badgen.net/badge/make%20with/love/pink)](#) [![License](https://badgen.net/badge/license/MIT/blue)](https://github.com/Fechin/reference/blob/main/LICENSE) -[![contributors](https://badgen.net/github/contributors/Fechin/reference)](https://github.com/Fechin/reference/graphs/contributors) -[![forks](https://badgen.net/github/forks/Fechin/reference)](https://github.com/Fechin/reference/network/members) -[![starts](https://badgen.net/github/stars/Fechin/reference)](#) [![Follow us on Twitter](https://img.shields.io/twitter/follow/FechinLi?style=social)](https://twitter.com/FechinLi) From 8232c8e9a8cc0a0edd3b6cf068b0d8890e287565 Mon Sep 17 00:00:00 2001 From: Fechin Date: Thu, 9 Feb 2023 12:05:28 +0800 Subject: [PATCH 10/10] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b9cb527..d657df8 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,10 @@ -**Reference** is a collection of **cheatsheets** contributed by open source angels. It shares a quick reference cheat sheet for developers in a nice layout. \[ [中文版](https://github.com/jaywcjlove/reference) | ... \] +Reference is a collection of cheatsheets contributed by open source angels. It shares a quick reference cheat sheet for developers in a nice layout. \[ [中文版](https://github.com/jaywcjlove/reference) | ... \] -We're happy to see your best skill cheat sheets in **Reference**, If you see a cheatsheet here is not fit, you can fix it or provide a better cheatsheet by submitting a [PR](#contributing). + +We're happy to see your best skill cheat sheets in Reference, If you see a cheatsheet here is not fit, you can fix it or provide a better cheatsheet by submitting a [PR](#contributing). ## Live Demo