Skip to content

Instantly share code, notes, and snippets.

View thiagomgo's full-sized avatar
💜

Thiago Gomes thiagomgo

💜
  • Brazil
View GitHub Profile
@thiagomgo
thiagomgo / wp-config.php
Created June 29, 2021 22:21
Fix broken SSL access
<?php
if ((isset($_ENV["HTTPS"]) && ("on" == $_ENV["HTTPS"]))
|| (isset($_SERVER["HTTP_X_FORWARDED_SSL"]) && (strpos($_SERVER["HTTP_X_FORWARDED_SSL"], "1") !== false))
|| (isset($_SERVER["HTTP_X_FORWARDED_SSL"]) && (strpos($_SERVER["HTTP_X_FORWARDED_SSL"], "on") !== false))
|| (isset($_SERVER["HTTP_CF_VISITOR"]) && (strpos($_SERVER["HTTP_CF_VISITOR"], "https") !== false))
|| (isset($_SERVER["HTTP_CLOUDFRONT_FORWARDED_PROTO"]) && (strpos($_SERVER["HTTP_CLOUDFRONT_FORWARDED_PROTO"], "https") !== false))
|| (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && (strpos($_SERVER["HTTP_X_FORWARDED_PROTO"], "https") !== false))
) {
$_SERVER["HTTPS"] = "on";
}
@thiagomgo
thiagomgo / install-kubectx-ubuntu.sh
Last active November 13, 2020 21:58
install-kubectx-ubuntu.sh
# Install kubectx (Switch between Kubernetes contexts/namespaces)
sudo curl -sSL https://github.com/ahmetb/kubectx/releases/download/v0.9.1/kubens_v0.9.1_linux_x86_64.tar.gz | sudo tar -C /usr/local/bin -xz
# Install kubens (Switch between Kubernetes namespaces)
sudo curl -sSL https://github.com/ahmetb/kubectx/releases/download/v0.9.1/kubens_v0.9.1_linux_x86_64.tar.gz | sudo tar -C /usr/local/bin -xz
@thiagomgo
thiagomgo / check-user-web.php
Created February 10, 2020 13:16
Check which user is running under web server
<?
echo "I am running as user=";
system("whoami");
echo "<P>I can write here= ";
system("pwd");
$fname="write_test.txt";
if (file_exists($fname)) {
echo "<P> I found file $fname and will delete it";
unlink($fname);
echo "...Done";
@thiagomgo
thiagomgo / production.rb
Last active January 20, 2020 14:04 — forked from pvin/production.rb
Ruby on Rails production log rotation
# Log Rotate by initialising logger from the app
#Way one
# reference : http://ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html#method-c-new
# This one from Atinder Singh https://medium.com/@atinders/easy-log-rotation-with-rails-5-7b8d3c173461
# config/environments/production.rb
Rails.application.configure do
@thiagomgo
thiagomgo / rsync-txt-files.sh
Created August 2, 2019 14:02
Simple bash script to copy txt files to another directory.
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
set -e
set -o pipefail
FROM="/tmp/FROM/"
TO="/tmp/TO/"
DATE=$(date '+%d-%m-%Y %H:%M:%S')
LOG_FILE=/scripts/rsync-txt-files.log
@thiagomgo
thiagomgo / logrotate-kafka.sh
Last active February 11, 2019 21:26
logrotate kafka
##
## to test:
## logrotate -d /etc/logrotate.conf
##
## to enforce:
## logrotate -v -f /etc/logrotate.conf
##
/data/kafka/log/*.log {
daily
@thiagomgo
thiagomgo / proxy_ajp.conf
Created February 1, 2019 21:30
Proxy AJP
<IfModule proxy_ajp_module>
ProxyPass "/" "ajp://127.0.0.1:10001/"
</IfModule>
@thiagomgo
thiagomgo / Update remote repo
Last active January 25, 2019 19:59 — forked from mandiwise/Update remote repo
Transfer repo from Bitbucket to Github
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/user/awesome-new-repo.git
$ git branch --set-upstream-to=origin/master master
$ git push origin master
$ git pull origin master --allow-unrelated-histories
@thiagomgo
thiagomgo / imapsync.sh
Created January 25, 2019 19:08
Sync accounts using imapsync
#!/bin/bash
LISTA="/opt/sync-mail/list.txt"
LISTA_TMP="/tmp/list"
HOST_ORIGEM="xxx.xxx.xxx.xxx"
HOST_DESTINO="xxx.xxx.xxx.xxx"
cat ${LISTA}|grep -v "^#" | sed '/^ *$/d' > ${LISTA_TMP}
while IFS=: read usuario nome senha;do
@thiagomgo
thiagomgo / chroot.sh
Created March 25, 2018 16:47
Mount tips to chroot
sudo fdisk -l
sudo mount /dev/sdax /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt