I am like 6 days late on my 2014 post

2014 was freaking awesome. I went to New Orleans for the first time, and then back again a few weeks later. It was an amazing city and I cannot wait to go back soon. I moved to a new department in my previous job and as a result made some awesome new friends. I continued to plow through my graduate program and am excited to continue to make progress this year. I got a great new job at Linode, uprooted my life, moved to South Jersey, and met some amazing people. I wrote more code, solved more problems, and learned more than any previous year to date. I cannot wait to see what 2015 has in store. 🙂

Diagraming Tools for Linux

In Grad school and supposedly in the real world, we make a lot of diagrams of stuff. There are a lot of tools to do this.

For Windows, Visio probably works the best but I don’t like the way that Visio 2013 makes it really difficult to add new members if you are making a class or an ER diagram. Visio 2013 is prettier, but a lot more clunky in my opinion.

For Mac, I am a pretty big fan of Omnigraffle. It is simple, easy to use, has good stencils and gets the job done.

For Linux, although there are various choices they all leave something to be desired. I recently tried out Visual Paradigm, even though it has a “free” version for non-commercial use, they put in gross watermarks if you make more than one of the same type of diagram. This is not very professional and I do not think that the software is good enough to pay for. It seems like they just took eclipse and added some drawing functionality.

As much as I want to like Dia, it is just too clunky for every day use. I would not recommend this for anything other than very simple diagrams.

yEd is a really neat tool, it is simple and free to use. This tool really stands out from the pack for me because it “just works”. It also gets extra points for using an open standard drawing format which makes it compatible with other standards based software.

I think the best tool (but also the one with the highest learning curve) is Graphviz. Specifically, I am referring to using dot to make drawings. Despite the steep learning curve, it is 100% free software, standards based, is flexible and will draw exactly what you ask it to without too much trouble. Graphviz products embed perfectly in other programs which can be challenging when writing reports or papers. Also, if you master dot you will feel like a real hacker.

If you make diagrams for work or school (UML, ER, etc) what tool do you use? Let me know in the comments below!

Convert Markdown to PDF in Sublime Text

Sublime Text is an awesome text editor that has a ton of useful extensions that can be installed through the Package Manager that make it even better.

One of my favorite parts of emacs is org-mode, this allows you to organize your life, make awesome notes, and even perform spreadsheet calculations all from with in the emacs text editor. The best part about org-mode is that you can export your documents to HTML, PDF, and LaTex.

In my opinion, sublime text is almost a modern successor to emacs because a lot of the extensions that have been developed for Sublime Text allow you to do fancy things like this as well. I am a huge fan of Markdown, It makes writing structured documents super simple, and is especially useful when your documents contain code snippets. As a CS student, I am often writing papers that include code snippets and this is not handled very well in most word processors. Org-mode does a great job of creating documents with code snippets, and I was excited to find out that with a few extensions to Sublime text you can make beautiful documents including code with little to no hassle. The following steps are being done with Sublime Text 3 running on Debian Testing, the steps may be a bit different for other Operating Systems. In order to make beautiful documents with code snippets in Sublime Text you will need to do the following.

  1. If you have not already install Package Control
  2. Install MarkdownEditing in Sublime Text
  3. Install Pandoc in Sublime Text
  4. Install Pandoc in Debian
  5. Install TexLive in Debian (this is to convert things to PDF)

sudo apt-get install pandoc texlive

We are going to be leveraging the awesome tools that are provided by pandoc in order to make really cool things happen with our text editor! This even supports syntax highlighting! Once you have installed all of those pre requisites you can save a text file as markdown using the .md extension and then convert it to HTML, PDF, or other formats using pandoc. Simply open the command launcher with Control+Shift+P type in pandoc and select your output format.

 

Built In PDF Magic in Debian

