<?xml version="1.0" encoding="UTF-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Mike Kruckenberg</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/" />
<modified>2011-09-02T17:59:19Z</modified>
<tagline>Thoughts on technology, recreation, society, etc</tagline>
<id>tag:mike.kruckenberg.com,2011://2</id>
<generator url="http://www.movabletype.org/" version="5.031">Movable Type</generator>
<copyright>Copyright (c) 2011, mike</copyright>

<entry>
<title>Andriod to iPod/iPhone Dock Adapter Cable</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/09/andriod_to_ipodiphone_dock_adapter_cable.html" />
<modified>2011-09-02T17:59:19Z</modified>
<issued>2011-09-01T22:11:04Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1174</id>
<created>2011-09-01T22:11:04Z</created>
<summary type="text/plain">I&apos;ve gotten a Zune connected to an iPod/iPhone dock in the past, but what seems more compelling these days with the rise of Android is to make an adapter or a cable to get a micro USB device to an...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Recreation</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p><img src="/images/android-iphone-dock-small.png" width="300" height="445" align="right" style="padding-left: 15px">I've gotten a <a href="http://mike.kruckenberg.com/archives/2008/12/connect-your-zune-to-an-ipod-or-iphone-dock.html">Zune connected to an iPod/iPhone dock</a> in the past, but what seems more compelling these days with the rise of Android is to make an adapter or a cable to get a micro USB device to an iPhone, iPod, or iPad docking station.</p>

<p><b>Important caveat</b>: it's technically impossible to provide the same kind of device integration that an iPod/iPhone car or speaker system provides; audio, video, track and playlist control, viewing track information on the car system, etc. Those are things that Apple's 30-pin docking adapter all have built in, which is why it is so compelling and revolutionary. A micro USB connector can only really charge and sync a device, it doesn't not have the connections to do all that fancy integration.</p>

<p>I wish there wasn't this caveat. However, if you're willing to accept the compromise that Android integration cannot match what Apple provides, but want to at least get <b>something</b> out of that iPod/iPhone speaker or other docking system, there's a way.</p>

<p>Apple's dock connector (the 30-pin plug on the bottom of the iPhone, iPod, and iPad) provides many functions. Most Android phones include two jacks; a micro USB connector for charging and syncing, and a standard 1/8" (2.5mm) audio jack for standard headphones. The pins for these two connectors on Android phones can be isolated on the 30-pin connector and provided for</p>

<p><a href="http://www.cablejive.com/products/dockBossplus.html">CableJive's dockBoss+ adapter cable</a> does exactly this, it lets you plug a smart little adapter onto your iPod or iPhone speaker dock or car system, and provides a micro USB and audio cable so you can charge your Android phone and listen to audio, both through your docking system.</p>

<p>It's not the ultimate solution, but until Apple decides to open up their proprietary communication system (never going to happen), getting micro USB and audio to connect an Android phone to your iPhone, iPod, or iPad dock at least keeps your phone charged and the music playing.<br />
</p>]]>

</content>
</entry>

<entry>
<title>Ruby on Rails 3, Octopus, and Sharding with Groups</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/07/ruby_on_rails_3_octopus_and_sharding_with_groups.html" />
<modified>2011-07-14T20:07:44Z</modified>
<issued>2011-07-09T12:27:14Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1173</id>
<created>2011-07-09T12:27:14Z</created>
<summary type="text/plain">The Ruby on Rails app I&apos;m building from the ground up needs to be able to handle *lots* of data. From the get-go I&apos;ve known I&apos;d need to put some kind of data partitioning to make this thing scale, but...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Technology</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p>The Ruby on Rails <a href="http://blog.cablejive.com/2011/04/09/inventory-management-and-forecasting-for-a-growing-business/">app I'm building</a> from the ground up needs to be able to handle *lots* of data. From the get-go I've known I'd need to put some kind of data partitioning to make this thing scale, but just finally tackled it this week.</p>

