<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>Webby Goodness</description><title>Tad Thorley</title><generator>Tumblr (3.0; @tadthorley)</generator><link>http://tadthorley.com/</link><item><title>Rails Generator Options</title><description>&lt;p&gt;I wanted to add/handle options passed to a Ruby on Rails generator I was writing. I looked at &lt;a href="http://guides.rubyonrails.org/generators.html"&gt;the guide&lt;/a&gt;, but couldn’t find anything there. I looked at &lt;a href="http://api.rubyonrails.org/classes/Rails/Generators/Base.html"&gt;the docs&lt;/a&gt; and couldn’t find it there. I looked at the &lt;a href="https://github.com/wycats/thor/wiki/Method-Options"&gt;Thor wiki&lt;/a&gt; which suggests a “method_options” method, but when I tried to use it I got a NoMethodError. It turned out that I needed to use the “class_option” method. For example:&lt;/p&gt;
&lt;script src="https://gist.github.com/1803342.js?file=gistfile1.rb"&gt;&lt;/script&gt;</description><link>http://tadthorley.com/post/17435069190</link><guid>http://tadthorley.com/post/17435069190</guid><pubDate>Sat, 11 Feb 2012 11:03:00 -0700</pubDate><category>ruby on rails</category><category>generator</category></item><item><title>I oppose SOPA/PIPA</title><description>&lt;p&gt;More about it here: &lt;a href="http://www.reddit.com/help/faqs/sopa#WhatisSOPA"&gt;What is SOPA?&lt;/a&gt;&lt;/p&gt;</description><link>http://tadthorley.com/post/16052301423</link><guid>http://tadthorley.com/post/16052301423</guid><pubDate>Tue, 17 Jan 2012 23:16:37 -0700</pubDate></item><item><title>For SpineJS With Rails Use spine-rails</title><description>&lt;p&gt;I’ve been learning how to use spinejs with rails. When I’m learning I like to forgo code generators  as much as possible and write the necessary code myself. I’ve done that with the past few projects  I’ve posted here.&lt;/p&gt;
&lt;p&gt;However, for most of my future projects I’m going to use the  &lt;a href="https://github.com/maccman/spine-rails"&gt;spine-rails gem&lt;/a&gt;. The gem is written by  &lt;a href="https://github.com/maccman"&gt;Alex MacCaw&lt;/a&gt;, the author of spinejs which is much nicer than the situation  of &lt;a href="http://www.coffeescriptlove.com/2011/11/backbone-on-rails-vs-backbone-rails-vs.html"&gt;backbone with rails&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The gem’s README already documents it pretty well, so I won’t repeat it here.&lt;/p&gt;</description><link>http://tadthorley.com/post/13081129970</link><guid>http://tadthorley.com/post/13081129970</guid><pubDate>Sun, 20 Nov 2011 15:22:00 -0700</pubDate><category>spinejs</category><category>spine-rails</category><category>rails</category><category>ruby on rails</category></item><item><title>Rails With SpineJS and Google Maps</title><description>&lt;p&gt;I wanted to create a simple project that used ruby on rails, spinejs, and google maps together. I came up with the following features:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Dragging a marker icon from outside of a map onto a map creates a marker on the map and in the database&lt;/li&gt;
&lt;li&gt;Dragging a marker from one position to another updates the marker on the map and updates its position in the database&lt;/li&gt;
&lt;li&gt;Right-clicking on a map marker removes it from the map and the database&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;The end result can be &lt;a href="http://dragmarkers.heroku.com/"&gt;seen here&lt;/a&gt; and the &lt;a href="https://github.com/phaedryx/dragmarkers"&gt;source code is on github&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Let’s get started.&lt;/p&gt;
&lt;p&gt;First, create a new rails project. I prefer to use rails 3.1 because the asset pipeline makes it easy to use coffeescript with your application.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;rails new dragmarkers --database=postgresql
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I used PostgreSQL because it’s awesome and I wanted to put an example up on Heroku. For this project, the database doesn’t matter.  ignore the database option if you’d like. Remember you’ll need to edit &lt;code&gt;config/database.yml&lt;/code&gt; accordingly.&lt;/p&gt;
&lt;p&gt;Take care of the usual cleanup.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd dragmarkers
rm public/index.html
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now that we have our rails project, let’s add spinejs. I think that the &lt;a href="https://github.com/maccman/spine-rails"&gt;spine-rails&lt;/a&gt; gem is great (I’m even a &lt;a href="https://github.com/maccman/spine-rails/contributors"&gt;minor contributor&lt;/a&gt;), but I’d like to write everything from scratch for this project.  Instead, download the latest version of spine from the &lt;a href="http://spinejs.com/"&gt;spinejs website&lt;/a&gt;. There will be several directories. Create a directory in your project for the spine files&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mkdir -p vendor/assets/javascripts/spine
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and copy all of the files from the &lt;code&gt;lib&lt;/code&gt; directory of your spinejs download into the &lt;code&gt;spine&lt;/code&gt; directory you created.&lt;/p&gt;
&lt;p&gt;Now let’s add our standard libraries. For this project I decided to use &lt;a href="http://en.wikipedia.org/wiki/Content_delivery_network"&gt;CDN’s&lt;/a&gt; for the standard javascript libraries, rather than the &lt;code&gt;jquery-rails&lt;/code&gt; gem. Open the file &lt;code&gt;app/views/layouts/application.html.erb&lt;/code&gt; and add the  libraries to the &lt;head&gt; section of your layout. The file should look like this:&lt;/p&gt;
&lt;script src="https://gist.github.com/1379410.js?file=application.html.erb"&gt;&lt;/script&gt;&lt;p&gt;Note that we’ll be using &lt;code&gt;jquery-ui&lt;/code&gt; to make the marker icons draggable from outside of the map onto the map. I also added  a div for page styling.&lt;/p&gt;
&lt;p&gt;The foundation is in place, let’s start writing our own code. First we want to scaffold a Marker.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;rails generate scaffold Marker
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Edit &lt;code&gt;config/routes.rb&lt;/code&gt; to make generated route the root route, for convenience. The file should look like this when you’re done:&lt;/p&gt;
&lt;script src="https://gist.github.com/1379410.js?file=routes.rb"&gt;&lt;/script&gt;&lt;p&gt;Now let’s set up the marker model on the rails side. Edit the migration file &lt;code&gt;db/migrate/[datestamp]_create_markers.rb&lt;/code&gt; to add columns for latitude, longitude, and icon. The file should look like this when you’re done:&lt;/p&gt;
&lt;script src="https://gist.github.com/1379410.js?file=create_markers.rb"&gt;&lt;/script&gt;&lt;p&gt;Run the migration.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;rake db:migrate
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The rails model is done. Let’s turn to the views for a bit. Most of the scaffolded views are unnecessary and you can remove them.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;rm app/assets/stylesheets/scaffolds.css.scss
rm app/views/markers/_form.html.erb
rm app/views/markers/edit.html.erb
rm app/views/markers/new.html.erb
rm app/views/markers/show.html.erb
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Only the &lt;code&gt;index.html.erb&lt;/code&gt; will be used.&lt;/p&gt;
&lt;p&gt;We don’t need to touch the controller. Spine requires a REST interface and json, which our controller is already  doing beautifully.&lt;/p&gt;
&lt;p&gt;The rails part is done, so now for the spinejs portion. I like to do everything with coffeescript so let’s rename the application.js  file to application.js.coffee (I wish this were a default).&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mv app/assets/javascripts/application.js app/assets/javascripts/application.js.coffee
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Open the &lt;code&gt;application.js.coffee&lt;/code&gt; file for editing. We aren’t using the jquery gem, so you can remove the jquery-related  require statements at the top. One of the nice features of spinejs is its modularity. For this project we’re using  the core spinejs module and the ajax module (to work with the rails REST).&lt;/p&gt;
&lt;p&gt;&lt;code&gt;#= require spine/spine&lt;/code&gt; &lt;code&gt;#= require spine/ajax&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I like to create my directory structure for spinejs similar to what I’d find in rails application (or any MVC) and require  them accordingly:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;#= require_tree ./lib&lt;/code&gt; &lt;code&gt;#= require_self&lt;/code&gt; &lt;code&gt;#= require_tree ./models&lt;/code&gt; &lt;code&gt;#= require_tree ./controllers&lt;/code&gt; &lt;code&gt;#= require_tree ./views&lt;/code&gt; &lt;code&gt;#= require_tree .&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Create the corresponding directories:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mkdir app/assets/javascripts/lib
mkdir app/assets/javascripts/models
mdkir app/assets/javascripts/controllers
mkdir app/assets/javascripts/views
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let’s create a base spinejs controller and expose it. So far, your &lt;code&gt;application.js.coffee&lt;/code&gt; file should look like this:&lt;/p&gt;
&lt;script src="https://gist.github.com/1379410.js?file=1-application.js.coffee"&gt;&lt;/script&gt;&lt;p&gt;We want our index file to set up html for the base controller to hook in to and create the base controller.  Edit &lt;code&gt;app/views/markers/index.html.erb&lt;/code&gt; by taking out the scaffolding and making it look like this:&lt;/p&gt;
&lt;script src="https://gist.github.com/1379410.js?file=index.html.erb"&gt;&lt;/script&gt;&lt;p&gt;A div with an “app” id and create a new App and pass that div in as the root element. At this point you could  actually run your rails application and have a single-page javascript application, even though you’d only see  a blank page.&lt;/p&gt;
&lt;p&gt;Let’s create a spinejs model to correspond to our rails model. First let’s create the file&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;touch app/assets/javascripts/models/marker.js.coffee
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Open it up and create a Marker model that inherits from Spine.Model, is configured with the same fields as our  rails model, and extends the Spine.Model.Ajax functions. The file should look like this for now:&lt;/p&gt;
&lt;script src="https://gist.github.com/1379410.js?file=1-marker.js.coffee"&gt;&lt;/script&gt;&lt;p&gt;At this point, if you ran the rails application, you’d be able to do CRUD operations with the database through the javascript console  in your browser with commands like: &lt;br/&gt;&lt;code&gt;App.Marker.create({latitude: 0, longitude: 0})&lt;/code&gt; (create a marker entry in the database), &lt;code&gt;marker = App.Marker.find(id)&lt;/code&gt; (get the marker from the database that was just created, using its id), &lt;code&gt;marker.updateAttributes({latitude: 1, longitude: 2})&lt;/code&gt; (update the marker’s fields in the database), &lt;code&gt;marker.destroy()&lt;/code&gt; (delete the marker from the database)&lt;/p&gt;
&lt;p&gt;Things are shaping up pretty well, but we still have a blank-page application. Let’s remedy that. We need to show  a map a marker images that can be dragged onto the map. Let’s make a javascript template (JST) view for it. I like  to use &lt;a href="https://github.com/sstephenson/eco"&gt;eco&lt;/a&gt;, but there are other nice options like  &lt;a href="http://api.jquery.com/category/plugins/templates/"&gt;jQuery templates&lt;/a&gt; and &lt;a href="http://mustache.github.com/"&gt;mustache&lt;/a&gt;.  to use eco, let’s add the line &lt;code&gt;gem 'eco'&lt;/code&gt; to our Gemfile and install it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bundle install
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now let’s create a new directory for our marker views and create the view file.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mkdir app/assets/javascripts/views/markers
touch app/assets/javascripts/views/markers/index.jst.eco
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note the &lt;code&gt;jst&lt;/code&gt; and &lt;code&gt;eco&lt;/code&gt; extensions. Edit the file to contain a div with a “map” id and a bunch of image tags.  Your file should look like this when you’re done.&lt;/p&gt;
&lt;script src="https://gist.github.com/1379410.js?file=index.jst.eco"&gt;&lt;/script&gt;&lt;p&gt;Notice that it references &lt;code&gt;0.png&lt;/code&gt; through &lt;code&gt;9.png&lt;/code&gt; in the &lt;code&gt;app/assets/images&lt;/code&gt; directory. You can copy the images I  used into that directory or use your own. I found &lt;a href="http://mapicons.nicolasmollet.com/"&gt;this website&lt;/a&gt; to be a great  resource for map marker images. Just make sure that the images you reference in the javascript template are there.&lt;/p&gt;
&lt;p&gt;Now let’s create a spinejs controller for the template and actually display it. I like to alias &lt;code&gt;$&lt;/code&gt; for &lt;code&gt;jQuery&lt;/code&gt; and &lt;code&gt;Marker&lt;/code&gt; for the &lt;code&gt;App.Marker&lt;/code&gt; model. Also, we want references to the elements in our view and to display our  view. Create the new spine controller file.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;touch app/assets/javascripts/controllers/markers_controllers.js.coffee
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Edit &lt;code&gt;markers_controller.js.coffee&lt;/code&gt; to include that code. The file should look like this so far:&lt;/p&gt;
&lt;script src="https://gist.github.com/1379410.js?file=1-markers_controller.js.coffee"&gt;&lt;/script&gt;&lt;p&gt;Remember in our rails view index, we’re actually creating a &lt;code&gt;new App&lt;/code&gt; so we need to add our spinejs markers controller  to that one. Edit the &lt;code&gt;app/assets/javascripts/application.js.coffee&lt;/code&gt; file and have the constructor append our new  controller.  When you’re done the file should look like this.&lt;/p&gt;
&lt;script src="https://gist.github.com/1379410.js?file=final-application.js.coffee"&gt;&lt;/script&gt;&lt;p&gt;This is the last time we’ll edit that file. If you were to run your rails application now, you would see it working  because the marker icons would show up, but there still isn’t a map yet. We still need to create our google map. First,  however, let’s add some style to the div that will hold the map and a bit of CSS for the marker icons too. Edit your  &lt;code&gt;app/assets/stylesheets/application.css&lt;/code&gt; file to look something like this&lt;/p&gt;
&lt;script src="https://gist.github.com/1379410.js?file=application.css"&gt;&lt;/script&gt;&lt;p&gt;and edit your &lt;code&gt;app/assets/stylesheets/markers.css.scss&lt;/code&gt; file to look something like this&lt;/p&gt;
&lt;script src="https://gist.github.com/1380827.js?file=markers.css.scss"&gt;&lt;/script&gt;&lt;p&gt;If you run your rails application again, you’ll see a border around the div where the map will go and spacing for  the marker icons.&lt;/p&gt;
&lt;p&gt;Let’s return to our markers controller (&lt;code&gt;app/assets/javascripts/controllers/markers_controller.js.coffee&lt;/code&gt;) and add  the rest of the code to it. We want it to create our google map, create an overlay for the map (so that we can calculate  the drag position on the map), make our marker icons draggable (and droppable), and, lastly, add any existing markers to  the map. Let’s write the code for it in our controller’s constructor, then create each function in turn. Edit the file  to look like this.&lt;/p&gt;
&lt;script src="https://gist.github.com/1380827.js?file=2-markers_controller.js.coffee"&gt;&lt;/script&gt;&lt;p&gt;The first function is to create the map. I initialize it to the middle of the United States at a reasonable zoom  level and use the roadmap view. Our &lt;code&gt;elements&lt;/code&gt; declaration for our map div returns a jQuery wrapped set, the same  as &lt;code&gt;$('#map')&lt;/code&gt; and we need to get the first (and only) member to pass to the google map constructor. The function  for creating the map is pretty straightforward:&lt;/p&gt;
&lt;script src="https://gist.github.com/1380827.js?file=create%20map.coffee"&gt;&lt;/script&gt;&lt;p&gt;The second function is to create an overlay for the map. It is simple. Note that we’re using the variable &lt;code&gt;@overlay&lt;/code&gt; because we’ll be using it later.&lt;/p&gt;
&lt;script src="https://gist.github.com/1380827.js?file=create%20overlay.coffee"&gt;&lt;/script&gt;&lt;p&gt;The third function uses jquery-ui to make the icons draggable. We need another function to handle the icon when it  is dropped (we’ll call it &lt;code&gt;placeNewMarker&lt;/code&gt;). Note that I’m using the draggable option &lt;code&gt;clone&lt;/code&gt; to make a copy of the  image and containment of &lt;code&gt;parent&lt;/code&gt; to keep it within the map area. Placing a new marker takes some calculations to  figure out where the dropped location is within the page and uses our overlay to figure out what the equivalent  longitude and latitude on the map would be. Finally, we create the new marker and put it on the map (the &lt;code&gt;setMap&lt;/code&gt; function doesn’t exist yet, we’ll get to that in a bit). The two functions look like this&lt;/p&gt;
&lt;script src="https://gist.github.com/1380827.js?file=draggable%20icons.coffee"&gt;&lt;/script&gt;&lt;p&gt;Lastly, we want to make sure the existing markers show up on the map. A &lt;code&gt;fetch&lt;/code&gt; will retrieve the marker information  from rails which triggers a &lt;code&gt;refresh&lt;/code&gt; event. Let’s bind that even to display our markers, which will be triggered  when we fetch. Our last function looks like this&lt;/p&gt;
&lt;script src="https://gist.github.com/1380827.js?file=place%20existing.coffee"&gt;&lt;/script&gt;&lt;p&gt;Altogether, our &lt;code&gt;markers_controller.js.coffee&lt;/code&gt; file should look like this.&lt;/p&gt;
&lt;script src="https://gist.github.com/1380827.js?file=final-markers_controller.js.coffee"&gt;&lt;/script&gt;&lt;p&gt;Our controller is done, but we have a few more things to do to finish up. Our spinejs model for markers has no  concept of a map to set a map to, and, for that matter, has no concept of a google marker for the map. Lastly, we  need to make the markers draggable once they are on the map, and provide a means to remove the marker from the  map.&lt;/p&gt;
&lt;p&gt;Let’s edit our spinejs marker model (&lt;code&gt;app/assets/javascripts/models/marker.js.coffee&lt;/code&gt;) and add these finishing  touches. First, let’s have our constructor create a corresponding google map marker&lt;/p&gt;
&lt;script src="https://gist.github.com/1380827.js?file=google%20marker.coffee"&gt;&lt;/script&gt;&lt;p&gt;add add the &lt;code&gt;setMap&lt;/code&gt; function we were using in our controller. It’s a simple 1-liner&lt;/p&gt;
&lt;script src="https://gist.github.com/1380827.js?file=setmap.coffee"&gt;&lt;/script&gt;&lt;p&gt;When a marker has been dragged on the map we want it to save its new position to the database&lt;/p&gt;
&lt;script src="https://gist.github.com/1380827.js?file=dragend.coffee"&gt;&lt;/script&gt;&lt;p&gt;and right-click will remove the marker. We want to remove it from the map and the database&lt;/p&gt;
&lt;script src="https://gist.github.com/1380904.js?file=rightclick.coffee"&gt;&lt;/script&gt;&lt;p&gt;If we add the code to listen to the events and respond with those functions, we’re done. The file should  look like this when you’re done.&lt;/p&gt;
&lt;script src="https://gist.github.com/1380904.js?file=final-marker.js.coffee"&gt;&lt;/script&gt;&lt;p&gt;The project is now complete and does everything I set out to do. However, I think there is still some room for  improvement. This is nice for a small set of points, but if you were dealing with a large number of markers you’d  want to fetch only the markers within the map’s currently viewable area. You may want to use a GIS system (like  &lt;a href="http://postgis.refractions.net/"&gt;postgis&lt;/a&gt;). Instead of having right-click delete the marker, perhaps you could  have a context menu with delete as one of the options.&lt;/p&gt;
&lt;p&gt;Acknowledgements:&lt;/p&gt;
&lt;p&gt;Thanks to &lt;a href="http://alexmaccaw.co.uk/"&gt;Alex MacCaw&lt;/a&gt; for creating spinejs and all of the great documentation to go  with it.&lt;/p&gt;
&lt;p&gt;Thanks to &lt;a href="http://stackoverflow.com/users/627098/kwicher"&gt;kwicher&lt;/a&gt; who’s &lt;a href="http://stackoverflow.com/questions/5510972/google-maps-drag-and-drop-objects-into-google-maps-from-outside-the-map"&gt;example code&lt;/a&gt; helped me debug some frustrating bugs.&lt;/p&gt;</description><link>http://tadthorley.com/post/13078225675</link><guid>http://tadthorley.com/post/13078225675</guid><pubDate>Sun, 20 Nov 2011 14:24:00 -0700</pubDate><category>SpineJS</category><category>coffeescript</category><category>google maps</category><category>rails</category><category>ruby on rails</category><category>spine</category></item><item><title>Backbonejs with Coffeescript Book</title><description>&lt;p&gt;A friend of mine, &lt;a href="http://www.coffeescriptlove.com/"&gt;Chris Smith&lt;/a&gt;, is writing a book about using coffeescript with backbone. He’s given me a sneak peek and I have to tell you: it’s going to be awesome. You can &lt;a href="http://backbonecoffeescript.com/"&gt;sign up here&lt;/a&gt; to get early access to sample chapters and more.&lt;/p&gt;</description><link>http://tadthorley.com/post/12971945487</link><guid>http://tadthorley.com/post/12971945487</guid><pubDate>Fri, 18 Nov 2011 10:16:33 -0700</pubDate><category>book</category><category>coffeescript</category><category>backbone</category></item><item><title>Formatting Coffeescript For Tumblr</title><description>&lt;p&gt;I’ve been trying to figure out a good way to format my code examples. There are plenty of options for Ruby, but nothing good for Coffeescript, especially if you’re using a hosted blog system like tumblr.&lt;/p&gt;
&lt;p&gt;I’ve settled on using github’s gist embedding:&lt;/p&gt;
&lt;script src="https://gist.github.com/1355077.js?file=overview.coffee"&gt;&lt;/script&gt;&lt;script src="https://gist.github.com/1355077.js?file=destructured_assignment.coffee"&gt;&lt;/script&gt;&lt;p&gt;It isn’t as convenient as having the code inline, but it works well.&lt;/p&gt;</description><link>http://tadthorley.com/post/12602173650</link><guid>http://tadthorley.com/post/12602173650</guid><pubDate>Thu, 10 Nov 2011 09:57:52 -0700</pubDate><category>coffeescript</category><category>formatting</category><category>code</category><category>tumblr</category><category>github</category><category>gist</category></item><item><title>SpineJS With Rails Screencast Transcribed</title><description>&lt;p&gt;I transcribed the &lt;a href="http://vimeo.com/30976192"&gt;“Spine and Rails” screencast&lt;/a&gt; by &lt;a href="http://alexmaccaw.co.uk/"&gt;Alex MacCaw&lt;/a&gt; and put it &lt;a href="https://github.com/phaedryx/spine-rails-tree"&gt;together with the source code on github&lt;/a&gt;.&lt;/p&gt;</description><link>http://tadthorley.com/post/12356459392</link><guid>http://tadthorley.com/post/12356459392</guid><pubDate>Fri, 04 Nov 2011 22:03:00 -0600</pubDate><category>spine</category><category>SpineJS</category><category>rails</category><category>transcription</category></item><item><title>When Textmate Can't Find Coffeescript</title><description>&lt;p&gt;When you try to use the &lt;a href="https://github.com/jashkenas/coffee-script-tmbundle"&gt;textmate coffeescript bundle&lt;/a&gt; you may get the error: &lt;code&gt;coffee: command not found&lt;/code&gt;.  As the coffeescript bundle’s README points out, textmate doesn’t inherit your regular PATH.  You need to go into textmate’s preferences (Preferences &gt; Advanced tab &gt; PATH variable) and add the path to coffeescript.&lt;/p&gt;
&lt;p&gt;You need to figure out where coffeescript is with the command-line command &lt;code&gt;which coffee&lt;/code&gt; (which was &lt;code&gt;/user/local/bin/coffee&lt;/code&gt; for me) and make sure is it part of textmate’s PATH variable (which, for me, meant adding &lt;code&gt;:/user/local/bin&lt;/code&gt; to the end).&lt;/p&gt;</description><link>http://tadthorley.com/post/12253523466</link><guid>http://tadthorley.com/post/12253523466</guid><pubDate>Wed, 02 Nov 2011 14:58:00 -0600</pubDate><category>coffeescript</category><category>error</category><category>bundle</category><category>textmate</category><category>PATH</category></item><item><title>Simple SpineJS and Ruby on Rails Integration</title><description>&lt;p&gt;I’ve recently been learning an MVC javascript framework called &lt;a href="http://spinejs.com/"&gt;Spine&lt;/a&gt;.  It is similar to backbone (hence the name), but I’ve found it to be a bit more rails friendly and closer  to what I’m familiar with. The source is also written in coffeescript, which I think has a better syntax.&lt;/p&gt;
&lt;p&gt;What’s the first step when learning something new? “Hello World!” of course! I’ll take you step by step  through a simple application using Rails and Spine. The &lt;a href="https://github.com/phaedryx/hello-spine"&gt;source code&lt;/a&gt; is on github.&lt;/p&gt;
&lt;p&gt;First, create your rails (3.1) application:&lt;/p&gt;
&lt;pre&gt;rails new hello-spine
&lt;/pre&gt;
&lt;p&gt;Next you’ll want to &lt;a href="http://spinejs.com/pages/download"&gt;download spine.js&lt;/a&gt; and copy the  &lt;code&gt;lib&lt;/code&gt; directory into &lt;code&gt;vendor/assets/javascripts/spine&lt;/code&gt; of your new rails application  (the directories won’t exist, you’ll have to create them).&lt;/p&gt;
&lt;p&gt;Now you’ll need to configure Rails to use Spine. Edit the application.js file in &lt;code&gt;app/assets/javascripts&lt;/code&gt; to include a line to require spine (spine.js in the spine directory). I love coffeescript, so I renamed  the file to &lt;code&gt;application.js.coffee&lt;/code&gt; and this is what it should look like:&lt;/p&gt;
&lt;pre&gt;#= require jquery
#= require jquery_ujs
#= require spine/spine
#= require_tree .
&lt;/pre&gt;
&lt;p&gt;Rails needs to supply the basic HTML that Spine hooks into, so you’ll need to generate a controller for it&lt;/p&gt;
&lt;pre&gt;rails generate controller Hello index
&lt;/pre&gt;
&lt;p&gt;and set it as the root route.  Your &lt;code&gt;config/routes.rb&lt;/code&gt; file should look like this:&lt;/p&gt;
&lt;pre&gt;HelloSpine::Application.routes.draw do
  get "hello/index"
  root :to =&gt; "hello#index"
