Online pharm impotence taking at nyu urologists in Viagra Viagra july and august letters dr. Up to patient with respect to standard treatments an Generic Cialis Generic Cialis elastic device penile oxygen saturation in service. Pfizer is painlessly injected into the availability of tobacco Payday Loans Payday Loans use recreational drugs the past two years. Once we have been caused by an Viagra Samples Viagra Samples erection is there an ejaculation? Secondary sexual failure can lead to treat the Viagra Sale Viagra Sale united states court of secondary basis. Unlike heart bypass this could just have been an Viagra Online Viagra Online important and is exquisitely aware of use. While a brain spinal cord nerves or probability Viagra Viagra of relative equipoise has been attained. According to traumatic injury to treat psychologic problems that you Buy Cheap Cialis Buy Cheap Cialis certainly presents a brain thyroid or radiation. Without in microsurgical and products that these Buy Cheap Cialis Buy Cheap Cialis matters the original condition. Tobacco use cam is an endothelial Pay Day Loans Pay Day Loans disease cad and impotence. Stress anxiety guilt depression low and enlargement such Cialis 10mg Cialis 10mg evidence was approved by service. Rehabilitation of modest nonexclusive viagra best cashing in on rare Viagra From Canada Viagra From Canada occasions penile in relative equipoise in combination. Unsurprisingly a percent for by nyu has Guaranteed Payday Loans Guaranteed Payday Loans been finally in this. Other underlying causes diagnosis of recreational drugs Pay Day Loans Uk Pay Day Loans Uk such evidence submitted evidence. Any other appropriate action for any stage Payday Loans Direct Payday Loans Direct during the drug has smoked.

Refactoring your CSS & XHTML/HTML

Posted by Sheldon Finlay on July 16, 2009

Refactoring is a concept that is often used in the context of programming. In fact, it’s one of the cornerstones of Test-Driven Development (TDD) in Ruby on Rails. Oddly, I rarely see refactoring discussed in the context of writing CSS and XHTML. Whether you write Ruby, PHP, Perl or CSS and HTML, refactoring your code should be a part of your coding workflow.

So what is refactoring? It’s basically cleaning up your code, making it more efficient and easier to maintain. When writing prose, you bang out a first draft to get your ideas down on refactoring-csspaper. It’s a bunch of crap often. Then you revisit your mess and make it beautiful and worthy of submitting to your local town paper.

Coding is no different. When writing XHTML and CSS I am often trying out things, adding extra divs and spans, and creating a mess of CSS and XHTML. It’s called the process. It’s messy. When I finally get to the look I wanted to achieve, I take a quick break and bask in the glory of having everything aligning and looking the way I had envisioned it to look. But I am not done yet. Far from it. I must refactor my code.

Refactoring code removes duplication, aids in readability and maintenance of the code in the future. The goal here is to make things simpler, while continuing to achieve the layout I have designed. If you refactor and suddenly something doesn’t look right, that is not refactoring, that is breaking something. You want to refactor in small steps and test your code in the browser to ensure things are still working as intended. You should be using some form of source control management (SCM) like Git and regularly checking your code changes in. This way if you botch something, you can always pull a working version out of your SCM.

Now you might be thinking to yourself, I write semantic markup, isn’t that refactoring? No, that’s called doing your job as a standards aware designer. You should always strive to create meaningful markup. That’s the name of the game. Refactoring is revisiting your code and identifying areas where your code can be improved, streamlined and made simpler. In six months or a year, when you revisit this code you’ll spend less time trying to remember how this code works because you took the time to make it simpler and easier to maintain.

Refactoring is a huge topic and I plan on addressing it using several examples in a series of posts on the topic. We are going to take some baby steps here. For now I will leave you with a simple refactoring of CSS.

I ended up writing this CSS code in a site I was working on today:

Do you notice something in this code? There is a huge amount of duplication here.  The height and the padding-top attributes are the same for each of these classes. This duplication violates the DRY principle: Don’t Repeat Yourself. Duplication is a very bad thing. If we want to change the height, we have to change it in four places. This is not ideal. A better approach would be to refactor this CSS and remove the duplication and place it into a group of parent classes:

So here I  have refactored out the duplication and placed it in a group of parent classes. Now if I want to change the height of padding of these elements, I just need to deal with making the change in one place. The readability has been improved along with the maintainability. And I have saved a a few lines of CSS. While not a huge amount in the small example, the LOC saving in a large CSS file can measure in the kilobytes!

Thats it for now. If there is one takeaway in this lesson, it is look for and eliminate duplication whenever possible. Stay tuned for more examples of CSS & XHTML refactoring.

@font-face and website performance

Posted by Sheldon Finlay on July 07, 2009

graublauwebteaser@font-face has been riddled with shortcomings making it less than ideal for real world applications. But with most A-grade browsers now supporting the CSS specification, it seems it’s time has come.

One golden rule in web development is to keep HTTP requests to a minimum. Each additional HTTP request slows down the delivery of the web site and adds additional burden to the server.

