Wednesday, October 29, 2008

SVN tips

I'm going to keep track of some SVN tips here. For instance I always get confused about when I'm supposed to use a URL and when I'm supposed to use a path with SVN. And I always have to recreate those annoying trunk/ branch/ and tag/ directories every time I want to import a project and sometimes if you do it wrong you're truly screwed. Hopefully this will help you (and me) out in future.

Create a repository and import a project

svnadmin create --fs-type fsfs /home/kjvarga/svnroot svn import newproject file:///home/kjvarga/svnroot/newproject/
Some things to notice
  • The triple slash on the local file URL.
  • Specifying the file store type as fsfs. I'm on a shared host and apparently it's really not a good idea to use the BerkleyDB in this scenario. I found out the hard way when after about 4 months of no problems I was suddenly unable to access my repository (something about a BDB version mismatch).
  • In this scenario newproject has the structure newproject/trunk tags branches.
  • Don't forget to append the directory name to the SVNROOT in the import. Otherwise the contents of newproject/ will be imported to the root of your SVNROOT, which isn't very useful.
Verify your import with svn list file:///home/kjvarga/svnroot/newproject/

Checkout your import

The next logical step is to checkout the project you just checked in.
svn checkout file:///home/kjvarga/svnroot/newproject/trunk svnproject

Don't forget that you're checking out the trunk/ directory!

If you're not checking out the project locally you will need to supply a URL pointing to the repository resource.

I'm on a shared host which doesn't allow any direct access to SVN so I have to connect using ssh+svn. In taht case your checkout would look something like this:

svn checkout svn+ssh://kjvarga@varzyfamily.com/home/kjvarga/svnroot/newproject/trunk newproject

Friday, October 17, 2008

CSS Tips and Tricks

Every time I get back into CSS I forget some of the basic rules about inline and block level elements, positioning and box models. I'm not a fan of browser hacks, so you won't find any of those here.

Inline Elements

  • Can have width, padding-left, padding-right, margin-left and margin-right applied. However height, padding-top, padding-bottom, margin-top and margin-bottom are not applied.
  • To set the height you can use the line-height property.

Vertically Centered Text

  • An easy way center text vertically within an element is to use the line-height property. If the line-height is greater than the font size, the extra space is distributed evenly above and below the text.

Horzontally Centered Elements

  • Set a width and margin: 0 auto; on an element to have it horizontally centered.

Clearing Floats

  • Clearing floats with clear: left; clear: right; or clear: both; will clear all floats that precede the element in the document model. So use floats wisely because you will probably end up clearing floats on other parts of the page which you did not intent to clear.

Absolute vs Relative Positioned Elements

  • A relatively positioned element's margins will collapse (the margin will be the maximum of the two adjacent element's margins). However an absolutely positioned element will start a new block formatting context and its margins will not collapse with adjoining elements.
  • An absolutely positioned element is taken out of the document flow and positioned relative to the first positioned (rel or abs) ancestor.

100% Height Divs

  • Assigning height: 100% to a div will have no effect without a height defined on the parent.

Tuesday, October 7, 2008

How to determine your hourly rate as a contractor

This is a useful bit of information I pulled off of salary.com about how to derive your hourly rate as a contractor based on your current salary:

Independent contractor fees. If you work as an independent contractor without going through an agency, you have some leeway in establishing your professional fees, but you should charge close to market. To calculate this rate, start with the prevailing full-time salary for that job. Then divide by 2080, the number of work hours in a year (2080 = 52 X 40). This is the hourly rate for your job if benefits are being paid for by the employer.

But as a contractor, you need to pay for your own benefits, as well as additional Social Security contributions, so the number needs to be higher. Salary.com uses an adjustment factor of 30 percent to convert an hourly wage for a salaried employee to an hourly wage for a contract employee. Multiply your unadjusted hourly rate by (1 + 0.3) to get your adjusted hourly rate. For example, if your unadjusted hourly rate comes out to $20 per hour, your contract rate should be $20 * (1.3) = $26.

An example shows how this works for a senior-level web designer in Kansas City. A Web designer III working in Kansas City makes $66,244. The unadjusted hourly rate for this position is $66,244/2,080, or $31.85. Adjusted by 30 percent, the contract rate comes to $41.40.

Contract fee for a Web designer III in Kansas City

Salary$66,244
Hourly rate, unadjusted$31.85
Adjustment factor30%
Hourly rate, adjusted$41.40

Source: Salary.com, May 2002.