chris barr

Photo/Dev/Design

A New Life in Georgia & a Wedding Website

Life Update
In less than a month now I’ll be getting married – it almost seems surreal.  I’ve been looking forward to this for a long time, mostly since I proposed to Kirstin about a year ago, but it’s so close I can hardly believe it.  I’ve lived in pensacola, Florida for the past 5+ years and Kirstin has lived Rome, Georgia for a little over 4 years now.  We had a long distance relationship for the entirety of our 2 years of dating, but in the past few weeks I’ve actually taken the plunge and moved up to Georgia.  We figured it was probably a good idea to at least live in the same state if we were going to be getting married.

It all actually worked out quite well.  The company I work for, AppRiver, recently opened an office in Midtown Atlanta.  The office is about 1.5 hours from where Kirstin works in Rome, so we decided to live somewhere in the middle and then we each commute to our workplaces.  The drives are fairly long, but  we think it’s worth it because we finally get to see each other on a regular basis and we both get to keep the jobs we love.

A Wedding Website!

chrisandkirstin

Soon after we were engaged, the wedding planning began.  One task on the list was to get a wedding website.  I thought “I got this!” since I do something similar for a living, so I made one.  I might have gone a bit overboard with the site, but it covers 100% of our needs, we love it, and we’ve gotten nothing but compliments about it.  I’ve made it in a fairly modular way, so I hope that others might be able to make use of it as well.  I’ve decided to put all the code on GitHub because… well why not.

Check out the site: http://ChrisAndKirstin.com
Get the code: https://github.com/chrismbarr/Wedding-Website

 

Lyric Converter V2!

If you just want to go use it: LyricConverter.com

But first…

The Backstory…

A few years ago my church used some lyric presentation software called SongShowPlus, and it worked… but we didn’t love it.  It only ran on Windows, it had some UI issues that made it hard to use and add/change songs before services. We wanted to get a Mac and run ProPresenter instead.  Friends in the same industry were telling us how they had switched and how much they loved it.  ProPresenter had a lot going for it, especially in the ease-of-use department and scalability for things we wanted to do in the future.

We were hesitant to make the change because there was no way to move all of our song files over. Neither program had a decent way to import or export song files, and there was certainly no way to convert between formats. A good friend of mine at a different church told me they were in the same position; they wanted to move from SongShowPlus to ProPresenter but they were holding off due to the inability to convert their songs. Honestly  I’m still surprised that to this day neither program provides a standard import/export for other file types.

The day finally came when our Windows machine died. We either had to buy a new one, or just go ahead and get a Mac with ProPresenter. We chose the latter option and manually converted the few songs we needed each week, or just downloaded them from a service called SongSelect. In the end this process wasn’t the best, but we got through it.  However, everything would have been much easier and less intimidating if there was just a simple way to import and export songs.

Version 1

This is the point when I decided to take a crack at it. I put our entire SongShowPlus library on my thumb drive and opened up the files in a text editor to see if it would be possible to get the text out.  The SongShowPlus file format is crazy, it appears to be a binary file with lots and lots of invisible control characters, but there is plain readable lyrics in there as well. Overall it seemed possible. Ok, so what about ProPresenter? Luckily the ProPresenter file format is a nicely formatted XML data, very easy to read and write from.  No problem!

At the time I was pretty comfortable programming in PHP, and I knew it’s file read/write capabilities so I decided to start there. I wrote a few complicated regular expressions to get the raw lyrics into an array, and it pretty much worked for most song files (with some tweaking)! This process took quite a while to get right because understanding the SongSHowPlus file format was fairly difficult. After that it wasn’t too much work to get it to generate the proper XML needed for a ProPresenter file. All that needed to be made now was a web UI for people to upload and download the songs! I put something together and I was pretty happy with it, and a few people used it. Yay! I even found out that the support staff at Renewed Vision (the company that makes ProPresenter) was actually recommending my site to customers making the switch, and that was pretty exciting news!

Oh and the name, LyricConverter… it just seemed obvious. (Also the domain was available.)

Problems