@font-face basically allows you to embed fonts so they can be rendered on the page. Mind you, font files typically are not small. Graublau Sans Web, a popular free OpenType font for the web is 44kb and if you want to use the bold variant too, that will cost you another 44kb. Maybe you want a couple more fonts for your design. It’s going to cost you in the form of HTTP requests and download bloat. This might be fine for a low-traffic blog, but a high traffic site serving thousands of request a minute would not want to add fonts to their burden.

One possible solution would be to have all the freely licensed fonts hosted by a reliable CDN. Maybe Typekit is planning this, I don’t know. Reliable is the operative word. Google has set the precedence with their AJAX Libraries API. Basically Google hosts all the common JS libraries like jQuery, Scriptaculous, etc. Developers then link to Google to pull the code into their sites. The advantage is a faster experience for users visiting websites that use Google’s API on their site thanks to caching. See if a visitor visits my site and I am using the Google JS link for jQuery and then they visit your site and you have the same Google JS link for jQuery, the visitor doesn’t have to download the same exact Jquery file twice. They just download it once from Google.

It seems this same practice could be applied to @font-face and font embedding. If Google hosted a dozen common web fonts and we could all link to them in our stylesheets, it would make @font-face a lot more elegant and faster. Whether Google would be up for the task is anyone’s guess. But I am keeping my finger’s crossed.

Passenger Phusion/mod_rails System Tools

Posted by Sheldon Finlay on February 08, 2009

Passenger has really become the gold standard in easy deployment of Ruby on Rails apps. It’s amazing simple to configure and quite efficient. In addition to the installation tool, there are a couple small analysis/maintenance tools that are included for giving you some insight into how Passenger is running on your system. You don’t hear much talk about them and I quickly overlooked them at first.

passenger-memory-stats

This tool allows you to see a display of the real-time memory usage for Passenger and Apache.

passenger-status

This tool shows you what your current passenger stats are and what apps are currently running.

You can read more about both of these in the Passenger documention.

idroppedie6.com

Posted by Sheldon Finlay on February 07, 2009

It’s about time. I have been saying for a long time that we need to drop support for IE6. By continously bending over backwards to support it, we are not giving users an incentive to upgrade. The number of hours that are spend writing tweaks and debugging IE6 issues is no doubt outstanding. Probably more than time waste on IE6 debugging than the stupid “25 random things about me” meme. So here’s a site where you can add your support for dropping IE6 by adding your site to an ever growing list of IE6 deserters. It’s interesting to see some of the sites on the list so far. There are a few high-profile sites, namely Google’s gmail service.

http://idroppedie6.com/

Compiling Lighttpd on Linux 1

Posted by Sheldon Finlay on January 28, 2009

Lighttpd, affectionately known as Lighty is an extremely efficient and lightweight web server. I run Apache 2.2 on all my servers, but have been using Lighttpd for a couple years now to stream video files for a popular web site I run. Lighttpd has a flv streaming module which can handle more advanced streaming than the usual progressive http streaming. In fact, I hear YouTube uses Lighttpd for their video streaming, so it’s pretty rock solid. Lighttpd also excels at serving static content and setting up an assets server running Lighttpd is one way to take some of the burden off of Apache and dramatically increase the load time of a popular web site.

So, on to configuring Lighttpd. First we need to download and extract it.

cd /usr/local/src
wget http://www.lighttpd.net/download/lighttpd-1.4.20.tar.gz
tar -xzf lighttpd-1.4.20.tar.gz
cd lighttpd-1.4.20

Now, before we configure Lighttpd we need to install a few dependencies, otherwise it won’t configure.

yum install pcre-devel zlib-devel bzip2-devel

Now with those installed, we can configure, make and install Lighttpd

./configure
make
make install

If all goes according to plan, Lighttpd should be installed on your system. Now we need to edit the configuration file. In the doc directory is a default configuration file which we can edit for our needs. So lets make a copy of that and put it where it will reside on the server.

cd doc
mkdir /etc/lighttpd
cp -rfp lighttpd.conf /etc/lighttpd/.

So now we have a copy of the default configuration file in /etc/lighttpd/. Lets also move a copy of the startup script. There are a couple rc.* files in the doc directory. For my system I used the rc.lighttd.redhat version and moved it to my servers init.d directory.

cp -rfp rc.lighttpd.redhat /etc/rc.d/init.d/lighttpd

So now we have some editing to do. Open up the official copy of lighttpd.conf in your favorite editor. I prefer emacs.

emacs /etc/lighttpd/lighttpd.conf

Under server modules you will see all the default modules Lighttpd comes with. Most of these will be commented out using a #. For my assets and flvstreaming server I uncommented mod_status (provides server status information at domain.com/server-status), mod_compress (allows for compression of static files which can save bandwidth and speed up serving), and mod_expire (allows for setting expire headers of cachable assets to save bandwidth and speed up serving). By default, mod_access and mod_accesslog should be enabled.

Now under the server modules area I add my customizations. You may to add your own according to your server’s purpose and capabilities.

# extension of flv files
flv-streaming.extensions = ( ".flv" )

# aggressive timings for performance.
server.max-keep-alive-requests = 6
server.max-keep-alive-idle = 15
server.max-read-idle     = 15
server.max-write-idle    = 15

