<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0" xml:base="http://www.davidgrant.ca/">
  <channel>
    <title>David Grant</title>
    <link>http://www.davidgrant.ca/</link>
    <description/>
    <language>en</language>
    
    <item>
  <title>My new job at Grow Financial</title>
  <link>http://www.davidgrant.ca/my_new_job_grow_financial</link>
  <description>
&lt;span&gt;My new job at Grow Financial&lt;/span&gt;

            &lt;div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"&gt;&lt;p&gt;Just a month ago I got a job at &lt;a href="http://www.poweredbygrow.com"&gt;Grow Financial&lt;/a&gt;. We're a small fintech startup that provides unsecured loans to prime borrowers. So far we're just in Canada and just offering unsecured loans up to $30,000, but we're growing fast and hopefully we'll be offering even more products in the future. We are really small; I was the third software engineer to join the team (neglecting a very key part of our team, the data scientists), and since I started in December 2015, we've since added 2 more engineers to our team. We have an awesome team of top-notch people, which is the main reason why I accepted an offer at Grow (despite having a few other opportunities available to me). Management's enthusiasm, vision, and success so far blew me away.&lt;/p&gt;
&lt;p&gt;We just made a big announcement today, a partnership with &lt;a&gt;. Full article in the Globe and Mail: "&lt;a href="http://www.theglobeandmail.com/globe-investor/first-west-partners-with-online-lending-startup-grow/article28677593/"&gt;First West partners with online lending startup Grow&lt;/a&gt;."&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
      
&lt;span&gt;&lt;span&gt;David Grant&lt;/span&gt;&lt;/span&gt;

&lt;span&gt;&lt;time datetime="2016-02-10T17:15:11-08:00" title="Wednesday, February 10, 2016 - 17:15"&gt;Wed, 02/10/2016 - 17:15&lt;/time&gt;
&lt;/span&gt;
</description>
  <pubDate>Thu, 11 Feb 2016 01:15:11 +0000</pubDate>
    <dc:creator>David Grant</dc:creator>
    <guid isPermaLink="false">430 at http://www.davidgrant.ca</guid>
    <comments>http://www.davidgrant.ca/my_new_job_grow_financial#comments</comments>
    </item>
<item>
  <title>GAE + GWT + Maven + Eclipse</title>
  <link>http://www.davidgrant.ca/gae_gwt_maven_eclipse</link>
  <description>
&lt;span&gt;GAE + GWT + Maven + Eclipse&lt;/span&gt;

            &lt;div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"&gt;&lt;p&gt;Just documenting a few issues I've had in setting up GWT + GAE + Maven + Eclipse.&lt;/p&gt;
&lt;p&gt;This is based on the sample "mobilewebapp" that comes with GWT (the version on master as of December 2015).&lt;/p&gt;
&lt;h2&gt;Eclipse not finding GAE&lt;/h2&gt;
&lt;p&gt;Eclipse might complain about not being able to find GAE under the ~/.m2/repository folder. To fix this, in the project's build path settings, under the "Order and Export" tab, put the Maven dependencies last.&lt;/p&gt;
&lt;h2&gt;"Choose war folder" prompt&lt;/h2&gt;
&lt;p&gt;WARNING: whatever folder you choose here will be deleted!!! When you try to run (as "Web Application (GWT Super Dev Mode)") and it asks you to choose the war folder, choose the target/${artifactId}-${version} folder.&lt;/p&gt;
&lt;h2&gt;GWT complains about CssResource&lt;/h2&gt;
&lt;p&gt;You need to add this to your .gwt.xml file:&lt;/p&gt;
&lt;div class="geshifilter"&gt;
&lt;pre class="xml geshifilter-xml" style="font-family:monospace;"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;set-configuration-property&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"CssResource.enableGss"&lt;/span&gt; &lt;span style="color: #000066;"&gt;value&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"true"&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;set-configuration-property&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"CssResource.legacy"&lt;/span&gt; &lt;span style="color: #000066;"&gt;value&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;"true"&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;&lt;br&gt;
test&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;
      
