Class names are CamelCase
.
Methods and variables are snake_case
.
Methods with a ?
suffix will return a boolean.
sed: | |
to substitute something with something else: | |
sed "s/something/something_else/g" file.sh | |
the g in the right is for changing all occurrences in all lines, if it was not written, only the first occurrence of each line is replaced | |
sed example to substitute new lines with spaces: | |
sed ':a;N;$!ba;s/\n/ /g' file |
# write/overwrite file | |
f = open("text.txt", "w") | |
f.write("bla bla") | |
f.close() | |
# search for something in file | |
with open('data') as f: | |
if 'test' in f.read(): |
[Unit] | |
Description=Gitea (Git with a cup of tea) | |
After=syslog.target | |
After=network.target | |
#After=mysqld.service | |
#After=postgresql.service | |
#After=memcached.service | |
#After=redis.service | |
[Service] |
# delete all pods that are evicted | |
kubectl get pods --all-namespaces | grep Evicted | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod | |
# delete all pods that are erroring and sleep a bit to avoid rate limit | |
# you can add head or tail to work in batches | |
kubectl get pods --all-namespaces | grep 'Evicted\|Error\|ContainerStatusUnknown' | awk '{print $2 " --namespace=" $1}' | xargs -I % sh -c '{ kubectl delete pod %; sleep 0.1; }' | |
# print all failing pods with their describe reason of failiure |
gcloud auth list
gcloud config set compute/zone us-central1-a
gcloud container clusters create bootcamp --num-nodes 5 --scopes "https://www.googleapis.com/auth/projecthosting,storage-rw"
// any file to use the Eloquent driver | |
<?php | |
require "../vendor/autoload.php"; | |
require "../config/database.php"; | |
use Illuminate\Database\Capsule\Manager as Capsule; | |
$dbclass = new Database(); | |
$capsule = new Capsule(); | |
$capsule->addConnection($dbclass->EloquentConnection()); |
Copy a file from host to container:
docker cp file.xz container_name:/tmp/file.xz
List all containers with their volumes
docker ps -a --format '{{ .ID }}' | xargs -I {} docker inspect -f '{{ .Name }}{{ printf "\n" }}{{ range .Mounts }}{{ printf "\n\t" }}{{ .Type }} {{ if eq .Type "bind" }}{{ .Source }}{{ end }}{{ .Name }} => {{ .Destination }}{{ end }}{{ printf "\n" }}' {}
# This is a comment, we will use comments to explain. | |
# There are three types of data in YAML: | |
# - key value pair, lists/arrays, dictionaries | |
# key value pair: | |
Fruit: Apple | |
Vegetable: Carrot | |
Liquid: Water | |
Meat: Chicken |