27 May 2010, 11:32am
Programming:
by

1 comment

NO Table Cell Spacing Please

Remove cell padding on a table you add the cellspacing attribute and set it to “0″. Is there a better way to do this with straight up CSS? Nothing seems to work…

<table id='my-favorite-table' cellspacing="0" >
...

Offset an Element with Relative Position Property with CSS Without Taking Up Any Space in the Document

Using CSS positioning it’s possible to offset an element and collapse its width and height where it would normally appear. Wrapping the content in an absolute positioned element, the space that the element would normally take up is collapsed.

<div style='position:relative;top:-10px;left:-100px;color:blue;width:50px;'>
  <div style='position:absolute;top:0px;left:0px;'>
      Position of this element will be -100px from the left and -10px from the top. Because it is wrapped
      by an absolute positioned element, the original location of this element will be collapsed.
   </div>
</div>

Here is an example

[this is where the div should be]

Position of this element will be -100px from the left and -10px from the top. Because it is wrapped
by an absolute positioned element, the original location of this element will be collapsed.

but we see that this block of text is next in line instead!

20 May 2010, 10:32am
Projects
by

leave a comment

Postlearn Job Board

Postlearn is a job board focused on delivering quality jobs listings to people in education. more »

Workshop Dog

Workshop Dog is a free events calendar for dog training workshops and group lessons.
more »

Natural Dog Training Buzz

NDT Buzz is a companion news site to Natural Dog Training.
more »

20 May 2010, 10:27am
Projects:
by

leave a comment

Natural Dog Training

Natural Dog Training uses WordPress to run a blog and content management system.
more »

Launch Photoshop (Or Any App) From The Command Line on Mac OS X

I often find myself coding with the terminal open. Cding around a web app project I usually end up at some point launching Photoshop. Either to touch up or work on a psd, png, jpg …etc. I fire up Photoshop and then navigate to the app’s public directory, where the site images are kept. Then begins the hunt in finder for the image. This takes some time and if I’m already at the command line it would be nice to launch Photoshop with the exact file I want with a single command! To accomplish this just make an alias in your bash profile like so…

#fire up your text editor and edit your profile
vim ~/.bash_profile
#create the alias command
alias psd="open -a /Applications/Adobe\ Photoshop\ Elements\ 3/Photoshop\ Elements\ 3.app"

You need to fire up a new terminal instance before this setting will take place. CMD+N.
Then from the command line type

psd my-image.psd

Note, I didn’t use “ps” as the alias because this is already taken by the system. Also the path to the application may be different on your system. Make sure you use the correct path or you may have an error like

LSOpenFromURLSpec() failed with error -10827 for the file...

Programmatically Turn Off Comments in WordPress with Filter

To turn comments off programmatically with a filter in WordPress, you can set the post object’s comment_status variable to “closed”. Call the filter at some point after the post is loaded but before the comments are rendered. This is a hack, but I haven’t seen a simpler approach, beside installing another plugin. In the example below, the condition to disable comments is simple. If a post is in a certain category, comments aren’t allowed. Otherwise, go ahead and behave as normal. You can still disable comments on a per post basis in other categories.

One thing to note is the use of the global $post object. The function needs access to the object to set the variable.

add_filter('get_header', 'sb_turn_comments_off');
function sb_turn_comments_off(){
    if(in_category("Projects") AND is_single() ){
      global $post;
      $post->comment_status="closed";
  }
}

I’ve only tested this with the Thematic framework. I assume that other themes will check the comment_status variable before allowing comments.