Adding Version to CSS Files

blog — Tags: , , — anon @ 10/03 1:52 pm

Okay, this is something I have seen before, but it were never attracting my interest so far. But after reading Vladimir Prelovacs short note about adding a version to CSS files using PHP, I clearly understood why this little trick can be so useful when updating CSS files. Dunno why this didn’t come into consideration before.

Basically if you often do any changes to your CSS the old version of the file will normally be served to your visitors as the cache expiration header is set to a far future time.

To remedy this a parameter needs to be added to the CSS file URL that will make it distinct every time you change it. Best way to do it is by using the timestamp of the file.

<style type="text/css" media="screen">
   @import url(<?php echo bloginfo('stylesheet_url'). '?' .
filemtime(get_stylesheet_directory() . '/style.css'); ?>);
</style>

For example here is how my CSS URL looks like:

<style type="text/css" media="screen">
   @import url(http://blog.datenkompost.de/wp-content/themes/barecity_1.5/
style.css?1266235697);
</style>

Hacking Cocoa: Method Swizzling

blog — Tags: , , , , , , , — anon @ 10/03 5:47 pm

From cocoadev.com:

The Objective-C runtime lets you modify the mappings from a selector (method name) to an implementation (the method code itself). This allows you to “patch” methods in code you don’t have the source to (AppKit, FoundationKit, etc).

Unlike creating a category method with the same name as the original method (effectively replacing the original method), MethodSwizzling lets your replacement method make use of the original method, almost like subclassing.

This is best used in cases where a single method needs substitution or extension but if you need to modify many behaviors of a class, you may be better off using ClassPosing.

But I found this article way more informative and that, in turn, led my way to the SIMBL Framework which I can greatly recommend.

After thinking about this a couple of minutes you’ll also find a huge amount of possibilities and hack-arounds. But seriously, there are some things to consider like this.

To make it short, Kevin Ballards code did fail in the 10.5 Mac OS X release and had to be rewritten. In fact, many code had to be rewritten which somehow led to JRSwizzle, a very good implementation that runs under Leopard and Snow Leopard.

So either using SIMBL or MethodSwizzling (JRSwizzle in particular) does the trick. It’s absolutely obvious to be very careful when swizzling methods or creating plugins via SIMBL – but the possibilities appear very clear and vast to me.

Another great possibility to hack around with Cocoa is F-Script by Philippe Mougin and F-ScriptAnywhere by Ken Ferry. Two very essential tools when hacking just for fun or seriously developing Cocoa applications.

Ghetto hacks

blog — Tags: , , — anon @ 09/08 10:31 am

via hackaday and engadget

After hearing that his video card might be repairable by heating it up to reflow it, this user did just that. He stripped it down and tossed it in his oven. It’s amazing how often this type of hackish repair works. We’ve heard of people using candles on ibooks, tossing video cards in ovens and wrapping an xbox 360 in a towel and running it for 30 minutes to get it hot enough to reflow itself. Why even bother with controlled temperatures and exact measurements? What other crazy fixes have you had to employ? We had a Playstation that only worked upside down.

Well, I once had for myself a 2.5″ hard disk that operated as long as one would keep waving it gently around. A kind of gyro-driven hard disk.

How to Customize the Wordpress Tag Cloud

blog — Tags: , , , — anon @ 09/01 4:02 pm

If you’re like me you might also want to change the default settings that the Wordpress Tag Cloud use. Normally this would be done in the sidebar.php that lives inside your theme folder, but in my case – I use the Widget Editor – I don’t have any control over the Tag Cloud. So I decided to hack the Wordpress core no matter what others are saying about that. Of course, I have to mention that changes getting reverted after you update.

For this you need to modify the wp_tag_cloud function in the category-template.php file. It’s remarkably easy to do. Here’s how.

  1. Open the file /wp-includes/category-template.php
  2. Search for the line that begins with function wp_tag_cloud
  3. Make changes in the array as follows:
    • To specify the smallest font size, set the value after ’smallest’. The default is 8 points
    • To specify the largest font size, set the value after ‘largest’. The default size is 22 points
    • To specify the maximum number of tags included in the cloud, set the value after ‘number’. The default number of tags is 45
  4. Overwrite the existing file with the changed file

Easy, huh? This is considered as a hack. So don’t blame me if something happens to your Wordpress install or if suddenly everything blows up completely.

copyright © 2008-2010 datenkompost.de/blog - barecity derivative | imprint
* a title remix inspired by a popular german book