<p>Rails doesn't come with a built-in ability to connect to multiple databases, but there are lots of folks who have tackled it. Ryan Tomayko's post <a href="http://tomayko.com/writings/rails-multiple-connections">Rails and Scaling with Multiple Databases</a> (written way back in 2007) is a good indicator that there are folks doing serious business with rails and multiple databases, and has some good links to other sources.</p>

<p>I was looking at writing something myself, but in digging around came across <a href="https://github.com/tchandy/octopus">Octopus</a> a few times and realized it does exactly what we need, data sharding with the ability to programmatically select databases in controllers and models, as well as good migration handling.</p>

<p>For the application we'll have a master database which centralizes account, user and session information with a pointer to the appropriate data shard. Once a user request has been authenticated, the actual application data gets pulled off of one of the shards they've been assigned to. The master database has a simple schema for user, account, and session information, the schema on the shards is significantly more complex, but the same on each shard.</p>

<p>Octopus documentation is there, but not extensive. Through some trial and error I found that the following shard.yml configuration file was what I needed (the Octopus documentation doesn't spell out how to use shard groups in a rails environment, but it makes sense once you get it working). The master shard for the environment is defined in database.yml.</p>

<pre>
octopus:
  environments:
    - development
    - test
    - production
  development:
        data_shards:
            data_1:
                adapter: postgresql
                database: dev_data_1
                username: something
                password: cryptic
                template: template0
            data_2:
                adapter: postgresql
                database: dev_data_2
                username: something
                password: cryptic
                template: template0
...
</pre>

<p>It's obviously paramount that the models know where to connect for their data. When a user authenticates I invoke ActiveRecord::Base.establish_connection() to connect to the shard so it's the default data source everywhere in the application for that request. Requests that need to interact with the master database are handled in the controller:</p>

<pre>
  around_filter :select_shard
  def select_shard(&block)
    Octopus.using(:master, &block)
  end
</pre>

<p>The other important piece of this is migrations. Octopus works well for our needs here. When a migration is written it either needs to update a single master database or be applied to all data shards. This is where shard groups come in. To apply a migration to all shards we specify the group with using_group() method, and the migration then runs for each shard in the specified group.</p>

<pre>
class CreateInventoryEvents < ActiveRecord::Migration
  using_group(:data_shards)
  ...
end
</pre>

<p>Pretty slick, happy with Octopus from a functionality perspective. Not sure about scalability and the overhead to move requests between database connections, will dig more into that next.</p>]]>

</content>
</entry>

<entry>
<title>Developer Happiness at Etsy</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/05/developer_happiness_at_etsy.html" />
<modified>2011-05-20T14:02:25Z</modified>
<issued>2011-05-19T20:03:25Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1172</id>
<created>2011-05-19T20:03:25Z</created>
<summary type="text/plain">Listening to Chad Dickerson (CTO at Etsy) speaking about optimizing for developer happiness at RailsConf 2011. Etsy releases software 25 times a day with 75 engineers. They emphasize constant progress with a radical decentralization. It shouldn&apos;t work, but they are...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Technology</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p>Listening to Chad Dickerson (CTO at Etsy) speaking about optimizing for developer happiness at <a href="http://en.oreilly.com/rails2011/">RailsConf 2011</a>.</p>

<p>Etsy releases software 25 times a day with 75 engineers. They emphasize constant progress with a radical decentralization. It shouldn't work, but they are built on trust. There is one button that folks can press (after some fanfare) that pushes code up to production</p>

<p>They've had developers push code on their first day, they've had board members deploy code.</p>

<p>Chad contrasts industrial revolution assembly line times with how Etsy works. Etsy highly prioritizes letting the developers be human, having lunches together, having offices that are full of creative, fun stuff. Dogs have deployed code by guiding a paw to pressing the button.</p>

<p>Releases are done with a self-managed push queue, developers put their names in a queue kept track of in an IRC topic. When the first person in line pushes and is clear he/she notifies the next in line.</p>

<p>Remember, your team is your community. Help people finish things and see their progress.</p>

