<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Geoff Evason's Blog</title>
    <link>http://geoff.evason.name</link>
    <description>Rails, iOS and Startups</description>
    <language>en-us</language>
    <atom:link rel="self" type="application/rss+xml" href="http://geoff.evason.name/feed.xml"/>
    <item>
      <title>React on Rails with webpack  - React is not defined</title>
      <description>&lt;p&gt;I'm using the &lt;a href='https://github.com/shakacode/react_on_rails'&gt;react on rails&lt;/a&gt; gem in a project I've been working on. It's great for using of React components in a Rails project and supports both server side and client side rendering.&lt;/p&gt;

&lt;p&gt;If you've got webpack set up to work as part of your rails stack &lt;a href='https://github.com/shakacode/react-webpack-rails-tutorial/'&gt;(example)&lt;/a&gt; the gem is a breeze to set up.&lt;/p&gt;

&lt;p&gt;I did run into 1 problem recently though.  I was getting an error when I deployed to heroku that I wasn't getting in dev mode.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Exception in rendering!
ReferenceError: React is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src='http://res.cloudinary.com/geoffevason/image/upload/v1443555203/react-on-rails-react-not-defined_kpc5op.png'/&gt;

&lt;p&gt;To fix this, make sure you are exposing react in your webpack config file.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;module.exports = {
  ...
  module: {
    loaders: [
      // Make sure you have this line in your config!
      {test: require.resolve('react'), loader: 'expose?React'},
      ...
    ]
  }
};
&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Tue, 29 Sep 2015 00:00:00 +0000</pubDate>
      <link>http://geoff.evason.name/2015/09/29/react-on-rails-with-webpack-react-is-not-defined</link>
      <guid>http://geoff.evason.name/2015/09/29/react-on-rails-with-webpack-react-is-not-defined</guid>
    </item>
    <item>
      <title>Remapping Keypad on a Kinesis Advantage Keyboard</title>
      <description>                                                                                                                                                                                            &lt;p&gt;If you're a kinesis advantage user, you'll know it has an embedded number pad and directional pad in the right key well.  I want to quickly toggle this on and off.&lt;/p&gt;

&lt;p&gt;The keypad button is in the top right though. That is too far away for my liking. Unfortunately, the keypad button cannot be remapped to another location.&lt;/p&gt;

&lt;p&gt;&lt;img src='http://res.cloudinary.com/geoffevason/image/upload/c_scale,w_800/v1430418793/kinesis-desired-remap_nkv1bo.png' /&gt;&lt;/p&gt;

&lt;p&gt;If you have the foot switch accessory, the default action for it is to toggle the keypad. The foot switch CAN be remapped, but ONLY if you have one.&lt;/p&gt;

&lt;p&gt;OR you can use a staple to mimic the foot switch so that you can remap it (and hence a keypad toggle) to a key on the keyboard.  Here's how:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Press and hold 'Program' and 'F12/Remap'.  The green lights should be blinking fast. &lt;/li&gt; 
&lt;li&gt;Locate the RJ-11 connecter on the back of your keyboard. (This is where the foot switch would connect).  Use a staple or wire to connect the middle two pins (green and red) to mimic a foot switch press as a source key (&lt;a href='https://geekhack.org/index.php?topic=69547.0'&gt;thanks for the tip&lt;/a&gt;). The green lights should be blinking slower. &lt;br/&gt;&lt;img src='http://res.cloudinary.com/geoffevason/image/upload/c_scale,w_600/v1430418792/kinesis-footswitch-mimic_oy5yr5.jpg' /&gt;&lt;/li&gt; 
&lt;li&gt;Press the button you want to become your keypad button (destination key). The green lights should be blinking fast again.&lt;/li&gt; 
&lt;li&gt;Press and hold 'Program' and 'F12/Remap' to exit remapping mode.  The green lights should stop blinking.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;IMPORTANT: Depending where you map the key to, you ay need to map it twice (with both the keypad on and off) to make sure your key can both toggle it on AND off.&lt;/p&gt;
</description>
      <pubDate>Thu, 30 Apr 2015 00:00:00 +0000</pubDate>
      <link>http://geoff.evason.name/2015/04/30/remapping-keypad-on-a-kinesis-advantage-keyboard</link>
      <guid>http://geoff.evason.name/2015/04/30/remapping-keypad-on-a-kinesis-advantage-keyboard</guid>
    </item>
    <item>
      <title>An exception occurred: &amp;#39;PG::ConnectionBad: PQconsumeInput() SSL connection has been closed unexpectedly&amp;#39; on Heroku</title>
      <description>