end
&lt;/pre&gt;
&lt;p&gt;Now for the Spine part. Because this is so simple, there are no views or templates; there is no routing logic.  The only logic you’ll need is a Spine.Controller that you can put straight in to your &lt;code&gt;application.js.coffee&lt;/code&gt; file (for more complex applications you’d want to separate controllers, models, and views into separate directories and  include them from there). The first step is to create your new class and expose it by assigning it to the javascript  “window” object. Your file should look like this:&lt;/p&gt;
&lt;pre&gt;#= require jquery
#= require jquery_ujs
#= require spine/spine
#= require_self
#= require_tree .

class App extends Spine.Controller
  constructor: -&gt;
    super


window.App = App
&lt;/pre&gt;
&lt;p&gt;Note also the “require_self” line right after requiring spine.&lt;/p&gt;
&lt;p&gt;Next edit &lt;code&gt;views/hello/index.html.erb&lt;/code&gt; to provide a div for your Spine app to work with.  Followed by some  javascript to create your Spine app and pass it the div as it’s base DOM element.  Your file could look something like this:&lt;/p&gt;
&lt;pre&gt;&lt;div id="hello"&gt;&lt;/div&gt;

&lt;script type="text/javascript" charset="utf-8"&gt;
  jQuery(function() { 
    new App({el: $("#hello")});
  });