&lt;span&gt;&lt;span&gt;David Grant&lt;/span&gt;&lt;/span&gt;

&lt;span&gt;&lt;time datetime="2015-12-31T10:46:51-08:00" title="Thursday, December 31, 2015 - 10:46"&gt;Thu, 12/31/2015 - 10:46&lt;/time&gt;
&lt;/span&gt;
</description>
  <pubDate>Thu, 31 Dec 2015 18:46:51 +0000</pubDate>
    <dc:creator>David Grant</dc:creator>
    <guid isPermaLink="false">429 at http://www.davidgrant.ca</guid>
    <comments>http://www.davidgrant.ca/gae_gwt_maven_eclipse#comments</comments>
    </item>
<item>
  <title>Can't connect with ssh and sshd complains about permissions on authorized_keys files</title>
  <link>http://www.davidgrant.ca/cant_connect_ssh_and_sshd_complains_about_permissions_authorized_keys_files</link>
  <description>
&lt;span&gt;Can't connect with ssh and sshd complains about permissions on authorized_keys files&lt;/span&gt;

            &lt;div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"&gt;&lt;p&gt;I was recently trying to connect to a CentOS box from Windows and had the following error in /var/log/secure (after enabling DEBUG3 level logging in /etc/ssh/sshd_config):&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;br&gt;
Dec 19 18:01:05 hostname sshd[25119]: debug1: trying public key file /root/.ssh/authorized_keys&lt;br&gt;
Dec 19 18:01:05 hostname sshd[25119]: debug1: Could not open authorized keys '/root/.ssh/authorized_keys': Permission denied&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;It's an SELinux problem, and I don't quite understand it, but here's the one-liner that fixes it:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;br&gt;
restorecon -FRvv ~/.ssh&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Found on stackoverflow: "&lt;a href="http://stackoverflow.com/a/20818775"&gt;SSHD Gives error could not open Authorized Keys, although permissions seem correct&lt;/a&gt;"&lt;/p&gt;
&lt;/div&gt;
      
&lt;span&gt;&lt;span&gt;David Grant&lt;/span&gt;&lt;/span&gt;

&lt;span&gt;&lt;time datetime="2015-03-18T16:40:31-07:00" title="Wednesday, March 18, 2015 - 16:40"&gt;Wed, 03/18/2015 - 16:40&lt;/time&gt;
&lt;/span&gt;
</description>
  <pubDate>Wed, 18 Mar 2015 23:40:31 +0000</pubDate>
    <dc:creator>David Grant</dc:creator>
    <guid isPermaLink="false">428 at http://www.davidgrant.ca</guid>
    <comments>http://www.davidgrant.ca/cant_connect_ssh_and_sshd_complains_about_permissions_authorized_keys_files#comments</comments>
    </item>
<item>
  <title>Vancouver Housing Prices are NOT caused by foreigners</title>
  <link>http://www.davidgrant.ca/vancouver_housing_prices_are_not_caused_foreigners</link>
  <description>
&lt;span&gt;Vancouver Housing Prices are NOT caused by foreigners&lt;/span&gt;

            &lt;div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"&gt;&lt;p&gt;A recent article titled "&lt;a href="http://www.vancouversun.com/business/Barbara+Yaffe+Vancouver+housing+prices+tied+China+economic+growth+with+video/10399964/story.html#ixzz3K4E02vEl"&gt;Vancouver housing prices tied to China’s economic growth&lt;/a&gt;", Barbara Yaffe quoted two "experts" (&lt;a href="http://ibis.geog.ubc.ca/~dley/David_Leys_Homepage.html"&gt;David Ley&lt;/a&gt; and &lt;a href="https://www.linkedin.com/pub/robin-wiebe/7a/786/a07"&gt;Robin Wiebe&lt;/a&gt;) who will tell anyone who will listen that "housing prices here [in Vancouver] are tied inextricably to purchase activity by foreign buyers." You'll find the use of words like "coincide," "relationship," and "exceptional correlation" between 1) periods of faster growth in China and growth of Vancouver's housing market, 2) house sales and housing starts and GDP growth in China, and 3) international immigration to Vancouver and the city's property prices. Nowhere do we see the words "cause" or "leads to."&lt;/p&gt;