&lt;p class='tldr' style='border:1px solid #ccc;padding:10px;margin-bottom: 20px'&gt;tl;dr:  Always use at least a &lt;a href="https://devcenter.heroku.com/articles/heroku-postgres-plans#standard-tier"&gt;standard&lt;/a&gt; database plan for production apps on Heroku.&lt;/p&gt;

&lt;p&gt;Recently I came across some unexpected exceptions in an app running on Heroku.  &lt;a href="https://discussion.heroku.com/t/intermittent-postgres-connection-issues-from-rails/865"&gt;Others&lt;/a&gt; have had a &lt;a href="https://discussion.heroku.com/t/postgresql-dev-connections-are-all-pooching-a-lot/862/5"&gt;similar&lt;/a&gt; experience.&lt;/p&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;# It starts with the connection being unexpectedly closed
An exception occurred: 'PG::ConnectionBad: PQconsumeInput() SSL connection has been closed unexpectedly'
# Followed by a bunch of these
An exception occurred: 'PG::ConnectionBad: PQsocket() can't get socket descriptor'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It turns out that the hobby tier for databases on Heroku have "Unannounced maintenances and database upgrades". &lt;a href="http://stackoverflow.com/questions/26792943/heroku-rails-pg-activerecordstatementinvalid-pgconnectionbad-pqconsum/27127603#27127603"&gt;Heroku responded&lt;/a&gt; basically saying: &lt;em&gt;`The hobby plans have their connections closed sometimes. ActiveRecord should deal with it via a connection pool. If not, you'll have to reconnect.`&lt;/em&gt;.  The exceptions I saw were on a long running background job (in this case a RabbitMQ consumer), where ActiveRecord was not handling reconnecting. :-(&lt;/p&gt;

&lt;p&gt;If you get these exceptions, the first thing to do is to restart your server, which you can do by running this command.&lt;/p&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;#assuming your git remote is named production
heroku restart -r production &lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The best long term fix is to &lt;a href="https://devcenter.heroku.com/articles/upgrading-heroku-postgres-databases"&gt;upgrade you Heroku database&lt;/a&gt; to at least the &lt;a href="https://devcenter.heroku.com/articles/heroku-postgres-plans#standard-tier"&gt;standard-0&lt;/a&gt; plan (currently $50/mth).  This will prevent connections from being unexpectedly closed.  It will also help performance.&lt;/p&gt;

&lt;p&gt;If you really don't want to upgrade, you can try reconnecting with your code
&lt;pre&gt;&lt;code class='ruby'&gt;begin
  # Do the action you want to do here.
rescue ActiveRecord::StatementInvalid =&gt; e
  # Make sure someone finds out!
  # ExceptionNotifier.notify_exception(e)
  # Rails.logger.error { "[insert details here] : {e}" }

  # Now, try to reconnect
  ActiveRecord::Base.connection.reconnect! 
  
  # Don't forget - you need to make sure to retry the original action somehow.
end &lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;On a final note - there is no way to tell when this might happen.  For this particular app, there is both a production and a staging server that are configured in the same way.  These exceptions have occurred multiple times on different days on the production server, but have never happened on staging.&lt;/p&gt;


</description>
      <pubDate>Sun, 18 Jan 2015 00:00:00 +0000</pubDate>
      <link>http://geoff.evason.name/2015/01/18/postgres-ssl-connection-has-been-closed-unexpectedly</link>
      <guid>http://geoff.evason.name/2015/01/18/postgres-ssl-connection-has-been-closed-unexpectedly</guid>
    </item>
    <item>
      <title>Case insensitive LIKE in postgres (or why it&amp;#39;s important to use the same DB for test and prod)</title>
      <description>&lt;p&gt;
I recently ran into a production bug where a simple 'like' query wasn't working properly, even though I had passing tests which explicitly tested this case.
&lt;/p&gt;
&lt;p&gt;
The problem, of course, is that I was using different databases: sqlite on my dev machine, and postgres on the production machine.
&lt;/p&gt;
&lt;pre&gt;&lt;code class="ruby"&gt;# case insensitive on sqlite
# BUT case sensitive on postgres
where(["description LIKE ?", like_value])
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
In postgres you need to use 'ILIKE' for case insensitive queries.
&lt;/p&gt;
&lt;pre&gt;&lt;code class="ruby"&gt;# case insensitive on postgres
where(["description ILIKE ?", like_value])
&lt;/code&gt;&lt;/pre&gt;  
&lt;p&gt;
The more important takeaway, however, is to make sure that you &lt;strong&gt;use the same database in your test env as do in production!&lt;/strong&gt;
&lt;/p&gt;</description>
      <pubDate>Fri, 17 Oct 2014 00:00:00 +0000</pubDate>
      <link>http://geoff.evason.name/2014/10/17/case-insensitive-LIKE-in-postgres</link>
      <guid>http://geoff.evason.name/2014/10/17/case-insensitive-LIKE-in-postgres</guid>
    </item>
    <item>
      <title>Active Admin : Undefined Method `per&amp;#39; for #&amp;lt;ActiveRecord::Relation:&amp;gt; with will_paginate</title>
      <description>&lt;p&gt;