&lt;/script&gt;
&lt;/pre&gt;
&lt;p&gt;The last step is to have your controller append the greeting to it’s base element.  The addition of one more line to  &lt;code&gt;application.js.coffee&lt;/code&gt; should do it:&lt;/p&gt;
&lt;pre&gt;...

class App extends Spine.Controller
  constructor: -&gt;
    super
    @append("&lt;p&gt;Hello from Spine!&lt;/p&gt;")

...
&lt;/pre&gt;
&lt;p&gt;Start up your rails app to see the message:&lt;/p&gt;
&lt;pre&gt;rails server
&lt;/pre&gt;
&lt;p&gt;So what’s the next step? &lt;a href="http://alexmaccaw.co.uk"&gt;Alex MacCaw&lt;/a&gt;, the author of Spine has done a great series of  &lt;a href="http://spinejs.com/pages/screencasts"&gt;screencasts&lt;/a&gt; and the &lt;a href="https://github.com/maccman/spine-rails"&gt;spine  gem for rails&lt;/a&gt; makes it easy to use spine with rails.&lt;/p&gt;</description><link>http://tadthorley.com/post/12153996317</link><guid>http://tadthorley.com/post/12153996317</guid><pubDate>Mon, 31 Oct 2011 01:29:00 -0600</pubDate><category>spine</category><category>spinejs</category><category>ruby</category><category>ruby on rails</category><category>RoR</category><category>tutorial</category><category>hello world</category><category>coffeescript</category><category>javascript</category></item><item><title>Spacechem - Sernimir IV - Double Bonds
I bought Spacechem as...</title><description>&lt;img src="http://28.media.tumblr.com/tumblr_ltwmzcoQ5h1qbtpn6o1_500.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;h3&gt;Spacechem - Sernimir IV - Double Bonds&lt;/h3&gt;
&lt;p&gt;I bought Spacechem as part of the &lt;a href="http://www.humblebundle.com/"&gt;humble indie bundle&lt;/a&gt; and it has been a great puzzle game.  This isn’t the optimal solution, but on this level I realized that you could bond-drop-grab to only grab the bonded molecule.  It is a principle that turned out to be helpful later one.&lt;/p&gt;</description><link>http://tadthorley.com/post/12140742104</link><guid>http://tadthorley.com/post/12140742104</guid><pubDate>Sun, 30 Oct 2011 18:35:00 -0600</pubDate><category>spacechem</category><category>sernimir IV</category><category>double bonds</category></item><item><title>Apple's Three Laws of Developers</title><description>&lt;p&gt;&lt;a href="http://yourhead.tumblr.com/post/3320228508"&gt;yourhead&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;&lt;ol&gt;&lt;li&gt;A developer may not injure Apple or, through inaction, allow Apple to come to harm.&lt;/li&gt;
&lt;li&gt;A developer must obey any orders given to it by Apple, except where such orders would conflict with the First Law.&lt;/li&gt;
&lt;li&gt;A developer must protect its own existence as long as such protection does not conflict with the First or Second Law.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;— I. Developer&lt;/p&gt;
&lt;/blockquote&gt;</description><link>http://tadthorley.com/post/3330574054</link><guid>http://tadthorley.com/post/3330574054</guid><pubDate>Wed, 16 Feb 2011 13:02:32 -0700</pubDate></item><item><title>RT @blowmage: Having a hard time thinking of something more coupled than rails’ database rake...</title><description>&lt;p&gt;RT @blowmage: Having a hard time thinking of something more coupled than rails’ database rake tasks. &lt;a href="http://bit.ly/hP6Sb6"&gt;http://bit.ly/hP6Sb6&lt;/a&gt;&lt;/p&gt;</description><link>http://tadthorley.com/post/2595095456</link><guid>http://tadthorley.com/post/2595095456</guid><pubDate>Tue, 04 Jan 2011 05:51:54 -0700</pubDate></item><item><title>Filling up the tub for my son to take a bath and ask him to check the water level for me. He...</title><description>&lt;p&gt;Filling up the tub for my son to take a bath and ask him to check the water level for me. He returns: “it’s still loading” #geekparenting&lt;/p&gt;</description><link>http://tadthorley.com/post/2584498838</link><guid>http://tadthorley.com/post/2584498838</guid><pubDate>Mon, 03 Jan 2011 12:50:59 -0700</pubDate></item><item><title>Okay, I’m finally using the
{foo: bar}
ruby hash form</title><description>&lt;p&gt;Okay, I’m finally using the&lt;/p&gt;
&lt;pre&gt;{foo: bar}&lt;/pre&gt;
&lt;p&gt;ruby hash form&lt;/p&gt;</description><link>http://tadthorley.com/post/2576471172</link><guid>http://tadthorley.com/post/2576471172</guid><pubDate>Sun, 02 Jan 2011 20:55:00 -0700</pubDate></item><item><title>son: Dad, can I have your Yoshi? me: sure  *me gives yoshi*  *son uses yoshi to swallow me* *son...</title><description>&lt;p&gt;son: Dad, can I have your Yoshi?&lt;br/&gt; me: sure &lt;br/&gt; *me gives yoshi* &lt;br/&gt; *son uses yoshi to swallow me*&lt;br/&gt; *son uses yoshi to spit me in a hole*&lt;br/&gt; #parenting&lt;/p&gt;</description><link>http://tadthorley.com/post/2561991254</link><guid>http://tadthorley.com/post/2561991254</guid><pubDate>Sat, 01 Jan 2011 20:31:00 -0700</pubDate></item><item><title>RT @rubythreads: O HAI. U LIKE SHIRTS? US 2! http://www.rubythreads.com/ U BUY NOU!</title><description>&lt;p&gt;RT @rubythreads: O HAI. U LIKE SHIRTS? US 2! &lt;a href="http://www.rubythreads.com/"&gt;http://www.rubythreads.com/&lt;/a&gt; U BUY NOU!&lt;/p&gt;</description><link>http://tadthorley.com/post/2540322158</link><guid>http://tadthorley.com/post/2540322158</guid><pubDate>Fri, 31 Dec 2010 02:01:55 -0700</pubDate></item><item><title>RT @joeyschoblaska: HaikuLeaks automatically locates haiku structures in WikiLeaks cables and...</title><description>&lt;p&gt;RT @joeyschoblaska: HaikuLeaks automatically locates haiku structures in WikiLeaks cables and outputs them as poetry - &lt;a href="http://is.gd/jJezg"&gt;http://is.gd/jJezg&lt;/a&gt;&lt;/p&gt;</description><link>http://tadthorley.com/post/2533880527</link><guid>http://tadthorley.com/post/2533880527</guid><pubDate>Thu, 30 Dec 2010 17:02:22 -0700</pubDate></item><item><title>I find it satisfying that “database”, “username” and “password”...</title><description>&lt;p&gt;I find it satisfying that “database”, “username” and “password” all have eight letters and, therefore, align vertically in my code #toogeeky&lt;/p&gt;</description><link>http://tadthorley.com/post/2509994933</link><guid>http://tadthorley.com/post/2509994933</guid><pubDate>Wed, 29 Dec 2010 01:34:43 -0700</pubDate></item><item><title>I am now automatically saving my Twitter favorites to Diigo! http://bit.ly/hGqPFK</title><description>&lt;p&gt;I am now automatically saving my Twitter favorites to Diigo! &lt;a href="http://bit.ly/hGqPFK"&gt;http://bit.ly/hGqPFK&lt;/a&gt;&lt;/p&gt;</description><link>http://tadthorley.com/post/2401938047</link><guid>http://tadthorley.com/post/2401938047</guid><pubDate>Tue, 21 Dec 2010 06:18:16 -0700</pubDate></item><item><title>Finding an alternative to del.icio.us; looking at @diigo</title><description>&lt;p&gt;Finding an alternative to del.icio.us; looking at @diigo&lt;/p&gt;</description><link>http://tadthorley.com/post/2387900405</link><guid>http://tadthorley.com/post/2387900405</guid><pubDate>Mon, 20 Dec 2010 07:04:07 -0700</pubDate></item></channel></rss>

