All in vain

Some rants about technology, PHP, people, tools, web etc from a developers perspective. Feel free to copy ideas, code or anything from here.

Friday, May 29, 2009

creating png images from latex

No comments
Recently at work i had to generate images from latex equations. I used Miktex latex suite to generate the images. Here is the template i used for generating the images.

== Preamble ==
\documentclass[11pt]{article}
\newenvironment{custommargins}[2]%
{\addtolength{\leftskip}{#1}\addtolength{\rightskip}{#2}}{\par}
\pagestyle{empty}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{mathptmx} % rm & math
\usepackage[scaled=1.0]{helvet} % ss
\usepackage[papersize={5.75in},top=1pt,bottom=1pt,left=5pt,right=1pt]{geometry}
\begin{document}
\begin{custommargins}{-2cm}{-2cm}
\begin{flushleft}

== Your equation latex snippet ==

== Postable ==

\end{flushleft}
\end{custommargins}
\newpage
\end{document}

Steps to create image
1) Create a tex file using the above template
2) Create a DVI file using - $LATEX_PATH --quiet --interaction=nonstopmode $temp_tex_file_name
3) you may need to run it twice for formulas to render properly
4) Create png image using - $DVIPS_PATH -q $tmp_filename.dvi -o $tmp_filename.png


You are done!!

Dont forget to write to me if you find it useful.

Make your HTML go on a diet!

No comments
In one of my previous posts i showed a technique wherein you could reduce the size of your css and javascript files. You run them through a minify engine which strips down all the spaces and comments and possibly zip it as well while serving.

While it is all fine and dandy for a while but after a while you start to think even after the minify-ing process my html page size is still upwards of 300-400K! Then i think you need to do soul searching like i did. Why do we need all those javascript and CSS for anyway? cant we write css which is only 30-40 lines and still keeps my site functional and javascript which "really" helps the vistior.

Post your comments and suggestions :)

Textpattern and the art of CMS design

No comments
Phew a new post after such a long time. It has been a long time i have blogged. So here it goes. This post is about TextPattern. A PHP MySQL based CMS.

I was searching for a simple, elegant and unobtrusive CMS for my personal site. I dutifully headed to opensourcecms.com for seeing the latest and greatest PHP powered CMSes but sadly none of them fitted the bill for me. I was amazed by the bloat and stupidity of those CMSes.

Thats when i remembered about textpattern. I had known it existed for quite a while but never had the time to take it for a ride. Now that i have done it i am quite happy with it and it seems natural to me. I have added one WYSIWYG plugin and an admin theme. Now i am good to go. More to come later.