Debian has some awesome PDF tools built right in via the poppler-utilspackage that I never knew about. In my previous post I talked about how to make beautiful documents with code snippets using various Sublime Text extensions to convert markdown into PDF. One issue that I ran into was getting a cover page created. As far as I know There is really no easy way to make a nice cover page in markdown. Specifically in Github Flavored Markdown (which is what I am using) there is not a good way to make a page break. The easy solution would be to simple write up your entire document in Markdown, and then make a separate cover page. The problem is how to merge these two files together to make one document. Thanks to the built in PDF tools in debian this becomes very simple! The poppler-utils package has the following utilities built in:

  • pdfdetach — lists or extracts embedded files (attachments)
  • pdffonts — font analyzer
  • pdfimages — image extractor
  • pdfinfo — document information
  • pdfseparate — page extraction tool
  • pdftocairo — PDF to PNG/JPEG/PDF/PS/EPS/SVG converter using Cairo
  • pdftohtml — PDF to HTML converter
  • pdftoppm — PDF to PPM/PNG/JPEG image converter
  • pdftops — PDF to PostScript (PS) converter
  • pdftotext — text extraction
  • pdfunite — document merging tool

In order to combine a coverpage with another document we can simple run the following command inside a terminal.

pdfunite coverpage.pdf content.pdf final.pdf

This will create a document called final.pdf (of course you should change coverpage.pdf and content.pdf to match your actual files). Warning: be sure to include the final output file or pdfunite will replace the last file that you type will all over the previous files!

Connect LibreOffice Base to MySQL

I think LibreOffice Base has so much underutilized potential as a rapid application development platform, business intelligence platform and just a general reporting platform. Not to mention the fact that registered data objects can be used in all of the other LibreOffice applications to make really amazing documents and improve the work-flow of any office. Anyone who has actually used MS Access knows how powerful it can be used to be for these types of purposes. The most recent version of Access seems to have lost a lot of the features that made it useful. This is okay since most power-users are still using Access 2003. LibreOffice Base is not nearly as powerful as Access, specifically from a usability perspective. My biggest frustration with getting started with LibreOffice Base is the obscure and somewhat cryptic documentation around the platform that makes way too many assumptions about what someone new to LibreOffice actually knows. My hope is to provide some practical tutorials with real world use cases. So let’s get started by connecting Base to an existing MySQL database. In my opinion, the built in HSQL engine has a somewhat weird syntax and is generally not worth learning unless you are not planning on ever actually writing any SQL and only using the built in wizards. I would prefer to work with MySQL databases because they are ubiquitous, use a “standard” syntax and very powerful. In addition most practical office use cases will involve a central database and not a local database.

Preparing Your MySQL Server

This is the part of the documentation that I find most obscure and confusing, so here is how to do it using LibreOffice 4.3 running on Ubuntu 14.04 LTS. The steps here will be slightly different depending on if you are developing on a local database or a remote database. If you are using a local MySQL database please feel free to skip this section. I do most of my database development inside of Linux Containers which essentially makes my databases “remote”. In order to allow remote connections we need to make a few changes to the default MySQL configuration. Please note that if you are doing these steps on a live production system you will need to be extra careful with users, permissions, ports that are opened, etc.. This falls outside of the scope of this tutorial but the rule of thumb is that if your database accepts connections from the outside world you should white list each IP address that will be connecting to it and block all others. The easiest way to do this in my opinion is with your firewall. By default MySQL only runs on the local host and is not accessible from remote hosts. To change this setting you need to edit the my.cnf file. 1) Open up my.cnf which is found in /etc/mysql/my.cnf 2) Find the bind-address and change if from the local host to the IP address of the server.

bind-address 10.0.1.30

3) Restart MySQL

sudo service mysql restart

Install the MySQL JDBC Driver

On Ubuntu 14.04 this is very easy and can be done by running the following command:

sudo apt-get install libmysql-java

Configure the Class Path in LibreOffice

Open up any LibreOffice App and go to Tools -> Options On the right hand side navigate to LibreOffice -> Advanced Select on the Class Path…button and load the new driver that was installed in the previous step. In order to do this you will need to select Add Archive… and select /usr/share/java/mysql.jar Once this has been loaded restart LibreOffice

Connect to your Database