&lt;p&gt;Correlation is mostly meaningless, especially when you're using it in the way that David Ley does (see &lt;a href="http://www.scmp.com/comment/blogs/article/1440792/immigration-property-prices-and-vancouver-experts-view"&gt;Figure 5.8&lt;/a&gt;). One commenter says:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
I work at the same institution as Professor Ley, but still I must critique the "evidence" presented in the graph. Perhaps there is more elsewhere in the study, but Figure 5.8 does not provide evidence of anything.&lt;br&gt;
A correlation of 0.94 or 94% looks impressive, but those who know statistics will understand that in the analysis of time-series data, one cannot just correlate the level of something (house prices) and the level of something else (immigration). It is very easy to get very high correlations. Don't believe me. Just try computing the correlation of the house prices with your age. I did. Guess what--the correlation is 94.5%. Evidently, my age predicts Vancouver house prices better than net immigration. Obviously, you can put in anyone's age and the result would be the same.
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;You can see more examples of ridiculous correlations at &lt;a href="http://www.tylervigen.com/"&gt;spurious correlations&lt;/a&gt;, like "US spending on science, space, and technology correlates with suicides by hanging, strangulation and suffocation" (0.992) and "Divorce rate in Maine correlates with Per capita consumption of margarine" (0.993).&lt;/p&gt;
&lt;p&gt;Repeat after me: &lt;a href="http://en.wikipedia.org/wiki/Correlation_does_not_imply_causation"&gt;correlation does not imply causation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Also lacking in the Yaffe article was any serious discussion of the more obvious causes of housing price increases, such as interest rates, 0% down mortgages and 40 year amortizations in the mid 2000s, and the effect of CMHC default insurance. These all have a real effect on housing prices. There was a singling out of Vancouver, and no discussion of all the other Canadian cities that have experienced similar relative price increases, and no mention of all the non-foreign buyers owning multiple condos (and renting them for very little profit), thus speculating on price increases on the value of the home.&lt;/p&gt;
&lt;p&gt;The effect that interest rates have is huge. The Bank of Canada bank rate was 6% at it's peak of the tech bubble (2000)! then the tech bubble burst and the Bank of Canada started slashing the interest rates to as low as 0.5% (2009); a swing of 5.5%! The bank variable rates are a bit more than that, I'm getting 2.2% which is about the lowest they've ever gone. So let's say 2% and 7.5% for a spread of 5.5%. To make things even crazier, throw in the 40 year mortgage which was available for a little while:&lt;/p&gt;
&lt;p&gt;Effect of amortization period and interest rate for a $500,000 home:&lt;br&gt;
$3650 monthly payment (at 7% for 25 years)&lt;br&gt;
$1500 monthly payment (at 2% for 40 years)&lt;/p&gt;
&lt;p&gt;That's with no change to down payments. Add in the effect of lower down payments (increased leveraging) due to lower requirements + CMHC default insurance, people owning multiple properties (more leveraging and speculation), and people buying more house than they can afford (if interest rates increased but they assume house value will only go up), and you have a recipe for the bubble we have today.&lt;/p&gt;
&lt;p&gt;Finally, Vancouver has experienced the same growth in housing prices that the rest of Canada has.&lt;/p&gt;
&lt;p&gt;All figures below are from &lt;a href="http://www.housepriceindex.ca"&gt;http://www.housepriceindex.ca&lt;/a&gt; (which actually measures same house sale pairs over time, not just "average home prices"). I downloaded the spreadsheet and calculated the total percentage increase in the index from early 1999 (data is spotty before then, some cities go back to 1990, others don't).&lt;/p&gt;
&lt;p&gt;Winnipeg 305%&lt;br&gt;
Edmonton 290%&lt;br&gt;
Quebec City 285%&lt;br&gt;
Vancouver 276%&lt;br&gt;
Calgary 272%&lt;br&gt;
Montreal 259%&lt;br&gt;
Toronto 242%&lt;br&gt;
Victoria 231%&lt;br&gt;
Hamilton 229%&lt;br&gt;
Ottawa 225%&lt;br&gt;
Halifax 217%&lt;/p&gt;
&lt;p&gt;So is the "foreigner effect" happening everywhere in Canada? Or maybe the increases are due to something other than foreigners? During a bubble people are often quoted as saying "it's different this time" or "it's different here." They always end up being wrong.&lt;/p&gt;
&lt;/div&gt;
      
