Tiernan's Comms Closet

Geek, Programmer, Photographer, network egineer…

Currently Viewing Posts in Blogging

Bulk compressing images for the Web

Now that all my sites are running Jekyll I am trying to get them optimized for SPEED which meant
looking at all the stuff that takes time to download… There are more tweaks (and possibly posts) coming down
the road, but to start, I needed to look at images.

First things first. I’m running this on a Sabayon Linux box, so some of the install commands will be different… (Also, i do need to explain why I moved from Windows to Linux on the GodboxV2, but that’s a different post…)

First, install OptiPNG (they have a Windows build too…) and JPEGOptim

sudo equo install optipng
sudo equo install jpegoptim

[UPDATE] I tried this on an Ubutnu Box, and to install both of these, the package names are the same. so, to install both:

sudo apt-get install optipng jpegoptim

Next, using the Linux find command (this should work also on OSX…) run OptiPNG and JPEGOptim on all pngs and
jpgs in your given directory:

find . -iname "*.png" -exec optipng {} \;
find . -iname "*.jpe?g" -exec jpegoptim {} \;

depending on how many images (and how fast your machine is) it should take a min or two…

That’s it! I did a git status, which showed me all the changed images, and then deployed the Jekyll sites… All
good! That’s it!

Moving sites to NearlyFreeSpeech

I have been running a Dedicated Server from Hetzner for a while now, but have started to look at what i am running on the site, and reailized i under utilize the machine a lot… For example, this site is generated using Jekyll, which takes up very little power, and becomes static HTML files. My other blogs (Tiernan’s Comms Closet and GeekPhotographer) are both low traffic WordPress sites, and I run a couple of other static sites also for friends… All in all, not a lot of power…

Its not a fortune to run the server, the box i have has a Quad Core, Hyper threaded Intel i7, 32Gb RAM, 2 3TB Hdds (not raid…) and runs a copy of VMWare ESXi, and it costs about EUR60 a month, including a couple of IP addresses… But, i dont use it all that often… So, i am in the process of getting rid of it…

So, the 2 other blogs (GeekPhotographer and Tiernan’s Comms Closet) have already moved. They where easy enough… Export the WordPress DB, copy the file up, tweak the config, import the DB, DNS updates, etc… All done… but this site… that is more “Complicated”…

Since it is generated on a ‘git push’, Jekyll and Ruby needs to be installed on the box… I am using static sites on NearlyFreeSpeech which only charge me per meg (about 0.1c, but that reduces as you transfer more) transfered and per 5 meg stored (1c). Thats for STATIC sites… if you are running a dynamic site, its about 1c per 1mb stored, plus 1c per day, plus another 2c for MySQL instances. Check out their pricing calculator to see the magic at work!

Anyway, my GIT repo is on a machine in the house. It has Jekyll and all required bits installed. In the ‘post-receive’ hook (check the original zerosum post), i generate the site, and then do an rsync copy to NFSN servers. That is it!

Any question, leave a comment.

[update] forgot to add the gist which shows how i do the rsync call…

[update2] you in my case, the folder that Jekyll is being built in needed to be chmoded and chowned… I chowned the the folder to the gitolite user and i chmodded the folder to 777… before i did this, some files where unreadable on NFSN… with this, all works grand…

More Jekyll Stuff

Couple of bits and pieces on Jekyll stuff today… I am tweaking the outline of the site, so i am surfing around finding stuff… here is what i have found

  • Host a static site on Amazon S3: Interesting idea, and something i would look into eventually… And with the help of CloudFront you could host your whole blog on a CDN!
  • Rake tasks for Jekyll: Rake is the Ruby version of make… and a RakeFile can have tasks, which are in Ruby… They can do, from what i can gather, pretty much anything… So, some examples of what you can do with them are linked here… I especially like the New Post generator… very handy!
  • Jekyll Plugins: Various different plugins for Jekyll… I am interested in a few of these, mainly the Generate_projects one, which generates a page for your projects based on your GitHub projects… very cool stuff…
  • Strictly speaking, this is not just a Jekyll how to, but Migrating from WordPress to Jekyll is a handy read. my main blog, my podcast and photography blog both run WordPress. migrating them to Jekyll would mean i could move them directly to a CDN and make things a lot faster… Maybe something i plan doing soon…

If you have any tips or tricks, why not leave a comment and i can add them to the post.