Now comes the fun part. Now that we have taken care of all of the previous steps the rest is easy. To connect to your database open up LibreOffice Base.

  1. In the Database Wizard select Connect an existing database and chose the MySQL option from the dropdown menu.
  2. Select Connect using JDBC and hit next
  3. Enter the database name, server IP, port number and select next
  4. Enter the username for an existing user in your database and select next
  5. If you wish to use this database in other LibreOffice applications you should select the Yes, register the database for me radio button.
  6. Select Finish

Congratulations! Now you can rock some custom queries, fancy forms, and TSP reports using Base. We will go through how to do all of that an more in future posts.

Amtrak

I took the Amtrak train for the first time from Philadelphia down to Washington DC this weekend and I was pleasantly surprised at how awesome it was! I spent a lot of time out on the road these past few years, so I have gotten used to the many annoyances of airline travel and mass transit. The last time that I was on a non-commuter train was in Ukraine when I was very young. It was certainly a very different experience to say the least! Here are my favorite parts about Amtrak:

  • You can get your tickets on your smart phone a few minutes before the train leaves. A very stress free experience!
  • Even with a lot of people riding the train the boarding process is smooth, quick, and painless.
  • There is usually a ton of room on board.
  • The seats are big and comfy, even in coach!
  • They have a power outlet at every seat.
  • They have free wifi.

Taking the train was so much better than driving down I-95 and dealing with the traffic. It was a very relaxing and enjoyable experience. It is a shame that the train system only seems to make sense on the East Coast (and perhaps the West Coast too). For example, in Cincinnati there is only one train that comes a few times a week at around 3:00 a.m. Most people in Cincinnati do not even know that the Amtrak comes there. I am not sure if we will ever get to experience an efficient high speed rail system in the US, but I am looking forward to a few more trips up and down the East Coast!

Secure Your Self Hosted WordPress

Self hosting WordPress rocks. Unsecured websites do not rock. It does not matter how long or complicated your password is if it is being transmitted in plain text over HTTP. Luckily, it is easy to create a Self Signed certificate and use it on your website. Keep in mind that browsers become very unhappy with Self Signed Certificates and tend to yell at the user. So, if you have a lot of traffic and want your users to feel safe purchase an SSL certificate from a real Certificate Authority. In any case, at the very least you should be using a self signed SSL for all of the admin portions of your site. Here’s how to do it on Debian 7.5 running a standard LAMP stack.

  1. Create your self signed Certificate by running the following commands sequentially.
mkdir /etc/apache2/ssl  
openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/wp.pem -keyout /etc/apache2/ssl/wp.key

2.  Create a Virtual Host for your website in /etc/apache2/conf.d/yoursite.conf

<VirtualHost 1.2.3.4:443> 
SSLEngine on 
SSLCertificateFile /etc/apache2/ssl/wp.pem 
SSLCertificateKeyFile /etc/apache2/ssl/wp.key 
DocumentRoot /srv/www/yoursite.com/public_html 
  <Directory *> 
  AllowOverride All 
  order allow,deny 
  Allow from all  
  </Directory> 
</VirtualHost>
  • Change yoursite.conf to something more meaningful
  • Change 1.2.3.4 to the IP of your server, which you can obtain by running ifconfig in a terminal
  • Change the document root to your actual document root.

3.  Enable the SSL module in Apache

sudo a2enmod ssl

4.  Restart apache

sudo service apache2 restart

All set! Now, you can navigate to https://yourwebsite.com, confirm the security exception, and administer and view your WordPress site securely.

WordPress on Linode

One of my first tasks at Linode was to set up some nodebalancers. It was a good exercise, and I learned a lot. I set up redundant wordpress sites and had the nodebalancer handle all of the traffic. It is a pretty neat concept and a very useful tool! I have not used wordpress in ages and I am amazed at how far it has come in terms of features, ease of installation, usability. It is the perfect content management system. In fact, I was so inspired by how beautiful and easy WP was to set up, that I migrated my whole blog over to it. So welcome to Rev3 of my move from blogger. I loved drukkar, and would highly recommend it for a very simple blog, but I just needed something with a few more features and extras. Setting up a WP site on Linode is a breeze thanks to the handy dandy StackScripts that are available. It literally took me about 5 minutes to have a complete WP site up and running. One thing to note, is that if you do deploy using stackscripts and want to use the Permalinks feature you must do the following: 1) Update the .htaccess file to have the following content:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
RewriteRule ^index.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