<p>Optimize your teams for the happiness of people.</p>]]>

</content>
</entry>

<entry>
<title>Glenn Vanderburg on Building Software</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/05/glenn_vanderburg_on_building_software.html" />
<modified>2011-05-19T20:01:56Z</modified>
<issued>2011-05-19T19:43:18Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1171</id>
<created>2011-05-19T19:43:18Z</created>
<summary type="text/plain">Fantastic closing keynote by Glenn Vanderburg at RailsConf 2011 about software engineering. Great ideas about software engineering and how it compares to classical engineering disciplines (civil, structural, industrial, mechanical, electrical, traffic, etc). Compares the definition and process of structural engineering...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Technology</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p>Fantastic closing keynote by Glenn Vanderburg at <a href="http://en.oreilly.com/rails2011">RailsConf 2011</a> about software engineering.</p>

<p>Great ideas about software engineering and how it compares to classical engineering disciplines (civil, structural, industrial, mechanical, electrical, traffic, etc). Compares the definition and process of structural engineering to software engineering.</p>

<p>Is software engineering or craftsmanship? In software, the documentation that is required by other disciplines is actually the artifact that gets built in software engineering. Classical engineers diagram, plan, document, model and then take those and build the artifact. Software engineers diagram, plan, document, and model as a part of building the actual artifact. Also interesting, software is changing the way classical engineering works, a lot of software being used in the planning process to understand how the actual artifact</p>

<p>We are designers and builders. Software has to <strong>be</strong> the solution and <strong>describe</strong> the solution.</p>

<blockquote>Programs must be written for people to read and only incindentally for machines to execute.
<em>Harold Abelson and Gerald Jay Sussman</em></blockquote>

<p>We are engineers and craftsmen.</p>]]>

</content>
</entry>

<entry>
<title>Software Version Numbers</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/05/software_version_numbers.html" />
<modified>2011-05-19T19:43:02Z</modified>
<issued>2011-05-19T18:40:31Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1170</id>
<created>2011-05-19T18:40:31Z</created>
<summary type="text/plain">In the RailsConf 2011 RubyGems presentation this afternoon, Nick Quaranto spent some time talking about versioning software, showing the versioning of TeX as kind of crazy where they use PI, adding a new digit of PI on the end of...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Technology</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p>In the RailsConf 2011 RubyGems presentation this afternoon, Nick Quaranto spent some time talking about versioning software, showing the <a href="http://en.wikipedia.org/wiki/Software_versioning#TeX">versioning of TeX</a> as kind of crazy where they use PI, adding a new digit of PI on the end of the software version number for each release.</p>

<p>Nick suggests that Semantic Versioning is the best methodology. Read more at <a href="http://semver.org/">http://semver.org/</a></p>

<p>The idea is:</p>

<p>1.2.3 (major.minor.patch)</p>

<p>major versions - for major releases where there may be some backward incompatible changes<br />
minor versions - for minor changes, no API or other changes that make it incompatible with previous versions<br />
patch version - for fixes, improving stability</p>]]>

</content>
</entry>

<entry>
<title>Long Evening At Camden Yards</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/05/at_camden_yards.html" />
<modified>2011-05-19T16:30:50Z</modified>
<issued>2011-05-19T14:46:52Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1169</id>
<created>2011-05-19T14:46:52Z</created>
<summary type="text/plain">If the value of a baseball ticket is measured in hours spent in the park, I definitely got my money&apos;s worth last night. Baltimore Orioles vs New York Yankees, 15 innings, Orioles lose it in the 15th after having many...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Recreation</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p>If the value of a baseball ticket is measured in hours spent in the park, I definitely got my money's worth last night. Baltimore Orioles vs New York Yankees, 15 innings, Orioles lose it in the 15th after having many chances to put it away earlier in the game.</p>

