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
| #!/usr/bin/env bash | |
| # To deploy using cron: | |
| # | |
| # sudo crontab -l | tail -n1 | |
| # */5 * * * * /home/ubuntu/docker_prune.sh >/dev/null 2>&1 | |
| USED_SPACE=$(df -h | grep -viE "(tmpfs|loop)" | awk '{print $5}' | grep -v Us | grep -vi loop |sort -rV | head -n1 | tr -d '%') | |
| DISK_LIMIT_PERCENTAGE=60 |
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
| defmodule Logging.Logger do | |
| @moduledoc "Handle application errors and log." | |
| require Logger | |
| def log_info(message) do | |
| Logger.info(message) | |
| end | |
| def log_error(message, stacktrace \\ []) |
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
| SELECT current_database(), schemaname, tblname, pg_size_pretty(bs*tblpages) AS real_size, | |
| pg_size_pretty(((tblpages-est_tblpages)*bs)::numeric) AS extra_size, | |
| CASE WHEN tblpages - est_tblpages > 0 | |
| THEN 100 * (tblpages - est_tblpages)/tblpages::float | |
| ELSE 0 | |
| END AS extra_ratio, fillfactor, pg_size_pretty(((tblpages-est_tblpages_ff)*bs)::numeric) AS bloat_size, | |
| CASE WHEN tblpages - est_tblpages_ff > 0 | |
| THEN 100 * (tblpages - est_tblpages_ff)/tblpages::float | |
| ELSE 0 | |
| END AS bloat_ratio, is_na |
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
| -- slow queries RUNNING | |
| SELECT now() - query_start AS duration, datname, pid, query | |
| FROM pg_stat_activity | |
| WHERE state = 'active' | |
| ORDER BY 1 DESC; | |
| select * from locks(); | |
| select * from lock_relations(); |
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
| Add this (from /etc/screenrc) to your ~/.screenrc: | |
| # Change the xterm initialization string from is2=\E[!p\E[?3;4l\E[4l\E> | |
| # (This fixes the "Aborted because of window size change" konsole symptoms found | |
| # in bug #134198) | |
| termcapinfo xterm* 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l' |
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
| resource "aws_launch_template" "nodes_template" { | |
| name_prefix = "nodes.stock-staging.querobolsa.space-" | |
| image_id = "ami-03b850a018c8cd25e" | |
| instance_type = "t3.small" | |
| key_name = "${aws_key_pair.kubernetes-stock-staging-querobolsa-space-ec167cae983d36fa6a38301fa47f31da.id}" | |
| iam_instance_profile { | |
| name = "${aws_iam_instance_profile.nodes-stock-staging-querobolsa-space.name}" | |
| } | |
| network_interfaces { |
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
| #!/usr/bin/env bash | |
| # install weave network driver | |
| kubectl create -f https://git.io/weave-kube-1.6 | |
| # install kubernetes dashboard service | |
| kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml | |
| # Create service account | |
| kubectl create serviceaccount cluster-admin-dashboard-sa |
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
| In order to build a site optimized for organic search engine rankings, it is important to implement certain standards throughout the code. These include: | |
| - Specifying an alt tag on images | |
| - Using the correct HTML tags for content hierarchy i.e., <h1>/<h2>/<h3> and p | |
| - Connect the site to the company’s social pages | |
| - Add an XML sitemap |
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
| Optimizing websites is an art that few are familiar with. The more the engineer is able to list off the top of their head, the more likely they are to do all of the following naturally as they code instead of having to return later. | |
| (Also, typically a professionally constructed site should score over 75 percent when analyzed by gtmetrix.com, which can also serve as a checklist.) | |
| - Optimize all assets | |
| - Place all assets on a separate, cookie-free domain. Using a CDN is best | |
| - Avoid inline JavaScript and CSS | |
| - Enable gzipping | |
| - Ensure all code is minified | |
| - Defer parsing of JavaScript |
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 | |
| # Access the current logs of the provided POD | |
| # | |
| # Parameter 1: the app name, which should match the deployment name (<app name>-deployment) and the container name. | |
| POD_NAME=$(kubectl get pods -n stock --no-headers -o custom-columns=":metadata.name" | grep -m1 "$1-deployment") | |
| echo "Acessing pod $POD_NAME" | |
| kubectl logs "$POD_NAME" -n stock -c "$1" --follow |
OlderNewer