While what I wrote worked, it was a bit of a pain to use. If someone tried to upload too many songs at once the website would choke due to PHP’s upload file-size limit. Sure I could increase that, but someone could always upload more.  To solve this I had to impose restrictions of no more than 30 files at a time. This solved the problem, but if you had several hundred files to convert you were going to be here all day.

Another big problem was downloading the converted files. Each file was converted individually and stored on my server, but that meant after conversion you had to click on each file to download it.  So again, if you had several hundred files you were going to be here all day. That combined with the upload limit of 30 made this quite a pain to use. My eventual goal was to be able to have it produce a single .zip file with all the converted files in it, but that seemed a daunting task for PHP at the time.

One more problem I had, that was compounded by the above problems, was the amount of disk space and bandwidth used up on my server each month! I wrote a cron job that should have run once a day and deleted any files left on the server that were more than 12 hours old, but I found out that this did not run reliably on schedule and I often had to trigger it manually after I would get a “disk space exceeded” email form my hosting company. I also kept having to increase my monthly bandwidth because I was getting “bandwidth limit exceeded” emails. It was not uncommon for the site to blow through 1 or 2 Gigs of bandwidth in a month… and that’s for text files! (Although, it was a few hundred of them all transferred up once and then again back down)

Version 2

In my day job I’m a front-end web developer/designer, so I try to keep up with what the current browser technology supports and I’m quite honestly stunned at how many amazing things can be done all in the browser now.  Once I learned that there was a way to generate files in-browser with JavaScript to save to your desktop, I began to think about how re-writing LyricConverter could be a 100% in-browser process would solve all of the current problems I had.

Reading files dragged onto the browser was no problem, I was already doing that in the previous version.  Now I just had to take some of the regular expressions I had written in PHP and re-use or find a better way to achieve the same outcome in JavaScript. After some trial and error, I finally got this working how I wanted.  It will read SongShowPlus files and ProPresenter files, the output from either of those can be made to display in-browser as slides, convert to plain text files, or convert to ProPresenter files. Yes, you can convert ProPresenter files to ProPresenter files. Why? Well, why not. I doubt this is needed, but this does prove how flexible it is.

Since this is all in-browser there are no more “upload” limits, and there are no bandwidth restrictions. The only bandwidth used is just initially serving the page up to the browser. In fact since it’s all JavaScript now, it’s just being hosted on GitHub for free and none of my server resources are even needed any more.

Since files could be auto-downloaded (thanks to a library called FileSaver.js), that was great and it solved a huge problem of having to click individual links. A user could drag 1000 files into the browser, and then immediately click a button to download 1000 converted files… that is if you want 1000 files on your desktop… hmmm, that’s not appealing.  After some quick searching around I was amazed to find that someone has written a JavaScript library called jsZip that can actually generate .zip files with JavaScript! This was my ultimate goal, and it was to each to achieve with this library. Now when you convert songs you have the option to download all N number of files individually, or just download a .zip file containing them all.

I’m also extremely happy with how the code is structured now. Previously it was a huge mess and half of that was due to my unfamiliarity with PHP. Now it’s all written in JavaScript and it’s very modular. It should be easy to add on new file types that it could read from or output to.  It’s also all on GitHub, so anyone can feel free to improve the existing code or add new functionality like new input/output formats!

Use It & Improve It!

Like I said, all the code is on GitHub and I would just absolutely love it if people would contribute to this project to make it better.  Right now it works, but it certainly could be made better.  Occasionally I do get some strange conversion errors or random incorrect characters that slip through into the converted files.  I’d love to squash these bugs, but they aren’t deal-breakers at the moment.

So, please use it, let me know how it could be made better, and please contribute if you can.

CSS Pixels

Several weeks ago I made this presentation for work after doing a bit of research and becoming interested in how pixels on our screens are actually calculated.  It’s not at all what I expected at first, but find out for yourself and check out the presentation below.

View on SlideShare or Google Docs.

(Apologies for the audio not syncing up with the sides.  I’ve set it to do so, but SlideShare seems to refuse to work with me here)

