task_boiler
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
task_boiler [2022/08/11 21:57] – raju | task_boiler [2022/09/01 13:57] – raju | ||
---|---|---|---|
Line 4: | Line 4: | ||
Start the first heading with " | Start the first heading with " | ||
- | ===== Apply unix commands to all but the first line ===== | + | ===== Impact of enabling SSL on google page indexing |
- | ==== Situation ==== | + | |
- | Let's say we want to sort a series of numbers in descending order but keep the header at the top. For example, given | + | |
- | < | + | |
- | % echo -e " | + | |
- | value | + | |
- | 8 | + | |
- | 2 | + | |
- | 6 | + | |
- | 3 | + | |
- | </ | + | |
- | we want to output | + | |
- | < | + | |
- | value | + | |
- | 2 | + | |
- | 3 | + | |
- | 6 | + | |
- | 8 | + | |
- | </ | + | |
- | We can't directly use ' | + | On 2022-08-16, I enabled SSL on this website using certificate from letsencrypt. This resulted in google indexing more pages. |
- | < | + | |
- | % echo -e " | + | |
- | 2 | + | |
- | 3 | + | |
- | 6 | + | |
- | 8 | + | |
- | value | + | |
- | </ | + | |
- | ==== Bare bones solution ==== | + | {{:impact_of_enabling_ssl_on_20220816.png?direct|}} |
- | Create a script called ' | + | |
- | < | + | |
- | # | + | |
- | # | + | |
- | # body: apply expression to all but the first line. | + | |
- | # Use multiple times in case the header spans more than one line. | + | |
- | # | + | |
- | # Example usage: | + | |
- | # $ echo -e " | + | |
- | # | + | |
- | IFS= read -r header | + | |
- | printf ' | + | |
- | " | + | |
- | </ | + | |
- | + | ||
- | Make it executable | + | |
- | < | + | |
- | % chmod +x body | + | |
- | </ | + | |
- | + | ||
- | place it somewhere in your PATH (say ~/bin) | + | |
- | < | + | |
- | % mv body ~/bin | + | |
- | </ | + | |
- | + | ||
- | This script will apply any unix command to all but the first line. For example, using it on our example | + | |
- | + | ||
- | < | + | |
- | % echo -e " | + | |
- | value | + | |
- | 2 | + | |
- | 3 | + | |
- | 6 | + | |
- | 8 | + | |
- | </ | + | |
- | + | ||
- | ==== Practical solution ==== | + | |
- | I got the above script from https:// | + | |
- | + | ||
- | A more practical approach is to clone that entire repository and add it to your PATH. | + | |
- | + | ||
- | I did it as follows. | + | |
- | + | ||
- | Remove the bare bones script we added in the previous step | + | |
- | < | + | |
- | % rm ~/ | + | |
- | </ | + | |
- | + | ||
- | Clone the repository | + | |
- | < | + | |
- | % mkdir -p ~/ | + | |
- | % cd ~/ | + | |
- | + | ||
- | % git clone git@github.com: | + | |
- | Cloning into ' | + | |
- | remote: Enumerating objects: 62, done. | + | |
- | remote: Counting objects: 100% (62/62), done. | + | |
- | remote: Compressing objects: 100% (52/52), done. | + | |
- | remote: Total 62 (delta 20), reused 48 (delta 10), pack-reused 0 | + | |
- | Receiving objects: 100% (62/62), 18.59 KiB | 9.29 MiB/s, done. | + | |
- | Resolving deltas: 100% (20/20), done. | + | |
- | </ | + | |
- | + | ||
- | Update the PATH in ~/.bashrc by adding the following lines | + | |
- | < | + | |
- | # | + | |
- | # Add data science utils such as body, header | + | |
- | export PATH=~/ | + | |
- | # | + | |
- | </ | + | |
- | + | ||
- | Open a new bash session and verify that these utilities are correctly picked up. | + | |
- | < | + | |
- | % which body | + | |
- | / | + | |
- | + | ||
- | % which header | + | |
- | / | + | |
- | </ | + | |
- | + | ||
- | Verify that the utilities are working as expected. | + | |
- | < | + | |
- | % echo -e " | + | |
- | value | + | |
- | 2 | + | |
- | 3 | + | |
- | 6 | + | |
- | 8 | + | |
- | </ | + | |
- | ==== Works with any command ==== | ||
- | The beauty of this approach is that you can use it with any unix command (and not just sort). For example, you can grep a value and it will show the header along with the value. | ||
< | < | ||
- | % echo -e "value\n8\n2\n6\n3" | + | % cat Chart.csv | csvsql |
- | value | + | Date, |
- | 8 | + | 2022-08-13, |
+ | 2022-08-14, | ||
+ | 2022-08-15, | ||
+ | 2022-08-16, | ||
+ | 2022-08-17, | ||
+ | 2022-08-18, | ||
+ | 2022-08-19, | ||
+ | 2022-08-20, | ||
+ | 2022-08-21, | ||
+ | 2022-08-22, | ||
+ | 2022-08-23, | ||
+ | 2022-08-24, | ||
+ | 2022-08-25, | ||
+ | 2022-08-26, | ||
+ | 2022-08-27, | ||
+ | 2022-08-28, | ||
+ | 2022-08-29, | ||
</ | </ | ||
- | ==== How I came across it ==== | + | tags | http vs https, |
- | I came across it while reading the book "Data Science at the Command Line" (2nd Edition) by Jeroen Janssens (https:// | + |
task_boiler.txt · Last modified: 2024/01/23 22:55 by raju