Showing posts with label work. Show all posts
Showing posts with label work. Show all posts

Monday, July 02, 2012

Sync Sublime Between Multiple Macs

I’ve been using Sublime Text 2 since way, way back when it was just starting to be developed. I’ve used it since and still love it. It’s light, fast and extensible. However, something that I wanted was the ability to have it in sync between my two Macs. I know, first world problem, but something I wanted a solution to nonetheless. I have an iMac at home and a MacBook Air that I use at the office, when I’m not working remotely from my home office. Using Dropbox I was able to easily accomplish this. Please note that this is for Mac OS X, and should also work on Linux, but probably not on Windows (possible solution here)

Install Sublime Text 2

This should be obvious, but if you haven’t installed Sublime Text 2 already, you’ll want to do this first. You can grab your copy here and I’d encourage you to purchase a license to support the developer.

Install Dropbox

I’m using Dropbox to keep my settings, packages and other supporting files in sync between my two Macs. Now I’m sure you have Dropbox already, but if you’re the 1 person left on the planet that doesn’t, then please use this link so that both you and I receive an extra 500MB free for our accounts.

You’ll want to make sure you have Dropbox installed on all of the Mac’s you’ll want to have your settings in sync.

Setup Sync on First System

Here are the steps I took to setup the sync. I did this on my iMac desktop first, then my MacBook Air second (shouldn’t matter which one you do first, just one at a time). Note that this requires you to use the Mac OS X Terminal, or the excellent iTerm2.

  1. Quit Sublime Text 2 if it’s running
  2. Open the Terminal or iTerm2
  3. Change to your Dropbox folder
    cd ~/Dropbox
    
  4. I recommend creating a new folder for Sublime Text 2 to organize everything. I created one for the Application Support folder and one for the Preferences file. This is what I did, but you can use a different path if you want:
    mkdir -p ~/Dropbox/Applications/Sublime\ Text\ 2/Application\ Support
    mkdir -p ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences
    
  5. Now we move your current Preferences file to the new Dropbox folder
    mv ~/Library/Preferences/com.sublimetext.2.plist ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences/
    mv ~/Library/Preferences/com.sublimetext.2.plist.lockfile ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences/
    
  6. Now we need to create a symlink for each of those files. The symlink will be in the ~/Library/Preferences folder where Sublime Text 2 looks for the Preferences file, and will point to the actual copy that’s stored in your Dropbox folder
    ln -s ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences/com.sublimetext.2.plist ~/Library/Preferences/com.sublimetext.2.plist
    ln -s ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences/com.sublimetext.2.plist.lockfile ~/Library/Preferences/com.sublimetext.2.plist.lockfile
    
  7. As you probably guessed, we need to do the same thing with the Application Support folder, move it then symlink it.
    mv ~/Library/Application\ Support/Sublime\ Text\ 2 ~/Dropbox/Applications/Sublime\ Text\ 2/Application\ Support/
    ln -s ~/Dropbox/Applications/Sublime\ Text\ 2/Application\ Support/Sublime\ Text\ 2 ~/Library/Application\ Support/Sublime\ Text\ 2
    

At this point your first computer should be setup to use the Preferences file and Application Support folder (contains your packages, key-bindings, etc) stored in your Dropbox. Go ahead and launch Sublime Text 2, it should open just like before, nothing should be different.

Setup Sync on Second System

Now go to your second system. Install Dropbox if you haven’t already, At this point it’s important to wait for Dropbox to finish it’s sync. If you haven’t already installed Sublime Text 2, go ahead and do that as well, but don’t launch it.

Now let’s setup this second computer to point to the Dropbox versions of the Preference file and Application Support folder.

  1. Quit Sublime Text 2 if it’s running
  2. Open the Terminal or iTerm2
  3. Change to your Dropbox folder
    cd ~/Dropbox
    
  4. If you’ve run Sublime Text 2 on this second computer before, we’ll rename the current Preference file and Application Support folder so that these are saved, but not used. If you’ve never run Sublime Text 2 on this second computer, skip to the numbered step
    mv ~/Library/Preferences/com.sublimetext.2.plist ~/Library/Preferences/old-com.sublimetext.2.plist
    mv ~/Library/Preferences/com.sublimetext.2.plist.lockfile ~/Library/Preferences/old-com.sublimetext.2.plist.lockfile
    mv ~/Library/Application\ Support/Sublime\ Text\ 2 ~/Library/Application\ Support/Old\ Sublime\ Text\ 2
    
  5. Now let’s setup the symlink for the Preference file
    ln -s ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences/com.sublimetext.2.plist ~/Library/Preferences/com.sublimetext.2.plist
    ln -s ~/Dropbox/Applications/Sublime\ Text\ 2/Preferences/com.sublimetext.2.plist.lockfile ~/Library/Preferences/com.sublimetext.2.plist.lockfile
    
  6. Then the Application Support folder
    ln -s ~/Dropbox/Applications/Sublime\ Text\ 2/Application\ Support/Sublime\ Text\ 2 ~/Library/Application\ Support/Sublime\ Text\ 2
    

At this point you should be able to launch Sublime Text 2 on the second computer and have all of your same Preferences, packages and key-bindings setup and installed. Note that I haven’t run Sublime Text 2 on both computers at the same time, so I can’t comment on what this may or may not do.

Displaying PDF Form Fields Using iText and ColdFusion

One of my most recently developed web application is a new health care system for a number of laborites that perform various testing. The initial workflow has the central office receiving the lab test order and sample, entering it into the system, and then sending the sample and five or six (depending on the test ordered) worksheets along to the lab techs. Currently the worksheets that have to be completed are a variety of MS Excel, MS Word and an Adobe PDF file. This can take anywhere between 3 to 8 minutes to complete, depending on which forms are needed and what information is available on the test order. They asked for an easier way to do this.