<p>I walked into the park at 6:30pm, left just under 6 hours later at 12:10am. Although I went by myself, I made a bunch of friends with the Orioles fans in the Picnic Perch (food isn't fancy, but a nice thing to have all-you-can-eat at your fingertips).</p>

<p>It was supposed to rain, and we saw a little lightning in the distance. It misted up a little, but not a drop of rain.</p>

<p><img src="/images/camden_yards_2011.png"></p>]]>

</content>
</entry>

<entry>
<title>LivingSocial&apos;s Aaron Batalion says &quot;Be Nervous&quot;</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/05/livingsocials_aaron_batalion.html" />
<modified>2011-05-19T14:22:33Z</modified>
<issued>2011-05-19T13:29:28Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1168</id>
<created>2011-05-19T13:29:28Z</created>
<summary type="text/plain">Great keynote this morning at RailsConf 2011 from LivingSocial&apos;s Aaron Batalion. Favorite thought: be nervouse or your aren&apos;t trying hard enough. Aaron says the right way to go at a new idea is to make decisions that make you nervous,...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Technology</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p>Great keynote this morning at <a href="http://en.oreilly.com/rails2011">RailsConf 2011</a> from LivingSocial's Aaron Batalion.</p>

<p>Favorite thought: be nervouse or your aren't trying hard enough.</p>

<p>Aaron says the right way to go at a new idea is to make decisions that make you nervous, all the time. This means you are pushing forward.</p>

<p>Advice that makes me feel better about some of the crazy stuff I've faced as the leader at a growing company. And excited to try some new stuff.</p>]]>

</content>
</entry>

<entry>
<title>Rails 3 Gemfile: Installing PostgreSQL on OS X</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/05/rails_3_gemfile_installing_postgresql_on_os_x.html" />
<modified>2011-05-19T14:25:10Z</modified>
<issued>2011-05-18T20:45:24Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1167</id>
<created>2011-05-18T20:45:24Z</created>
<summary type="text/plain">After two months of building my Rails app working on remote servers, I&apos;m sick of always having to SSH in and use a server-side text editor to work. Not to mention that any time I move the laptop I&apos;ve got...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Technology</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p>After two months of building my Rails app working on remote servers, I'm sick of always having to SSH in and use a server-side text editor to work. Not to mention that any time I move the laptop I've got to break and then re-establish all the terminal windows I had open.</p>

<p>So I embarked on setting things up to run my Rails app right on my MacBook Pro. Yea, the thing that 99% of the rest of the Rails community has been doing for years.</p>

<p>I figured everything except PostgreSQL is either already on the laptop or is nicely grouped together in the my Rails application in git. So I installed Postgres from their <a href="http://www.enterprisedb.com/products-services-training/pgdownload#osx">OS X Postgres install page</a>.</p>

<p>Checked my git repo out on OS X, ran the "bundle install" and got:<code><br />
Installing pg (0.11.0) with native extensions /Library/Ruby/Site/1.8/rubygems/installer.rb:533:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)</p>

<p>        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb <br />
checking for pg_config... yes<br />
Using config values from /Library/PostgreSQL/8.3/bin/pg_config<br />
checking for libpq-fe.h... yes<br />
checking for libpq/libpq-fs.h... yes<br />
checking for PQconnectdb() in -lpq... no<br />
checking for PQconnectdb() in -llibpq... no<br />
checking for PQconnectdb() in -lms/libpq... no<br />
Can't find the PostgreSQL client library (libpq)<br />
*** extconf.rb failed ***<br />
</code></p>

<p>Obviously a failure. The Gemfile includes "gem 'pg'", which works fine up on the Linux servers but apparently doesn't do so well on OS X.</p>

<p>A lot of digging and reading, followed by a lot more digging and reading.</p>

<p>The first solution...when compiling pg, the gem needs to have an environment variable set:<code><br />
env ARCHFLAGS="-arch i386" bundle install --path /Users/mike/inventory/vendor<br />
</code></p>

