Newly available services

I am now ready to start moving forward by providing additional services. I have plenty of experience with automation, developer support and resilient infrastructure management which is why I now want to pass my abilities onto the consumer. At this point, I am looking for folks who have smaller environments (I can handle larger environments, but a small start would be ideal) which they would like to move into a newly automated infrastructure.

Services I am now offering are as follows:

  • Chef server management (*** shared or individual)
  • Chef cookbook development
  • Check_MK / OMD server automation and monitoring (*** shared or individual)
  • Docker image development and container automation (Ubuntu and Base Image Phusion preferred)
  • On-Premises and cloud migrations
  • Infrastructure Design and Architecture
  • High Availability and Resiliency

Other technologies I support:

  • Ruby (via rbenv), and Ruby on Rails with the Passenger-Nginx module
  • Php (any required version – later preferred for security)
  • MySQL / Percona XtraDB clustering
  • Apache and Nginx (plus use as reverse proxies)
  • DNS Management (typically using Omnis, Amazon Route53, but custom BIND servers available as well)

*** Shared or individual means I can build a server that you share with other clients for a reduced cost, or I can build you your own that is completely separate from other clients.

Simple command to show or hide hidden files on Mac OS X

If you have ever come across a need to have Mac OS X show the files starting with a dot (.) in your GUI, you may have found the command to do it, only to forget it later. Instead of remembering the command, why not just create a logical shortcut that does the job for you?

In my case, I have created two new commands on my system:

show-hidden
hide-hidden

 

Here’s how to set this up:

Add the following three lines to your ~/.profile file (you can use vim or nano):

# Hide or Show hidden files in the OS X file system
alias show-hidden='defaults write com.apple.finder AppleShowAllFiles YES && killall Finder'
alias hide-hidden='defaults write com.apple.finder AppleShowAllFiles NO && killall Finder'

If you do not know the command to edit your ~/.profile file, here’s what you can use (I’m giving the nano example since most find nano easier to use than vim):

nano -w ~/.profile

When you are done, save the file and quit the editor with the following keystrokes (control + o, enter, and control +x):

[ ctrl + o ], [ enter ], [ crtl + x ]

Source your ~/.profile file:

source ~/.profile

Test it out:

  • Open your finder window and navigate to your home directory. You should see no hidden files unless you have previously executed the commands to make them show.
  • Run the following commands in any order you wish, any time you want and they will control wether hidden files show up or not (if you watch your Finder window while you run them, you will see the changes made in real time):
    • show-hidden
    • hide-hidden

Docker

Docker is truly awesome! For the past year at my job working with the AT&T Developer Program, I have done a lot of research and testing on Docker and found it to be an absolutely amazing tool to use for managing isolated, sandboxed servers which use minimal overhead and are easily replaced. It turns out that I liked Docker so much, I ended up adopting it here on the KASL Network. As of Sunday, May 3, 2015, the KASL Network of sites is now running in a Docker container. This makes disaster recovery much more efficient by requiring less configuration and, since I have also set up a 100% automated off-site backup system, we are very portable as well.

I hope to add a tutorial on how I use Docker here in the near future.

Hail to Docker!

Getting Docker to Work with Mac OS X Yosemite

Docker Logo

Docker Logo

I use Docker for some personal and work related projects. Docker has always worked great for me until I upgraded my Mac operating system from Mavericks to Yosemite. Once I upgraded to Yosemite, despite having Docker configured to work properly, the Docker command line couldn’t connect to the boot2docker vm that is required in order to run Docker on OS X. I could use `boot2docker ssh` and then do my Docker tasks, but that didn’t work for me as I am also trying to use `knife container` to manage Docker containers via Chef.

To fix this issue, here is what I did:

  • boot2docker delete
  • In Virtualbox, go to VirtualBox (menu) => Preferences => Network => Host Only Networks, delete the host only networks, then I re-added them
  • boot2docker init
  • boot2docker up

Now Docker works from the OS X command line via iTerm2 for me.

OS X Mavericks: Pause a Quicktime Screen Recording

If you are a user of OS X Mavericks and use Quicktime to record screencasts and whatnot, you may have noticed that Quicktime appears to no longer have the option to pause your recording. The truth is that the functionality is still there, but it is just very well hidden.

During your recording, if you would like to pause the recording, follow these steps:

1) Click on the Quicktime icon in your app bar:

Quicktime

 

 

 

 

 

 

2) Press the “esc” (escape) key

At this point, you will see the control window for Quicktime, and then you will notice it only has a stop button – not a pause button.

Screen Shot 2014-07-23 at 12.06.07 PM

 

 

 

 

 

3) Hold down the “alt” key and you will now see a pause button

If your video is already paused, you will then see the record (red) button which allows you to continue. If you with to simply stop the video, hold down the “alt” key and press stop.

 

OSX Mavericks – Keeping Windows on Top

Back when I was using OS X Snow Leopard and Lion, I used a handy app called Afloat for Mac in order to keep windows on top. The reason one might want this type of feature is if you are using multiple windows, but want to permanently keep one on top so that it is never out of view. Linux distributions have this feature built-in by default in all desktop environments that I’ve ever used including Gnome, KDE, etc.