2) Enable the Apache Rewrite Module :

sudo a2enmod rewrite 
sudo service apache2 restart

Your permalinks should now be working fine!  This is what I had to do using a clean StackScript install on Debian 7.5. WP makes it super easy to import other blogs, so I am going to go ahead and move everything from my blogger blog over here, and move forward from there. Hopefully no more migrations for a while.

Moving to New Jersey

There have been a lot of big changes going on in my life and I wanted to take a moment to document them all here. A few weeks ago I learned about an opening for the support team at Linode. I have been a customer and huge fan of Linode for a long time and went ahead and applied for the job. I was very pleased to have the opportunity to interview for this position, and even more pleased to have been offered it! So I am excited to announce that starting Monday, I will be an official member of the Linode Support team! It was difficult to leave my current job, and friends, and family, and pretty much everything that I had worked so hard to build over the last few years in my first attempt at a post-military civilian career. But for as long as I can remember my passion has been Linux, so having the opportunity to work with Linux every day is not something that I could have passed on in a million years. So long story short, I am packing up my stuff this weekend and moving to New Jersey! I have had the pleasure of spending the week here looking for a place to live and this is what I have found.

  • You cannot make left turns on some roads, it is kind of weird.
  • You are not allowed to fill up your own car at a gas station, also very weird.
  • It is very easy to lose a lot of money at the Casino’s in Atlantic City.
  • Despite the terrible reputation that NJ has, the people here are pretty nice and the state as a whole is absolutely beautiful.

I am going to be living in Absecon which is just minutes from the ocean! I am really excited to explore the area more and report back what I find here. My biggest concern at the moment is finding a Linux User Group,  it looks like there are a bunch of defunct ones in New Jersey, and a couple of pretty active ones in Philadelphia which is just about an hour away. If you know of any LUG’s in South Jersey, or if you want to start one with me, let me know!

Fake Web IDE with External Tools in Gedit

Gedit is my favorite text editor. I like that it is fast, reliable, cross platform, and has a ton of useful plugins and features. I am currently using it to work with LaTeX and unless I am working on a huge project, I will typically use gedit for all of my development work, specifically when it comes to web development. I use a lot of the plugins in gedit, but I have never used the External Tools plugin before. External tools is a very useful plugin because it allows you to do pretty much anything. The reason why I wanted to use it in the first place was to find a way to quickly launch HTML files that I was currently working on in a web browser, while also saving all of the changes to other HTML/CSS/JavaScript files that were related and currently opened in gedit. This is essentially what an IDE would do when you hit Run. In the past, I would just save all of my document and find the file in Nautilus to launch it. The problem with this approach is that I have an obsessive need to organize all of my projects into obscure and seemingly endless file paths. This can make it pretty difficult to find the file that I am looking for. The External Tools plugin solves all of these issues in a very elegant and simple way. So, without further ado, here is how you make a fake Web Development IDE in Gedit using External Tools.

  1. Enable External Tools: Edit –> Preferences –> Plugins
  2. Create a New External Tool: Tools -> Manage External Tools -> Hit the Plus sign
  3. Name the tool whatever you would like
  4. Assign it a shortcut key (optional)
  5. Set the following options on the bottom right
    • Save: All Documents
    • Input: Current Document
    • Output: None
    • Applicability: All Documents
  6. In the script editor, enter the following short script. This script will open the current document in your default web browser.
    #!/bin/sh x-www-browser $GEDIT_CURRENT_DOCUMENT_PATH 
  7. Close, and you are done!

You should now be able to use whichever shortcut you created to save all documents that you are working on, and open the current document in a web browser. This makes debugging much easier for web applications, and makes gedit a perfect lightweight web IDE.

If you have some handy tips and tricks for gedit custom tools, please share in the comments below!