&lt;span&gt;&lt;span&gt;David Grant&lt;/span&gt;&lt;/span&gt;

&lt;span&gt;&lt;time datetime="2014-11-25T00:53:34-08:00" title="Tuesday, November 25, 2014 - 00:53"&gt;Tue, 11/25/2014 - 00:53&lt;/time&gt;
&lt;/span&gt;
</description>
  <pubDate>Tue, 25 Nov 2014 08:53:34 +0000</pubDate>
    <dc:creator>David Grant</dc:creator>
    <guid isPermaLink="false">427 at http://www.davidgrant.ca</guid>
    <comments>http://www.davidgrant.ca/vancouver_housing_prices_are_not_caused_foreigners#comments</comments>
    </item>
<item>
  <title>How I increased my Nexus 4 battery life to 48 hours on one charge</title>
  <link>http://www.davidgrant.ca/how_i_increased_my_nexus_4_battery_life_48_hours_one_charge</link>
  <description>
&lt;span&gt;How I increased my Nexus 4 battery life to 48 hours on one charge&lt;/span&gt;

            &lt;div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"&gt;&lt;p&gt;I did several things to increase the battery life on my Nexus 4 phone. Here's a list of all the things I did. I am not sure exactly what led to the biggest improvement in battery life because I didn't do extensive testing at each step. Here they are:&lt;/p&gt;
&lt;h2&gt;Unlock, custom ROM, packages&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://wiki.cyanogenmod.org/w/Install_CM_for_mako"&gt;Unlock, install ClockworkMod Recovery, install CyanogenMod 11 and Google Apps.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Install the &lt;a href="http://forum.xda-developers.com/nexus-4/general/qa-kernel-hells-core-kitkat-b45-stable-t2495373"&gt;hells-Core&lt;/a&gt; kernel from ClockworkMod Recovery.&lt;/li&gt;
&lt;li&gt;Install the &lt;a href="https://play.google.com/store/apps/details?id=com.themike10452.hellscorekernelmanager&amp;amp;hl=en"&gt;Hellscore Kernel Manager&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Install the &lt;a href="https://play.google.com/store/apps/details?id=com.oasisfeng.greenify&amp;amp;hl=en"&gt;Greenify&lt;/a&gt; app.&lt;/li&gt;
&lt;li&gt;Install the &lt;a href="https://play.google.com/store/apps/details?id=com.asksven.betterbatterystats&amp;amp;hl=en"&gt;BetterBatteryStats&lt;/a&gt; app.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Configuration&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;If you can, delete the Facebook app and use Facebook in your browser instead.&lt;/li&gt;
&lt;li&gt;Disable notifications and auto-updating/auto-syncing in as many apps as you can.&lt;/li&gt;
&lt;li&gt;Look at what is using the most battery under "Setings-&amp;gt;Battery" and remove any apps that you don't actually need.&lt;/li&gt;
&lt;li&gt;If you can, disable Google Now and Google Location Reporting (found in "Settings-&amp;gt;Location").&lt;/li&gt;
&lt;li&gt;Put "Location-&amp;gt;Mode" into "Battery saving" mode&lt;/li&gt;
&lt;li&gt;Under "Settings-&amp;gt;Sound" disable "Touch sounds", "Vibrate on touch", and "Screen lock sound"&lt;/li&gt;
&lt;li&gt;Under "Settings-&amp;gt;Language &amp;amp; Input-&amp;gt;Android Keyboard (AOSP)" disable "Sound on keypress" and "Vibrate on keypress"&lt;/li&gt;
&lt;li&gt;In the Hellscore Kernel Manager, set the CPU "Min Freq" to 94 MHz.&lt;/li&gt;
&lt;li&gt;After recharging your phone and using it for a whole discharge cycle, look at Partial Wakelocks in the BetterBatteryStats app.&lt;/li&gt;
&lt;li&gt;Using the Greenify app, Hibernate as many of the apps that show up in the "App Analyzer" as you can.&lt;/li&gt;
&lt;li&gt;In "Settings-&amp;gt;Display &amp;amp; lights-&amp;gt;Brightness", set to "Auto" and then click the gear to configure. Enable "adjust to sunrise and sunset". Click "Adjust" and move all the sliders to the left by about 5% or so.&lt;/li&gt;
&lt;li&gt;Get a watch so you don't have to wake-up your phone to check the time.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now I can get about 48 hours on one charge with minimal usage (checking email once in a while, sending a few messages, checking a few web pages.&lt;/p&gt;
&lt;/div&gt;
      
