• 301 redirect all subdomains to new domain on apache

    While trying to consolidate many subdomains under one new domain on apache we had to add the following into the sites configuration file to redirect the multiple subdomains to one. This could be added into the .htaccess as well.

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^newdomain.com$ [NC]
    RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]

    Read the rest of this entry »

  • Merging 100+K Gzipped Files Together

    In order to open a large volume of cloudfront logs in a spreadsheet, we needed to merge over 100K .gz files on OS X Maverick into a single file. Trying to use the following command resulted in a /usr/bin/cat: Argument list too long error:

    cat logs/*.gz >> combined_logs.gz 

    The reason this error occurs is because bash expands the asterisk to all matching files, producing a very long command line. To circumvent this problem the xargs command needs to be used to split up the list:
    Read the rest of this entry »

  • Remote Desktop MAC and wrong keyboard

    Recently I upgraded to the remote desktop app from microsoft that is available in the app store. Previously I was using the 2.1.1 version which worked quite well but felt like changing anyway. Upon switching I noticed that some of my keys were not working as they should, in particular the @ key was coming up with ” and # was ? instead. In fact there were many keys that were not outputting correctly. It turns out that upon making a RDP connection from my MAC to a windows server, the RDP connection was incorrectly identifying my remote keyboard. Read the rest of this entry »

  • Showing images on WordPress search page

    When searching a blog using the twenty-twelve theme the images get commented out. It only will display an excerpt so your image is commented out. In order to fix this you must edit your CONTENT.PHP file, not your SEARCH.PHP.

    Open content.php and find the following lines:

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    <div class=”entry-summary”>
    <?php the_excerpt(); ?>
    </div><!– .entry-summary –>
    <?php else : ?>
    <div class=”entry-content”>
    <?php the_content( __( ‘Continue reading <span class=”meta-nav”>&rarr;</span>’, ‘twentytwelve’ ) ); ?>
    <?php wp_link_pages( array( ‘before’ => ‘<div class=”page-links”>’ . __( ‘Pages:’, ‘twentytwelve’ ), ‘after’ => ‘</div>’ ) ); ?>
    </div><!– .entry-content –>
    <?php endif; ?>

    Read the rest of this entry »

  • Simple Bash Automation for EC2 Instance Backups using Cron on a Mac Mini

    The problem that needed to be solved was to have a simple backup system that could be used to maintain a bunch of EBS backed Windows instances on AWS. We wanted to keep a weeks worth of backups, always discarding the older AMI’s. A local mac mini was used to run the necessary scripts and cron. We didn’t want just EBS snapshots, we wanted a full AMI everyday. There are other solutions if you just want to backup an EBS drive on a schedule, and even for this but this one suits our needs.

    Read the rest of this entry »