Jan
29
2007
I have been using a PowerBook G4 for nearly two years and just today I figured out something that I wish I had known a long time ago.
Here is a scenario… When I have too many application windows opened and I need to see the desktop, I would normally minimize and shuffle around all the windows. As you can imagine, this is very annoying prone. So today not unlike Columbus, I discovered something that might have been known to a whole continent! If you hit F11 on OS X all your windows will fly to the edge of the screen leaving you with an undisturbed view of the desktop. Kewl!
If anyone else has any tips like this holla at me, that is drop me a line!
Technorati Tags: mac, osx, macosx, f11, columbus, powerbook, desktop
7 comments | posted in Programming, Rant, TechKnow
Jan
22
2007
Classes and interfaces are the primary building blocks of a typical Java application. Classes are the blue prints used to create objects in a running system. In contrast to Java, Ruby’s building blocks are classes, modules, and mixins. In this post we will take a tour of classes in Ruby.
Classes
To get started, lets define a basic Person class.
class Person
end
The above class is the simplest class type we can define in Ruby. The first thing you will notice is that the curly braces that are so pervasive in other programming languages are omitted here. This is not a typo. It is intentional. In fact, curly braces are rarely used in Ruby code blocks.
As in Java, we use the class reserve keyword to define a class type and the class name is capitalized in camel case. In Ruby, end is the reserved keyword used to demarcate the end of a code block such as an if statement, a method declaration, or a class definition. At this point, the Person class is the simplest class that we can define. Our Person class implicitly inherits from Object.
So far the Person class defined above is not even interesting enough to instantiate. As we know a class typically has state and behavior. Lets add two instance variables to our Person class to hold the first and last name and the necessary getters and setters in a very Java-like fashion.
class Person
def fname
@fname
end
def fname=(fname)
@fname = fname
end
def lname
@lname
end
def lname=(lname)
@lname = lname
end
end
Continue reading
18 comments | posted in Programming, Ruby, TechKnow
Jan
17
2007
In Ruby the implementation of a class is not closed. In Ruby, it is incredibly easy to add new methods to any existing class at runtime, even core system classes like String, Array, and Fixum. You just reopen a class and add new code. This language feature makes the language incredibly flexible. You might be wondering, why would you need this? Well, take a look at the API documentation of the Java String class. In most development organizations that I have been a part of we have had to write small string libraries that provide far more functionality that provided by the Java String class. The Apache Jakarta Commons Lang project provides a String helper class in StringUtils. StringUtils provides methods such as IsEmpty, Chomp/Chop, and LeftPad. StringUtils. StringUtils is a great class that has saved me from re-inventing the wheel several times, but it is another library to download, configure, learn, and import. Using the StringUtils class is more verbose calling a method on a string.
// Using StringUtils to trim a string.
str = StringUtils.trim(str);
// Calling a trim on a string.
str = str.trim();
Isn’t more concise and easier to read when you invoke a method on a string instead of using StringUtils? Unfortunately, even if an JCP is approved to add your custom string methods to the String class, the whole process is very time consuming. Each incremental release of Java takes years to develop. In Ruby, you can just reopen the String class to add the few methods you feel it lacks. To reopen the Ruby String class we can use the following code:
# reopen the class
String.class_eval do
# define new method
def get_size
# method implementation
length
end
end
Continue reading
8 comments | tags: class_eval, dsl, Java, mixin, module, reopen class, Ruby, stringutils | posted in Java, Ruby, TechKnow
Jan
16
2007
1. Akismet by Automattic is probably the best WP plugin out there. Akismet is a comment and trackback spam filter for your WP powered blog. It is a true mathematical equation that your blogs page rank is exponentially proportional to the number of viagra and penis enlargement spam comments you will receive. Akismet blocks them all. One thing to note about Akismet is that it sometimes flags honest comments as spam, so make sure to manage Akismet spam frequently. To use Akismet you will need a free WordPress API key.
2. If you are using Google Analytics to track your blog’s performance I recommend the Google Analytics plugin by Boakes. It is simple to install and configure, just have your Google Analytics User Account handy.
Continue reading
17 comments | posted in CMS, PHP, TechKnow
Jan
14
2007
The most common HTML tag I use is div. The div tag is a web designer’s best friend. It is the Swiss army knife of tags. That said my favorite HTML tag is the fieldset. The fieldset tag is similar to the div in that it is a container for other design elements. The key difference between a div and a fieldset is that you can add a text legend to the fieldset, which appears inside the top right of border of the fieldset!!!
[source:html]
<FIELDSET>
<LEGEND>Header for Grouping</LEGEND>
CONTENT
</FIELDSET>
[/source]
You might be asking, what are fieldset good for? The fieldset tag helps to visually group elements, such as a login form or a group of links. If you want an example of the fieldset tag in use look below to the Related Posts table below…
Technorati Tags: html, xhtml, webdesign, fieldset, legend, div
no comments | posted in HTML/XML, TechKnow
Jan
14
2007
When playing with custom web designs, or off the shelf templates, the most common CSS work involves changing the margin, padding, color and background of HTML elements. I usually also usually align elements either to the left, right, or center using CSS.
To get started with code samples, to center a div in the middle of a container div you can use the following CSS:
.center {
margin-left: auto;
margin-right: auto;
}
If you want to align a div to the right and another div opposite to the first on the left you can use the following CSS classes.
.right {
float: right;
}
.left {
float: left;
}
I have found that when I used both div that float both to the right and left that you have to follow that with an empty div that clears, or resets, the float CSS property. If I don’t clear the float property other elements such as a menu that is aligned to the right might not render correctly. Here is the CSS class to clear the float property, use it in a div the divs that have been aligned to the right, left, or both right and left.
.clear {
clear: both;
}
6 comments | tags: align left, align right, clear, cs class, CSS, div, float, html, webdesign | posted in CSS, HTML/XML, TechKnow