&lt;span&gt;&lt;span&gt;David Grant&lt;/span&gt;&lt;/span&gt;

&lt;span&gt;&lt;time datetime="2014-10-23T13:27:18-07:00" title="Thursday, October 23, 2014 - 13:27"&gt;Thu, 10/23/2014 - 13:27&lt;/time&gt;
&lt;/span&gt;
</description>
  <pubDate>Thu, 23 Oct 2014 20:27:18 +0000</pubDate>
    <dc:creator>David Grant</dc:creator>
    <guid isPermaLink="false">425 at http://www.davidgrant.ca</guid>
    <comments>http://www.davidgrant.ca/how_i_increased_my_nexus_4_battery_life_48_hours_one_charge#comments</comments>
    </item>
<item>
  <title>Technical documents should be reviewed by technical people</title>
  <link>http://www.davidgrant.ca/technical_documents_should_be_reviewed_technical_people</link>
  <description>
&lt;span&gt;Technical documents should be reviewed by technical people&lt;/span&gt;

            &lt;div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"&gt;&lt;p&gt;Just recently, I was implementing a protocol at work. The protocol was handed to me in the form of a Word document and it appeared to have already cleared some approval stages. The protocol seemed over-engineered to me. It used HTTP POST with XML in the request and response bodies. There was actually only one message type and it seemed like it could have easily been implemented with a simple GET request and no response body (just an HTTP response with a proper response code). The document was 24 pages long when it only required 1. It had about 10 error response message types, about half of which had to do with XML errors. I looked at who reviewed the document and it was as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Author: Engineering Manager&lt;/li&gt;
&lt;li&gt;Reviewer: VP Engineering&lt;/li&gt;
&lt;li&gt;Reviewer: Technical Director&lt;/li&gt;
&lt;li&gt;Reviewer: Director of Engineering, Client Engineering&lt;/li&gt;
&lt;li&gt;Reviewer: Director of Engineering, Host and Infrastructure Engineering&lt;/li&gt;
&lt;li&gt;Reviewer: Engineering Manager, Quality Engineering&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Missing are Principal Engineers and most importantly, Senior Developers, like myself, who will be implementing the protocol. It's not even necessary to consult the people who will be implementing the protocol, but you need to consult with people who understand HTTP, have experience with using web protocol, and an understanding of programming. One of those listed above qualifies in that respect, but that is still just one person. I am sure that if this was shown to three other people who aren't managers, directors, or VPs, they would say this protocol is over-engineered. If even one person thinks it's over-engineered, and over-engineering things is costly. It adds complexity on both sides of the protocol which means more development, more bugs, more testing. There's no excuse for over-engineering things and not excuse not to have technical documents revealed by those who will implement, the hands-on technical people.&lt;/p&gt;
&lt;/div&gt;
      
&lt;span&gt;&lt;span&gt;David Grant&lt;/span&gt;&lt;/span&gt;