<p>No problem running the bundler, but when you actually try to use the database:<code><br />
bash$ rake<br />
rake aborted!<br />
dlopen(/Users/mike/inventory/vendor/ruby/1.8/gems/pg-0.11.0/lib/pg_ext.bundle, 9): no suitable image found.  Did find:<br />
	/Users/mike/inventory/vendor/ruby/1.8/gems/pg-0.11.0/lib/pg_ext.bundle: mach-o, but wrong architecture - /Users/mike/inventory/vendor/ruby/1.8/gems/pg-0.11.0/lib/pg_ext.bundle<br />
/Users/mike/inventory/Rakefile:4<br />
</code></p>

<p>Tons more reading and digging, trying lots of suggestions.</p>

<p>Finally I stumbled into something that made a lot of sense. <a href="http://railsforum.com/viewtopic.php?id=34110">A post on the rails forum</a> suggests that Ruby and PostgreSQL are compiled for different architectures and the gem pg connector isn't going to work unless Ruby and Postgres are on the same page.</p>

<p>I got an updated Ruby using <a href="http://www.macports.org/">MacPorts</a>, same error. I got an updated PostgreSQL from MacPorts and attempted to run "bundle install" as standard.</p>

<p>Failed.</p>

<p>Then I went back to including the architecture-specific command:<code><br />
env ARCHFLAGS="-arch x86_64" bundle install --path /Users/mike/inventory/vendor<br />
</code></p>

<p>Works, and I'm able to run "rake db" commands.</p>

<p>Everything else looks like it's in place, am running the Rails app in my browser at localhost:3000 and have TextMate loaded up with my project files.</p>

<p>Much, much, much better.</p>]]>

</content>
</entry>

<entry>
<title>RailsConf 2011: Deploying with Bundler</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/05/railsconf_2011_deploying_with_bundler.html" />
<modified>2011-05-18T20:02:07Z</modified>
<issued>2011-05-18T18:59:08Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1166</id>
<created>2011-05-18T18:59:08Z</created>
<summary type="text/plain">Listening to Andre Arko at RailsConf 2011 talking about Bundler. Bundler exists to make running your app consistent, repeatable, and guaranteed. Bundler doesn&apos;t let you use a gem unless it&apos;s in the Gemfile. Gemfile.lock keeps track of which version of...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Technology</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p>Listening to Andre Arko at <a href="http://en.oreilly.com/rails2011">RailsConf 2011</a> talking about <a href="http://www.gembundler.com">Bundler</a>.</p>

<p>Bundler exists to make running your app consistent, repeatable, and guaranteed. Bundler doesn't let you use a gem unless it's in the Gemfile. Gemfile.lock keeps track of which version of the gem is running.</p>

<p>To publish the app. A very simple way is to tell Heroku or EngineYard to do it, they build right from your Gemfile and deploy.</p>

<p>To do it yourself. Make sure gems are installed within the app, not as the root user: bundle install --path app/vendor</p>

<p>Bundler provides a --frozen mode that makes sure that all of the Gemfile entries match up with the Gemfile.lock. This is a good thing to have in place on production.</p>

<p>For production: bundle install --deployment (turns on --path and --frozen)</p>

<p>For bundling to send to a server that has no outbound internet access: bundle path (not advised unless the only option, because requires downloading a ton of binary data from version control)</p>]]>

</content>
</entry>

<entry>
<title>RailsConf 2011: The Future of Stylesheets with Sass</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/05/railsconf_2011_the_future_of_stylesheets_with_sass.html" />
<modified>2011-05-18T15:56:02Z</modified>
<issued>2011-05-18T14:49:00Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1165</id>
<created>2011-05-18T14:49:00Z</created>
<summary type="text/plain">Listening to Chris Eppstein at RailsConf 2011 this morning talk about Sass., a technology for making CSS stylesheets more robust with preprocessing. Rational, problems it solves, syntax, best practices. What is Sass? Syntactically Awesome StyleSheets, a stylesheet generator. CSS is...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Technology</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p>Listening to Chris Eppstein at <a href="http://en.oreilly.com/rails2011/">RailsConf 2011</a> this morning talk about Sass., a technology for making CSS stylesheets more robust with preprocessing.</p>

