This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RELEASE_URL=https://www.python.org/ftp/python/3.10.5/Python-3.10.5.tgz | |
| wget ${RELEASE_URL} -O Python-src.tgz && tar xzf Python-src.tgz &&\ | |
| cd Python-src &&\ | |
| ./configure --enable-optimizations --with-openssl=$(which openssl) &&\ | |
| sudo make altinstall &&\ | |
| rm -rf Python-src Python-src.tgz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import datetime | |
| # ISO formatting | |
| datetime.datetime.utcnow() # ('2022-05-10 04:18:09.297644') | |
| datetime.datetime.now() # ('2022-05-10 01:18:09.297743') | |
| # Custom formatting | |
| ## Pretty ('Saturday, 15. December 2012 11:19AM') | |
| datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M%p") | |
| ## Calendar ('2012-12-15') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://techoverflow.net/2019/04/01/how-to-find-zone-of-google-cloud-vm-instance-on-command-line/ | |
| gcloud compute instances list --filter='name="${INSTANCE_NAME}"' --format 'get(zone)' | rev | cut -d/ -f1 | rev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bs4 | |
| source_path = "annotations_source.xml" | |
| output_xml_path = "annotations_out.xml" | |
| LABELS = [ | |
| "no-category", "valid", "non-centered", "occluded", "spoof", | |
| "rotated", "blurred"] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # In case of simple logging | |
| complex_command && echo "Success" >> log.txt || echo "Failure" >> log.txt | |
| # In case of complex command chaining | |
| complex_command | |
| if [ $? -ne 0]; then | |
| success_complex_command # this command could fail as well | |
| # its exit code can be treated in a nested manner by testing $? again |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Adapted from (https://unix.stackexchange.com/a/269080/388950) | |
| no_sudo_func () { | |
| apt update | |
| } | |
| F=$(declare -f no_sudo_func) | |
| sudo bash -c "$F; no_sudo_func" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| PATH_TO_GCLOUD=/snap/bin/google-cloud-sdk.gcloud | |
| ${PATH_TO_GCLOUD} $@ --tunnel-through-iap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| class OnlineStatsCompute(): | |
| def __init__(self, *l): | |
| if len(l) > 0: | |
| self.add_l(*l) | |
| def add_e(self, e): | |
| """Includes a single element `e` in the OnlineStatsCompute. | |
| Updates attributes `N` and `mean`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def foo(): | |
| """<FUNCTION DESCRIPTION> | |
| <BLANK LINE> | |
| Parameters | |
| ---------- | |
| <VARIABLE> : <TYPE> | |
| <DESCRIPTION> | |
| ... | |
| <BLANK LINE> | |
| Returns |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Configs | |
| chmod 700 $HOME/.ssh | |
| chmod 644 $HOME/.ssh/authorized_keys | |
| chmod 644 $HOME/.ssh/known_hosts | |
| chmod 644 $HOME/.ssh/config | |
| # Keys | |
| chmod 600 $HOME/.ssh/id_rsa |