This file contains 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 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 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 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 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 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 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 |
This file contains 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 | |
# For Ubuntu 20 (reference: https://rstudio.com/products/rstudio/download-server/debian-ubuntu/ accessed at Thu 04 Mar 2021 12:39:05 PM -03) | |
sudo apt-get install r-base | |
sudo apt-get install gdebi-core | |
cd /tmp | |
# Server | |
# wget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-1.4.1106-amd64.deb | |
# sudo gdebi rstudio-server-1.4.1106-amd64.deb |
This file contains 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(a, | |
b, | |
*, # arguments after `*` should be named when calling function | |
c): | |
print(f"a: {a}") | |
print(f"b: {b}") | |
print(f"c: {c}") | |
try: | |
foo(1, 2, 3) | |
except TypeError as e: |
This file contains 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 | |
import pandas as pd | |
from sklearn.svm import OneClassSVM | |
from sklearn.ensemble import IsolationForest | |
from sklearn.model_selection import KFold | |
from sklearn.metrics import accuracy_score | |
def df2np(df, dtype=np.float64): | |
return df.to_numpy().astype(dtype) |