<p>Rational, problems it solves, syntax, best practices.</p>

<p>What is Sass? Syntactically Awesome StyleSheets, a stylesheet generator. CSS is 14 years old, selectors, properties, and values. Web developers need to support many browsers, many output types. CSS 3 will have 33 new selectors, 120 new properties, new @rules, but no new syntax. CSS was created for designers who wouldn't have to do any abstraction.</p>

<p>The reality is that most stylesheets are written by programmers.</p>

<p>Sass comes from real world experience, brings software development methodologies to stylesheets. Brings variables, mixins, inheritance, transformations, loops, and more to CSS.</p>

<p>CSS has many problems. Sass has some cool stuff to address them:</p>

<p>- Variables: define at the top of the file and then include the variable in the stylesheet<br />
- Color transformations is awesome: define one color and then a bunch of variations of that color to get a<br />
- @import directive lets you pull in files, build smaller CSS sheets and then only include what you need<br />
- nested selectors let you simplify definition of selectors</p>

<p>As the session winds down I added "gem 'haml'" to my Rails 3 Gemfile and did a "bundle install" to start using this now. </p>]]>

</content>
</entry>

<entry>
<title>RailsConf 2011: Fat Models Aren&apos;t Enough</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/05/railsconf_2011_fat_models_arent_enough.html" />
<modified>2011-05-17T17:48:57Z</modified>
<issued>2011-05-17T14:54:48Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1164</id>
<created>2011-05-17T14:54:48Z</created>
<summary type="text/plain">Listening to Jeff Casimir from JumpstartLabs at RailsConf 2011 talking about practices in Rails, skinny controllers and fat models. Jamis Buck started the idea of fat models. Originally when rails was getting going tons of stuff was going into the...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Technology</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p>Listening to Jeff Casimir from JumpstartLabs at <a href="http://en.oreilly.com/rails2011">RailsConf 2011</a> talking about practices in Rails, skinny controllers and fat models.</p>

<p>Jamis Buck started the idea of fat models. Originally when rails was getting going tons of stuff was going into the views, then folks started stuffing everything into the controller. 80-100 line methods. The call to action was to move logic down into the model with well described method names.</p>

<p>Beautiful views are HTML. Views should be data access, a little bit of looping.</p>

<p>Controller actions should be 8 lines.</p>

<p>Most of the logic should go into the model. But fat models aren't enough. A model should be like a bento box, little pieces of art, structured division. The model layer is where we get to do real programming. But models don't have to get totally stuffed full of junk.</p>

<p>Let's look at the presenter and presenter pattern. The formal definition of a presenter is a decorator, takes in an object and adds some new options. Jeff likes to think of a presenter as more than just adding a new option or two but to add significant simplification to the app.</p>

<p>Helpers are stupid, a big mess.</p>

<p>[I'm going to have to grab the slides from this, a lot of good food for thought and practical advice.]</p>]]>

</content>
</entry>

<entry>
<title>RailsConf 2011: Tuesday Morning Keynote</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/05/railsconf_2011_tuesday_morning_keynote.html" />
<modified>2011-05-17T14:46:17Z</modified>
<issued>2011-05-17T13:04:26Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1163</id>
<created>2011-05-17T13:04:26Z</created>
<summary type="text/plain">At RailsConf 2011 this morning, after conference welcome, logistics updates, and a video about donorschoose.org, the keynote speaker is David Heinemeier Hansson. After the DHH presentation. Yes, folks are excited for Rails 3.1....</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Technology</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p>At <a href="http://en.oreilly.com/rails2011/">RailsConf 2011</a> this morning, after conference welcome, logistics updates, and a video about donorschoose.org, the keynote speaker is David Heinemeier Hansson.</p>

<p>After the DHH presentation. Yes, folks are excited for Rails 3.1.</p>]]>

</content>
</entry>