I decided to explore generating a single PDF file that would be generated after the test order is entered in the system. The fields on the various documents that normally the administrative staff have to fill in would be populated by the web application. Normally this would be easy to do using cfpdfform, however for this project we’re using Railo instead of Adobe ColdFusion and the cfpdfform tag isn’t available. I was hoping that Railo 4 would include this tag as a feature, but there was no mention of it being included at cf.Objective() 2012 by the Railo team when I asked. I’ve asked on the Railo list twice, initially they said yes but most recently they haven’t responded. Therefore I needed to find an alternative solution, which I did, and here’s what I ended up doing.

Create a single Adobe Acrobat PDF Form

The first step was to use Adobe Acrobat Professional to combine the MS Excel, MS Word and Adobe PDF files into a single PDF file. The next step was to create the form fields within the PDF for the web application to populate from the database. Since every page had a “name” field, we just made that field name the same on each page.

Get iText

iText is a Java component that is designed to work with PDF files. It can create, read and update PDF files. The technical documentation on the website is pretty thin, they really encourage you to buy a copy of their “iText in Action” book. I’d have no problem with this, but they don’t currently offer a Kindle version yet so I’m holding off on that. I did find the API documentation is available online that you can use, and they do have the samples from the book available for download that may help.

Download the iText PDF community version from here. I decompressed these files and placed them in the same directory as I had my Railo JAR files, then I restarted Apache Tomcat. I’m pretty sure I could put these in my ColdFusion on Wheels application directory /lib directory and load them using the javaLoader for CFWheels, but I haven’t tried it yet.

CFDump the form fields

The next thing I wanted to do was to dump the form fields from the PDF file to make sure I was able to read the file correctly. I placed the single PDF file that we had created with all of the form fields with my ColdFusion on Wheels application directory. I then created a CFML page and used the following code to dump the form fields that are found within the entire file.


readPDF = expandpath("the_file_name_here.pdf");
writePDF = expandpath("#createUUID()#.pdf");
fileIO = createObject("java","java.io.FileOutputStream").init(writePDF);
reader = createObject("java","com.itextpdf.text.pdf.PdfReader").init(readPDF);
stamper = createObject("java","com.itextpdf.text.pdf.PdfStamper").init(reader, fileIO);
pdfForm = stamper.getAcroFields();


This dumped out a list of all of the form fields within the PDF so I can make sure that iText was able to read them, and that I spelled them correctly.

Populate the Form Fields

The next step was to populate these fields with data from my database. I also wanted to display this PDF in the users browser. I was able to to this pretty much as I did above, but just with a minor changes.


readPDF = expandpath("the_file_name_here.pdf");
writePDF = expandpath("#createUUID()#.pdf");
fileIO = createObject("java","java.io.FileOutputStream").init(writePDF);
reader = createObject("java","com.itextpdf.text.pdf.PdfReader").init(readPDF);
stamper = createObject("java","com.itextpdf.text.pdf.PdfStamper").init(reader, fileIO);
pdfForm.setField("date_sample_collected", "#date_sample_collected#");
pdfForm.setField("patient_name", "#patient_name#");
pdfForm.setField("date_of_birth", "#date_of_birth#");
pdfForm.setField("order_number", "#order_number#");
stamper.setFormFlattening(true);
stamper.close();
reader.close();
fileIO.close();


Summary

Using this code I was able to satisfy the initial request that the administrative staff, to save them from creating these additional forms manually with the data they had just entered into the web application.

I know I can make this better though, since not every page of that PDF is needed, it depends on the test selected. I plan to re-factor this application code in the future to to determine which test was selected, then only grab those worksheets. This means I’ll need to separate each of the worksheets out into a separate PDF file, then stitch them together, depending on what the user has entered for the order, into a single file.

Thanks To

Thanks to this cfSearching blog post that helped, as well as rip747’s Stackoverflow posting that helped me complete this task.

Wednesday, April 11, 2012

Installing activerecord-sqlserver-adapter on Mac OS X Lion

I’m on Mac OS X 10.7.3 “Lion” and want to develop a Ruby on Rails 3.2.2 application using a MS SQL Server 2008 database. To do this I needed to install the activerecord-sqlserver-adapter which requires TinyTDS. While the gem install activerecord-sqlserver-adapter worked fine, the gem install tiny_tds failed to compile. It required a freetds component.

This took me a while and I ended up having to install Homebrew to get it to work. Here are the steps I took to get this working, hopefully it’ll save others the hour or so I spent trying to get it working.

  1. Install Homebrew Package Manager by using these instructions
  2. Install the FreeTDS component
    brew install freetds
  3. Install the TinyTDS gem
    gem install tiny_tds -- --with-freetds-include=/usr/local/include --with-freetds-lib=/usr/local/lib --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
  4. Now install the SQL Server ActiveRecord gem
    gem install activerecord-sqlserver-adapter

You’ll need to then setup your database.yml file accordingly:

development:
  adapter: sqlserver
  host: 10.1.1.100
  database: mydb
  usernane: user
  password: s3cr3t
  

Tuesday, March 13, 2012

Incorrect string value: ‘\xCE\x94F508…’ for column ‘value’ at row 1

Problem

Last week I was working on importing data from a vendors database into our database and for, what seemed like, random records I’d receive the error message above. Upon further inspection it turned out that the records that weren’t able to be inserted had special characters, like 'Diagnostic, ΔF508 and R117H with 5T/9T'. I knew I had set our MySQL database to use UTF-8 for the collation of the server by default, I’d even posted about it here.

