<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Less Everything Blog - Code</title>
  <id>tag:b.lesseverything.com,2008:mephisto/code</id>
  <generator version="0.7.2" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://b.lesseverything.com/feed/code/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://b.lesseverything.com/code" rel="alternate" type="text/html"/>
  <updated>2008-06-25T18:55:18Z</updated>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Steven Bristol</name>
    </author>
    <id>tag:b.lesseverything.com,2008-06-25:3399</id>
    <published>2008-06-25T18:54:00Z</published>
    <updated>2008-06-25T18:55:18Z</updated>
    <category term="Code"/>
    <link href="http://b.lesseverything.com/2008/6/25/patch-your-rubies" rel="alternate" type="text/html"/>
    <title>Patch your rubies</title>
<content type="html">
            &lt;p&gt;You probably have heard by now that there are some security issues with all the versions of Ruby and that you should upgrade your Ruby to get the fixes. The holes mainly involve buffer overruns and a particularly nasty vulnerability that only affects non-Unix based operating system. These effect Ruby versions 1.8.5, 1.8.6, 1.8.7 and 1.9.0. (Since I only use 1.8.6, that&#8217;s all I&#8217;ll talk about here.) The solution is to update 1.8.6 to version 1.8.6-230. Unfortunately p230 breaks rails and almost everything else running ruby. So what is a boy to do? Well &lt;a href=&quot;http://blog.phusion.nl&quot;&gt;Hong Li&lt;/a&gt; has come to the rescue. He has back ported the changes to p111 so the rest of us can apply his patch and secure our 1.8.6 machines at p111. The fix involves downloading Ruby 1.8.6-111, patching the source, compiling ruby and restarting your apps.&lt;/p&gt;


	&lt;h2&gt;Here is how you do it:&lt;/h2&gt;


&lt;ul&gt;
&lt;li&gt;Run the following commands:
&lt;pre&gt;&lt;code&gt;
&amp;gt; wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.gz
&amp;gt; tar zxvf ruby-1.8.6-p111.tar.gz
&amp;gt; cd ruby-1.8.6-p111
&amp;gt; wget http://blog.phusion.nl/assets/r8ee-security-patch-20080623.txt
&amp;gt; patch -i r8ee-security-patch-20080623.txt
&amp;gt; ./configure
&amp;gt; make
&amp;gt; sudo make install
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Restart you mongrels and any other Ruby applications.&lt;/li&gt;
&lt;/ul&gt;

	&lt;h2&gt;Notes:&lt;/h2&gt;


&lt;ul&gt;
&lt;li&gt;While patching I would get the following:
&lt;pre&gt;&lt;code&gt;
index 410cc6f..c8278b7 100644
|--- a/lib/webrick/httpservlet/filehandler.rb
|+++ b/lib/webrick/httpservlet/filehandler.rb
--------------------------
File to patch: 
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
 * Just give it this path: lib/webrick/httpservlet/filehandler.rb

&lt;/li&gt;
&lt;li&gt;Sometimes the sudo make install would fail with an error:
&lt;pre&gt;&lt;code&gt;
/bin/sh: ./miniruby: No such file or directory
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
* Just run &#8220;make clean&#8221; and then ./configure, make, sudo make install again.

&lt;/li&gt;
&lt;/ul&gt;

	&lt;p&gt;&lt;sub&gt;Thanks to &lt;a href=&quot;http://metaclass.org/&quot;&gt;Wilson Bilkovich&lt;/a&gt; for pointing me in the direction of Hong Li&#8217;s patch. &lt;/sub&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Steven Bristol</name>
    </author>
    <id>tag:b.lesseverything.com,2008-06-09:2972</id>
    <published>2008-06-09T12:48:00Z</published>
    <updated>2008-06-09T16:34:25Z</updated>
    <category term="Code"/>
    <link href="http://b.lesseverything.com/2008/6/9/converting-tzinfo-from-rails-2-0-to-2-1" rel="alternate" type="text/html"/>
    <title>Converting tzinfo from rails 2.0 to 2.1</title>
<content type="html">
            &lt;p&gt;For those of you cool enough to have time zone support in your pre-rails 2.1 app, here is how you can convert the tzinfo stuff to the new way.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;In you environment.rb, change config.active_record.default_timezone = :utc to config.time_zone = &#8216;UTC&#8217;.&lt;/li&gt;
		&lt;li&gt;In your application.rb change the set_timezone around filter to a before filter. Make sure it is called after there is a valid user.
	&lt;ul&gt;
	&lt;li&gt;In that filter, you probably have two paths, one for a user and one for no user. Change the user line from TzTime.zone = user.tz to Time.zone = user.tz. Remove the other path, it&#8217;s no longer necessary.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;In your users model you can remove the line that used to say: composed_of :tz, :class_name =&amp;gt; &#8216;TZInfo::Timezone&#8217;, :mapping =&amp;gt; %w( time_zone time_zone ).
	&lt;ul&gt;
	&lt;li&gt;Just make sure the column that holds the time_zone info is called &#8220;time_zone.&#8221; &lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;Remember the helper method called &#8220;tz&#8221; which converts the times in columns to the user&#8217;s time? Remove it, this happens automatically now.&lt;/li&gt;
		&lt;li&gt;Delete the tz* plugins.&lt;/li&gt;
		&lt;li&gt;If you had something like this in your view: &amp;lt;&lt;span&gt;= time_zone_select &#8216;person&#8217;, :time_zone, TZInfo::Timezone.us_zones, :model =&amp;gt; TZInfo::Timezone %&amp;gt; change it to &amp;lt;&lt;/span&gt;= time_zone_select &#8216;person&#8217;, :time_zone, TimeZone.us_zones %&amp;gt;.&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;http://www.workingwithrails.com/recommendation/new/person/8170-trevor-turk&quot;&gt;Trevor&lt;/a&gt; &lt;a href=&quot;http://almosteffortless.com/&quot;&gt;Turk&lt;/a&gt; has created a &lt;a href=&quot;http://almosteffortless.com/2008/06/03/migrate-to-the-rails-default-time-zones/&quot;&gt;nice little script&lt;/a&gt; that will migrate your existing users&#8217; time zone data to the new format. (The string that holds the time zone data has changed in the new version, so we have to map the old strings to the new.)
	&lt;ul&gt;
	&lt;li&gt;You will want to use the PseudoCursors plugin or the WIll Paginate pagination stuff instead of User.find.all.each so you don&#8217;t kill your server when running this migration.&lt;/li&gt;
		&lt;li&gt;Thanks Trevor!&lt;/li&gt;
	&lt;/ul&gt;&lt;/li&gt;
	&lt;/ul&gt;


&amp;lt;strike&gt;
h2. One unresolved problem:

If you used something like the previous helper method to display the drop down of time choices you find that what is returned in the new list is significantly shorter, and they all have different values. E.G. in the old list you would find things like: &#8220;America/New_York,&#8221; &#8220;Africa/Ndjamena,&#8221; and &#8220;Etc/GMT-7&#8221; but in the new list the items are like this: &#8220;Eastern Time (US &amp;amp; Canada),&#8221; &#8220;Nairobi,&#8221; and &#8220;Wellington.&#8221; The problem is that we need to convert the values in our production apps to the new values. I haven&#8217;t figured out a way to do this yet. If you open script/console in a &amp;lt; 2.1 app you can find the old values are generated via:
TZInfo::Timezone.get(TZInfo::Timezone.all_identifiers&#91;0]), which returns the first time zone. The to_s and name methods are what get called on the object to create the value and text for the options. In a 2.1 app, TimeZone.all&#91;7] is what get called to find the 8th time zone. (to_s and name are still what get called.) I haven&#8217;t yet figured out how to map the old to the new, assuming there is a way. If someone figures this out, please post in the comments and I&#8217;ll update this post.
&amp;lt;/strike&gt;

	&lt;h2&gt;One last bit of coolness.&lt;/h2&gt;


	&lt;p&gt;The new method of doing time zones even works when rendering values from the model. So on those rare times when you need to render &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; from the model (like if you&#8217;re sending &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; via &lt;span class=&quot;caps&quot;&gt;XMPP&lt;/span&gt;) you don&#8217;t have to jump through any hoops to make that happen.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Steven Bristol</name>
    </author>
    <id>tag:b.lesseverything.com,2008-05-20:2447</id>
    <published>2008-05-20T20:05:00Z</published>
    <updated>2008-05-20T20:52:57Z</updated>
    <category term="Code"/>
    <link href="http://b.lesseverything.com/2008/5/20/where-do-the-hottest-rails-programmers-sleep" rel="alternate" type="text/html"/>
    <title>Where do the hottest rails programmers sleep?</title>
<content type="html">
            &lt;p&gt;&lt;a href=&quot;http://workingwithrails.com&quot;&gt;Working With Rails&lt;/a&gt; is a community site for rails developers. We all put our stats there (to some greater or lesser degree).  When I come across someone new I go to &lt;span class=&quot;caps&quot;&gt;WWR&lt;/span&gt; to see their info. One of the cool things on the &lt;span class=&quot;caps&quot;&gt;WWR&lt;/span&gt; site is the &lt;a href=&quot;http://www.workingwithrails.com/browse/popular/people&quot;&gt;Top 100 Popular list&lt;/a&gt;. This is a source of amusement for those of us in the community. If you look at the list, you will see that I am currently number 42 and Allan is number 61.&lt;/p&gt;


	&lt;p&gt;I&#8217;ve always wondered which are the hottest cities for rails development. Surely the answer is Chicago, because &lt;a href=&quot;http://www.loudthinking.com/&quot;&gt;David&lt;/a&gt; &lt;a href=&quot;http://www.workingwithrails.com/person/5246-david-heinemeier-hansson&quot;&gt;(1)&lt;/a&gt; lives there, but the other cities? San Fransisco, Seattle, San Diego, Jacksonville? Jacksonville? Yes, Jacksonville. We decided to find out, so we created &lt;a href=&quot;http://railscities.com&quot;&gt;Rails Cities&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;This one page site looks at the &lt;span class=&quot;caps&quot;&gt;WWR&lt;/span&gt; Popular page and sorts it based on city. The cities are ranked based on the number of people who are on the popular list. If two cities are tied, the lowest cumulative ranking bewteen the the two cities wins. Looking at the list it becomes apparent that many on this list do not keep their address current, hopefully they will now.&lt;/p&gt;


	&lt;p&gt;We get the data and regenerate the page every night. That&#8217;s it. Enjoy it.&lt;/p&gt;


	&lt;p&gt;Oh, and where does Jacksonville place? Currently number five; behind Chicago.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Allan Branch</name>
    </author>
    <id>tag:b.lesseverything.com,2008-04-22:1960</id>
    <published>2008-04-22T13:21:00Z</published>
    <updated>2008-04-22T13:24:11Z</updated>
    <category term="Code"/>
    <category term="Design"/>
    <link href="http://b.lesseverything.com/2008/4/22/weallhatequickbooks-com" rel="alternate" type="text/html"/>
    <title>WeAllHateQuickbooks.com</title>
<content type="html">
            &lt;br&gt;
Here's a screencast of the css trickery from our newest app &lt;a href=&quot;http://www.weallhatequickbooks.com&quot;&gt;WeAllHateQuickbooks.com&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;http://screencast.com/t/UpTDltgn&quot;&gt;Link to Screencast&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
The app scans Twitter.com for the word &quot;Quickbooks&quot; and displays the tweet.
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Steven Bristol</name>
    </author>
    <id>tag:b.lesseverything.com,2008-04-17:1967</id>
    <published>2008-04-17T14:19:00Z</published>
    <updated>2008-04-17T14:24:50Z</updated>
    <category term="Code"/>
    <link href="http://b.lesseverything.com/2008/4/17/how-to-convince-developers-to-test" rel="alternate" type="text/html"/>
    <title>How to convince developers to test.</title>
<content type="html">
            &lt;p&gt;I was sent an email from a colleague asking about our testing philosophy and how we would get a developer to take a test driven development approach to writing code.&lt;/p&gt;


	&lt;p&gt;Here was his question:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;Do you guys approach development with &lt;span class=&quot;caps&quot;&gt;TDD&lt;/span&gt;/BDD?&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;blockquote&gt;
		&lt;p&gt;If so, do you ever have any issues with developers slipping back into the &#8216;traditional&#8217; modes of development? i.e. &#8220;Who needs these tests.. I&#8217;ll fix it if its broken&#8221;.  Obviously, &lt;span class=&quot;caps&quot;&gt;TDD&lt;/span&gt; is a concept where all involved really need to buy in &#8211; but it takes discipline.  I was wondering if you guys simply run rcov now and again to check for coverage, review code periodically etc..&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;My response:&lt;/p&gt;


	&lt;p&gt;Everyone at Less breathes tests. We love them. In my experience the easiest way to make a developer fall in love with testing is to have them write tests on their own code. Assuming they know how to write tests, they will find bugs in their own code. Some mentoring may be required to teach proper testing.&lt;/p&gt;


	&lt;p&gt;If someone said to me &#8220;Who needs these tests. I&#8217;ll fix it if its broken&#8221;. I would reply, &#8220;It is broken right now. You just haven&#8217;t found the bugs yet.&#8221; If I was asked that question again I would start thinking that maybe that person isn&#8217;t such a good fit for Less. If finding their own bugs wasn&#8217;t inspiring enough, I would start thinking that maybe that person isn&#8217;t such a good fit for Less.&lt;/p&gt;


	&lt;p&gt;From our perspective a buggy app is not done, so we will keep fixing the bugs until the app is right. If your developer has already used up the budget writing the buggy code, then you, as the owner, are paying
for the bug fixes. Writing tests either before, or while the code is being written ends up being faster and cheaper because when you ship you are done. Otherwise you can&#8217;t have a proper budget for a project
and you are likely loosing out.&lt;/p&gt;


	&lt;p&gt;We use rcov to see if there is a test we are missing. There usually is one or two so we fill in the blanks. But we rarely get 100% coverage. 100% coverage feels good, but it does not mean the app is well tested, just well covered. Also, rcov only provides C0 coverage, so it can be fooled into reporting something is covered when it is not. (Does anyone know a C1 or C2 tool for Rails?)&lt;/p&gt;


	&lt;p&gt;Code reviewing is actually very hard to do well. I admit that I am not the best at doing code review, so we don&#8217;t use it a lot. Code review is very good for making sure the code is good in general terms. Checking for obvious things, are finders being scoped or is security being applied properly. But reviewing the code diff between revision 737 and 738 may be tricky enough that you approve something that has a new bug in it.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Steven Bristol</name>
    </author>
    <id>tag:b.lesseverything.com,2008-04-10:1924</id>
    <published>2008-04-10T16:06:00Z</published>
    <updated>2008-04-10T16:11:00Z</updated>
    <category term="Code"/>
    <link href="http://b.lesseverything.com/2008/4/10/rails-tip-always-scope-your-finders" rel="alternate" type="text/html"/>
    <title>Rails Tip: Always Scope Your Finders</title>
<content type="html">
            &lt;p&gt;It is easy to open a security hole in your Rails application. Fortunately, by scoping your finders, it is also easy to write your code without opening it.&lt;/p&gt;


	&lt;p&gt;Here is an example. Let&#8217;s say you have a expense tracking application and the url is /expenses/151. Obviously this calls the expenses controller with a params[:id] = 151.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
#bad:
def show
  @expense = Expenses.find(params[:id])
end

#good:
#@user is the logged on user.
def show
  @expense = @user.expenses.find(params[:id])
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;The scoped finders actually add the proper where clause to the sql. It happens automatically. Without scoping the expense finder, anyone can see anyone else&#8217;s data. Generally you will want to set this up as a before filter.&lt;/p&gt;


	&lt;p&gt;This also works for nested routes. Let&#8217;s say the url is /invoices/25/line_items/87:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
class LineItemsController &amp;lt; ApplicationController
  before_filter :setup
#snip many lines

  protected
  def setup
    @invoice = @user.invoices.find(params[:invoice_id]) unless params[:invoice_id].blank?
    @line_item = @invoice.blank? ? @user.line_items.find(params[:id]) : @invoices.line_items.find(params[:id])
  end
end
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;You don&#8217;t have to use the @user variable. In &lt;a href=&quot;http://lessaccounting.com&quot;&gt;Less Accounting&lt;/a&gt; we use sub-domains for each business. Since each business may have several users, all the controllers are scoped around the @business variable, which is determined by the sub-domain of the url. The @business variable itself is scoped by the @user variable.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Steven Bristol</name>
    </author>
    <id>tag:b.lesseverything.com,2008-04-09:1910</id>
    <published>2008-04-09T12:14:00Z</published>
    <updated>2008-04-09T12:14:07Z</updated>
    <category term="Code"/>
    <link href="http://b.lesseverything.com/2008/4/9/redirect-from-www-to-non-www-using-nginx" rel="alternate" type="text/html"/>
    <title>Redirect from www to non-www using Nginx</title>
<content type="html">
            &lt;p&gt;Let&#8217;s say you want to redirect users from the www sub-domain of your website to direct access via the non-sub-domain url. &lt;a href=&quot;http://wiki.codemongers.com/Main&quot;&gt;Nginx&lt;/a&gt;  makes it really easy to do.&lt;/p&gt;


	&lt;p&gt;Just add this to your server{} block:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
if ($host != 'your_domain.com' ) {
    rewrite  ^/(.*)$  http://your_domain.com/$1  permanent;
 }

&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;This actually will redirect any sub-domain to the non-sub-domain url.&lt;/p&gt;


	&lt;p&gt;But what if, like &lt;a href=&quot;http://lessaccounting.com&quot;&gt;Less Accounting&lt;/a&gt;, your site has user accounts for sub-domains or you have other valid sub-domains, but you still want to get users away from www?&lt;/p&gt;


	&lt;p&gt;Just add this to your server{} block:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
if ($host = 'www.your_domain.com' ) {
    rewrite  ^/(.*)$  http://your_domain.com/$1  permanent;
 }
&lt;/pre&gt;&lt;/code&gt;
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Steven Bristol</name>
    </author>
    <id>tag:b.lesseverything.com,2008-04-04:1889</id>
    <published>2008-04-04T17:52:00Z</published>
    <updated>2008-04-04T18:15:57Z</updated>
    <category term="Code"/>
    <link href="http://b.lesseverything.com/2008/4/4/git-howto-start-a-new-project-based-on-an-other-project" rel="alternate" type="text/html"/>
    <title>Git HOWTO Start a new project based on an other project</title>
<content type="html">
            &lt;p&gt;In my &lt;a href=&quot;http://b.lesseverything.com/2008/3/25/got-git-howto-git-and-github&quot;&gt;previous article&lt;/a&gt; we talked about how to use git and github. In this article we&#8217;ll talk about how to make a project that is based on another project.&lt;/p&gt;


	&lt;p&gt;The scenario: There is an existing open source project that you would like to use as the starting point for your new killer web 2.1 website. You are the bomb. I&#8217;m going to use one of my existing open source projects so you can all play along at home.&lt;/p&gt;


	&lt;h2&gt;Note:&lt;/h2&gt;


	&lt;ol&gt;
	&lt;li&gt;If you haven&#8217;t read the &lt;a href=&quot;http://b.lesseverything.com/2008/3/25/got-git-howto-git-and-github&quot;&gt;previous article&lt;/a&gt;, please go do so now.&lt;/li&gt;
		&lt;li&gt;This assumes that you are using &lt;a href=&quot;http://github.com&quot;&gt;github&lt;/a&gt;. (I still have some invites, so if you&#8217;d like one, just send me a note).&lt;/li&gt;
		&lt;li&gt;You are using git 1.5.4 or greater on your local machine. (git&#8212;version)&lt;/li&gt;
	&lt;/ol&gt;


	&lt;h2&gt;Here we go&lt;/h2&gt;


	&lt;ol&gt;
	&lt;li&gt;Go to github and create a new repo. 
	&lt;ul&gt;
	&lt;li&gt;Make sure you follow the instructions, doing the local git init through the git push origin master.&lt;/li&gt;
		&lt;li&gt;You now have a fresh repo for you new fancy almost funded web 2.2 website. You are the man.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;git remote add stevenbristol git://github.com/stevenbristol/lovd-by-less.git
	&lt;ul&gt;
	&lt;li&gt;Now you have two remotes. One to your origin and one to the lovd-by-less master.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;git pull stevenbristol master
	&lt;ul&gt;
	&lt;li&gt;this gets the lovd-by-less source and puts it into your local directory.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;git push
	&lt;ul&gt;
	&lt;li&gt;This will push your changes to your master.&lt;/li&gt;
		&lt;li&gt;What!? I didn&#8217;t commit anything, what&#8217;s going on here? When you did the remote pull, the files are automatically comited.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;git fetch stevenbristol
	&lt;ul&gt;
	&lt;li&gt;Git magic is happening right now.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;git branch stevenbristol stevenbristol/master
	&lt;ul&gt;
	&lt;li&gt;This creates a tracking branch.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;git branch
	&lt;ul&gt;
	&lt;li&gt;See all of your branches.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;git remote
	&lt;ul&gt;
	&lt;li&gt;See all of your remotes.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;git checkout stevenbristol&lt;/li&gt;
		&lt;li&gt;git pull
	&lt;ul&gt;
	&lt;li&gt;Nothing to pull because there have been no changes since the previous pull (step 3).&lt;/li&gt;
		&lt;li&gt;Notice that we didn&#8217;t have to specify which remote to pull from, as we would have if this had been a normal branch created with git branch -b.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;git checkout master
	&lt;ul&gt;
	&lt;li&gt;Back to your master.&lt;/li&gt;
		&lt;li&gt;Now you can git (sic) to work building your ultimate about to be tech crunched web 2.3 website. Everyone is jealous of you. And you love it.&lt;/li&gt;
	&lt;/ol&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Thanks to &lt;a href=&quot;http://web20show.com/&quot;&gt;Josh&lt;/a&gt; &lt;a href=&quot;http://tastyplanner.com/&quot;&gt;Owens&lt;/a&gt; who keeps answering my git questions and made this post possible.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Steven Bristol</name>
    </author>
    <id>tag:b.lesseverything.com,2008-04-04:1887</id>
    <published>2008-04-04T13:08:00Z</published>
    <updated>2008-04-04T13:09:32Z</updated>
    <category term="Code"/>
    <link href="http://b.lesseverything.com/2008/4/4/git-got-gooder-textmate-support" rel="alternate" type="text/html"/>
    <title>Git got gooder. Textmate Support!!</title>
<content type="html">
            &lt;p&gt;You all know &lt;a href=&quot;http://b.lesseverything.com/2008/3/25/got-git-howto-git-and-github&quot;&gt;how to use git&lt;/a&gt;, and now there is a Textmate bundle to make git even easier to use. Go &lt;a href=&quot;http://gitorious.org/projects/git-tmbundle&quot;&gt;here&lt;/a&gt; and follow the instructions. That&#8217;s all. Enjoy,&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Steven Bristol</name>
    </author>
    <id>tag:b.lesseverything.com,2008-03-26:1830</id>
    <published>2008-03-26T13:46:00Z</published>
    <updated>2008-03-26T14:41:21Z</updated>
    <category term="Code"/>
    <link href="http://b.lesseverything.com/2008/3/26/steven-bristol-on-rails-envy-podcast" rel="alternate" type="text/html"/>
    <title>New Rails Envy Podcast is out -- Starring Me!</title>
<content type="html">
            &lt;p&gt;Go to &lt;a href=&quot;http://www.railsenvy.com/&quot;&gt;http://www.railsenvy.com/&lt;/a&gt; to hear the latest episode of this great podcast. This week I was a guest host.&lt;/p&gt;


	&lt;p&gt;Passisizzle &lt;span class=&quot;caps&quot;&gt;FTW&lt;/span&gt;!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Steven Bristol</name>
    </author>
    <id>tag:b.lesseverything.com,2008-03-25:1818</id>
    <published>2008-03-25T13:19:00Z</published>
    <updated>2008-03-25T13:19:31Z</updated>
    <category term="Code"/>
    <category term="Lovd by Less"/>
    <link href="http://b.lesseverything.com/2008/3/25/got-git-howto-git-and-github" rel="alternate" type="text/html"/>
    <title>Got Git? HOWTO git and github</title>
<content type="html">
            &lt;h1&gt;Background:&lt;/h1&gt;


	&lt;p&gt;Last week we released the open source social network &lt;a href=&quot;http://lovdbyless&quot;&gt;Lovd By Less&lt;/a&gt;. Almost immediately we had requests for people wanting to add code back into Lovd. Lovd had been housed in a private svn repository and distributed via a zip file. This was really good for me, but not so for people that want to take the current version, build on it and later merge whatever newer version of Lovd is available into their app. Although I hadn&#8217;t yet tried git I knew that it made this sort of branching a lot easier than subversion, so I decided to try it.&lt;/p&gt;


	&lt;h1&gt;Getting started with Github:&lt;/h1&gt;


	&lt;p&gt;&lt;a href=&quot;http://github.com&quot;&gt;Github&lt;/a&gt; is the new cool git repository website (social network for geeks). I asked a friend for an invite and got started. Creating a github account and repository is really easy. The instructions are well laid out. The last step is to export your svn repo into the git directory and then commit and push. I&#8217;ve been told that if anyone needs a git invite to let me know and I&#8217;ll be given invites to send out. So let me know.&lt;/p&gt;


	&lt;h1&gt;Now what?&lt;/h1&gt;


	&lt;p&gt;So now I had my git repo setup on github and I started sending out the repo&#8217;s public address. And before I know it I had my first patch. Now what? I read &lt;a href=&quot;http://drnicwilliams.com/2008/02/03/using-git-within-a-team/&quot;&gt;Dr. Nic&#8217;s blog post about git&lt;/a&gt; when it came out, so I went back and read it again. After reading a few times I realized two things: (1) That git is very complicated and (2) Dr. Nic is a way bigger StarWars geek than I ever gave him credit for. I called my friend &lt;a href=&quot;http://tastyplanner.com/&quot;&gt;Josh Owens&lt;/a&gt; (of the &lt;a href=&quot;http://web20show.com/&quot;&gt;Web 2.0 Show&lt;/a&gt;) and asked for some help. Josh talked me through my first merge and push, but I still didn&#8217;t quite get it. The next day I was trying to merge another patch (branch) and since Josh wasn&#8217;t around I went into #github where Tom Preston-Werner (mojombo) helped sort me out quite a bit.&lt;/p&gt;


	&lt;h1&gt;Disclaimer:&lt;/h1&gt;


	&lt;p&gt;I am still new at git so I may have things wrong, so if you find an error or omission, please say so in the comments.&lt;/p&gt;


	&lt;h1&gt;Git explained (I think):&lt;/h1&gt;


	&lt;p&gt;Understatement: Git is very different from Subversion. Git is a distributed source control system, which means you can work disconnected from the main repo (branch) and still commit. But you commit to your local repo (branch). The basic flow is (some crucial steps have been left out for now. I&#8217;ll fill those in later. Don&#8217;t use the following as a step by step guide, that comes later):&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;git clone. This basically tells your local git to go out an pull the files from the server.&lt;/li&gt;
		&lt;li&gt;Make your changes.&lt;/li&gt;
		&lt;li&gt;git commit. This commits your files to your &lt;span class=&quot;caps&quot;&gt;LOCAL&lt;/span&gt; repository, not the one on the server.&lt;/li&gt;
		&lt;li&gt;git push. This &#8220;pushes&#8221; you committed changes up to the server.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;OK, so far so good. This feels a lot like svn. So much that it&#8217;s time to get overconfident and think we get git. But we don&#8217;t. And our confidence is about to be shaken like a dry martini.&lt;/p&gt;


	&lt;p&gt;But I have my own repo and people are trying to commit to me. What do I do, how does that work?&lt;/p&gt;


	&lt;h1&gt;You are the master:&lt;/h1&gt;


	&lt;p&gt;In git everything revolves around branches (github calls them forks&lt;sup&gt;&lt;a href=&quot;#fn1&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;). When you create a git repo, that main branch is called &#8220;master.&#8221; Your master branch is kind of like what trunk is in svn. When someone wants to fork/branch your master, they go to your page in github and click the fork button. Now they have a fork/branch of your master branch. When they are ready for you to check out their changes and merge theirs back into your master they&#8217;ll send you a message via git hub. You&#8217;ll get this message in your inbox and have no idea what to do with it. Cool.&lt;/p&gt;


	&lt;p&gt;The first thing to notice is that the url for their branch looks a lot like the url to your master. My &#8220;public clone url&#8221; is git://github.com/stevenbristol/lovd-by-less.git. Dr. Nic&#8217;s looks like this: git://github.com/drnic/lovd-by-less.git. The similarities matter.&lt;/p&gt;


	&lt;p&gt;To get Dr. Nic&#8217;s branch and merge it into my master I do the following (let&#8217;s assume I have my master cloned to /lovd):&lt;/p&gt;


	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;NOTE&lt;/span&gt;: Put the contents of &lt;a href=&quot;http://pastie.textmate.org/170118&quot;&gt;this pastie&lt;/a&gt; in the top of your ~/.bash_profile file to see which branch you are currently working in. This is demonstrated in the examples below. The part in parens is the branch. (&lt;a href=&quot;http://pastie.caboo.se/pastes/165446&quot;&gt;Another version&lt;/a&gt; of the same thing.) (After changing your ~/.bash_profile file you&#8217;ll either have to restart terminal or source the file to see the changes.)&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;/luvd(master) $ git remote add drnic git://github.com/drnic/lovd-by-less.git&lt;/li&gt;
		&lt;li&gt;/luvd(master) $ git pull&lt;/li&gt;
		&lt;li&gt;/luvd(master) $ git checkout -b drnic/master&lt;/li&gt;
		&lt;li&gt;/luvd(drnic/master) $ git pull drnic master&lt;/li&gt;
		&lt;li&gt;[look at the files, rake, test, etc]&lt;/li&gt;
		&lt;li&gt;/luvd(drnic/master) $ git status&lt;/li&gt;
		&lt;li&gt;/luvd(drnic/master) $ git checkout master&lt;/li&gt;
		&lt;li&gt;/luvd(master) $ git merge drnic/master&lt;/li&gt;
		&lt;li&gt;/luvd(master) $ git status&lt;/li&gt;
		&lt;li&gt;/luvd(master) $ git commit -a&lt;/li&gt;
		&lt;li&gt;/luvd(master) $ git push&lt;/li&gt;
	&lt;/ol&gt;


	&lt;ul&gt;
	&lt;li&gt;Step 1 tells my local git repo to add a new remote repository. This means that the same repo can pull and push to two different server&lt;sup&gt;&lt;a href=&quot;#fn2&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;. There is nothing analogous in svn. The syntax is &#8220;git remote add {name} {url}.&#8221; I am naming this remote &#8220;drnic,&#8221; because I am going to pull his branch.&lt;/li&gt;
		&lt;li&gt;Step 2 simply pulls my local master. This is like doing an svn up. I do this because I gave commit rights to someone else and I want to make sure I have the latest changes in my local master. Step 4 also does a pull, but there we have to specify where we are pulling from. Here it defaults to the &#8220;origin,&#8221; which is my git master on github.&lt;/li&gt;
		&lt;li&gt;Step 3 is a bit confusing because I am not doing anything like an svn checkout. A git checkout basically changes the branch I am working with. The -b switch means to create the new branch&lt;sup&gt;&lt;a href=&quot;#fn3&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;. Notice that in steps 1 -3 I was in branch master (master) but after I &#8220;git checkout drnic/master&#8221; I am in branch drnic/master (drnic/master&lt;sup&gt;&lt;a href=&quot;#fn4&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;). Get ready: Rather than have each branch in a different directory on the file system, all the branches live in the same directory. What? Exactly. Try this: Open Textmate and open a file that you know has changed between the two branches. Now go in to terminal and &#8220;git checkout {other branch}.&#8221; Go back to Textmate and notice that the file did actually change. What? Exactly. Isn&#8217;t this cool? But it means you must use the .bash_profile hack to know what branch you&#8217;re working in. Other wise you will go crazy. You can also do &#8220;git branch&#8221; which will tell you what branches are available locally and which one you are in.&lt;/li&gt;
		&lt;li&gt;Step 4 just says pull all of the files from the remote repo named &#8220;drnic&#8221; (which we created in step 1) and the branch, in this case &#8220;master.&#8221; Syntax: &#8220;git pull {name of remote} {name of branch}.&#8221; This is kind of like an svn checkout.&lt;/li&gt;
		&lt;li&gt;Step 6 shows which files have modifications. If you didn&#8217;t change anything then you can go on to step 7, otherwise you might have to git commit to your local branch of drnic&#8217;s branch of your master. (Don&#8217;t feel bad if you have to reread that a few times :)&lt;/li&gt;
		&lt;li&gt;Step 7 puts us back in the context of our master branch.&lt;/li&gt;
		&lt;li&gt;Step 8 merges the local drnic branch into our master branch.&lt;/li&gt;
		&lt;li&gt;Step 10 commits all unadded files to the local master repo. Unadded? Yes, in git a file with local modifications needs to be added back into the repo for committing. You can do this with &#8220;git add {file}&#8221; or just git commit all the added and unadded files.&lt;/li&gt;
		&lt;li&gt;Step 11 pushes your local changes back to your origin (master branch on github). Now other may fork/branch your master and start again. Easy right?&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h1&gt;You just want to patch some else&#8217;s repo:&lt;/h1&gt;


	&lt;p&gt;This is really simple. Here are the steps:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Go to github and click the &#8220;fork&#8221; button.&lt;/li&gt;
		&lt;li&gt;git clone git://github.com/stevenbristol/lovd-by-less.git&lt;/li&gt;
		&lt;li&gt;cd lovd-by-less&lt;/li&gt;
		&lt;li&gt;Make your cahnges&lt;/li&gt;
		&lt;li&gt;git status&lt;/li&gt;
		&lt;li&gt;git commit -a&lt;/li&gt;
		&lt;li&gt;git push&lt;/li&gt;
		&lt;li&gt;go back to git hub and click the &#8220;pull request&#8221; button.&lt;/li&gt;
	&lt;/ol&gt;


I&#8217;m guessing that by now this is really clear. 
	&lt;ol&gt;
	&lt;li&gt;Step 1 will create you own fork of the repo where you can make your changes. Click this on the person&#8217;s page you want to fork from.&lt;/li&gt;
		&lt;li&gt;Steps 2-7 you should understand by now. (I hope. :)&lt;/li&gt;
		&lt;li&gt;Step 8 will send a message to the person notifing them that you have something for them to see. Click this from your repo page.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;h1&gt;References:&lt;/h1&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://cheat.errtheblog.com&quot;&gt;cheat git&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;http://drnicwilliams.com/2008/02/03/using-git-within-a-team/&quot;&gt;http://drnicwilliams.com/2008/02/03/using-git-within-a-team/&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;http://github.com/guides/&quot;&gt;http://github.com/guides/&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;http://wiki.sourcemage.org/Git_Guide&quot;&gt;http://wiki.sourcemage.org/Git_Guide&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;http://git.or.cz/gitwiki/QuickStart&quot;&gt;http://git.or.cz/gitwiki/QuickStart&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h1&gt;Notes from Dr. Nic:&lt;/h1&gt;


	&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt; Technical not correct.  &#8220;Within a repository/clone you can have branches. A fork is a clone of a repository. Its a conceptual thing.&#8221; He continues, &#8220;I could manually create a fork by cloning 1+ branches from a target repository, then push that repository to my own remote repository. At this stage, I&#8217;ve theoretically got a remote clone of your remote repo. &#8220;Forking&#8221; is a nice word for this.&#8221; This is how someone can take Lovd, put it in their own private repo, build their app on top of Lovd, and easily get the latest patches from Lovd into their new killer app.&lt;/p&gt;


	&lt;p&gt;&lt;sup&gt;2&lt;/sup&gt; &#8220;A &#8220;remote&#8221; repo and a &#8220;local&#8221; repo contain the same information about the commits etc. The difference is that a &#8220;local&#8221; repo has a checkout of one branch plus a .git folder containing all the commit info. The remote repo just contains the commit etc information, but no checkout (see &#8220;git checkout&#8212;bare&#8221; I think creates a remote repo that you could host on from your laptop&#8217;s ~/Sites folder for example.&#8221;&lt;/p&gt;


	&lt;p&gt;&lt;sup&gt;3&lt;/sup&gt; &#8221;&#8221;git checkout -b drnic/master&#8221; &#8211; I tend to use &#8220;local/drnic/master&#8221; now &#8211; using local/ as a namespace to separate it out from any clashes with the remote repo. I think this is different from my original blog post.&#8221;&lt;/p&gt;


	&lt;p&gt;&lt;sup&gt;4&lt;/sup&gt; &#8220;The -b switch means to create the new branch, based on the current branch.&#8221;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Steven Bristol</name>
    </author>
    <id>tag:b.lesseverything.com,2008-03-12:1734</id>
    <published>2008-03-12T12:37:00Z</published>
    <updated>2008-03-12T12:54:19Z</updated>
    <category term="Code"/>
    <link href="http://b.lesseverything.com/2008/3/12/what-if-it-s-nil-what-if-it-s-method-is-nil" rel="alternate" type="text/html"/>
    <title>What if it's nil? What if it's method is nil? </title>
<content type="html">
            &lt;p&gt;&lt;a href=&quot;http://www.workingwithrails.com/person/5241-chris-wanstrath&quot;&gt;Chris Wanstrath&lt;/a&gt; wrote a nice little post about a method he created called &lt;a href=&quot;http://ozmm.org/posts/try.html&quot;&gt;try()&lt;/a&gt;, I thought this was pretty cool, but I really want to be able to specify the return value if the object is nil. Plus, what if I want to use this sweetness on a method? So I wrote two methods to do just that:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
class Object
  def if_nil out = nil
    return out if nil?
    self
  end

  def if_method_nil method, out = nil
    return out if nil?
    return send(method) if out.nil?
    return out if respond_to?(method) &#38;&#38; send(method).nil?
    send method
  end
end
&lt;/code&gt;&lt;/pre&gt;

And here are some tests for them, which illustrate their usage:
&lt;code&gt;&lt;pre&gt;

  def test_if_nil1
    n = nil
    assert_equal nil, n.if_nil
  end

  def test_if_nil2
    n = 1
    assert_equal 1, n.if_nil
  end

  def test_if_nil3
    n = :yo
    assert_equal :yo, n.if_nil
  end

  def test_if_nil4
    n = nil
    assert_equal 'blah', n.if_nil('blah')
  end

  def test_if_method_nil1
    n = nil
    assert_equal nil, n.if_method_nil(:to_s)
  end

  def test_if_method_nil2
    n = 1
    assert_raise NoMethodError do
      n.if_method_nil :yo
    end
  end

  def test_if_method_nil3
    n = 1
    assert_nothing_raised do
      assert_equal '1', n.if_method_nil( :to_s)
    end
  end

  def test_if_method_nil4
    n = 1
    assert_nothing_raised do
      assert_equal '1', n.if_method_nil( :to_s, 'blah')
    end
  end

  def test_if_method_nil5
    n = nil
    assert_nothing_raised do
      assert_equal 'blah', n.if_method_nil( :to_s, 'blah')
    end
  end
&lt;/code&gt;&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Steven Bristol</name>
    </author>
    <id>tag:b.lesseverything.com,2008-03-11:1728</id>
    <published>2008-03-11T15:47:00Z</published>
    <updated>2008-03-11T15:50:02Z</updated>
    <category term="Code"/>
    <link href="http://b.lesseverything.com/2008/3/11/use-attr_protected-or-we-will-hack-you" rel="alternate" type="text/html"/>
    <title>Use attr_protected or we will hack you</title>
<content type="html">
            &lt;p&gt;A good friend of mine recently asked me to look at his open source project and tell me what I think. While looking through the very nice code I discovered a security hole and promptly created a user account with administrative privileges using one command.&lt;/p&gt;


	&lt;p&gt;Here is the command:&lt;/p&gt;


	&lt;p&gt;curl -d &#8220;user[login]=hacked&#38;user[is_admin]=true&#38;user[password]=password&#38;user[password_confirmation]=password&#38;user[email]=hacked@by.me&#8221; http://url_not_shown/users&lt;/p&gt;


	&lt;p&gt;That&#8217;s right, that&#8217;s all it took. Try it. Take this line and point it at your favorite website and see if you can create an admin account.&lt;/p&gt;


	&lt;p&gt;There are a few easy things anyone can do to prevent this hack. In order of importance:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Use attr_protected.&lt;/li&gt;
		&lt;li&gt;Don&#8217;t use mass assignments for your users table.&lt;/li&gt;
		&lt;li&gt;Don&#8217;t have a users controller.&lt;/li&gt;
		&lt;li&gt;Split the users table into a users table and a profiles/people table.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;At Less we do all four.&lt;/p&gt;


	&lt;h2&gt;&lt;strong&gt;Use attr_protected&lt;/strong&gt;&lt;/h2&gt;


	&lt;p&gt;The attr_protected method in Rails will prevent the fields from being assigned via mass assignment. Here is an example:&lt;/p&gt;


Bad:
&lt;code&gt;&lt;pre&gt;
class User &amp;lt; ActiveRecord::Base
#no attr_protected here
#this will allow the creation of your hacked admin user
end

class Users &amp;lt; ApplicationController
  def create
      @user = User.create params[:user]
  end
end
&lt;/pre&gt;&lt;/code&gt;

Good:
&lt;code&gt;&lt;pre&gt;
#this will not allow the creation of your hacked admin user
class User &amp;lt; ActiveRecord::Base
  attr_protected :is_admin
end

class Users &amp;lt; ApplicationController
  def create
      @user = User.create params[:user]
#user is created, but the is_admin flag is not set
  end
end
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;Wasn&#8217;t that easy? You should all do this.&lt;/p&gt;


	&lt;h2&gt;&lt;strong&gt;Don&#8217;t use mass assignments for your users table&lt;/strong&gt;&lt;/h2&gt;


	&lt;p&gt;No where in your code should you allow the users table to use mass assignments. What this means is that when a user account is created, assign each field individually. Here is an example:&lt;/p&gt;


Bad:
&lt;code&gt;&lt;pre&gt;
class Users &amp;lt; ApplicationController
  def create
      @user = User.create params[:user]
  end
end
&lt;/pre&gt;&lt;/code&gt;

Good:
&lt;code&gt;&lt;pre&gt;
class Users &amp;lt; ApplicationController
  def create
      @user = User.new
      @user.login = params[:user][:login]
      @user.password = params[:user][:password]
      @user.password_confirmation = params[:user][:password_confirmation]
      @user.save
#user is created, but the is_admin flag is not set
  end
end
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;I know what you&#8217;re thinking &#8220;Steve, that is too many lines of code, can&#8217;t we use the built in stuff that Rails gives us to make thing easy?&#8221; My wife&#8217;s cousin is an Assistant Warden at a prison in Texas. While taking a tour I noticed a sign that says &#8220;Security is not convenient.&#8221; This is also true for security code. It is more lines of code, it is harder to write, it should fail securely.&lt;/p&gt;


	&lt;p&gt;If you need to have an admin screen where admins set is_admin on users, then that action should also not use mass assignment and it should be protected so that only users who are already is_admin can access it.&lt;/p&gt;


	&lt;h2&gt;&lt;strong&gt;Don&#8217;t have a users controller&lt;/strong&gt;&lt;/h2&gt;


	&lt;p&gt;This one is stupid. Obfuscation is the worst form of security, but combined with the others it is not too bad and worth doing. This will prevent all the script kiddies I just created from attacking your site because they will not know the name of the controller to hit. Of course if they just looked at the url that your signup form submits to they will know. That is why this is the weakest form of security. In fact it&#8217;s so weak it&#8217;s not really even security.&lt;/p&gt;


	&lt;h2&gt;&lt;strong&gt;Split the users table into a users table and a profiles/people table&lt;/strong&gt;&lt;/h2&gt;


	&lt;p&gt;Keep user settings that the system needs in the untouchable users table and user configurable settings in a separate table called profiles or people or something. Doing this means the only place the users table gets written to is on account creation and if you have an admin screen. The fewer access points you have, the safer you are.&lt;/p&gt;


	&lt;p&gt;It also means that for profile data, you can use your profiles controller which allows mass assignment and keep the code nice and tight.&lt;/p&gt;


	&lt;p&gt;Why are you still reading? Go, fix your code right now. My spider is already loose, looking for your rails app.&lt;/p&gt;


	&lt;p&gt;Go fix it already!!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Allan Branch</name>
    </author>
    <id>tag:b.lesseverything.com,2008-03-06:1699</id>
    <published>2008-03-06T16:21:00Z</published>
    <updated>2008-03-06T16:45:04Z</updated>
    <category term="Code"/>
    <category term="Design"/>
    <link href="http://b.lesseverything.com/2008/3/6/i-ve-found-the-holy-grail-ie6-png-transparency-fix-for-repeating-background-images" rel="alternate" type="text/html"/>
    <title>I've found the holy grail...</title>
<content type="html">
            &lt;img src=&quot;http://b.lesseverything.com/assets/2008/3/6/pee_on_IE6_1.png&quot; /&gt;
&lt;h2&gt;IE6 PNG Transparency Fix for Repeating Background Images&lt;/h2&gt;

****Update: its not actually repeating, its scaling the image which give the appearance of repeating vertically.
&lt;br&gt;&lt;br&gt;
This hack is for making transparent pngs, actually transparent in IE6 when used as a repeating background. I'm sure most people have a hack they use for transparent png images in the html for IE6. This isn't another fix for that, again, this is for background images that repeat.
&lt;br&gt;&lt;br&gt;
First, put a conditional statement in your head to display this hack when IE6 is used. Inside of this conditional statement you will insert the hack.
&lt;br&gt;&lt;br&gt;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/transparent_bg.png', sizingMethod='scale');
&lt;br&gt;&lt;br&gt;
Now, I haven't experimented much with this, with certain images, in certain situations this can give the appearance of a repeating background.
&lt;br&gt;&lt;br&gt;
In your normal css sheet it's business as normal, just place the background in the css and have a nice day.  Below is an example of the conditional statement and the css hack.
&lt;br&gt;

&lt;br&gt;&lt;br&gt;
&lt;b&gt;here are some screen captures, notice the &quot;rocks&quot; in the background behind the black background.&lt;/b&gt;&lt;br&gt;
&lt;a href=&quot;http://b.lesseverything.com/assets/2008/3/6/Picture_1.png&quot;&gt;Firefox Capture&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;http://b.lesseverything.com/assets/2008/3/6/Picture_2.png&quot;&gt;IE6 Capture&lt;/a&gt;&lt;br&gt;

&lt;div&gt;
&lt;code&gt;
&lt;pre&gt;

&amp;lt;!--[if IE 6]&gt;
&amp;lt;style&gt;
#IE_blows {
height: 100%; 
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/transparent_bg.png', sizingMethod='scale');}
&amp;lt;/style&gt;
&amp;lt;![endif]--&gt;

/* put in normal css sheet */
#IE_blows { 
  background: url(/images/transparent_bg.png) repeat-y;
}
/* put in normal css sheet */
&lt;/code&gt;
&lt;/pre&gt;
&lt;/div&gt;

****Update: its not actually repeating, its scaling the image which give the appearance of repeating vertically.
          </content>  </entry>
  <entry xml:base="http://b.lesseverything.com/">
    <author>
      <name>Allan Branch</name>
    </author>
    <id>tag:b.lesseverything.com,2008-03-06:1695</id>
    <published>2008-03-06T16:03:00Z</published>
    <updated>2008-03-06T16:04:41Z</updated>
    <category term="Code"/>
    <category term="Design"/>
    <link href="http://b.lesseverything.com/2008/3/6/i-ve-found-the-holy-grail-ie6-png-transparency-fix-for-repeating-background-images" rel="alternate" type="text/html"/>
    <title>I've found the holy grail...</title>
<content type="html">
            &lt;img src=&quot;http://b.lesseverything.com/assets/2008/3/6/pee_on_IE6_1.png&quot; /&gt;
&lt;h2&gt;IE6 PNG Transparency Fix for Repeating Background Images&lt;/h2&gt;
This hack is for making transparent pngs, actually transparent in IE6 when used as a repeating background. I'm sure most people have a hack they use for transparent png images in the html for IE6. This isn't another fix for that, again, this is for background images that repeat.
&lt;br&gt;&lt;br&gt;
First, put a conditional statement in your head to display this hack when IE6 is used. Inside of this conditional statement you will insert the hack.
&lt;br&gt;&lt;br&gt;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/transparent_bg.png', sizingMethod='scale');
&lt;br&gt;&lt;br&gt;
Now, I haven't experimented much with this.  I haven't tried X and Y repeating, if you do try this, post the results as a comment on this blog post. However it does work great with standard repeating of a background image.
&lt;br&gt;&lt;br&gt;
In your normal css sheet it's business as normal, just place the background in the css and have a nice day.  Below is an example of the conditional statement and the css hack.
&lt;br&gt;

&lt;div&gt;
&lt;code&gt;
&lt;pre&gt;

&amp;lt;!--[if IE 6]&gt;
&amp;lt;style&gt;
#IE_blows {
height: 100%; 
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/transparent_bg.png', sizingMethod='scale');}
&amp;lt;/style&gt;
&amp;lt;![endif]--&gt;

/* put in normal css sheet */
#IE_blows { 
  background: url(/images/transparent_bg.png) repeat-y;
}
/* put in normal css sheet */
&lt;/code&gt;
&lt;/pre&gt;
&lt;/div&gt;
          </content>  </entry>
</feed>