<entry>
<title>RailsConf 2011: Rails Best Practices</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/05/railsconf_2011_rails_best_practices.html" />
<modified>2011-05-17T11:34:32Z</modified>
<issued>2011-05-16T17:37:48Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1162</id>
<created>2011-05-16T17:37:48Z</created>
<summary type="text/plain">This afternoon I&apos;m at RailsConf 2011 listening to a bunch of the Envy Labs guys talk about best practices in rails. Excited for this tutorial because I&apos;ve used rails long enough now that there&apos;s a bunch more to know than...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p>This afternoon I'm at <a href="http://en.oreilly.com/rails2011">RailsConf 2011</a> listening to a bunch of the Envy Labs guys talk about best practices in rails. Excited for this tutorial because I've used rails long enough now that there's a bunch more to know than just the syntax. There are many ways to do things, want to get some direction on how rails does it.</p>

<p>The better title is Rails Best Opinions. This is a lab, so we listen to a presentation and see some slides and then get on our computers and implement the ideas in code.</p>

<p>A few things that caught my eye, as time permitted to jot down.<br />
<ul><br />
<li>Use scopes and default scope in the model to simplify controller logic, use a lambda for scoping where variables need to be re-evaluated.</li><br />
<li>Use unscoped to override default scope.</li><br />
<li>Envy Labs are coding things now where instance variables are always defined in the action (not in some helper method or down in another method where they aren't visible).</li><br />
<li>Envy Labs are also parameters should not be used outside of the action, pass parameters to functions as arguments.</li><br />
<li>Nested attributes simplifies code quite a bit.</li><br />
<li>Use app presenters, not for HTML but bringing together a bunch of objects.</li><br />
<li> use ActiveSupport::Memoizable for storing values to be retrieved more than one time.</li><br />
<li> use responds_to() and responds_with() to simplify responding to different data formats.</li><br />
<li> Add indexes, use something like new relic to see where there are performance issues in the app.</li><br />
<li> Protect attributes with attr_accessible.</li><br />
<li> use database defaults instead of in the code.</li><br />
<li> Implement proper use of callbacks (after_create).</li><br />
<li> Use rails date helpers.</li><br />
<li> Improve validation with validate method for ActiveRecord::Base object, create class ActiveRecord::EachValidator to automatically run validation across many objects.</li><br />
<li> Add errors to model with self.errors.add.</li><br />
<li> Use db/seeds.db to put data in database, not in your migration scripts.</li><br />
<li> Use the bullet gem, a great tool to tell you where your queries are N+1.</li><br />
<li> When using the pluralize function, but be sure it scales to get the count of items.</li><br />
<li> Use counter_cache technique to reduce queries when checking counts of related records.</li><br />
</ul></p>

<p>For me, having worked heavily in Rails for the past month, the labs were a prefect stretch. Understandable, but challenging to work through the exercises.</p>]]>

</content>
</entry>

<entry>
<title>RailsConf 2011: Rails for Zombies</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/05/railsconf_2011_rails_for_zombies.html" />
<modified>2011-05-16T14:43:44Z</modified>
<issued>2011-05-16T13:02:27Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1161</id>
<created>2011-05-16T13:02:27Z</created>
<summary type="text/plain">I&apos;m at RailsConf 2011 this morning, listening to a bunch of guys from envy labs doing an introductory course to Ruby on Rails. I&apos;ve dug in deep on Ruby on Rails for a month now, this might be a bit...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Technology</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p>I'm at <a href="http://en.oreilly.com/rails2011">RailsConf 2011</a> this morning, listening to a bunch of guys from envy labs doing an introductory course to Ruby on Rails. I've dug in deep on Ruby on Rails for a month now, this might be a bit too introductory for where I'm at but want to make sure I've got the basics.</p>

