macOS Change the Default Save Location of Screenshots

MacOS have a built-in screenshot feature which can be used right off the bat. This feature is an important one which I previously never met in Windows environment. It’s so helpful to chat and give instant example of my screen.

However, I took screenshots often, so it started to pile up on my desktop. Something I’m not very fond about. Fortunately, I can set up a dedicated folder for them and have them automatically save there. This can be done with a simple Terminal command

First, I create a dedicated screenshots folder via Finder.

Create Screenshots Folder

Open Terminal, and fire these commands. Don’t forget to change the path on the first command. The easy way rather than typing the path by yourself is by dragging the newly created screenshots folder into the Terminal, after you type

defaults write com.apple.screencapture location /Users/username/Pictures/Screenshots
killall SystemUIServer

The first command, sets the screenshot location to defined path, and the seconds restarts the SystemUIServer so the alteration can be recognized instantly by system.

Nginx Block Countries Using GeoIP Modules

Nginx block countries using GeoIP modules. Fortunately using EasyEngine installation, nginx is already installed with -with-http_geoip_module option. You can check with this command

nginx -V 2>&1 | grep -- 'http_geoip_module'

The IP database is also already downloaded on /usr/share/GeoIP/GeoIP.dat

1. Map and Declare $allowed_country Variable

This means the only steps we need to do is create a conf file inside /etc/nginx/conf.d/ directory. For a reminder, creating a conf file inside the conf.d directory will be auto-included from nginx.conf file. The configuration content below is meant to be put inside http block. Let’s name it badcountries.conf.

1
2
3
4
5
6
7
8
9
10
11
12
geoip_country /usr/share/GeoIP/GeoIP.dat;
map $geoip_country_code $allowed_country {
    default yes;
    CN no;
    ID no;
    IN no;
    RU no;
}
geo $exclusions {
    default 0;
    10.8.0.0/24 1;
}

2. Check $allowed_country Variable with Active IP Visitor

Next step is check the $allowed_country variable against the current visitor’s IP address. Put this code inside server block.

1
2
3
if ($allowed_country = "no") { 
  return 444; 
}

Restart nginx after editing is done.

service nginx restart

Now, every visitors coming from countries you defined as no inside badcountries.conf will be served with 444 error code.

For the list of ISO 3166 country codes you can put inside badcountries.conf file, follow this link.