Once I upgraded my Mac to Mavericks using the fresh install method, of course I lost my settings and I could never figure out how to get Afloat for Mac installed again because it was apparently compatible. I found multiple links on the Internet for Afloat for Mac, but something about the links was always off.

Today I gave one last ditch effort to find that app and sure enough, I found the website that I had found before and figured I’d give it a try. The URI: http://infinite-labs.net/afloat/.

Use the download link at that site, install Afloat for Mac, reboot your computer and then you’re set.

Afloat

Samsung Galaxy S3 GPS Fix

GPS Test

GPS Test application for Android from the Google Play Store

Ever since Verizon released the recent Android 4.3 update for the Samsung Galaxy SIII, the GPS on both my phone and my wife’s phone hasn’t worked. We have both tried various methods to fix the issue but none of the recommended approaches solved the issue. I was just about to the point where I thought I might have to root my phone and install a custom ROM such as Cyanogenmod because it has typically always been stable for me and also included features which are typically missing from stock ROM’s.

Before I proceeded with rooting my phone, I gave Google one last search to see if anybody had figured out the issue to this very common problem (currently known issue with the GSIII and Razr on Verizon). I managed to stumble upon this article at Android Central, followed the instructions, and the problem was solved!

In summary, here is what I did:

  1. Install the “GPS Test” application from the Google Play Store
  2. Open GPS Test and clear / update AGPS
  3. Remove the back cover of the phone and remove the battery
  4. Ensure all of the tiny phillips screws are tight
  5. Reboot the phone

After the phone has finished rebooting, turn on the GPS radio and open the GPS Test application again. It should lock onto multiple GPS satellites now.

The new PingServer.net

I have recently decided to resurrect my old PingServer.net domain. When it used to be up, it was a public server monitoring tool which checked for server outages and notified the owners of the server. I had close to 100 clients back then, but there was so much work to do and so little time to do it, I decided to kill the project. Not to mention that it was hard to compete with Pingdom.

I recently came up with a new idea for PingServer.net. This time, rather than being a subscription-based service, it is just a simple on-demand tool which may be used by anybody. Please check it out and let me know what I’m missing and what I can do better.

Also, if anybody has a clever Php function that can intelligently determine the domain name from any given URL/URI, I am interested in knowing. I am currently using the parse_url function, but it is rather limited as it will leave the www or whatever other subdomain connected to the domain name.

http://pingserver.net

Screenshot:

PingServer.net image

One Liner: Check Cron Jobs for All Users on a *nix Server

If you are ever in a situation where you are asked to find out whether or not a server is being used for anything important, some of the first things you would want to check is whether or not there are active websites, databases and automated tasks. Automated tasks often times are run by the Cron daemon on behalf of a user on the server. If you would like to check the Crontab entries for all users on the server, you can run a one-line command as a super user and get a nice long list of who does and does not have a Crontab entry:

for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done | grep -v '#'

The “grep -v” after the pipe simply ensures that no lines starting with a hash mark (#) are listed.

Full MySQL Search & Replace in All Databases and Tables

If you get into half of the database stuff that I regularly get into, you probably have a need to replace a specific string, such as a URL, very often – especially if you are cloning databases for use with WordPress. Sure, there are a lot of plugins or programs out there which do the same thing, but most of them avoid three-dimensional arrays and work on only one database – excluding that low level option of modifying all databases.

Because I couldn’t find anything worthwhile for what I was doing, I decided to make one myself.

This script is designed to be run by Php in the command line, but will also work in  a web browser if you replace all instances of PHP_EOL with HTML line breaks. To run this script the way that I wrote it, simply run it like this (assuming you saved the code below to a file named query-db.php):

php ./query-db.php

To make this work, change the credentials in the “Database Credentials” below, and change the strings in $search and $replace variables below.

<?php

/* Search & Replace All Databases + Fields + Columns
*
* Written by Kris Law for KASL Network
* October 21, 2012
*
* This script will search and replace specified strings from
* all columns from all tables from all databases.
*
* USE AT YOUR OWN RISK!
*/


// Database Credentials
$test_db='db.host.com';
$db_user='myDb_us3r';
$db_pass='myDb_p@ssw0rd';

// Search & Replace
$search = 'the quick brown fox jumped over the lazy dog'; // term to have replaced
$replace = 'the lazy dog was quicker and blocked the quick brown fox'; // string to put in place

// Open DB Connection
$link = mysql_connect($test_db, $db_user, $db_pass);

### Show list of databases
$query_string = "SHOW databases";
$query = mysql_query($query_string);

echo "Running Search & Replace on Databases. This will take a while..." . PHP_EOL . PHP_EOL;

while($array = mysql_fetch_array($query)){

$database = $array['Database'];
$q2 = mysql_query("show tables in $database");

if($database != 'information_schema' && $database != 'mysql' && $database != 'test'){

while($array2 = mysql_fetch_array($q2)){

$tables = $array2['Tables_in_'. $database];

$q3 = mysql_query("show columns in $database.$tables");

while($array3 = mysql_fetch_array($q3)){

$column = $array3['Field'];

$replace_query = "update $database.$tables set $column = replace($column, '$search','$replace')";
$replace = mysql_query($replace_query) or die(mysql_error());

echo "Searching $database.$tables->$column" . PHP_EOL;

}

}
}

}

echo PHP_EOL . "All instances of $search have been replaced with $replace!";

?>