Skip to content

Instantly share code, notes, and snippets.

View pauiglesias's full-sized avatar
🏠
Working from home

Pau Iglesias pauiglesias

🏠
Working from home
View GitHub Profile
# No passphrase (!important), save as [name]_ed25519
ssh-keygen -t ed25519
# File ~/.ssh/config
Hostname gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/[filename]
User [username]
# Add to known hosts
@pauiglesias
pauiglesias / ssh-keys-fingerprint
Created July 23, 2021 06:42
Shows the ssh key fingerprint in SHA256 or MD5 formats.
# Change id_rsa by your ~/.ssh private key file
# SHA256 version
ssh-keygen -l -f id_rsa
# MD5 version
ssh-keygen -l -E md5 -f id_rsa
@pauiglesias
pauiglesias / nginx-conf-cloudflare-ips
Last active July 23, 2021 10:35
Set nginx real IPs from Cloudflare
# Add to server section
# Cloudflare https://www.cloudflare.com/ips
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 104.16.0.0/13;
set_real_ip_from 104.24.0.0/14;
set_real_ip_from 104.16.0.0/12;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 131.0.72.0/22;
@pauiglesias
pauiglesias / nginx-conf-host-request-time
Created July 22, 2021 15:41
Set nginx log format with the current host called and total request time
# Log format
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format main2 '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$host" $request_time';
log_format bytes '$body_bytes_sent';
access_log /var/log/nginx/access.log main2;
{
"Version": "2017-08-28",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "arn:aws:s3:::*"
},
{
"Sid": "the-Sid",
UPDATE wp_posts SET post_content = REPLACE(post_content, "http://base-dev-url/", "http://base-prod-url/") WHERE post_content LIKE "%http://base-dev-url/%"
set_error_handler('myHandlerForMinorErrors', E_NOTICE | E_STRICT);
function myHandlerForMinorErrors() {}
DB::enableQueryLog();
[.. query ..]
error_log(print_r(DB::getQueryLog(), true));
1. Modify /composer.json -> "autoload": { .. "files": [..
2. Run "composer dump-autoload"
3. Optionally add aliases in config/app.php
@pauiglesias
pauiglesias / filter-http-log-by-time
Created March 11, 2015 09:47
Filter HTTP log by time
# Filter log by hour and minute
sudo cat /my/log/path | grep "11\/Mar\/2015\:09\:3" | grep -v "[avoid server ip address]" > filtered.log
# # Filter log by hour and minute avoiding certain file extensions
sudo cat /my/log/path | grep "11\/Mar\/2015\:09\:3" | grep -v "\.css" | grep -v "\.js" | grep -v "\.png" | grep -v "\.jpg" | grep -v "\.jpeg" | grep -v "\.gif" | grep -v "\/wp-admin\/" > filtered.log
# Sort 10 IPs ordered by requests
awk '{print $1}' filtered.log | sort | uniq -c | sort -n | tail -10
# Sort 10 IPS and DNS ordered by requests