I was able to resolve this, but first just a little background.

Solution

After researching this and even exporting and importing my database, I found that my tables were being created specifically using the latin1 character set. I was able to determine this when I did MySQL dump of my database and examined the CREATE TABLE syntax, as shown below:

DROP TABLE IF EXISTS `addresstypes`; 
CREATE TABLE `addresstypes` 
( `id` int(11) NOT NULL AUTO_INCREMENT, 
`text` varchar(255) DEFAULT '', 
`createdat` datetime DEFAULT NULL, 
`updatedat` datetime DEFAULT NULL, 
`deletedat` datetime DEFAULT NULL, 
`createdby` varchar(25) DEFAULT NULL, 
`updatedby` varchar(25) DEFAULT NULL, 
`deletedby` varchar(25) DEFAULT NULL, 
`rixid` varchar(255) DEFAULT NULL, 
PRIMARY KEY (`id`) 
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

I found three ways to correct this. Here are the first two ways as I found at this blog post.

Single Table

Use the following SQL code block and replace the “database_name” and “table_name” values with your actual database name and table name:

ALTER TABLE `database_name`.`table_name` 
CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

Multiple Tables

Use the following SQL code block and replace the “database_name” with your actual database name:

SELECT CONCAT('ALTER TABLE `', t.`TABLE_SCHEMA`, '`.`', t.`TABLE_NAME`, '` 
CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;') as stmt 
FROM `information_schema`.`TABLES` t 
WHERE 1 AND t.`TABLE_SCHEMA` = 'database_name' ORDER BY 1

I also found that if I performed a MySQL dump of the database, then replaced the latin1 character set command with utf8, deleted the database and then re-imported it this resolved the issue as well.

Use the following code block and replace the “database_name” with your actual database name. You’ll also need to DROP or DELETE the database after you do the MySQL dump in the first step:

mysqldump -u root -p database_name > database_name.sql 
sed 's/utf8_bin/utf8_unicode_ci/' database_name.sql > database_name_fix.sql 
sed 's/CHARSET=latin1;/CHARSET=utf8;/' database_name_fix.sql > database_name.sql 
mysql -u root -p database_name < database_name.sql

Interesting Note

Interestingly if I copied and pasted the SQL INSERT syntax into the MySQL command-line, before I changed the tables to be UTF-8, the command was successful at inserting the data.

Update: MySQL 5.5.3+ Server Options

These options have changed in MySQL 5.5.3 and newer, in particular the "default-collation" and "default-character-set" server options have been deprecated. Instead, the following server options replace these "collation-server" and "character-set-server"

Thursday, January 05, 2012

Updated Twitter Bootstrap OmniGraffle Stencil

I updated my Twitter Bootstrap CSS ToolKit OmniGraffle stencil with a number of changes.

  • Complete replaced the tables
  • Added helper text below form fields
  • Added a stacked-form section
  • Added a radio button control
  • Made sure all form labels are right-aligned
  • Set all stacked-form labels are left-aligned
  • Added a date range control
  • Increased the size of the textarea
  • Resized the navigation bar to be 940px wide
  • Grouped the pagination control

You can grab the stencil now from my GitHub repo, along with directions on how to update to the latest stencil if you're using the previous version.

Friday, December 16, 2011

Twitter Bootstrap Omnigraffle Stencil

I often use the Twitter Bootstrap CSS ToolKit for my web applications.  While this toolkit helps to make things quickly look great, I wanted to be able to use it in OmniGraffle.  I found a few Photoshop files that had the elements, but none for OmniGraffle, so I decided to try creating one.  This is my first OmniGraffle stencil, but I'm pretty proud of how well it came out.  Thanks to the OmniGroup for such a great product.

You can grab the stencil now from my GitHub repo.

I've submitted the stencil to Graffletopia, but still waiting for their review and approval.

Semantic Versioning

I really like this suggestion on software version formatting and incrementing taken from http://semver.org/
Consider a version format of X.Y.Z (Major.Minor.Patch). Bug fixes not affecting the API increment the patch version, backwards compatible API additions/changes increment the minor version, and backwards incompatible API changes increment the major version.

Sunday, December 11, 2011

Beating the Flying Spaghetti Code Monster with CFWheels - Part 2

Beating the Spaghetti Code Monster

Recap

As I mentioned in part 1 of this post, when I started writing web applications with ColdFusion I quickly amassed a large collection of autonomous files that would often break if I changed a variable or parameter that should be passed into the next. Adding or removing a column to a form / database table could take 25 minutes to update all of the SQL files. I had become enslaved to the “Flying Spaghetti Code Monster”, as I like to call it, and knew there was a better way and wanted to find it.

The Application

As I also mentioned in part 1, I had been re-hired to maintain and update a web application I wrote 7 years prior. This application had well over 350 individual files and the folder size was near 80MB. Although I had started to use the Fusebox framework, which helped start to organize my files, I didn’t follow-through on converting everything to Fusebox. This meant that my directory structure looked something like this
Spaghetti Code Directories

Conversion

As also mentioned in part 1 of this post that I decided to slowly convert the application to the Coldfusion on Wheels framework. I decided to do this cutting off one “tenticle” at a time, or one section/feature at a time.
First I identified a small section of the application that I could replace with the CFWheels framework. I selected one of the “system options” that allows users to add new values to a drop-down list of patient types. The code for this was located off the root of my application in a /system folder along 15 other similiar system options that were almost identifcal. I also needed a place to put my CFWheels core files.
I decided to put the CFWheels framework files in a directory named “hla”, which is the web application name as referred to by the staff, under the /system folder, so /system/hla/
CFWheels framework location
I setup my database connection info in the /conf/settings.cfm file so that my database connection would be the same as the spaghetti code portion. Next, I didn’t want to have two sets of Javascript, CSS or other asset files like images, so I had to modify my CFWheels layout.cfm file to reference the ones that the spaghetti code files were using.
layout.cfm
At this point I could browse to the CFWheels portion, by manually entering the URL, and receive the default CFWheels welcome page. I then added a new entry on my system options menu to point to the new CFWheels location where the system option I was going to convert would live.
At this point I created a model file, Patiettype.cfc, and in the init function I added code to specify my database table names that didn’t follow the Wheels convention, but were used by the Spaghetti Code application
<cfset table("tbl_authors")>
Next I followed with each database table column as a property, using the current database column name for the column attribute but a CFWheels convention name for the name attribute, as outlined in the CFWheels documentation.
<cfset property(name="firstName", column="tbl_auth_f_name")>
These system options required that I setup some associations, and this was a great place to learn about that as I’d need it for every other part of the application.
At this point I could follow the CFWheels conventions and develop the CRUD for the Patienttype just like I would a brand new CFWheels app. After I have the CRUD working for this system option, I’d then remove the link to the old files and leave just the new one. Then I’d have the users work with that section for about a week. Once we were sure everything worked correctly, I’d slowly remove the old files (that I now had in Git version control).
Using this same method I slowly worked through all of the 16 system options, as if cutting off one “tenticle” of the Spaghetti Monster at a time. After I finished with those small, simple CRUD actions, I moved onto more complicated sections. The whole Contacts portion, then Hospitals portion, etc.

Progress

I found the Coldfusion on Wheels framework in February 2011, then started implementing it in March 2011, working part-time and slowly through each of the tenticles I mentioned. If new features were requested, or something needed to be changed, I fought the urge to do a “quick and easy” one or two file solution and forced myself to do it the CFWheels way. At first this was challenging, but once I got use to it, the changes happened faster.
At this point, December 2011, I’ve removed at least 23 of these “tenticles” with two medium sized tenticles and one large tenticle left to remove from the monster. I’m excited to finish these sections off and sever the head of this monster once and for all. In hindsight I’m glad I started with smaller tenticles as it allowed me to learn CFWheels with smaller sections of code, but also to find “gotchas” early on.

Gotchas

One of the things I didn’t expect was the Spaghetti Monsters session scope being overwritten when I moved went to a CFWheels framework page. This made it a little tricky because I’d use the session scope to retain the currently logged in user ID and if they were a valid user or not (to prevent unauthorized access). After I’d leave a CFWheels page and go back to the Spaghetti Monster code I’d be kicked out of my application. My “fix” for this, at least for the time being, was to use client variables for the Spaghetti code portion of the application and session variables for the CFWheels portion of the application.
The next thing I ran into, since my session scope was being overwritten, was once I moved to a CFWheels portion of the application I’d didn’t have my session variable with the user ID from the Spaghetti Monster code. To fix this I added an obtuse URL variable on the menu links in the Spaghetti Monster code that CFWheels would then use to identify the user and create the session scope variables I wanted.

Summary

I feel converting this application to the CFWheels framework has helped with the following:
  1. Brought some sanity back to how this application is structured and maintained (huge benefit)
  2. Saved gobs of time not having to maintain query files with endless CFIF statements and cfqueryparam tags (CFWheels ORM does that all for me, huge benefit)
  3. Made the application run faster, I mean noticably faster to my users
  4. Decreased the code folder from 80MB to 33MB
  5. Allows me to add new features or make changes in less time then before because things break less when changes are made
  6. Allows anyone that knows about the MVC pattern to help or take over this application
  7. Made Coldfusion programming fun again (most important of course)
While converting this application from the Spaghetti code to the CFWheels framework from “the inside out” has been a slow process (because of my, not the framework), I don’t regret doing it at all for the reasons stated above. It’s been a great way to learn CFWheels and to work with the CFWheels community. At this point I can’t imagine developing Coldfusion applications without using the CFWheels framework.

Thursday, December 01, 2011

Beating the Flying Spaghetti Code Monster with CFWheels - Part 1

Flying Spaghetti Code Monster

Background

I started writing web application using Coldfusion in 2000 with version 4.5. Like probably most of us back in those early days, we had one hand on the keyboard and a copy of Ben Forta’s Web Application Contrution Kit (WACK) in the other. My development of applications consisted of creating a single autonomous file, with both database queries and conditional display code. This of course was tied to yet another autonomous which did the same, etc, etc, etc. Thus the “Flying Spaghetti Code Monster” Even after I started to use the Application.cfm “framework” within ColdFusion, I still had all of these autonomous files that would often break if I changed a variable or parameter that should be passed into the next.
After developing a few applications like this I realized there had to be a better way. Somehow I came across the Fusebox 2 framework and started to look into it. This framework encouraged you to break the application up into separate files, query file, action file, display file, and then “chain” these together like fuses in an electrical circuit.
Shortly after Fusebox version 3 was released and I begin using this framework to develop my applications. I especially loved the formurl2attributes function that put all of your url and form variables into a single scope. I started to convert small pieces of my existing applications from my spaghetti code to organized code following the Fusebox methodology, however I ended up sticking more with the file naming then actually using the framework after a while. When Fusebox version 4 was released I found it difficult to grasp, as well as the CFC concept that was brand new. My two and a half years of part-time web application programming was coming to a close though as I left to work full-time as a systems administrator.
Over the next 7 years the largest of the web applications I wrote, a Laboratory Information System (LIS), continued to work for the University lab I wrote it for with minimal adjustments to it.

Back to Developing

At the end of those 7 years I was hired back, part-time, for this same lab, and part-time for another lab (so it’s a full-time position) on campus. When I looked at this old source code I saw the “Flying Spaghetti Code Monster” glaring back at me. I had well over 350 individual files and the folder size was near 80MB, not to mention no source control software to help manage it. I knew there had to be a better way to handle this, I didn’t want to continue to develop this way.
The first thing I did was get the software into a source control system. Subversion was the choice as it was the easiest for me to grasp initially. I went back to look at the Fusebox framework and saw it was still around, but it didn’t seem like many were using it any longer. There was the Mach-II framework, but I couldn’t seem to understand that either. In the meantime I continued to serve the hard master known as the “Flying Spaghetti Code Monster” and maintain the code as it was, even adding new features, without much difference in my development pattern.
After five months of developing this way I came across the ColdFusion on Wheels framework website, not sure how (probably Twitter). After greedily consuming all of the available screencasts I knew this was the way I needed to develop the application. The question was, how do I learn the CFWheels framework and use it to power this application? I saw two choices:
  1. start from scratch in a parallel environment using CFWheels and recreate all of the functionality
  2. slowly, one “tenticle” at a time, battle the “Flying Spaghetti Code Monster” by converting a section to the CFWheels framework
After considering it I decided choice 2 was for me, to slowly convert the application. In the following post I’ll explain how I’m doing this.

Thursday, October 27, 2011

Astaro “ICMP Destination unreachable (Fragmentation needed)” Problems

Problem:

Twice now my Astaro Security Gateway VMWare Virtual Appliance performance has dramatically decreased any traffic through and reports “ICMP x.x.x.x unreachable - need to frag (mtu 1500)”

Solution:

Change your VMWare virtual appliance network adapters from the pre-configured “Flexible” to “E1000” by editing the .vmx file.

Description:

I have four virtual machines that run on VMWare ESX 4. One of these VM’s is the ASG virtual appliance connected to a public (Internet) interface and a private (virtual network) interface. Each of the remaining three systems are connected to the private virtual network as well. One is a web server, another a database server.

Using a DNAT rule I make my web server accessible to external (Internet) users. Using the SSL VPN I made my database server accessible to internal (company) users.

For some reason, and after performing very well for months, the ASG starts exhibitng awful performance is passing the traffic back and forth. Web pages that external users try to access rarely display and more often timeout. (Interesting note is that Windows clients seems to timeout 93% but Mac clients display the web page, after a few extra seconds, 99% of the time).

Users connected via SSL VPN and accessing the database server also see horrible performance as well. If I do a SCP of a 3MB file from the database server to my laptop over the SSL VPN it transfers in 30 seconds. However uploading this same 3MB file from my laptop to the database server requires a transfer time of 12 minutes!

The ASG stats show very little load on the system during these transfers:

CPU: 4%
RAM: 31%
Swap: 1%
Log disk: 2%
Data disk: 5%

Using SSH on the Astaro I run a tcpdump to see what’s going on. I’m able to narrow it down by using:

tcpdump -ni any -s0 -v -f 'icmp[icmptype] == 3 and icmp[icmpcode] == 4'

After shutting down the ASG virtual appliance, then changing the network adapter type to “E1000” and restarting the ASG virtual appliance the problem vanishes.

Astaro Support Rant

At this point I just want to rant a little about Astaro Support. I’ve been working with Astaro products since 2005 and really, really like them. They’ve always been, in my opinion, an EXCELLENT value for the feature set you receive and the price that you pay, just excellent.

In those 6 years I’ve worked with Astaro products (6 different Astaro product installs) I’ve had to contact their support about 10 times, which I don’t think is bad. In almost all cases the support follow-up, communication and technical ability of the engineers has really been excellent.

However, in the past four months I’ve had to contact Astaro three times. In each instance the response and communication was pathetic, meaning that I either didn’t hear anything from Astaro or I had to call them to get any response.

In another instance I opened a ticket on July 6th, received a response back on that same day with some comments on the case, exchanged a few more emails on the 6th and 7th, then I didn’t receive another response until July 15th!

I called Astaro support again and spoke to a gentlemen that said all of the engineers were in a meeting and weren’t available.  He said he would note the case and leave a note on the engineers desk to have him call me back after the meeting.  I didn’t receive a phone call that day before I left at 5:40pm nor later then evening although I had my work phone forwarded to my cell expecting the call.

The next day, Thursday, I called again.  I spoke to the same gentlemen that wasn’t sure why the engineer hadn’t contacted me.  He said the engineer wouldn’t arrive until later today, as he does west coast support, and would contact me by 1:00pm.  Again he said he would note the case, leave a note for the engineer on his desk and would ask him directly to contact me.  I never received another call from the engineer.

After sending off an email to the sales rep and the support manager I was finally able to get someone’s attention and later the following day a new engineer was assigned to my case.

This instance has damaged my faith in Astaro support. I’m not sure if this has anything to do with Sophos aquiring Astaro, but it sure seems like since then the support has plummeted.

I’ll continue to use Astaro for my existing projects, however the next new project that comes along will have me looking for a competing device to try.

Thursday, October 20, 2011

MySQL won’t start after Ubuntu 11.10 upgrade

I upgrade my Ubuntu database server from 10.10 to 11.04 to 11.10 and suddenly my MySQL Server stopped responding.

Turned out the problem was that I didn’t accept one of the new apparmor configurations since it looked minimal and I had customized mine. Because of this my /var/log/mysql/error.log was filled with the following:

111020 17:31:44 [Note] Plugin 'FEDERATED' is disabled.
111020 17:31:44  InnoDB: Initializing buffer pool, size = 896.0M
111020 17:31:44  InnoDB: Completed initialization of buffer pool
111020 17:31:44  InnoDB: Started; log sequence number 0 172373406
111020 17:31:44 [ERROR] Can't start server : Bind on unix socket: Permission denied
111020 17:31:44 [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ?
111020 17:31:44 [ERROR] Aborting

I had to edit the app armor file for MySQL

sudo nano /etc/apparmor.d/usr.sbin.mysqld

changed

  /run/mysqld/mysqld.pid w,
  /run/mysqld/mysqld.sock w,

to

  /{,var/}run/mysqld/mysqld.pid w,
  /{,var/}run/mysqld/mysqld.sock w,

Wednesday, October 12, 2011

Changing Fonts in Sublime Text 2

I’ve been using the Sublime Text 2 app for this past week and really like it. One of the things I wanted to change though was the font used in the editor. A font I’ve liked in the past was Consolas but I couldn’t find that. I did find one named Inconsolata, which is almost identical from what I can tell, on Google Web Fonts. Here’s how I set everything up on my Mac

Get the font(s)

  • Head over to Google Web Fonts and search for “Inconsolata”, or any other font that you like (other suggestions are Ubuntu Mono or Varela Round)
  • Click the “Add to Collection” button to the far right of the font name
  • Click the “Download your Collection” link on the top-right.
  • Click the “Download the font families in your Collection as a zip-file” link on the pop-up dialog
  • Open the zip-file that’s downloaded
  • Double-click on each .ttf file
  • Select to “Install Font”

Configure Sublime Text 2

  • Open Sublime Text 2
  • Click on the “Sublime Text 2” application menu
  • Select “Preferences”
  • Select “File Settings - User”
  • In the file that opens, add the following line along with the name of the font you installed:
    "font_face": "Varela Round"
    Be sure to include a comma “,” if you’re adding this to a line already within the file, like a color scheme selection.

You can also change the font size using the following:

"font_size": 16
Notice that the number for the font size isn’t in quotes. Once you save the file you should see the results immediately as the configuration file you’re working in is redrawn using your selections.

Here’s my current complete configuration file

{
    "color_scheme": "Packages/Color Scheme - Default/Indy Merbivore Soft.tmTheme",
    "font_face": "Varela Round",
    "font_size": 16
}

Three New Sublime Text 2 Features

Here are three new Sublime Text 2 features that I learned today, thanks to this article at Net tuts+, that I feel really put it high on my list for a ColdFusion editor.

  • Function Crawling - while working within a CFC I press Command + R on my Mac and I now have a list all of functions within that component with my cursor focused in this box. I start typing the function and press enter to quickly jump to it. Awesome!
  • Command Palette - while working within a CFML page I press Shift + Command + P to have the entire list of snippets (i.e. cfml tags and functions) that I can start typing to find and press enter (sometimes I forget the exact name so this really helps).
  • Lightning-Fast File Switching - while working in a file I press Command + P and now have a list of the files with in the project I’m working in. I start typing the file to have it opened for me, I don’t even have to press Enter

Using Sublime Text 2 as ColdFusion Editor

I’ve tried a lot of different editors for writing my ColdFusion code, but never found one that really worked well for me until now. Now I think I’ve found the one that works best for me, Sublime Text 2.

In the past I’ve tried:

  • Coda by Panic = does a really good job with handling the auto-completion of quotes and parenthesis. Has tabs for multiple file editing and does CSS, has a web preview and a Terminal tab. It’s a Panic app, which has a tradition of working really well. However I started to run into these I’d really like, like code folding, easier code colouring and speed seemed to decrease with each release. Coda 2 is “in the works”, but no one really knows when it’ll show up.
  • CFEclipse = I like how extensible the Eclipse platform is, it’s much more of a Integrated Developer Environment (IDE) then Coda. With extensions like Subclipse (Subversion), eGit (GIT) and Mylyn, it can be a pretty sweet tool. However like any Eclipse based environment that I’ve used it suffers two serious problems that over-time frustrate me. It seems to get slower and slower, and the way that it auto-completes of quotes and parenthesis easliy gets confused.
  • ColdFusion Builder 2 = same as CFEclipse, except it costs money to run slow, and if I’m correct in what I’ve found, only runs in 32-bit mode and not 64-bit mode in Mac OS X.
  • TextMate = from what I’ve read this application is pretty “long in the tooth”, but it seems to have a good sized and very faithful following. There is a ColdFusion bundle available. It’s very fast, you can define projects to see all of the code in your directories and has tabs. It works very well with the auto-completes of quotes and parenthesis. TextMate charges for a license, which I paid, but I just had a hard time getting into how to use it and didn’t find much in the way of documentation or screencasts that explained it well to me.

Sublime Text 2

I’ve been using a beta copy of the Sublime Text 2 editor for the Mac and really like it so far. Some of the key things I like about it after a week are:

  • It’s fast
  • Auto-completes the use of quotes and parenthesis correctly.
  • Good code syntax colouring, that can be modified, although I’m using the “Merbivore Soft” theme by Indynagpal.
  • Can open a folder so I can see multiple files at once
  • For file contents that are taller then the screen, a “code overview” of sorts displays on the right to quickly jump to another locatio in the file.
  • Code-folding
  • Tabbed interface for files, and interestingly when you click on a file it will show the contents but not open it as a tab unless you start to edit the file or double-click on it, great for a “quick peek” of the contents!

As I work with Sublime Text 2 more, and as it evolves from it’s beta form, I’ll post more on how I’m using it and what I find benefical.

Tuesday, October 04, 2011

Force Internet Explorer 8 Not To use “Quirks” Mode

I’ve been using the excellent BluePrint CSS framework for a new web application I’m developing. It does a great job and making the site look very good, and consistent, on almost all browsers except Internet Explorer (I know, huge surprise).

In my particular case I have users that are forced to use Internet Explorer 8.0 as their browser. With the configuration that’s set by default for them, Compatibility View is enabled because the University Enterprise Business software doesn’t display correclty on modern browsers or recent versions, meaning anything newer then Firefox 3.6 or Internet Explorer 6.0.

To compound the annoyance, Internet Explorer Compatibility View can’t be set for one particular site only, it assumes that all pages under the domain also need it and forces this as well with no option to only use or exclude a subdomain.

When Internet Explorer 8.0 uses Compatiblity View, it renders the webpage as Internet Explorer 7.0 and earlier would, also called “quirks” mode, which doesn’t display correctly with BluePrint CSS or other web-standard layouts. I found that I can add HTML code to force Internet Explorer not to use Compatibility View on my web application. Not using Compatibility View uses the newer rendering engine that does a slightly better job with the newer HTML standards.

To do this, add the following to your HTML header:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">

Installing VMware Tools for Ubuntu 10.04+

Update your system to the latest packages

This updates your system with the catalog of the latest packages available, then upgrades any packages on your system that may have updates available.

sudo apt-get update -y
sudo apt-get dist-upgrade -y

Install the dynamic kernel modules

These modules will allow you to dymanically load modules with the kernel. I’m of the understanding that this prevents you from having to re-install the VMware Tools everytime the Linux kernel is updated.

sudo apt-get install dkms -y

Install VMware Tools

First you’ll need to initiate the VMware Tools install from the VMware Host system. This can usually be found on a “Tools –> VMware Tools Install” like menu.

Next we install the Linux build commands that are needed to compile the kernel with the VMware Tools extensions. This also requires the correct Linux headers for our system, which are determined using a system variable. Then we remove any packages that are no longer used (generally none, but just to be sure).

Finally we install the VMware Tools by doing the following:

  1. Create a directory to mount the tools CD-ROM to
  2. Mount the CD-ROM to the directory
  3. Copy the tools archive to the temporary directory on the system
  4. Unmount the CD-ROM
  5. Change to the temporary directory
  6. Extract the archive of the VMware Tools
  7. Change to the VMware Tools extraction directory
  8. Execute the VMware Tools installer script and indicate to use the defaults for all choices during the installation
sudo apt-get install build-essential gcc -y
sudo apt-get install linux-headers-$(uname -r) -y
sudo apt-get autoremove -y
sudo mkdir -p /media/cdrom
sudo mount /dev/cdrom /media/cdrom
cp /media/cdrom/VM* /tmp
sudo umount /media/cdrom
cd /tmp
tar -xzvf VMware*.gz
cd vmware-tools-distrib/
sudo ./vmware-install.pl -d

Restart the system

Last we want to restart the system for all of the changes to take affect.

sudo shutdown -r now

Monday, October 03, 2011

Lion Mail Crashes When Searching

I’ve had a very frustrating problem with searching in Mac OS X 10.7 “Lion” Mail app since I upgraded. After installing Lion after release, searching in Mail using the keywords like “subject:” and “from:” weren’t being honored and the search results weren’t correct. I was able to resolve this by one of the Apple engineers pointing me towards a bad index and rebuilding my mailbox indexes. This resolved that issue.

After that I started to see a problem where randomly when I’d type anything into the Mail search field the app would freeze, then crash. I was able to do the searches through Spotlight with the keywords, but it was kind of annoying. This became a consistent, reproducable problem after Mac OS X 10.7.1 was installed.

Earlier today I was able to talk again with one of the Apple engineers and he pointed me towards a corruption problem with the “Previous Recipients” list in Mail. Sure enough when I’d try “Window -> Previous Recipients” the window wouldn’t show, and when it finally did after a number of times and restarts, it was only half drawn on the screen.

Since I wasn’t able to clear this list using the GUI, I dig around and found I could do it from Terminal. Since doing this I’m able to search in Mail now without crashing, and it’s so nice

To fix this we need to open the “Previous Recipients” database, which is a sqlite database. First, close your Mail app if it’s running. Next, open Terminal and type:

sqlite3 ~/Library/Application Support/AddressBook/MailRecents-v4.abcdmr

Next we need to clear out all of the “Previous Recipients” addresses in this database. To do that, type:

DELETE FROM ZABCDMAILRECENT

To exit sqlite press CONTROL + Z.

Open Mail and you should now be able to search!

Thursday, September 29, 2011

Adding Syntax Highlighting to Blogger

I’ve switched back to Blogger from Posterous after so many failed attempts in trying to get the latters markdown syntax to display correctly. I still write my posts using markdown syntax in Byword, but then I display it in a full-formatted HTML syntax (Alt + Command + P) and click the “Copy to HTML” which I paste into Blogger.

One of the things I wanted on my blog was improved visual display of code (i.e. CSS, Coldfusion) or commands (i.e. bash) and I found the SyntaxHighlighter project. This project can be added to any website, including a Blogger template (except for the dynamic ones right now).

I found a number of references on how to add this to Blogger, but many were from a year or more ago (which is decades in Internet time). So here’s a quick guide on how you can add the SyntaxHighlighter project to Blogger.
Note: I’m using the new Blogger interface

  1. Login to your Blogger account
  2. Click on Template
  3. Click on the “Edit HTML” button under the “Live on Blog” thumbnail
  4. Click the “Proceed” button to the message warning you about editing the code
  5. Search for the text </head>
  6. Paste the following code
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'>
    <link href=’http://alexgorbatchev.com/pub/sh/current/styles/shCore.css’ rel=’stylesheet’ type=’text/css’/>
    <link href=’http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css’ rel=’stylesheet’ type=’text/css’/>
    <script src=’http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js’ type=’text/javascript’>
    <script src=’http://alexgorbatchev.com/pub/sh/current/scripts/shBrushColdFusion.js’ type=’text/javascript’>
    <script src=’http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js’ type=’text/javascript’>
    <script src=’http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js’ type=’text/javascript’>
    <script src=’http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js’ type=’text/javascript’>
    <script src=’http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js’ type=’text/javascript’>
    <script src=’http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js’ type=’text/javascript’>
    <script language=’javascript’> 
    SyntaxHighlighter.config.bloggerMode = true;
    SyntaxHighlighter.config.tagName = “pre”;
    SyntaxHighlighter.defaults.toolbar = false;
    SyntaxHighlighter.all();
      
  7. Click the “Save Template” button
  8. Click the “Close” button

Now let me explain a little of this to you.
The first line is loading the core Javascript file for the SyntaxHighlighter project, this is required.

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'> 

The second line is loading the core CSS file for the SyntaxHighlighter project, this is also required.

<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>

The third line is loading the display theme to be used. If you don’t like this particular theme, there are others you can choose from, see the list here.

<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>

Lines 4 through 10 are particular “brushes” that I want to load. A brush is specific for the language syntax you want to display. Here I’m loading brushes for Bash scripts, ColdFusion, CSS, JavaScript, SQL, XML (which includes HTML) and plain text. You must load at least one brush, but you can have as many as you want. You can find a list of the different language syntax brushes here.

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js' type='text/javascript'>
<script src=’http://alexgorbatchev.com/pub/sh/current/scripts/shBrushColdFusion.js’ type=’text/javascript’>
<script src=’http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js’ type=’text/javascript’>
<script src=’http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js’ type=’text/javascript’>
<script src=’http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js’ type=’text/javascript’>
<script src=’http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js’ type=’text/javascript’>
<script src=’http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js’ type=’text/javascript’>

Line 12 is required for the SyntaxHighlight project to work with Blogger.

SyntaxHighlighter.config.bloggerMode = true;

Line 13 is designating the <pre> tag as what will define the code block to have the brush applied to.

SyntaxHighlighter.config.tagName = "pre";

Line 14 disables the toolbar from displaying when the SyntaxHighlighter is applied. This seems to just be a “?” that’s displayed that the user can click on to see the name of the project. From what I can tell this is deprecated from previous versions so I disable it.

SyntaxHighlighter.defaults.toolbar = false;

Line 15 runs the SyntaxHighlighter code

SyntaxHighlighter.all();

User unable to login to Astaro User Portal

I recently setup some of the lab staff for access to their remote database through an SSL VPN using the awesome Astaro Security Gateway.

One of the users was having some problems to login to the user portal though to change their password. It turns out I gave them them wrong password initially, but even with this correct password they still weren’t able to login.

I entered the WebAdmin and checked the Logging & Reporting -> View Log Files -> User authentication daemon log. I could see the users attempts to login, shown as:

2011:09:29-13:19:48 secure aua[5336]: id="3005" severity="warn" sys="System" sub="auth" name="Authentication failed" srcip="x.x.x.x" user="smithjohn" caller="portal" reason="Too many failures from client IP, still blocked for 363 seconds"

I hadn’t seen this before. This is a really good thing to prevent brute force or automated attacks at guessing the users password. However in this case we didn’t want to wait the 6 1/2 minutes to try again.

Under the Management -> WebAdmin Settings -> Security I temporarily changed the values that block the authentication to:

 
After 30 attempts
block access for 3 seconds

The user was then able to login to the user portal, change their password and logout. I then changed the values back to the following:

 
After 3 attempts
block access for 300 seconds

Monday, September 19, 2011

Taking over CFWheels DBMigrate plugin development

The title pretty much says it all. I've taken over as the developer for the DBMigrate plugin used with the ColdFusion on Wheels framework. The previous developer, Ryan Hoppitt, has been really pressed for time in his schedule and hasn't been able to do much with the project. He's been very supportive and helpful in me take over the development.

The project is now hosted on GitHub at https://github.com/talltroym/cfwheels-dbmigrate-plugin along with the documentation, open issues and milestones.

This was a somewhat intimidating decision for me. While I started writing web applications with ColdFusion in 2000, I haven’t been actively developing with it for the entire past 11 years, more like half of that with a few years of not doing any ColdFusion work. Furthermore I’ve only been using the ColdFusion on Wheels framework since February (and I’ll never go back to creating applications without it), so I still consider myself “green” with it. Last I’m not an OO guy, and almost all of this project is multiple CFC’s, not to mention knowing others will be able to see my coding (mistakes). If I were to rate myself on a scale of 0 (what’s ColdFusion) and 10 (the likes of Ray Camden and Sean Corfield) I’d put myself squarely at a 5 1/2.

So why take it on? First, I’m actively developing a new web application and I’m using the DBMigrate plugin to handle all of the database schema interactions. I’ve found a few bugs with it, as well as some features I’d really like it to have. I decided to “tinker” with the code and was able to add/fix a few things.

Second, I think this is a good example to learn ColdFusion object-oriented programming from. I’m impressed with the code of this application and I’ve learned a good deal so far. I feel that in the end this will help me to become a better ColdFusion developer. Both in learning the current code base as well as receive feedback from others that will see the code I’ve written. As the saying goes, “nanos gigantium humeris insidentes

I’ve taken over as the developer since version 0.6.0 and you can find a complete list of the changes since then in the changelog.