<p>Things I learned that I didn't know about Rails:<br />
<ul><br />
  <li>When you do a lookup of an object you can call Object.save at any point and it will save the object back to the database with any changed values. I've always used Object.update_attributes</li><br />
  <li>Object.attributes method accepts a hash to update multiple values.</li><br />
  <li>You can reference a Rails value with object[:field] or object.field. The latter is more common in the Rails community.</li><br />
  <li> Rails typical thinking is to put validation in the model, not in the database.</li><br />
  <li> Rails 3 has different syntax for validation, you set the validation in the ActiveRecord::Base subclass with.</li><br />
  <li> When saving to the database that has the relationships set up in the model, you can pass in the object (not just the object_id) to the new/create method and it will find the id to store in the database.</li><br />
  <li> .erb files stand for Embedded Ruby</li><br />
  <li> Rails first checks the public folder for a match to the URL and then goes to the routes file.</li><br />
  <li> Show "no results found" by checking Object.all.empty?</li><br />
</ul></p>

<p></p>

<p><br />
</p>]]>

</content>
</entry>

<entry>
<title>Ruby on Rails: DateTime Records with Microseconds</title>
<link rel="alternate" type="text/html" href="http://mike.kruckenberg.com/archives/2011/05/ruby_on_rails_datetime_records_with_microseconds.html" />
<modified>2011-05-11T22:50:54Z</modified>
<issued>2011-05-11T17:06:30Z</issued>
<id>tag:mike.kruckenberg.com,2011://2.1160</id>
<created>2011-05-11T17:06:30Z</created>
<summary type="text/plain">I&apos;m working on a new web app for internal use at my company, from the ground up with Ruby on Rails. One thing that has emerged as a critical component; having database records timestamped with more granularity than seconds. The...</summary>
<author>
<name>mike</name>
<url>http://mike.kruckenberg.com</url>
<email>mike@kruckenberg.com</email>
</author>
<dc:subject>Technology</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://mike.kruckenberg.com/">
<![CDATA[<p><img src="/images/rails.png" align="right">I'm working on <a href="http://blog.cablejive.com/2011/04/09/inventory-management-and-forecasting-for-a-growing-business/">a new web app</a> for internal use at <a href="http://www.cablejive.com/">my company</a>, from the ground up with <a href="http://rubyonrails.org/">Ruby on Rails</a>.</p>

<p>One thing that has emerged as a critical component; having database records timestamped with more granularity than seconds. The solution was more involved than I would have guessed. Figured I'd log the steps since it took many hours of research and engineering effort.</p>

<p>1) Search for how to store microseconds in MySQL. Not possible in a traditional datetime or timestamp field. Explore all of the workarounds, none of which are ideal for the application. Realize there's no good current solution and a lot of folks have been begging since 2005 for someone at MySQL to fix so little hope it will come. <a href="http://bugs.mysql.com/bug.php?id=8523">See MySQL bug repot here</a>.</p>

<p>2) Swallow hard and enter less familiar territory of installing and getting PostgreSQL running with the app. Lots of reading about PostgreSQL setup, configuration, and administration. Get roles set up, connected with the command-line tool, and get Rails talking to PostgreSQL.</p>

<p>3) Repopulate data from data sources (easier for me than the various MySQL -> Postgres transfer instructions I'd looked at)</p>

<p>4) Put code into Rails app to insert datetime with microseconds (this may get finessed):<code><br />
...<br />
datetime = DateTime.now<br />
microseconds = Time.now.usec<br />
params[:event][:datetime] = "#{datetime.to_s(:db)}.#{microseconds}"<br />
@event = Event.new(params[:event])<br />
...<br />
</code></p>

<p>5) Back to building functionality I was originally attempting without microseconds but was failing.</p>

<p>That was about two days of work, compressed into one day and a long night.</p>

<p>Although I've used Postgres a little bit before, I know MySQL extremely well and am comfortable in any situation that one comes across with that database (replication, disk failure, query performance, I've done it all). Postgres is a new frontier. I'm quickly becoming comfortable using it and the \ commands but know there's a lot more to be learned before I'm confortable running a production app on it.</p>

<p>I guess the title of this post could also be "Switching from MySQL to PostgreSQL to get DateTime records with Microseconds."<br />
</p>]]>

</content>
</entry>

</feed>