&lt;span&gt;&lt;time datetime="2014-08-11T14:36:20-07:00" title="Monday, August 11, 2014 - 14:36"&gt;Mon, 08/11/2014 - 14:36&lt;/time&gt;
&lt;/span&gt;
</description>
  <pubDate>Mon, 11 Aug 2014 21:36:20 +0000</pubDate>
    <dc:creator>David Grant</dc:creator>
    <guid isPermaLink="false">421 at http://www.davidgrant.ca</guid>
    <comments>http://www.davidgrant.ca/technical_documents_should_be_reviewed_technical_people#comments</comments>
    </item>
<item>
  <title>Burning CDs/DVDs/Blu-Ray in Debian/Ubuntu</title>
  <link>http://www.davidgrant.ca/burning_cdsdvdsbluray_debianubuntu</link>
  <description>
&lt;span&gt;Burning CDs/DVDs/Blu-Ray in Debian/Ubuntu&lt;/span&gt;

            &lt;div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"&gt;&lt;p&gt;For long time I've been wondering why I can't seem to burn DVDs or Blu-Rays properly using k3b in Linux (or any other graphical burning software for that matter). The problem is &lt;a href="http://www.cdrkit.org/"&gt;cdrkit&lt;/a&gt; (a fork of the original &lt;a href="http://cdrecord.berlios.de/‎"&gt;cdrtools&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;You can get the latest version of cdrtools, which actually supports burning to Blu-Ray and also should create DVDs properly, by installing cdrecord from &lt;a href="https://launchpad.net/~brandonsnider/+archive/cdrtools"&gt;this PPA&lt;/a&gt;. You might as well also install mkisofs from there too.&lt;/p&gt;
&lt;p&gt;Prior to finding this PPA, I had compiled cdrtools from source, which is pretty easy. That also involved installing smake, also from the cdrtools author.&lt;/p&gt;
&lt;/div&gt;
      
&lt;span&gt;&lt;span&gt;David Grant&lt;/span&gt;&lt;/span&gt;

&lt;span&gt;&lt;time datetime="2014-03-20T15:38:39-07:00" title="Thursday, March 20, 2014 - 15:38"&gt;Thu, 03/20/2014 - 15:38&lt;/time&gt;
&lt;/span&gt;
</description>
  <pubDate>Thu, 20 Mar 2014 22:38:39 +0000</pubDate>
    <dc:creator>David Grant</dc:creator>
    <guid isPermaLink="false">419 at http://www.davidgrant.ca</guid>
    <comments>http://www.davidgrant.ca/burning_cdsdvdsbluray_debianubuntu#comments</comments>
    </item>
<item>
  <title>Logging in to a Django site with a magic token</title>
  <link>http://www.davidgrant.ca/logging_django_site_magic_token</link>
  <description>
&lt;span&gt;Logging in to a Django site with a magic token&lt;/span&gt;

            &lt;div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"&gt;&lt;p&gt;I have a simple &lt;a href="http://kids.davidgrant.ca"&gt;video website for my kids&lt;/a&gt; and each kid has a separate login. This is so they can each have their own videos, but also so that some videos can be private (ie. hidden from the outside world, or other logged in users). Typing in a username and password is impossible for my kids to do, as they are almost 5 and 2 years old, and they use this website on Google TV. So, with a magic token-style login, all they need to do is navigate to their bookmark on the Google TV homepage and press OK on the remote control.&lt;/p&gt;
&lt;p&gt;(I don't need crazy security--it wouldn't be the end of the world if somehow someone guessed the magic token and saw some private videos, which are basically just home videos uploaded to Youtube. Videos that I really wouldn't want the public to see don't get uploaded to Youtube in the first place.)&lt;/p&gt;
&lt;p&gt;I couldn't find how to do this easily, although one person on stackoverflow suggested "logging in the user in the view by calling 'login'". The tricky part was figuring out that I had to set the User object's backend to 'django.contrib.auth.backends.ModelBackend'. It's a bit of a hack, but it works, and it's simple.&lt;/p&gt;
&lt;p&gt;models.py:&lt;/p&gt;
&lt;div&gt;
&lt;pre&gt;&lt;span&gt;class&lt;/span&gt; MagicToken&lt;span&gt;(&lt;/span&gt;models.&lt;span&gt;Model&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;:
    &lt;span&gt;user&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; models.&lt;span&gt;OneToOneField&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;User&lt;span&gt;)&lt;/span&gt;
    magictoken &lt;span&gt;=&lt;/span&gt; models.&lt;span&gt;CharField&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;max_length&lt;span&gt;=&lt;/span&gt;&lt;span&gt;128&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; unique&lt;span&gt;=&lt;/span&gt;&lt;span&gt;True&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;
