Kevin Warrington

Loading clever subtitle...

Mounting an AFP Filesystem

Here’s a simple way to connect to an Apple Filing Protocol (AFP) based server and access shared files.

mkdir /Volumes/my-share
mount_afp "afp://" /Volumes/my-share

You can access your new connection in either /Volumes or in left pane of the finder.

Forward vs Reverse Proxy Using Apache

A proxy server acts as an intermediary between a client and a destination server, primarily controlling access to resources and caching content.

To enable proxy functionality in Apache, use the following:

# /etc/apache2/httpd.conf
LoadModule proxy_module modules/
LoadModule proxy_http_module modules/

Forward Proxy

A Forward Proxy is typically used to:

  • hide the identities of clients
  • provide internet access to clients blocked by firewall
  • cache content to reduce network traffic

A forward proxy accepts requests from internal clients and forwards them to an external resource.

To configure this in Apache, we can simply control who has access to external resources by specifying their IP address.

<VirtualHost *:80>
  # Enables Apache to acting as forwarding server
  ProxyRequests On

  # Adds Via header to requests
  ProxyVia On

  <Proxy *>
    Order deny,allow
    Deny from all

    # Only allows this client to proxy requests
    Allow from

Reverse Proxy

A Reverse proxy is typically used to:

  • hide the identities of servers
  • act as load balancer
  • act as web accelerator
  • used to perform A/B testing

A reverse proxy accepts requests from external clients and usually forwards them to an internal resource.

To configure this in Apache, we use the ProxyPass and ProxyPassReverse directives.

<VirtualHost *:80>
  # Prevents Apache from acting as forwarding server
  ProxyRequests Off

  # to be internally converted into a proxy request to
  ProxyPass /assets/

  # if has a redirect to
  # Apache will adjust the request to before forwarding response
  ProxyPassReverse /assets/

Querying MySQL Configuration

MySQL system variables can be queried using the show variables syntax:

mysql -uUSERNAME -pPASSWORD -e 'SHOW VARIABLES LIKE "ft_min_word_len"'

It’s also useful to find out with my.cnf file MySQL will try to load on init:

mysql --help | grep cnf

Moving on the Command Line

Moving along the command line will be a breeze, if you know the following shortcuts.

ctrl+a - move to start of line
ctrl+e - move to end of line
alt+b - move backwards a word
alt+f - move forwards a word
alt+del - remove word
ctrl+k - remove to end of line

On Mac, make sure you setup the following config in Terminal > Preferences > Keyboard:

  • use option as meta key is checked
  • option cursor left is set to \033b
  • option cursor right is set to \033f

where \033 = esc

Working With Background Processes

For long running processes, rather than blocking your prompt, it’s often useful to push commands to the background and complete other tasks.

To run a command in the background.

<command> &

With nohup you can run a command which will continue after logout. It will ignore SIGHUP signals. nice sets a lower priority.

nohup nice <command> &

With screen you can run a command which can be resumed after logout. It creates a new window with multiple processes instead of multiple Unix login sessions, so it is resource efficient.

screen -A -m -d -S mysessionname ./ &

List all background processes


To send currently running command to background, first stop the process, Ctrl-z.


To bring a background process to the foreground

fg %1

To destroy a background process

kill %1 
kill -9 %1  
kill <pid>

To receive an email notification when a background process finishes

<command> | tee command.log | mailx -s 'PROCESS COMPLETE' &

To run a set of jobs when cpu levels permit, use batch. ctrl+d to end input. > ~/.forward
batch -m

You can list batch jobs and kill using the id

at -l
at -r id

MySQL Import/Export Progress Bar

MySQL command line progress can be monitored using the terminal-based “Pipe Viewer” pv.


pv /path/to/sqlfile.sql | mysql -uUSERNAME -pPASSWORD -D DATABASE_NAME


We need to estimate the file size of our export to get an accurate reading. This can be done via the information schema:

    Data_BB / POWER(1024,1) Data_KB,
    Data_BB / POWER(1024,2) Data_MB,
    Data_BB / POWER(1024,3) Data_GB
    SELECT SUM(data_length) Data_BB
    FROM information_schema.tables
    WHERE table_schema IN ('DATABASE_NAME')
) A;

We then use the estimated size to track export progress:


Beer Break!