If you are using both &lt;a href="https://github.com/mislav/will_paginate"&gt;will_paginate&lt;/a&gt; and &lt;a href="http://activeadmin.info"&gt;activeadmin&lt;/a&gt;, you may see an error like this:
&lt;/p&gt;
&lt;pre&gt;&lt;code class="ruby"&gt;Undefined Method `per' for #&amp;lt;ActiveRecord::Relation:0x.....&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
This is because Active Admin uses &lt;a href="https://github.com/amatsuda/kaminari"&gt;kaminari&lt;/a&gt; for pagination.  To fix this error make sure will_paginate and kaminari don't collide, as per : &lt;a href="https://github.com/activeadmin/activeadmin/wiki/How-to-work-with-will_paginate"&gt;using active admin with will_paginate&lt;/a&gt; by adding some config to kaminari:
&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;# create config/initializers/kaminari.rb
Kaminari.configure do |config|
  config.page_method_name = :per_page_kaminari
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Google is likely to lead you to a github discussion that tells you to use a very specific version of will_paginate, but obviously the solution above is better.&lt;/p&gt;
</description>
      <pubDate>Thu, 02 Oct 2014 00:00:00 +0000</pubDate>
      <link>http://geoff.evason.name/2014/10/02/active_admin_undefined_method_per_with_will_paginate</link>
      <guid>http://geoff.evason.name/2014/10/02/active_admin_undefined_method_per_with_will_paginate</guid>
    </item>
    <item>
      <title>Focusing your Guard</title>
      <description>&lt;p&gt;&lt;a href="https://github.com/guard/guard" title="" target=""&gt;Guard&lt;/a&gt; is great for getting rapid feedback when you'd doing tdd/bdd. &amp;nbsp;By default, the guard plugins for spec and cucumber watch and run a lot. &amp;nbsp;Recently I've found myself wanting to just have guard only run the tests which I am focusing on.&lt;/p&gt;
&lt;p&gt;After setting up &lt;a href="https://github.com/guard/guard-rspec" title="" target=""&gt;guard-rspec&lt;/a&gt; and &lt;a href="https://github.com/guard/guard-cucumber" title="" target=""&gt;guard-cucumber&lt;/a&gt; I updated my Guardfile to:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;
def watch_cucumber
  watch(%r{^features/.+\.feature$})
  watch(%r{^features/support/.+$})          { 'features' }
  watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
end

def watch_rspec
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch('spec/spec_helper.rb')  { "spec" }

  # Rails example
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$})          { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  watch(%r{^app/controllers/(.+)_(controller)\.rb$})  { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
  watch(%r{^spec/support/(.+)\.rb$})                  { "spec" }
  watch('config/routes.rb')                           { "spec/routing" }
  watch('app/controllers/application_controller.rb')  { "spec/controllers" }
  watch('spec/rails_helper.rb')                       { "spec" }

  # Capybara features specs
  watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$})     { |m| "spec/features/#{m[1]}_spec.rb" }

  # Turnip features and steps
  watch(%r{^spec/acceptance/(.+)\.feature$})
  watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$})   { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end


group :tests do
  guard :cucumber, cmd: 'spring cucumber' do
    watch_cucumber
  end

  guard :rspec, cmd: 'spring rspec' do
    watch_rspec
  end
end


# Run guard -g focus
# It will watch all the reguslar rspec and cucumber watches files
# but will only run:
# cucumber tests tagged with @focus
# rspec tests with :focus =&amp;gt; true
group :focus do
  logger level: :warn
  logger template: ':message'

  guard :rspec, cmd: 'spring rspec --tag focus' do
    watch_rspec
  end

  guard 'cucumber', command_prefix: 'spring', bundler: false, cli: '--profile focus' do
    watch_cucumber
  end
end
&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;This creates 2 groups ('focus' and 'tests').  The focus group only runs the tests that I have tagged as a focus.  ('@focus' in cucumber and 'focus: true' in spec).  The focus:cucumber guard file definition tells cucumber to use the profile 'focus'.  Alternatively I could have used the &lt;a href="https://github.com/guard/guard-cucumber#options"&gt;focus_on option&lt;/a&gt; but a profile feels cleaner.  In order to use a profile you need to set it up in cucumber.yml like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
focus: --format progress --strict --tags @focus
&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;Then, when I want guard to automatically run only the tests I've tagged with focus, I run:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
guard -g focus
&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;I find this really helps me get into the flow when writing code.  If I'm doing something that could affect a to of areas, I can still run guard -g tests to fall back on the default guard behaviour.&lt;/p&gt;</description>
      <pubDate>Thu, 04 Sep 2014 00:00:00 +0000</pubDate>
      <link>http://geoff.evason.name/2014/09/04/focusing-your-guard</link>
      <guid>http://geoff.evason.name/2014/09/04/focusing-your-guard</guid>
    </item>
    <item>
      <title>Restarting iPhone with broken lock button</title>
      <description>&lt;p&gt;I ran into a situation where I needed to restart my iPhone, but unfortunately the lock button was broken. &amp;nbsp;Normally a restart requires holding the lock button and home button for 8 seconds.&lt;/p&gt;
&lt;p&gt;Fortunately - you can use&amp;nbsp;AssistiveTouch to get on screen versions of those buttons.&lt;/p&gt;

&lt;ol&gt;&lt;li&gt;Open the Settings app&lt;br&gt;&lt;/li&gt;&lt;li&gt;Tap "General"&lt;/li&gt;&lt;li&gt;Tap "Accessibility"&lt;/li&gt;&lt;li&gt;In the "Physical &amp;amp; Motor" section tap on "AssistiveTouch"&lt;/li&gt;&lt;li&gt;Turn "AssistiveTouch" on&lt;/li&gt;&lt;li&gt;A white circle will appear in the bottom right. Tap it.&lt;/li&gt;&lt;li&gt;Tap on "Device".&lt;/li&gt;&lt;li&gt;Hold the on screen "Lock Screen" icon and the real home button at the same time, for 8 seconds.&lt;/li&gt;&lt;li&gt;Voila!&lt;/li&gt;&lt;/ol&gt;

&lt;p style="text-align: center;"&gt;
&lt;img src="http://www.jrrehab.ca/wp-content/uploads/2011/12/photo.png" width="213" height="320"&gt;&lt;/p&gt;

&lt;p&gt;After your iphone restarts you'll want to go back an turn AssistiveTouch off.&lt;/p&gt;</description>
      <pubDate>Wed, 05 Sep 2012 00:00:00 +0000</pubDate>
      <link>http://geoff.evason.name/2012/09/05/restarting-iphone-with-broken-lock-button</link>
      <guid>http://geoff.evason.name/2012/09/05/restarting-iphone-with-broken-lock-button</guid>
    </item>
    <item>
      <title>On Techcrunch</title>
      <description>&lt;p&gt;Today I &lt;a href="https://twitter.com/#!/gevason/statuses/185794273306886146"&gt;tweeted&lt;/a&gt; a screenshot of Tweetdeck when it was letting me access other people’s accounts. &amp;nbsp;&lt;a href="http://techcrunch.com/2012/03/30/twitter-takes-tweetdeck-offline-after-apparent-bug-opens-access-to-accounts/"&gt;Techcrunch&lt;/a&gt; (and now &lt;a href="http://money.cnn.com/2012/03/30/technology/tweetdeck-bug-twitter/"&gt;CNN&lt;/a&gt;, &lt;a href="http://news.cnet.com/8301-1023_3-57407380-93/tweetdeck-interrupted-amid-reports-of-security-access-breach/"&gt;CNET&lt;/a&gt;, &lt;a href="http://blogs.wsj.com/digits/2012/03/30/tweetdeck-offline-as-user-makes-hack-claim/"&gt;WSJ&lt;/a&gt;, &lt;a href="http://www.technolog.msnbc.msn.com/technology/technolog/twitter-takes-tweetdeck-offline-possible-security-issue-610589"&gt;MSNBC&lt;/a&gt;) picked up the story. &amp;nbsp;It’s nice to get on Techcrunch, I just wish it had been for &lt;a title="Best kids apps" href="http://littlebigthinkers.com/"&gt;Little Big Thinkers&lt;/a&gt; or&amp;nbsp;&lt;a title="free wedding websites" href="http://www.momentville.com/"&gt;MomentVille&lt;/a&gt; :-S&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;To be clear – I DID NOT HACK Tweetdeck&lt;/span&gt;&lt;/strong&gt; (I’m looking at you &lt;a href="http://blogs.wsj.com/digits/2012/03/30/tweetdeck-offline-as-user-makes-hack-claim/"&gt;WSJ&lt;/a&gt;)&lt;strong&gt;. &amp;nbsp;All I did was log in and I saw and could post from the other accounts.&lt;/strong&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 31 Mar 2012 00:00:00 +0000</pubDate>
      <link>http://geoff.evason.name/2012/03/31/on-techcrunch</link>
      <guid>http://geoff.evason.name/2012/03/31/on-techcrunch</guid>
    </item>
    <item>
      <title>Rocket Speller is What’s Hot</title>
      <description>&lt;p&gt;We’re very pleased that &lt;a href="http://itunes.apple.com/us/app/rocket-speller/id492504689?mt=8"&gt;Rocket Speller&lt;/a&gt; has been featured in the New and Noteworthy and What’s Hot sections of the iTunes App Store for the Education, Educational Games, and Kids Games sections.&lt;/p&gt;
&lt;p&gt;We also hit a big milestone recently with over 1,000,000 words spelled! &amp;nbsp;If you haven’t got it yet, &lt;a href="http://itunes.apple.com/us/app/rocket-speller/id492504689?mt=8"&gt;go get it now&lt;/a&gt;. It’s a FREE!&lt;/p&gt;
</description>
      <pubDate>Thu, 29 Mar 2012 00:00:00 +0000</pubDate>
      <link>http://geoff.evason.name/2012/03/29/rocket-speller-is-whats-hot</link>
      <guid>http://geoff.evason.name/2012/03/29/rocket-speller-is-whats-hot</guid>
    </item>
    <item>
      <title>Apple iOS App Submission Approval Times</title>
      <description>&lt;p&gt;I just learned of a widget on Apple’s developer site which seems to give good insite into delays in having your app reviewed.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.apple.com/appstore/resources/approval/#expect"&gt;https://developer.apple.com/appstore/resources/approval/#expect&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As of the time of writing, 99% of apps submitted within the past 5 days have been reviewed. Nice.&lt;/p&gt;</description>
      <pubDate>Wed, 30 Nov 2011 00:00:00 +0000</pubDate>
      <link>http://geoff.evason.name/2011/11/30/apple-ios-app-submission-approval-times</link>
      <guid>http://geoff.evason.name/2011/11/30/apple-ios-app-submission-approval-times</guid>
    </item>
  </channel>
</rss>