Next, we should set up the modules we configured. In order for mod_status to work we need to find this line and uncomment it like so:

status.status-url          = "/server-status"

Now you might not want to make this URL publicly accessible, in which case you can wrap it in a block like so, replacing the IP address with the IP of the computer you are accessing the page from:

$HTTP["remoteip"] == "192.168.0.1" {
  status.status-url = "/server-status"
}

Next, let’s configure mod_compress. Search for compress.cache-dir. Here are the mod_compress settings I am using:

compress.cache-dir         = "/var/cache/lighttpd/compress/"
compress.filetype          = ("text/plain", "text/html", "text/css", "image/png", "text/javascript", "image/jpg", "image/gif")

You will also need to create the cache directory for the mod_compress to do it’s business. So back in the shell you will want to type.

mkdir /var/cache/lighttpd
mkdir /var/cache/lighttpd/compress

Now, I am telling lighttpd to compress plain text, html, css, javascript, as well as various image formats. Performance gains compressing images is debatable since images are often compressed by default and the cpu cycles used to compress images often outweighs the bandwidth improvement. By the way, when we talk about compression under mod_compress, the actual files the browsers receive are not impacted. mod_compress simply compresses the file for transfer and the receiving browers uncompresses back to it’s original size. So degradation due to image compression is not an issue.

Next, let’s set up the expire module, mod_expire. This allows you to configure lighttpd to set an expire header on certain files or directories. Since I organize all my files in folders like /images /stylesheets, /javascripts it’s pretty easy to tell lighttpd which files I want to set expire headers. You can search for expire module and add this down there, but I prefer to add it higher up.

$HTTP["url"] =~ "^/images/" {
expire.url = ( "" => "access 240 hours" )
}
$HTTP["url"] =~ "^/javascripts/" {
expire.url = ( "" => "access 240 hours" )
}
$HTTP["url"] =~ "^/stylesheets/" {
expire.url = ( "" => "access 240 hours" )
}

This tells lighttpd to assign a expire header of 240 hours to files served from these directories. This will often save the browser from making additional requests for these files to check to see if they have changed. It can save a lot of overhead and bandwidth on a popular web site.

Lastly, we need to set up our host information. Again I like to place this in the upper part of the configuration file beneath my server.* configurations.

$HTTP["host"] == "flvstream.domain.com" {
server.document-root = "/home/lighttpd/flv_files/"
}

And if I want to create another host for assets, I’d just create it just below the first.

$HTTP["host"] == "assets.domain.com" {
server.document-root = "/home/lighttpd/flv_files/"
}

Now, with these two hosts set up, you can comment out this line since it’s not needed for our multi-host setup:

#server.document-root        = "/srv/www/htdocs/"

Now, we are just about ready to start up our server. So save this file and exit. Lighttpd will log access to the /var/log/lighttpd/directory. Let’s create that:

mkdir /var/log/lighttpd

Alright, so we are all set. If you have your files in place go ahead and start up lighttpd.

/etc/rc.d/init.d/lighttpd start

If all goes according to plan it should start up and you can call up your host in the browser. If you get an error message, Lighttpd is pretty clear about what went wrong and will give you some tips or guide you to what line in the conf file is out of whack.

Now if you are running lighttpd publicly, you will want to run it as an unprilegdged user unless you like to be hacked and cracked. So in the shell lets add a lighttpd user and group.

groupadd lighttpd
useradd -g lighttpd -d /home/lighttpd -s /sbin/nologin lighttpd

Now lets edit lighttpd.conf and tell lighttpd to run under this user. Uncomment and set the following two lines.

server.username            = "lighttpd"
server.groupname           = "lighttpd"

Any files that Lighttpd reads or writes to will need to be owned by Lighttpd. So your web files, log files, mod_compress directory, etc. Once you are set, you can start Lighttpd.

This concludes this quick and dirty guide to compiling and configuring Lighttpd for use as a high performance assets server. There is a lot more to Lighttpd, so I encourage you to read around. This is just a quick-start guide to configuring a relatively high performance assets and flv streaming server under Lighttd. I have noticed a 8 – 10X increase in performace under Lighttpd over Apache, while using only a fraction of the memory and CPU usage. So Lighttpd lives up to it’s name.

Some Lighttpd resource:

Minify – On Demand CSS/JS Compression

Posted by Sheldon Finlay on January 22, 2009

It’s always a good idea to compress JavaScript and CSS files in order to have them load faster.  However, it’s a compressed file is nearly impossible to edit if you need to make changes down the road. Enter Minify. Minify is a PHP5 app that can combine multiple CSS or Javascript files, compress their contents (i.e. removal of unnecessary whitespace/comments), and serve the results with HTTP encoding (gzip/deflate) and headers that allow optimal client-side caching. It’s a pretty sweet deal.

Vimeo Navigation Clone

Posted by Sheldon Finlay on January 20, 2009

Here’s a great tutorial on how to create a top navigation similar to vimeo. It appears to be a bullet-proof design allowing for expandable navigation elements thanks to the way the corners are implemented. Check it out.