&amp;nbsp;
    &lt;span&gt;def&lt;/span&gt; &lt;span&gt;__unicode__&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;self&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;:
        &lt;span&gt;return&lt;/span&gt; &lt;span&gt;unicode&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;self&lt;/span&gt;.&lt;span&gt;user&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;views.py:&lt;/p&gt;
&lt;div&gt;
&lt;pre&gt;&lt;span&gt;from&lt;/span&gt; django.&lt;span&gt;http&lt;/span&gt; &lt;span&gt;import&lt;/span&gt; HttpResponse&lt;span&gt;,&lt;/span&gt; HttpResponseRedirect&lt;span&gt;,&lt;/span&gt; Http404
&lt;span&gt;import&lt;/span&gt; django.&lt;span&gt;contrib&lt;/span&gt;.&lt;span&gt;auth&lt;/span&gt;.&lt;span&gt;login&lt;/span&gt;
&amp;nbsp;
&lt;span&gt;class&lt;/span&gt; MagicTokenLogin&lt;span&gt;(&lt;/span&gt;View&lt;span&gt;)&lt;/span&gt;:
    &lt;span&gt;def&lt;/span&gt; get&lt;span&gt;(&lt;/span&gt;&lt;span&gt;self&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; request&lt;span&gt;,&lt;/span&gt; &lt;span&gt;token&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;:
        &lt;span&gt;try&lt;/span&gt;:
            magic_token_obj &lt;span&gt;=&lt;/span&gt; MagicToken.&lt;span&gt;objects&lt;/span&gt;.&lt;span&gt;get&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;magictoken&lt;span&gt;=&lt;/span&gt;&lt;span&gt;token&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;
        &lt;span&gt;except&lt;/span&gt; MagicToken.&lt;span&gt;DoesNotExist&lt;/span&gt;:
            &lt;span&gt;raise&lt;/span&gt; Http404
&amp;nbsp;
        &lt;span&gt;user&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; magic_token_obj.&lt;span&gt;user&lt;/span&gt;
        &lt;span&gt;user&lt;/span&gt;.&lt;span&gt;backend&lt;/span&gt; &lt;span&gt;=&lt;/span&gt; &lt;span&gt;'django.contrib.auth.backends.ModelBackend'&lt;/span&gt;
        django.&lt;span&gt;contrib&lt;/span&gt;.&lt;span&gt;auth&lt;/span&gt;.&lt;span&gt;login&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;request&lt;span&gt;,&lt;/span&gt; &lt;span&gt;user&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;
        &lt;span&gt;if&lt;/span&gt; request.&lt;span&gt;user&lt;/span&gt;.&lt;span&gt;is_authenticated&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;:
            &lt;span&gt;# login successful&lt;/span&gt;
            &lt;span&gt;return&lt;/span&gt; HttpResponseRedirect&lt;span&gt;(&lt;/span&gt;reverse&lt;span&gt;(&lt;/span&gt;&lt;span&gt;'some-view-for-logged-in-users'&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;
        &lt;span&gt;else&lt;/span&gt;:
            &lt;span&gt;# login failed&lt;/span&gt;
            &lt;span&gt;return&lt;/span&gt; HttpResponseRedirect&lt;span&gt;(&lt;/span&gt;reverse&lt;span&gt;(&lt;/span&gt;&lt;span&gt;'some-view'&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
      
&lt;span&gt;&lt;span&gt;David Grant&lt;/span&gt;&lt;/span&gt;

&lt;span&gt;&lt;time datetime="2014-03-06T15:35:48-08:00" title="Thursday, March 6, 2014 - 15:35"&gt;Thu, 03/06/2014 - 15:35&lt;/time&gt;
&lt;/span&gt;
</description>
  <pubDate>Thu, 06 Mar 2014 23:35:48 +0000</pubDate>
    <dc:creator>David Grant</dc:creator>
    <guid isPermaLink="false">417 at http://www.davidgrant.ca</guid>
    <comments>http://www.davidgrant.ca/logging_django_site_magic_token#comments</comments>
    </item>
<item>
  <title>Be careful renaming folders with copy.com</title>
  <link>http://www.davidgrant.ca/be_careful_renaming_folders_copycom</link>
  <description>
&lt;span&gt;Be careful renaming folders with copy.com&lt;/span&gt;

            &lt;div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"&gt;&lt;p&gt;I recently renamed a folder in my copy.com folder and caused Copy.com to think that I had deleted it. For example, I had the a folder called "Photos 2013." I installed the copy.com agent on a new computer and it began syncing. Midway through the sync, I wanted to change the folder's name to "Photos 2013-2014". This was interpreted as "Delete 'Photos 2013' folder and all sersver-side contents" and create a new folder called Photos 2014 with the photos in it. So let's say there were 100 photos, and 10 were were synced when I did it. The 90 photos that had not yet been synced would be flagged for deletion on the copy.com server. The 10 photos that actually got synced will remain, in the new "Photos 2013-2014" folder.&lt;/p&gt;
&lt;p&gt;All I can suggest to avoid this is don't touch the folders while they are being synced.&lt;/p&gt;
&lt;/div&gt;
      
&lt;span&gt;&lt;span&gt;David Grant&lt;/span&gt;&lt;/span&gt;

&lt;span&gt;&lt;time datetime="2014-03-03T23:19:54-08:00" title="Monday, March 3, 2014 - 23:19"&gt;Mon, 03/03/2014 - 23:19&lt;/time&gt;
&lt;/span&gt;
</description>
  <pubDate>Tue, 04 Mar 2014 07:19:54 +0000</pubDate>
    <dc:creator>David Grant</dc:creator>
    <guid isPermaLink="false">416 at http://www.davidgrant.ca</guid>
    <comments>http://www.davidgrant.ca/be_careful_renaming_folders_copycom#comments</comments>
    </item>
<item>
  <title>Wiping out a hard drive in Linux</title>
  <link>http://www.davidgrant.ca/wiping_out_hard_drive_linux</link>
  <description>
&lt;span&gt;Wiping out a hard drive in Linux&lt;/span&gt;

            &lt;div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"&gt;&lt;p&gt;To wipe a hard drive using zeros:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;br&gt;
dd if=/dev/zero | pv -s 250000000000 | dd of=/dev/sdX bs=10M&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;To wipe a hard drive with random data (more secure):&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;br&gt;
dd if=/dev/urandom | pv -s 250000000000 | dd of=/dev/sdX bs=10M&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;For the "pv" progress bar, do "apt-get install pv" or similar. I highly recommend using "pv" so you have some idea of when the dd job is going to finish.&lt;/p&gt;
&lt;/div&gt;
      
&lt;span&gt;&lt;span&gt;David Grant&lt;/span&gt;&lt;/span&gt;

&lt;span&gt;&lt;time datetime="2013-10-21T23:07:28-07:00" title="Monday, October 21, 2013 - 23:07"&gt;Mon, 10/21/2013 - 23:07&lt;/time&gt;
&lt;/span&gt;
</description>
  <pubDate>Tue, 22 Oct 2013 06:07:28 +0000</pubDate>
    <dc:creator>David Grant</dc:creator>
    <guid isPermaLink="false">415 at http://www.davidgrant.ca</guid>
    <comments>http://www.davidgrant.ca/wiping_out_hard_drive_linux#comments</comments>
    </item>

  </channel>
</rss>