Gmail Tricks

A while ago I found out about some pretty useful tricks that gmail allows you to do with your email address. While talking to some coworkers I was reminded that not everyone is aware of these, so I’d better share.

#1 – Dots Are Optional

Gmail will ignore any dots in the username portion of the email address. For example, the address joeshmo@gmail.com and joe.shmo@gmail.com are the same, mail sent to both addresses will be delivered the the same account. When I created my email address with gmail I used several dots, and over the years it’s gotten to be a bit cumbersome to always type them out (especially on mobile devices) or say it out loud to people.  It’s nice to know that I cam just omit them completely and everything will still work the same.  You can also go the other way with it of course.  If your email has no dots and you think dots are mega-rad, go ahead and start telling people your email address with added dots; it’s really the exact same anyways!

Do keep in mind though that whatever address you signed up with, you will still need to use that to log in to google services with.  It must match exactly, dots and all.

#2 – Add Whatever You Want After A Plus

Another optional character is the + sign in the username portion.  If your email is, again, joeshmo@gmail.com, the address joeshmo+ICanAddWhateverIWantHere@gmail.com is completely valid as well.  It will be delivered to you like normal, just like the trick above with optional dots.  But how is this useful?

I use this as a way of keeping track of who has my email address.  When I sign up for some new service I usually add the domain or company name after the plus sign.  If I’m signing up for a somewhat-sketchy looking site (let’s say it’s called SketchCo) I’ll tell them my email address is example+sketchco@gmail.com.  Now whenever I receive an email to this address that is not a SketchCo email, I know exactly who sold my email to a list!

This can also be used with the powerful rules and labels features in gmail. You could add a label on any email that comes in sent to a specific variation on your own email address. I personally don’t use it in this way, but it would be incredibly easy to do so.  Unfortunately, some sign up forms on websites do not treat the + symbol as a valid character in an email address, even though it totally is valid. When this is the case, you just won’t be able to use this trick on these sites.

So, what have we learned? Now we know that when using gmail, the email addresses billcosby@gmail.com and b.i.l.l.c.o.s.b.y+JelloPudding.KodakFilm@gmail.com are actually the same email address. It’s a little crazy, but it can be pretty useful if you know the tricks!

Easy Bundles for .NET MVC4

You’ve heard about bundles in .NET 4.5, right? If not you should read up on them, but the basics are that you can include multiple uncompressed JavaScript and CSS files in your project when in debug mode. When the project is deployed to production it will combine and minify the files for quicker downloads & fewer requests. Pretty handy!  At work we’ve recently begun using bundles in our MVC4 application.

The bundles are handy for the global files that need to be included everywhere, but nearly every page has it’s own specific CSS or JS files that needs to be linked to,  ideally minified as well, and possibly combined when there are multiples.

In razor, here’s the syntax we use to link to these files:

@Html.Style("~/Styles/someFile.css")
@Html.Script("~/Scripts/foo.js", "~/Scripts/bar.js")

Pretty easy right? Just link right the the file, or multiple files and they will be included on the page, but in production they will be minified and combined when multiples exist. How is this done you might ask? Well, take a look at this class below that gives us some extensions in the @Html. namespace.

That final MakeBundleName function will make the filename for the bundle (duh). Let’s say you provide it with the two script paths from the usage example above. The final output url for the bundle would be ~/Scripts/bundles/Scripts.foo+Scripts.bar – Basically it just replaces slashes with dots and concatenates multiple files with a plus. This allows for a unique name, but it also won’t change between page loads since it’s based on the input file names.

This all came about from a StackOverflow question I helped answer. There are a few caveats to this method that could be improved upon, the biggest of which is that this will automatically decide the bundle path for you.  This means that relative paths inside of your CSS/JS files will not work when the bundle URL is used!  For our use case, this is fine, but for what you do, it might not.  It would be fairly easy to extend this to have a different syntax like this if needed:

@Html.Script("~/bundles/my/custom/path", "~/Scripts/foo.js", "~/Scripts/bar.js")

Questions? Comments? Improvements? Let me know!