<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Technology Musings</title>
    <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>Deploying a Rails Application to Elastic Beanstalk</title>
      <description>&lt;p&gt;I'm not a big AWS fan because it is a lot of work.&amp;nbsp; However, sometimes a client requires it.&amp;nbsp; In any case, if you are wanting to deploy to AWS Elastic Beanstalk using a Rails app, here are your step-by-step instructions!&lt;/p&gt;
&lt;p&gt;p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545; min-height: 14.0px} li.li1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545} span.s1 {color: #e4af0a} ol.ol1 {list-style-type: decimal}&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;Preparing a Rails app for EB deployment:&lt;/p&gt;
&lt;p class=&quot;p2&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;ol class=&quot;ol1&quot;&gt;
&lt;li class=&quot;li1&quot;&gt;Install the elastic beanstalk tools:&lt;br /&gt; From Python: sudo pip install awscli awsebcli --upgrade&lt;br /&gt; From homebrew: brew install aws-elasticbeanstalk&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;AWS Config&lt;br /&gt; Set ~/.aws/config as follows:&lt;br /&gt; &lt;br /&gt;[default]&lt;br /&gt;region = us-east-1&lt;br /&gt;&lt;br /&gt; [profile eb-cli]&lt;br /&gt;aws_access_key_id = YOUR_ACCESS_KEY_ID&lt;br /&gt; aws_secret_access_key = YOUR_SECRET&lt;br /&gt; &lt;br /&gt; The name of the profile &quot;eb-cli&quot; will need to match future steps.&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Create an AWS EB application in the EB GUI:&lt;ol class=&quot;ol1&quot;&gt;
&lt;li class=&quot;li1&quot;&gt;Create the application and give it a name&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Create an environment (select &quot;web server environment&quot;) and name it whatever you want&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Select &quot;Ruby&quot; for the preconfigured platform&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Leave the application as &quot;sample application&quot;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Hit &quot;Create Environment&quot; and wait for it to finish (this takes forever)&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Enable load balancing so that you have more control (optional, but required for HTTPS I think):&lt;ol class=&quot;ol1&quot;&gt;
&lt;li class=&quot;li1&quot;&gt;Go to &quot;configuration&quot; then &quot;Capacity&quot;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Change &quot;Single Instance&quot; to &quot;Load Balanced&quot;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Reduce &quot;max&quot; to &quot;1&quot; to prevent additional instances from launching&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Hit &quot;apply&quot; and &quot;confirm&quot; and then wait (this takes forever)&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Change the instance type to &quot;t2.small&quot; at the lowest.&lt;span&gt;&amp;nbsp; &lt;/span&gt;If it is smaller than this, you will get strange errors when deploying because it is running out of RAM to do the deployment.&lt;ol class=&quot;ol1&quot;&gt;
&lt;li class=&quot;li1&quot;&gt;&quot;Configuration&quot; -&amp;gt; &quot;Instances&quot; -&amp;gt; &quot;Modify&quot; -&amp;gt; &quot;Instance Type&quot;.&lt;span&gt;&amp;nbsp; &lt;/span&gt;Set to t2.small.&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Add a data tier&lt;ol class=&quot;ol1&quot;&gt;
&lt;li class=&quot;li1&quot;&gt;&quot;Configuration&quot; -&amp;gt; &quot;Database&quot; -&amp;gt; &quot;Modify&quot;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Options:&lt;br /&gt; Engine: postgres&lt;br /&gt; Engine version: 9.6.8&lt;br /&gt; Username/password: set them and write them down, but you don't really need them&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Configure Environment Variables&lt;ol class=&quot;ol1&quot;&gt;
&lt;li class=&quot;li1&quot;&gt;&quot;Configuration&quot; -&amp;gt; &quot;Software&quot; -&amp;gt; &quot;Modify&quot;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;BUNDLE_WITHOUT: test:development&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;RACK_ENV: production&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;RAILS_SKIP_ASSET_COMPILATION: false&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;RAILS_SKIP_MIGRATIONS: false&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;RAILS_SERVE_STATIC_FILES: 1&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;SECRET_KEY_BASE: use &quot;rake secret&quot; to generate one (note that leaving this out can lead to some weird errors that seem senseless)&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Any other configuration (check your .env file if you have one)&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Modify your app to use your data tier.&lt;span&gt;&amp;nbsp; &lt;/span&gt;In config/database.yml, make sure that the adapter is postgresql for &quot;default&quot;, then set production to be like the following:&lt;br /&gt; &lt;br /&gt; production:&lt;br /&gt; &lt;span&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&amp;lt;: *default&lt;br /&gt; &lt;span&gt;&amp;nbsp; &lt;/span&gt;database: &amp;lt;%= ENV['RDS_DB_NAME'] %&amp;gt;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &lt;/span&gt;username: &amp;lt;%= ENV['RDS_USERNAME'] %&amp;gt;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &lt;/span&gt;password: &amp;lt;%= ENV['RDS_PASSWORD'] %&amp;gt;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &lt;/span&gt;host: &amp;lt;%= ENV['RDS_HOSTNAME'] %&amp;gt;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &lt;/span&gt;port: &amp;lt;%= ENV['RDS_PORT'] %&amp;gt;&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;In your app, Create a .elasticbeanstalk/config.yml file in your project's home directory&lt;ol class=&quot;ol1&quot;&gt;
&lt;li class=&quot;li1&quot;&gt;File contents:&lt;br /&gt; &lt;br /&gt; global:&lt;br /&gt; &lt;span&gt;&amp;nbsp; &lt;/span&gt;application_name: your-app-name&lt;br /&gt; &lt;span&gt;&amp;nbsp; &lt;/span&gt;default_region: us-east-1&lt;br /&gt; &lt;span&gt;&amp;nbsp; &lt;/span&gt;profile: eb-cli&lt;br /&gt; branch-defaults:&lt;br /&gt; &lt;span&gt;&amp;nbsp; &lt;/span&gt;master:&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;environment: your-staging-environment&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;The region should probably match the region of the application (though I am not certain), the profile should match the one in ~/.aws/config, and the application_name should match the actual name of the application in elastic beanstalk.&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&quot;branch-defaults&quot; allows you to set some parameters per-branch (based on the git branch).&lt;span&gt;&amp;nbsp; &lt;/span&gt;Here, we are saying that when using the master git branch, the environment we should push to is &quot;your-staging-environment&quot;.&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Create a file in your app .ebextensions/010_packages.config (loads packages we will probably need - may need others based on requirements):&lt;br /&gt; &lt;br /&gt; packages:&lt;br /&gt; &lt;span&gt;&amp;nbsp; &lt;/span&gt;yum:&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;git: []&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;gcc: []&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;libxml2-devel: []&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;libxslt-devel: []&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;patch: []&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;sqlite-devel: []&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;libffi-devel: []&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;postgresql96-devel: [] &lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Make sure that everything in your repository is committed and ready to go.&lt;span&gt;&amp;nbsp; &lt;/span&gt;Then, run&lt;br /&gt; &lt;br /&gt; eb deploy&lt;br /&gt; &lt;br /&gt; and everything should work.&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Add a CNAME for your environment in your DNS manager, whatever that is.&lt;span&gt;&amp;nbsp; &lt;/span&gt;It should CNAME to the name listed in your environment (i.e., &lt;a href=&quot;http://my-environment-name.us-east-1.elasticbeanstalk.com&quot;&gt;&lt;span class=&quot;s1&quot;&gt;my-environment-name.us-east-1.elasticbeanstalk.com&lt;/span&gt;&lt;/a&gt;) (optional - you can also just leave it with the generated name, but then you won't be able to add SSL).&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Turn on SSL (optional)&lt;ol class=&quot;ol1&quot;&gt;
&lt;li class=&quot;li1&quot;&gt;Go to AWS Certificate Manager&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Click &quot;Request a Certificate&quot; -&amp;gt; &quot;Request a Public Certificate&quot;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Enter in your domain name (the CNAME you created)&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Choose &quot;DNS Validation&quot;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;When it says &quot;Pending Validation&quot;, open up the &quot;domain&quot; area and create the requested CNAME in your DNS in order to validate your domain.&lt;span&gt;&amp;nbsp; &lt;/span&gt;When complete, click &quot;Continue&quot;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Go to your EB environment page&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Go to &quot;Configuration&quot; -&amp;gt; &quot;Load Balancer&quot; -&amp;gt; &quot;Modify&quot;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Click &quot;Add Listener&quot;:&lt;br /&gt; Listener Port: 443&lt;br /&gt; Listener Protocol: HTTPS&lt;br /&gt; Instance Port: 80&lt;br /&gt; Instance Protocol: HTTP&lt;br /&gt; SSL Certificate: select the certificate previously generated&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;Note that after adding the listener, there is an &quot;apply&quot; button buried on the webpage.&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;You can now access the site using SSL on the CNAME you created.&lt;br /&gt; &lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Sat, 14 Jul 2018 05:22:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/396</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/396</guid>
    </item>
    <item>
      <title>Hot-Patching Ruby for TLS 1.2</title>
      <description>&lt;p&gt;Authorize.net recently started denying TLS requests that were less than 1.2.&amp;nbsp; I thought I was fine, but I had one server running CentOS 5.&amp;nbsp; It was not fine.&amp;nbsp; I had a very ancient Rails application on an ancient box unable to connect to Authorize.net.&lt;/p&gt;
&lt;p&gt;Anyway, if you are in a similar situation, here is how I solved it.&amp;nbsp; This may not be exact, but should hopefully get you far enough along to figure it out yourself:&lt;/p&gt;
&lt;p&gt;p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545; min-height: 14.0px}
&lt;p class=&quot;p1&quot;&gt;For authorize.net's TLS upgrade, it is based on your server's OpenSSL library version.&lt;span&gt;&amp;nbsp; &lt;/span&gt;To see if you are compatible, run the following command:&lt;/p&gt;
&lt;p class=&quot;p2&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;openssl s_client -connect secure.authorize.net:443&lt;/pre&gt;
&lt;p class=&quot;p2&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;If you get a one-line error message like this:&lt;/p&gt;
&lt;pre&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;6641:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure:s23_clnt.c:586:&lt;/pre&gt;
&lt;p class=&quot;p2&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;Then you are NOT compatible.&lt;span&gt;&amp;nbsp; &lt;/span&gt;To fix, you need to either update your OpenSSL in Linux or get the latest OpenSSL from here - https://www.openssl.org/source/&lt;/p&gt;
&lt;p class=&quot;p2&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;For building, you may have to configure it something like this:&lt;/p&gt;
&lt;pre&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;export CFLAGS=-fPIC&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;./config shared&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;make&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;make install &lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;# this one as root&lt;/pre&gt;
&lt;p class=&quot;p2&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;I also copied the generated shared libs into /lib64.&amp;nbsp; In theory, after updating, it would be best to rebuild ruby from source.&lt;span&gt;&amp;nbsp; &lt;/span&gt;However, absent that, there is a trick you can do:&lt;/p&gt;
&lt;p class=&quot;p2&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;Create a new file, I called mine ruby_openssl in the same directory as the old ruby.&lt;span&gt;&amp;nbsp; &lt;/span&gt;The file should have the following contents:&lt;/p&gt;
&lt;p class=&quot;p2&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;#!/bin/sh&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;export LD_PRELOAD=/lib64/libssl.so.1.0.0:/lib64/libcrypto.so.1.0.0&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;exec /opt/ruby-1.8.7-p352/bin/ruby $*&lt;/pre&gt;
&lt;p class=&quot;p2&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;The LD_PRELOAD should go to the shared files that were installed by installing OpenSSL, wherever you happened to install them.&lt;/p&gt;
&lt;p class=&quot;p2&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;Then, in your apache config, reference your new ruby_newopenssl wherever you were referencing ruby.&lt;/p&gt;
&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Fri, 02 Mar 2018 22:21:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/395</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/395</guid>
    </item>
    <item>
      <title>Calculating an Even Baseline</title>
      <description>&lt;p&gt;So, I've been working in Xamarin for cross-platform phone development.&amp;nbsp; I was using their AbsoluteLayout class to try to get a bar graph working using relative sizes (AbsoluteLayout with relative sizes gives everything an absolute position from 0, top or left of the screen, to 1, the bottom or right of the screen).&amp;nbsp; The goal was to have the bottom of the bar graph halfway down the screen (to allow room for negative values to point down).&amp;nbsp; The goal was to look like this:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/site/bartpub/download/27?disposition=inline&quot; alt=&quot;&quot; width=&quot;150&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The problem, though is getting the boxes to align at the center line.&amp;nbsp; Now, part of the problem may be my inexperience with the platform.&amp;nbsp; There may be a really easy way to do this.&amp;nbsp; However, here is what I was running into:&lt;/p&gt;
&lt;p&gt;I thought that Xamarin worked by aligning the your specified position to the middle of the box.&amp;nbsp; Therefore, I started by calculated the box height, and then calculating the origin of the box by setting it above the 0.5 (i.e., 50%) line by half of the box height.&amp;nbsp; Therefore, when it extended, it should extend down to the 0.5 line.&lt;/p&gt;
&lt;p&gt;The problem, though, is that Xamarin &lt;em&gt;doesn't&amp;nbsp;&lt;/em&gt;&amp;nbsp;align to the middle of the box.&amp;nbsp; It varies the alignment by where in the positioning it is positioned.&amp;nbsp; So, if you position a box at 0.2, not only is it &lt;em&gt;positioned&lt;/em&gt;&amp;nbsp;at 0.2, but the anchoring point is also 0.2 down the box!&lt;/p&gt;
&lt;p&gt;Therefore, I needed a way to calculate where I needed to actually position the box to get it to rest on the 0.5 line.&lt;/p&gt;
&lt;p&gt;The way I calculated it is this - let's call the y-position that you want the box to rest on as P.&amp;nbsp; Let's call the y-position which you are going to set your box to as A (for the &lt;em&gt;anchoring&lt;/em&gt;&amp;nbsp;position).&amp;nbsp; Let's call the height of the box itself H.&lt;/p&gt;
&lt;p&gt;What we want to happen is for the bottom of the box to hit P.&lt;/p&gt;
&lt;p&gt;Now, we can split up the measurements from the top of the box to P into two lengths - the length from the top to the anchoring point (which is actually just A) and the length from the anchoring point to the bottom of the box.&lt;/p&gt;
&lt;p&gt;Since the anchoring point sits A down on the box, the length of the top half of the box is given by A*H.&amp;nbsp; However, this is not the distance we want.&amp;nbsp; We want the distance down the &lt;em&gt;rest&lt;/em&gt;&amp;nbsp;of the box.&amp;nbsp; That will be (1 - A)*H.&lt;/p&gt;
&lt;p&gt;So, our two distances are: A and (1 - A)*H.&amp;nbsp; They should add together to be P.&amp;nbsp; Therefore, our equation is:&lt;/p&gt;
&lt;p&gt;A + (1 - A)*H = P&lt;/p&gt;
&lt;p&gt;However, we want to solve this for A - we already know our box height (H), and we know what position we want this to extend to (P).&amp;nbsp; Therefore, we have to solve for A:&lt;/p&gt;
&lt;p&gt;A + (1 - A)*H = P&lt;br /&gt;A + H - A*H = P&lt;br /&gt;A - A*H = P - H&lt;br /&gt;A*(1 - H) = P - H&lt;br /&gt;A = (P - H) / (1 - H)&lt;/p&gt;
&lt;p&gt;And this gives a perfect calculation for A.&amp;nbsp; In my case, since P is 0.5, I just do A = (0.5 - H) / (1 - H) and it comes out perfectly.&lt;/p&gt;
&lt;p&gt;It should be fairly simple to come up with similar calculations for top alignment and center alignment.&amp;nbsp; Additionally, these work with right-to-left alignments as well.&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Tue, 24 Oct 2017 02:49:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/394</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/394</guid>
    </item>
    <item>
      <title>Finding Derivatives without Limits or Differentials</title>
      <description>&lt;p&gt;I always enjoy finding new ways of doing things. &amp;nbsp;I was reading Henle/Kleinberg's &lt;a href=&quot;http://www.amazon.com/Infinitesimal-Calculus-Dover-Books-Mathematics/dp/0486428869?tag=freeeducation-20&quot; target=&quot;_blank&quot;&gt;Infinitesimal Calculus&lt;/a&gt;, which is a great book. &amp;nbsp;It has, throughout the book, a main text and a side-text. &amp;nbsp;The side-text is infinitely more interesting than the main text.&lt;/p&gt;
&lt;p&gt;Anyway, on pages 65-66, it gives a method for finding the slope of y = x^2 at a specific point, let's say its at (2,4). &amp;nbsp;The way you do it is kind of strange, but it seems to work. &amp;nbsp;You start by defining a line to intercept the equation:&lt;/p&gt;
&lt;p&gt;y = mx + b&lt;/p&gt;
&lt;p&gt;Now, we don't know what m and b are, but we *do* know what x and y are. &amp;nbsp;Therefore,&lt;/p&gt;
&lt;p&gt;4 = 2m + b&lt;/p&gt;
&lt;p&gt;We don't really care about b in the long run, so we want to find an equation for b to remove it from the mix:&lt;/p&gt;
&lt;p&gt;b = 4 - 2m&lt;/p&gt;
&lt;p&gt;Now our equation for the line becomes:&lt;/p&gt;
&lt;p&gt;y = mx + 4 - 2m&lt;/p&gt;
&lt;p&gt;Interestingly, we actually have a value for y - y = x^2, so this becomes:&lt;/p&gt;
&lt;p&gt;x^2 = mx + 4 -2m&lt;/p&gt;
&lt;p&gt;We can rearrange this into quadratic form with:&lt;/p&gt;
&lt;p&gt;x^2 - mx + (2m - 4) = 0&lt;/p&gt;
&lt;p&gt;Using the quadratic formula, we can do:&lt;/p&gt;
&lt;p&gt;x = (m +- sqrt(m^2 - 4(2m - 4))) / 2&lt;/p&gt;
&lt;p&gt;x = (m +- sqrt(m^2 - 8m + 16)) / 2&lt;/p&gt;
&lt;p&gt;x = (m +- sqrt((m - 4)^2)) / 2&lt;/p&gt;
&lt;p&gt;x = (m +- (m - 4)) / 2&lt;/p&gt;
&lt;p&gt;Now, we want to take the &quot;+&quot; side of the &quot;+-&quot; since we are solving for &quot;m&quot;. &amp;nbsp;Otherwise, we will lose &quot;m&quot;. &amp;nbsp;Therefore, this becomes:&lt;/p&gt;
&lt;p&gt;x = (2m - 4) / 2&lt;/p&gt;
&lt;p&gt;x = m - 2&lt;/p&gt;
&lt;p&gt;So, at the point we are looking at, what is the value of x? &amp;nbsp;At (2, 4), x is 2. &amp;nbsp;Therefore&lt;/p&gt;
&lt;p&gt;2 = m - 2&lt;/p&gt;
&lt;p&gt;m = 4&lt;/p&gt;
&lt;p&gt;Therefore, the slope at (2, 4) is 4. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Interestingly, we can also generalize this to get the full derivative for y = x^2. &amp;nbsp;To do this, we will introduce the variables p and q to be the specific x and y values at a specific point. &amp;nbsp;Therefore, the slope at (p, q) for y = x^2 is:&lt;/p&gt;
&lt;p&gt;y = mx + b, therefore q = pm + b, therefore b = q - pm&lt;/p&gt;
&lt;p&gt;q = p^2, therefore b = p^2 - pm&lt;/p&gt;
&lt;p&gt;y = mx + p^2 - pm&lt;/p&gt;
&lt;p&gt;y = x^2, therefore:&lt;/p&gt;
&lt;p&gt;x^2 = mx + p^2 - pm&lt;/p&gt;
&lt;p&gt;x^2 - mx + (pm - p^2) = 0&lt;/p&gt;
&lt;p&gt;x = (m +- sqrt(m^2 - 4(pm - p^2)))/2&lt;/p&gt;
&lt;p&gt;x = (m +- sqrt(m^2 - 4pm + 4p^2))/2&lt;/p&gt;
&lt;p&gt;x = (m +- sqrt((m - 2p)^2))/2&lt;/p&gt;
&lt;p&gt;x = (m +- (m - 2p))/2&lt;/p&gt;
&lt;p&gt;x = (2m - 2p) / 2&lt;/p&gt;
&lt;p&gt;x = m - p&lt;/p&gt;
&lt;p&gt;m = x + p&lt;/p&gt;
&lt;p&gt;Since p = x, this gives&lt;/p&gt;
&lt;p&gt;m = x + x = 2x, which is the derivative of x^2&lt;/p&gt;
&lt;p&gt;I don't know how many classes of functions you can do this successfully for, but I imagine it should cover quadratics at least.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Thu, 11 Feb 2016 16:29:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/393</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/393</guid>
    </item>
    <item>
      <title>Ratios of Infinity</title>
      <description>&lt;p&gt;A lot of people do a lot of thinking about whether or not infinities exist, and wonder how real numbers can add up to infinity.&lt;/p&gt;
&lt;p&gt;Sometimes I wonder if that sort of thought might be the inverse of reality - perhaps the infinities are the foundational realities, and all finite numbers are merely infinities in ratio.&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Wed, 13 Jan 2016 03:49:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/391</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/391</guid>
    </item>
    <item>
      <title>A Meaning for d^2y/d^2x?</title>
      <description>&lt;p&gt;I have recently been randomly curious about random calculus-y things. &amp;nbsp;Anyway, the notion for the second derivative of a function is d^2y/dx^2. &amp;nbsp;This is the second differential of y divided by the first differential of x squared.&lt;/p&gt;
&lt;p&gt;However, there is, technically, also a d^2x, though it doesn't get much attention. &amp;nbsp;And, d^2y and d^2x can be put into ratio with each other, but I don't really know what it means. &amp;nbsp;But it is an interesting operation nonetheless.&lt;/p&gt;
&lt;p&gt;So, the derivative of an equation is dy/dx and the derivative of its inverse is dx/dy.&lt;/p&gt;
&lt;p&gt;The second derivative of an equation is d^2y/dx^2 and the second derivative of its inverse is d^2x/dy^2.&lt;/p&gt;
&lt;p&gt;Therefore, to get the d^2y/d^2x you just do:&lt;br /&gt;&lt;br /&gt;(2nd Derivative of y wrt x / 2nd derivative of x wrt y) * (First derivative of the inverse)^2&lt;br /&gt;&lt;br /&gt;Or:&lt;/p&gt;
&lt;p&gt;(d^2y/dx^2) / (d^2x/dy^2) * (dx/dy)^2&lt;/p&gt;
&lt;p&gt;I will post an example later when I have a good one.&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Fri, 01 Jan 2016 20:29:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/390</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/390</guid>
    </item>
    <item>
      <title>The derivative of u^v</title>
      <description>&lt;p&gt;I don't know why this isn't listed as a standard rule. &amp;nbsp;The differential of the exponent function, u^v (u raised to the v power), is pretty basic, and you can use it to formulate the other exponent rules for differentiation. However, for some reason it seems to be left off of most rules for differentiation.&lt;/p&gt;
&lt;p&gt;The basic rule is this:&lt;/p&gt;
&lt;pre&gt;d(u^v) = v*u^(v-1)*du + u^v*ln(u)*dv&lt;/pre&gt;
&lt;p&gt;This can be clearly seen to be a more general form of u^n, because if n is a constant, this becomes:&lt;/p&gt;
&lt;pre&gt;d(u^n) = n*u^(n - 1)*du + u^v*ln(u)*0&lt;/pre&gt;
&lt;p&gt;And that zero drops it to the rule we all know and love:&lt;/p&gt;
&lt;pre&gt;d(u^n) = n*u^(n - 1)*du&lt;/pre&gt;
&lt;p&gt;This can be derived as follows:&lt;/p&gt;
&lt;pre&gt;z = u^v&lt;br /&gt;ln(z) = ln(u^v)&lt;/pre&gt;
&lt;p&gt;Using log rules, we get:&lt;/p&gt;
&lt;pre&gt;ln(z) = v*ln(u)&lt;/pre&gt;
&lt;p&gt;Now take the differential of both sides:&lt;/p&gt;
&lt;pre&gt;d(ln(z) = d(v*ln(u))&lt;/pre&gt;
&lt;p&gt;Differentiating both sides, we get:&lt;/p&gt;
&lt;pre&gt;dz/z = v*du/u + ln(u) * dv&lt;/pre&gt;
&lt;p&gt;Then we multiply by z:&lt;/p&gt;
&lt;pre&gt;dz = z*v*du/u + z * ln(u) * dv&lt;/pre&gt;
&lt;p&gt;Substituting in z = u^v:&lt;/p&gt;
&lt;pre&gt;dz = u^v * v * du / u + u^v * ln(u) * dv&lt;/pre&gt;
&lt;p&gt;Now, u^v/u simplifies to u^(v-1), giving us:&lt;/p&gt;
&lt;pre&gt;dz = v*u^(v-1)*du + u^v*ln(u)*dv&lt;/pre&gt;
&lt;p&gt;Since z = u^v, dz = d(u^v), so&lt;/p&gt;
&lt;pre&gt;d(u^v) = v*u^(v-1)*du + u^v*ln(u)*dv&lt;/pre&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</description>
      <author>JB</author>
      <pubDate>Sun, 27 Dec 2015 06:45:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/389</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/389</guid>
    </item>
    <item>
      <title>Rails and Updated Postgres not Performing Migrations</title>
      <description>&lt;p&gt;Apparently, there was a change to something in postgres 9.5, or maybe just my install of it. &amp;nbsp;If you upgrade your Postgres database version and suddenly your rails app stops doing migrations, add the following line to config/database.yml database config to get it working again:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; schema_search_path: public&lt;/span&gt;&lt;/pre&gt;
&lt;p class=&quot;p1&quot;&gt;The error message i was getting was:&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;&lt;span class=&quot;s1&quot;&gt;ActiveRecord::StatementInvalid: PG::DuplicateTable: ERROR:&amp;nbsp; relation &quot;schema_migrations&quot; already exists&lt;/span&gt;&lt;/pre&gt;
&lt;p class=&quot;p1&quot;&gt;Basically, sometimes Rails was finding the schema_migrations table, and sometimes it wasn't, but setting the schema_search_path fixed it.&lt;/p&gt;
&lt;p class=&quot;p1&quot;&gt;I'm still not sure where exactly the problem came from, but setting the setting fixed it.&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Tue, 22 Dec 2015 16:50:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/388</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/388</guid>
    </item>
    <item>
      <title>Explanation of Liebniz Notation of the Second Derivative</title>
      <description>&lt;p&gt;The notation for the second (and higher) derivatives in Liebniz notation has always troubled me. &amp;nbsp;The second derivative is usually notated as d^y/dx^2. &amp;nbsp;And I always wondered, why is the the 2 in relation to the d on the top, but in relation to the whole term on the bottom?&lt;/p&gt;
&lt;p&gt;This puzzled me for a while, and I looked through at least 10 Calculus textbooks to find the answer, all to no avail. &amp;nbsp;Finally, I put pen to paper and figured it out. &amp;nbsp;The answer was straightforward, and I am sure that whoever invented the 2nd derivative Liebniz notation knew why they did it that way, it's just that every Calculus book since then seems to have forgotton.&lt;/p&gt;
&lt;p&gt;Anyway, the usual notation for the derivative operation id d/dx. &amp;nbsp;I eventually came to realize that this is not a single operation, but TWO operations in one. &amp;nbsp;The first is to take the differential (not derivative) of the equation. &amp;nbsp;For that, I mean, let's say you have the equation y = 2x. &amp;nbsp;The differential of that equation is dy = 2xdx. &amp;nbsp;Doing a differential instead of a derivative is powerful, because it allows a more natural approach to both implicit differentiation and multivariable differentiation.&lt;/p&gt;
&lt;p&gt;Now, the derivative is simply the differential divided by dx. &amp;nbsp;So, if our differential is dy = 2xdx, then when we divide by dx we get our normal notation dy/dx = 2x.&lt;/p&gt;
&lt;p&gt;Now, let's leave off dividing by dx, and just look at the differential. &amp;nbsp;What happens if we take a second differential?&lt;br /&gt;&lt;br /&gt;In this case, we have to treat dy as a separate variable. &amp;nbsp;So, if the differential of y is dy, what is the differential of dy? &amp;nbsp;This is where the d^2y comes in. &amp;nbsp;The 2 is by the &quot;d&quot; not because it is &quot;d squared&quot;, but it is &quot;d applied twice&quot;. &amp;nbsp;So, if we take our initial differential dy = 2xdx and take another differential, what do we have?&lt;/p&gt;
&lt;p&gt;By the product rule, we get:&lt;/p&gt;
&lt;p&gt;d^2y = 2((x)(d^2x) + (dx)(dx))&lt;/p&gt;
&lt;p&gt;Now, since we want the second derivative, we divide both sides by dx twice (once for the first derivative, and once for the second), which is the same as dividing by dx^2.&lt;/p&gt;
&lt;p&gt;That gives us:&lt;/p&gt;
&lt;p&gt;d^2y / dx^2 = 2((x)(d^2x) + (dx)(dx)) / dx^2&lt;br /&gt;&lt;br /&gt;The (dx)(dx) simplifies to dx^2, and we can separate this out at the plus sign to give us:&lt;/p&gt;
&lt;p&gt;d^2y / dx^2 = 2(x)(d^2x)/dx^2 + 2(dx^2)/dx^2&lt;/p&gt;
&lt;p&gt;This further simplifies to:&lt;/p&gt;
&lt;p&gt;d^2y / dx^2 = 2(x)(d^2x)/dx^2 + 2&lt;/p&gt;
&lt;p&gt;Now, we know that the second derivative is 2, so that means that 2(x)(d^2x)/dx^2 must equal zero. &amp;nbsp;But why?&lt;/p&gt;
&lt;p&gt;Well, let's rewrite this term a little:&lt;/p&gt;
&lt;p&gt;2x * (d^2x)/(dx^2)&lt;/p&gt;
&lt;p&gt;d^2x/dx^2 is simply the second derivative of x with respect to itself!&lt;/p&gt;
&lt;p&gt;To understand why this must be zero, first imagine the first derivative of x with respect to itself: dx/dx&lt;/p&gt;
&lt;p&gt;This must always be 1! &amp;nbsp;Another way of stating this is that &quot;for every change in x, the corresponding change in x is equivalent&quot;, which seems obvious.&lt;/p&gt;
&lt;p&gt;Now, 1 is a constant, so the second derivative must be zero! &amp;nbsp;This zeroes out the whole term, leaving:&lt;/p&gt;
&lt;p&gt;d^2y/dx^2 = 2&lt;/p&gt;
&lt;p&gt;Thus, we have the notation of the derivative from first principles.&lt;/p&gt;
&lt;p&gt;Another way to look at this is to use the quotient rule.&lt;/p&gt;
&lt;p&gt;If we start with dy/dx, then take the differential, what do we get?&lt;/p&gt;
&lt;p&gt;((dx)(d^2y) - (dy)(d^2x)) / dx^2&lt;/p&gt;
&lt;p&gt;If we separate, we get:&lt;/p&gt;
&lt;p&gt;(dx)(d^2y) / dx^2 - (dy)(d^2x)/dx^2&lt;/p&gt;
&lt;p&gt;The first term simplifies to d^2y / dx. &amp;nbsp;The second term is our second derivative of x with respect to itself again, so it becomes (dy)*0, giving us:&lt;/p&gt;
&lt;p&gt;d^2y/dx - (dy)*0&lt;/p&gt;
&lt;p&gt;Which gives us just&lt;/p&gt;
&lt;p&gt;d^2y/dx&lt;/p&gt;
&lt;p&gt;Now, the second step of the derivative is to divide by dx. &amp;nbsp;Doing so gives us:&lt;/p&gt;
&lt;p&gt;d^2y/dx^2&lt;/p&gt;
&lt;p&gt;Which is our second derivative!&lt;/p&gt;</description>
      <author></author>
      <pubDate>Sun, 13 Dec 2015 14:27:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/387</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/387</guid>
    </item>
    <item>
      <title>A General Solution for Line Integrals</title>
      <description>&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: I found that this is a standard formula, but it is referred to as an &quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Arc_length&quot;&gt;arc length&lt;/a&gt;&quot; formula, not a line integral. &amp;nbsp;I knew it had to be somewhere, I was just searching the wrong terms.&lt;/p&gt;
&lt;p&gt;I was playing around last night, and I came up with, what appears to be, a general solution for line integrals. &amp;nbsp;I have looked around and I have not found this equation anywhere, although I am certain in must be well-known &lt;em&gt;somewhere&lt;/em&gt;. &amp;nbsp;In any case, I will give it here, because it is definitely not well-known on the Internet.&lt;/p&gt;
&lt;p&gt;This is an equation for determining the line integral of y = f(x), where f(x) is a true function of x (i.e. it passes the vertical line test), and is differentiable on the portion of the line where you want to find the length of the line segment. &amp;nbsp;Most line integrals work by adding in an auxiliary parameter, t, to the equation. &amp;nbsp;This operates directly on the function itself.&lt;/p&gt;
&lt;p&gt;The short version:&lt;/p&gt;
&lt;p&gt;To get a line integral from x=a to x=b on y=f(x), we can use the following formula:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/site/bartpub/download/25?disposition=inline&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Evaluate this from x=a to x=b and you will have the length of the line. &amp;nbsp;Note, the software I was using gives this as a partial derivative on the inside. &amp;nbsp;I don't know enough to know if it is only limited to partials or not.&lt;/p&gt;
&lt;p&gt;So, if you know the derivate, you can figure out (in theory) the line integral. &amp;nbsp;Whether or not this actually helps you find a solution to the integral is another story.&lt;/p&gt;
&lt;p&gt;Now, how does one arrive at that?&lt;/p&gt;
&lt;p&gt;Well, first, remember, that an integral is an infinite sum of infinitesimals. &amp;nbsp;A curve is simply an infinite sum of tiny, infinitesimal lines. &amp;nbsp;So, all we need to do is find the length of each line segment and add it up.&lt;/p&gt;
&lt;p&gt;How big are our line segments?&lt;/p&gt;
&lt;p&gt;Well, if y=f(x), then the line segment is going to be the line between the points x, y and x + dx, y + dy. &amp;nbsp;The distance formula states that the line length is sqrt( (x1 - x0)^2 + (y1 - y0)^2). &amp;nbsp;The difference between x + dx and x is simply dx, and the difference between y + dy and y is simply dy. &amp;nbsp;So, each of our infinitesimal line segments (dL) will be:&lt;/p&gt;
&lt;p&gt;dL = sqrt(dx^2 + dy^2)&lt;/p&gt;
&lt;p&gt;If we square both sides, we get the following:&lt;/p&gt;
&lt;p&gt;dL^2 = dx^2 + dy^2&lt;/p&gt;
&lt;p&gt;dL^2 - dx^2 = dy^2&lt;/p&gt;
&lt;p&gt;Now we can divide both sides by dx^2 and get:&lt;/p&gt;
&lt;p&gt;dL^2/dx^2 - 1 = dy^2/dx^2&lt;/p&gt;
&lt;p&gt;dL^2/dx^2 = 1 + dy^2/dx^2&lt;/p&gt;
&lt;p&gt;dL^2/dx^2 = 1 + (dy/dx)^2&lt;/p&gt;
&lt;p&gt;Now we can square root both sides:&lt;/p&gt;
&lt;p&gt;dL/dx = sqrt(1 + (dy/dx)^2)&lt;/p&gt;
&lt;p&gt;dL = sqrt(1 + (dy/dx)^2) dx&lt;/p&gt;
&lt;p&gt;And this is the final form of our equation. &amp;nbsp;I tested it out with a few simple integrals (a line and the top half of a circle) and it seems to work as expected. &amp;nbsp;And, as I said, if you have a line that loops back around, you still need to use the parameterized methods. &amp;nbsp;But this is an easier way to setup line integrals where f(x) is a true function of x.&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Sat, 14 Nov 2015 17:27:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/385</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/385</guid>
    </item>
    <item>
      <title>ActiveMerchant, Authorize.Net Root Certificates, and Linux SSL</title>
      <description>&lt;p&gt;This week, Authorize.net is starting its rollout of new server certificates, signed by a new certificate authority - Entrust. &amp;nbsp;If you are using ActiveMerchant, this could break your stuff! &amp;nbsp;It may or may not affect newer versions of ActiveMerchant - I don't know, I only have sites using old versions (like 1.18). &amp;nbsp;So, even if it breaks, the solution may be different depending on your version of ActiveMerchant. &amp;nbsp;Still, I'll try to keep the info detailed enough that you can find the solution yourself.&lt;/p&gt;
&lt;p&gt;First, the problem. &amp;nbsp;This affects you if, when ActiveMerchant tries to connect to Authorize.net, you receive the error:&lt;/p&gt;
&lt;pre&gt;SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B:
  certificate verify failed&lt;/pre&gt;
&lt;p&gt;Note that you may not get this error when trying to connect to Authorize.net via manual Ruby code, but only via ActiveMerchant.&lt;/p&gt;
&lt;p&gt;The reason for this is ActiveMerchant maintains its own list of Root CAs!&lt;/p&gt;
&lt;p&gt;Therefore, to fix, you have to, (a) make sure that the new Root CAs for authorize.net are stored in your server's root CA list, and (b) make sure that ActiveMerchant is using your server's list rather than its own. &amp;nbsp;For good measure, you can also copy ActiveMerchant's CA list to yours.&lt;/p&gt;
&lt;p&gt;So, first, to add the Entrust root CAs to your Linux server (assuming it is a fairly recent CentOS-based distro), do the following as root:&lt;/p&gt;
&lt;p&gt;&lt;ol&gt;
&lt;li&gt;Enable the trust infrastructure with the following command:update-ca-trust enable&lt;/li&gt;
&lt;li&gt;Go to&amp;nbsp;/etc/pki/ca-trust/source/anchors&lt;/li&gt;
&lt;li&gt;Grab the .cer files from&amp;nbsp;https://www.entrust.net/downloads/root_request.cfm (just right-click on the links, copy the URLs, and download them to the current directory with wget)&lt;/li&gt;
&lt;li&gt;Go to wherever the gem files for your project are, and find the active_utils gem. &amp;nbsp;In the lib/certs directory, there is a file called cacert.ca or something like that. &amp;nbsp;Copy that to /etc/pki/ca-trust/source/anchors&lt;/li&gt;
&lt;li&gt;Now run the following command to update your CA list:&lt;br /&gt;update-ca-trust&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now you have all of the certs installed. &amp;nbsp;Now we need to tell ActiveMerchant to use your own certs rather than its internal list. &amp;nbsp;However, again, this is in the active_utils gem, not the activemerchant gem. &amp;nbsp;Within the gem, find the file called lib/active_utils/common/connection.rb. &amp;nbsp;Now look for a function called configure_ssl. &amp;nbsp;Copy that function to your clipboard.&lt;/p&gt;
&lt;p&gt;Now create a file in your own project called config/initializers/active_merchant_pem_fix.rb (the name doesn't matter as long as it is in config/initializers). &amp;nbsp;In this file you need to have:&lt;br /&gt;&lt;br /&gt;
&lt;pre&gt;module ActiveMerchant
  class Connection
    # Paste the configure_ssl function you copied from lib/active_utils/common/connection.rb here.
  end
end&lt;/pre&gt;
&lt;p&gt;Now, there will be a line that says something like this:&lt;/p&gt;
&lt;pre&gt;        http.ca_file = File.dirname(__FILE__) + '/../../certs/cacert.pem'
&lt;/pre&gt;
&lt;p&gt;This is the offending line!!! &amp;nbsp;Comment that sucker out!!!&lt;/p&gt;
&lt;p&gt;For my version of ActiveMerchant, this is what my file looks like:&lt;/p&gt;
&lt;pre&gt;   def configure_ssl(http)
      return unless endpoint.scheme == &quot;https&quot;

      http.use_ssl = true

      if verify_peer
        http.verify_mode = OpenSSL::SSL::VERIFY_PEER
        # http.ca_file = File.dirname(__FILE__) + '/../../certs/cacert.pem'
      else
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      end
    end&lt;/pre&gt;
&lt;p&gt;Now that you have the updated root CA on your server, and ActiveMerchant is using your server's list rather than your own, you are all set!&lt;/p&gt;
&lt;/p&gt;
&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Thu, 28 May 2015 21:27:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/384</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/384</guid>
    </item>
    <item>
      <title>Why You Shouldn't Put Validations on Your Model</title>
      <description>&lt;p&gt;This post is about model validators in Ruby on Rails, although it probably applies to validators in most similar MVC systems that allow declarative model validation.&lt;/p&gt;
&lt;p&gt;One of the biggest disasters, in my opinion, has been the trend for developers to put more and more validation in their models. &amp;nbsp;Putting validation in the model always *sounds* like a good idea. &amp;nbsp;&quot;We want our objects to look like X, therefore, we will stick our validations in the place where we define the object.&quot;&lt;/p&gt;
&lt;p&gt;However, this leads to many, many problems.&lt;/p&gt;
&lt;p&gt;There are two problems, and the most general way of stating them is this:&lt;/p&gt;
&lt;p&gt;&lt;ol&gt;
&lt;li&gt;life never works the way you expect it, but validating on the model assumes that it will. &amp;nbsp;&lt;/li&gt;
&lt;li&gt;while it is cleaner to validate on the model for a given configuration, when that validation needs to change, you don't always have enough information to understand the purpose of the validation in the first place (i.e., if a new developer is making the change)&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;
&lt;p&gt;Example of both -&lt;/p&gt;
&lt;p&gt;Let's say that we require all users to enter their first name, last name, birthdate, and email. &amp;nbsp;Okay, so we'll put validators on the model to make sure that this happens. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Let's say that six months go by, and your company signed an agreement with XYZ corporation to load in new users. &amp;nbsp;However, XYZ corp didn't require that their users enter in their birthdate. &amp;nbsp;However, you don't know that, and the bit of data you looked at, it looks like they are all there. &amp;nbsp;So, you do a load through the database, and everything loads in cleanly, and you think that everything is good. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;In fact, *Everyone* can view their records.&lt;/p&gt;
&lt;p&gt;However, the next week, people start getting errors when they try to update their profile. &amp;nbsp;Why? &amp;nbsp;Because the people who don't have a birthdate entered are getting validation errors when they try to update something else.&lt;/p&gt;
&lt;p&gt;So here is problem #1 - if an existing record doesn't match the validation, nothing can be saved, and this causes headaches because you are getting errors in places where they were unexpected. &amp;nbsp;This doesn't just happen with dataloads. &amp;nbsp;It happens every time you add a validator as well. &amp;nbsp;So, every time you change policy, even if it seems benign, you have the potential of messing up your entire program, even if all of your tests succeed (because your tests will never have had the bad data in them, since it doesn't have the old version of the code!).&lt;/p&gt;
&lt;p&gt;So, we go back and recode, and remove the validator from the model. &amp;nbsp;Great, but let's say this is a new programmer. &amp;nbsp;Now the programmer has to figure out where to put the validation in. &amp;nbsp;Presumably, we still want new users to enter in their birthdate, even if we allow non-birthdate users that we load from outside. &amp;nbsp;However, now, because we aren't validating on the model, we have to move it somewhere else. &amp;nbsp;But where? &amp;nbsp;Since the validator just floated out there declaratively, there is no direct link between the validator and *where* it was to be enforced. &amp;nbsp;Now the new programmer has to go through and recode and retest all of the situations to figure out the proper place(s) for the validator. &amp;nbsp;This is especially problematic if you have more than one path for entrance on your system. &amp;nbsp;It's not so bad if it is a system you wrote yourself, but when having to maintain someone else's code, this is a problem.&lt;/p&gt;
&lt;p&gt;Therefore, the policy I follow is this - only use model validation when a failure of the validator would lead to a loss of data *integrity*, not just cleanliness. &amp;nbsp;The phone number field should be validated somewhere else. &amp;nbsp;You should validate a uniqueness constraint only if uniqueness is actually required for the successful running of the code. &amp;nbsp;Otherwise, validate in the controller. &amp;nbsp;Now, you can make this easier by putting the code to validate in the model, but just don't hook it in to the global validation sequence. &amp;nbsp;So, go ahead and define a method called &quot;is_proper_record?&quot; or something, but don't hook it up to the validation system - call it directly from your controller when you need it.&lt;/p&gt;
&lt;p&gt;NOTE - if I don't get around to blogging about it, there are similar problems with State Machine, and a lot of other declarative-enforcement procedures in the model. &amp;nbsp;Basically, they are elegant ways of coding, but *terrible* when you need to modify them, especially if the person modifying the code wasn't the one who built it. &amp;nbsp;Untangling the interaction between declarative and manual processes leads to both delays (as the new developer tries to figure out the code) and bugs (when the new developer doesn't figure out the code perfectly the first time). &amp;nbsp;When your processes are coded *as processes* and not declarations, it is more visible to future programmers, and therefore more maintainable.&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Wed, 11 Jun 2014 21:19:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/382</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/382</guid>
    </item>
    <item>
      <title>New Library for Reading Pickle Files from Ruby</title>
      <description>&lt;p&gt;This is announcing the release of &quot;pickle-interpreter&quot;, a new ruby gem for reading Python pickle files in ruby and rails projects. &amp;nbsp;The project is available at&amp;nbsp;&lt;a href=&quot;https://github.com/newmedio/pickle-interpreter&quot; target=&quot;_blank&quot;&gt;https://github.com/newmedio/pickle-interpreter&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It is called &quot;pickle-interpreter&quot; because Pickle is actually a mini-stack-based programming language, so this is an interpreter for the Pickle language.&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Wed, 11 Jun 2014 04:18:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/381</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/381</guid>
    </item>
    <item>
      <title>New Book Integrating Engineering, Philosophy, and Theology</title>
      <description>&lt;p&gt;I thought some of you, my faithful blog readers, might be interested to know about a project I just completed with some other people - a new book about integrating engineering, philosophy, and theology.&amp;nbsp; It is titled &lt;a href=&quot;http://www.blythinstitute.org/site/sections/45&quot; target=&quot;_blank&quot;&gt;Engineering and the Ultimate: An Interdisciplinary Investigation of Order and Design in Nature and Craft&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.blythinstitute.org/site/sections/45&quot;&gt;&lt;img src=&quot;http://www.blythinstitute.org/images/data/attachments/0000/0043/frontcover.jpg&quot; alt=&quot;Engineering and the Ultimate book cover&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Mon, 03 Mar 2014 05:07:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/380</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/380</guid>
    </item>
    <item>
      <title>Creating a WSDL file for a RESTful Web Service</title>
      <description>&lt;p&gt;NOTE - this is about XML-based REST services.&amp;nbsp; There *might* be a way to write WSDL for JSON, but I don't know it yet.&lt;/p&gt;
&lt;p&gt;Most of my work is done in RESTful environments.&amp;nbsp; However, the Microsoft world seems to favor SOAP.&amp;nbsp; REST is simple.&amp;nbsp; It is so simple, that you don't even really need special APIs for the different services.&amp;nbsp; You just need the URL and the documentation.&amp;nbsp; However, SOAP is complex, and requires complex tooling. SOAP services are described using the WSDL format.&amp;nbsp; Usually what happens is that a program reads the WSDL file and spits out stubs that you can code against directly.&lt;/p&gt;
&lt;p&gt;In any case, the people that come from a SOAP environment don't realize that you can do cool stuff without tooling, and the idea that I could just give them a URL to hit and they could just hit it directly boggles their mind.&amp;nbsp; So, if I have a handy-dandy REST service, they still want to ask me for the WSDL file.&amp;nbsp; There's really no reason, but that's what they want.&amp;nbsp; So, thankfully, WSDL 2 allows for us to create WSDL descriptions of RESTful services.&lt;/p&gt;
&lt;p&gt;So, before I describe how WSDL works, let me first say that, if you are used to the simplicity of REST coding, WSDL will blow your mind.&amp;nbsp; WSDL is built around the complexities of SOAP.&amp;nbsp; There are a lot of things where you will say, &quot;why did they put in that extra layer?&quot;&amp;nbsp; The answer is, &quot;because the SOAP protocol was built by crack addicts.&quot;&lt;/p&gt;
&lt;p&gt;WSDL is grouped into 4 parts - services, bindings, interfaces, and types.&lt;/p&gt;
&lt;p&gt;An &lt;strong&gt;interface&lt;/strong&gt; is a list of operations you might want to perform.&amp;nbsp; This is, essentially, the API itself.&amp;nbsp; Our API will be for retrieving form submissions to our website.&amp;nbsp; The interface is a list of &lt;strong&gt;operation&lt;/strong&gt;s, where each operation is an individual API call.&amp;nbsp; In our example, we will have a &quot;list&quot; and a &quot;get&quot; operation in our inteface.&amp;nbsp; The interface relies on &lt;strong&gt;type&lt;/strong&gt;s in order to define the input and output of the operations.&lt;/p&gt;
&lt;p&gt;A &lt;strong&gt;binding&lt;/strong&gt; tells you &lt;em&gt;how&lt;/em&gt; to make an API call for an operation.&amp;nbsp; This is significantly simpler in REST than in SOAP, as you really only need the URL path and the method (this is the &lt;em&gt;relative&lt;/em&gt; URL - the absolute path will be defined in the service).&amp;nbsp; The binding will have a operation tag for each operation it binds.&lt;/p&gt;
&lt;p&gt;A &lt;strong&gt;service&lt;/strong&gt; defines where on the web you can go to in order to find the interfaces.&amp;nbsp; It defines a set of &lt;strong&gt;endpoint&lt;/strong&gt;s, each of which tells the top-level URL of the resources, like http://www.example.com/api, and what interfaces they support and which bindings to use on them (telling both the interface and the binding seems redundant to me, but then again so does writing a WSDL file to begin with).&lt;/p&gt;
&lt;p&gt;So, below, is a simple REST web service.&amp;nbsp; I've excluded the &quot;types&quot; section, which I will discuss later.&lt;/p&gt;
&lt;pre&gt;&amp;lt;?xml version=&quot;1.0&quot; ?&amp;gt;&lt;br /&gt;&amp;lt;wsdl2:description&lt;br /&gt;	xmlns:wsdl2=&quot;http://www.w3.org/ns/wsdl&quot;&lt;br /&gt;	xmlns:wsaw=&quot;http://www.w3.org/2006/05/addressing/wsdl&quot;&lt;br /&gt;	xmlns:whttp=&quot;http://www.w3.org/ns/wsdl/http&quot;&lt;br /&gt;	xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;&lt;br /&gt;	xmlns:myexample=&quot;http://www.example.com/api&quot;&lt;br /&gt;	targetNamespace=&quot;http://www.example.com/api&quot;&lt;br /&gt;	&amp;lt;wsdl2:types&amp;gt;&lt;br /&gt;	  &amp;lt;xs:schema&lt;br /&gt;			attributeFormDefault=&quot;unqualified&quot;&lt;br /&gt;			elementFormDefault=&quot;unqualified&quot;&amp;gt;&lt;br /&gt;             &amp;lt;!-- omitted --&amp;gt;&lt;br /&gt;          &amp;lt;/xs:schema&amp;gt;&lt;br /&gt;	&amp;lt;/wsdl2:types&amp;gt;&lt;br /&gt;&lt;br /&gt;	&amp;lt;wsdl2:interface name=&quot;FormSubmissionsInterface&quot;&amp;gt;&lt;br /&gt;		&amp;lt;wsdl2:operation&lt;br /&gt;			name=&quot;listFormSubmissionsOperation&quot;&lt;br /&gt;			pattern=&quot;http://www.w3.org/ns/wsdl/in-out&quot;&lt;br /&gt;			whttp:method=&quot;GET&quot;&amp;gt;&lt;br /&gt;			&amp;lt;wsdl2:input element=&quot;formSubmissionSearchParameters&quot; /&amp;gt;&lt;br /&gt;			&amp;lt;wsdl2:output element=&quot;response&quot; /&amp;gt;&lt;br /&gt;		&amp;lt;/wsdl2:operation&amp;gt;&lt;br /&gt;		&amp;lt;wsdl2:operation&lt;br /&gt;			name=&quot;getFormSubmissionOperation&quot;&lt;br /&gt;			pattern=&quot;http://www.w3.org/ns/wsdl/in-out&quot;&lt;br /&gt;			whttp:method=&quot;GET&quot;&amp;gt;&lt;br /&gt;			&amp;lt;wsdl2:input element=&quot;formSubmissionIdentifier&quot; /&amp;gt;&lt;br /&gt;			&amp;lt;wsdl2:output element=&quot;response&quot; /&amp;gt;&lt;br /&gt;		&amp;lt;/wsdl2:operation&amp;gt;&lt;br /&gt;	&amp;lt;/wsdl2:interface&amp;gt;&lt;br /&gt;&lt;br /&gt;	&amp;lt;wsdl2:binding name=&quot;FormSubmissionBinding&quot;&lt;br /&gt;		interface=&quot;myexample:FormSubmissionBinding&quot;&lt;br /&gt;		type=&quot;http://www.w3.org/ns/wsdl/http&quot;&amp;gt;&lt;br /&gt;		&amp;lt;wsdl2:operation&lt;br /&gt;			ref=&quot;myexample:getFormSubmissionOperation&quot;&lt;br /&gt;			whttp:method=&quot;GET&quot;&lt;br /&gt;			whttp:location=&quot;form_submissions/{id}.xml&quot; &lt;br /&gt;		/&amp;gt;&lt;br /&gt;		&amp;lt;wsdl2:operation&lt;br /&gt;			ref=&quot;myexample:listFormSubmissionsOperation&quot;&lt;br /&gt;			whttp:method=&quot;GET&quot;&lt;br /&gt;			whttp:location=&quot;form_submissions.xml&quot;&lt;br /&gt;		/&amp;gt;&lt;br /&gt;	&amp;lt;/wsdl2:binding&amp;gt;&lt;br /&gt;&lt;br /&gt;	&amp;lt;wsdl2:service&lt;br /&gt;		name=&quot;FormSubmissionsServiceSSL&quot;&lt;br /&gt;		interface=&quot;myexample:FormSubmissionsInterface&quot;&amp;gt;&lt;br /&gt;		&amp;lt;wsdl2:endpoint&lt;br /&gt;			name=&quot;FormSubmissionEndpoint&quot;&lt;br /&gt;			binding=&quot;myexample:FormSubmissionBinding&quot;&lt;br /&gt;			address=&quot;https://www.example.com/api&quot;&lt;br /&gt;		/&amp;gt;&lt;br /&gt;	&amp;lt;/wsdl2:service&amp;gt;&lt;br /&gt;	&amp;lt;wsdl2:service&lt;br /&gt;		name=&quot;FormSubmissionsService&quot;&lt;br /&gt;		interface=&quot;myexample:FormSubmissionsInterface&quot;&amp;gt;&lt;br /&gt;		&amp;lt;wsdl2:endpoint&lt;br /&gt;			name=&quot;FormSubmissionEndpoint&quot;&lt;br /&gt;			binding=&quot;myexample:FormSubmissionBinding&quot;&lt;br /&gt;			address=&quot;http://www.example.com/api&quot;&lt;br /&gt;		/&amp;gt;&lt;br /&gt;	&amp;lt;/wsdl2:service&amp;gt;&lt;br /&gt;&amp;lt;/wsdl2:description&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;So, starting at the bottom, we have 2 services defined - an HTTP service and an HTTPS service.&amp;nbsp; They both use the same binding and interface.&amp;nbsp; So, they are called exactly the same way, buy have a different base URL.&amp;nbsp; Depending on your client, the service name often corresponds to the main class name used to access the service.&lt;/p&gt;
&lt;p&gt;The services implement the myexample:FormSubmissionsInterface.&amp;nbsp; This interface defines two operations: listFormSubmissionsOperation and getFormSubmissionsOperation.&amp;nbsp; Each one defines its input and output parameters.&amp;nbsp; Now, the output parameter is just a regular XML element from your schema (defined in the &quot;types&quot; section).&amp;nbsp; The input parameter is special.&amp;nbsp; It, too, is defined in your types section, but, when bound to an HTTP endpoint, rather than being treated as an XML document, it will be treated as a combination of URL pieces and query string parameters.&amp;nbsp; Here is mine:&lt;/p&gt;
&lt;pre&gt;                       &amp;lt;xs:element name=&quot;formSubmissionSearchParameters&quot;&amp;gt;&lt;br /&gt;				&amp;lt;xs:complexType&amp;gt;&lt;br /&gt;					&amp;lt;xs:all&amp;gt;&lt;br /&gt;						&amp;lt;xs:element name=&quot;since&quot; type=&quot;xs:dateTime&quot; minOccurs=&quot;0&quot; /&amp;gt;&lt;br /&gt;						&amp;lt;xs:element name=&quot;since_id&quot; type=&quot;xs:integer&quot; minOccurs=&quot;0&quot; /&amp;gt;&lt;br /&gt;						&amp;lt;xs:element name=&quot;until&quot; type=&quot;xs:dateTime&quot; minOccurs=&quot;0&quot; /&amp;gt;&lt;br /&gt;						&amp;lt;xs:element name=&quot;until_id&quot; type=&quot;xs:integer&quot; minOccurs=&quot;0&quot; /&amp;gt;&lt;br /&gt;					&amp;lt;/xs:all&amp;gt;&lt;br /&gt;				&amp;lt;/xs:complexType&amp;gt;&lt;br /&gt;			&amp;lt;/xs:element&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;Each of the elements under xs:all actually become query-string parameters.&amp;nbsp; WSDL treats it like an XML document, because of its SOAP roots.&amp;nbsp; But, when we specify an HTTP binding, then this gets transmogrified from an XML document into query-string parameters.&amp;nbsp; I have a separate type for the &quot;get&quot; operation, which defines the ID number of the form submission I want:&lt;/p&gt;
&lt;pre&gt;			&amp;lt;xs:element name=&quot;formSubmissionIdentifier&quot;&amp;gt;&lt;br /&gt;				&amp;lt;xs:complexType&amp;gt;&lt;br /&gt;					&amp;lt;xs:sequence&amp;gt;&lt;br /&gt;						&amp;lt;xs:element name=&quot;id&quot; type=&quot;xs:integer&quot; /&amp;gt;&lt;br /&gt;					&amp;lt;/xs:sequence&amp;gt;&lt;br /&gt;				&amp;lt;/xs:complexType&amp;gt;&lt;br /&gt;			&amp;lt;/xs:element&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;As we will see, in the bindings section, we can move a named parameter into the URL itself, rather than just being sent as a query string.&lt;/p&gt;
&lt;p&gt;The output is simply an XML document, whose structure is defined in the types section.&amp;nbsp; I would need to teach you XSD documents to tell you how this works, but you can google it yourself.&amp;nbsp; The one thing I will say is that because my result document does not use namespaces at all, in the xs:schema declaration I set elementFormDefault to &quot;unqualified&quot;.&lt;/p&gt;
&lt;p&gt;The binding is where we tell WSDL that we are using REST rather than SOAP.&amp;nbsp; We tell it what interface we are binding, and the fact that we are using an HTTP binding.&amp;nbsp; Then, for each operation, we define the HTTP method and relative path for the binding.&amp;nbsp; We can substitute in our parameters into the URL path by saying {name-of-xml-input-element} in the location.&amp;nbsp; Any parameters given which are not inserted into the URL path will be put in the query string.&amp;nbsp; So, for instance&lt;/p&gt;
&lt;pre&gt;whttp:location=&quot;form_submissions/{id}.xml&quot;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;Says to take the &quot;id&quot; element and substitute it in the URL.&amp;nbsp; The other location,&lt;/p&gt;
&lt;pre&gt;whttp:location=&quot;form_submissions.xml&quot;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;just puts all of the parameters in the query string.&lt;/p&gt;
&lt;p&gt;So that's it!&amp;nbsp; That's a WSDL file for a REST service!&lt;/p&gt;
&lt;p&gt;I tested my service and WSDL using AXIS 2's WSDL2JAVA command:&lt;/p&gt;
&lt;pre&gt;wsdl2java.sh -uri path/to/wsdl -wv 2&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;Then I created a simple TestMe.java to make sure it ran right.&amp;nbsp; The example also shows how to use HTTP Basic Authentication with the service:&lt;/p&gt;
&lt;pre&gt;import java.rmi.RemoteException;&lt;br /&gt;import java.util.ArrayList;&lt;br /&gt;import java.util.Collection;&lt;br /&gt;import java.util.Iterator;&lt;br /&gt;import java.math.*;&lt;br /&gt;&lt;br /&gt;import org.apache.axis2.databinding.ADBBean;&lt;br /&gt;import org.apache.axis2.Constants;&lt;br /&gt;import org.apache.xmlbeans.XmlOptions;&lt;br /&gt;import org.apache.xmlbeans.XmlValidationError;&lt;br /&gt;import org.apache.axis2.client.*;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import com.example.www.FormSubmissionsServiceStub;&lt;br /&gt;import com.example.www.FormSubmissionsServiceStub.*;&lt;br /&gt;&lt;br /&gt;import org.apache.axis2.transport.http.*;&lt;br /&gt;&lt;br /&gt;public class TestMe {&lt;br /&gt;        public static void main(String[] args) throws RemoteException {&lt;br /&gt;                /* Setup Service */&lt;br /&gt;                FormSubmissionsServiceStub stub = new FormSubmissionsServiceStub();&lt;br /&gt;&lt;br /&gt;                /* If you need authentication */&lt;br /&gt;                HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator();&lt;br /&gt;                basicAuth.setUsername(&quot;USERNAMEHERE&quot;);&lt;br /&gt;                basicAuth.setPassword(&quot;PASSHERE&quot;);&lt;br /&gt;                basicAuth.setPreemptiveAuthentication(true);&lt;br /&gt;                final Options clientOptions = stub._getServiceClient().getOptions();&lt;br /&gt;                clientOptions.setProperty(HTTPConstants.AUTHENTICATE, basicAuth);&lt;br /&gt;&lt;br /&gt;                /* Setup Single Get */&lt;br /&gt;                BigInteger subm_id = BigInteger.valueOf(500);&lt;br /&gt;                FormSubmissionIdentifier myid = new FormSubmissionIdentifier();&lt;br /&gt;                myid.setId(subm_id);&lt;br /&gt;                System.out.println(TestMe.debugAxisObject(myid));&lt;br /&gt;&lt;br /&gt;                /* Run Single Get */&lt;br /&gt;                Response r = stub.getFormSubmissionOperation(myid);&lt;br /&gt;&lt;br /&gt;                /* Setup Multi Get */&lt;br /&gt;                FormSubmissionSearchParameters p = new FormSubmissionSearchParameters();&lt;br /&gt;                p.setSince_id(BigInteger.valueOf(3200));&lt;br /&gt;                System.out.println(TestMe.debugAxisObject(p));&lt;br /&gt;&lt;br /&gt;                /* Run Multi Get */&lt;br /&gt;                Response r2 = stub.listFormSubmissionsOperation(p);&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;Note that &quot;Response&quot; is not a generic Java class, it is actually com.example.www.FormSubmissionsServiceStub.Response, because the name of the output element is &quot;response&quot;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Other Resources:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://blog.sweetxml.org/2009/03/my-first-wsdl-20-generating-axis2.html&quot; target=&quot;_blank&quot;&gt;Building a WSDL File for REST and Axis2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.ibm.com/developerworks/library/ws-restwsdl/&quot; target=&quot;_blank&quot;&gt;IBM DeveloperWorks Article on WSDL REST interfaces&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://axis.apache.org/axis2/java/core/docs/userguide-creatingclients.html#choosingclient&quot;&gt;Apache Axis2 User Guide&lt;/a&gt;&amp;nbsp; &lt;/li&gt;
&lt;/ul&gt;</description>
      <author>JB</author>
      <pubDate>Wed, 12 Feb 2014 22:45:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/379</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/379</guid>
    </item>
    <item>
      <title>Getting my Inspiron 8000 to run Ubuntu 13.10</title>
      <description>&lt;p&gt;This is for my own benefit if I need to reinstall again.&lt;/p&gt;
&lt;p&gt;Links to helpful articles:&lt;/p&gt;
&lt;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://ubuntuforums.org/showthread.php?t=1531644&quot; target=&quot;_blank&quot;&gt;Ubuntuforums post&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://wiki.ubuntu.com/HardwareSupportMachinesLaptopsDell&quot; target=&quot;_blank&quot;&gt;Ubuntu Hardware Support&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;What I remember doing:&lt;/div&gt;
&lt;div&gt;&lt;ol&gt;
&lt;li&gt;I installed using a text-mode install from the network installer&lt;/li&gt;
&lt;li&gt;I booted into recovery mode root prompt (don't forget to remount / readwrite!)&lt;/li&gt;
&lt;li&gt;I modified /etc/default/grub to add &quot;nolapic nomodeset&quot; to the default parameter&lt;/li&gt;
&lt;li&gt;I made s imple xorg.conf file to say that Card0 should use vesa&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;Then everything seemed to work. &amp;nbsp;It shows it in a small box, though, and that is better than nothing.&lt;/div&gt;
&lt;/div&gt;
&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Wed, 30 Oct 2013 19:17:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/376</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/376</guid>
    </item>
    <item>
      <title>Uniqueness Methods for PostgreSQL</title>
      <description>&lt;p&gt;Just finished packaging together &lt;a href=&quot;https://github.com/johnnyb/uniqueness-pg&quot; target=&quot;_blank&quot;&gt;a set of uniqueness functions for PostgreSQL&lt;/a&gt;, mostly focused on Cantor pairing.&amp;nbsp; Here is the introduction &lt;a href=&quot;https://github.com/johnnyb/uniqueness-pg&quot; target=&quot;_blank&quot;&gt;from the documentation&lt;/a&gt;:&lt;/p&gt;
&lt;h3&gt;uniqueness-pg&lt;/h3&gt;
&lt;p&gt;A collection of functions such as cantor pairing which help make unique identifiers for PostgreSQL.&lt;/p&gt;
&lt;p&gt;What is a Cantor Pair?  Let's say that you have a table which is  uniquely identified by two numeric foreign keys.  However, let's say  that you need a single, unique key to refer to the row externally.   Probably a better approach is to create a new primary key, but, if you  can't, you can use a Cantor Pairing function to create a single number  from the two.&lt;/p&gt;
&lt;pre&gt;select cantorPair(23, 50);&lt;/pre&gt;
&lt;pre&gt;-- yields 2751
&lt;/pre&gt;
&lt;pre&gt;select cantorUnpair(2751);
&lt;/pre&gt;
&lt;pre&gt;-- yields {23,50};&lt;/pre&gt;
&lt;p&gt;Remember, in Postgres, you can even create indexes on these functions.&lt;/p&gt;
&lt;p&gt;create table cantortest(a int, b int, c text, primary key(a, b));   create index on cantortest(cantorPair(a, b));   insert into cantortest values (1, 5, 'hello');   insert into cantortest values (3, 18, 'there');&lt;/p&gt;
&lt;pre&gt;select cantorPair(3, 18); -- =&amp;gt;  (yields 249)&lt;/pre&gt;
&lt;p&gt;select * from cantortest where cantorPair(a, b) = 249; -- uses index on large enough tables, or if enable_seqscan set to no.&lt;/p&gt;
&lt;pre&gt;select * from cantortest where cantorUnpair(249)[1] = 3; -- parses 
number out into a foreign key that can be looked up on its own&lt;/pre&gt;
&lt;p&gt;You can use more than two values with an array and the cantorTuple function:&lt;/p&gt;
&lt;pre&gt;select cantorTuple(ARRAY[5, 16, 9, 25]);
&lt;/pre&gt;
&lt;pre&gt;-- yields 20643596022
&lt;/pre&gt;
&lt;pre&gt;select cantorUntuple(20643596022, 4); -- NOTE - the 4 tells how many components
&lt;/pre&gt;
&lt;pre&gt;-- yields {5,16,9,25}&lt;/pre&gt;
&lt;p&gt;Additional functions include:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;cantorPairBI&lt;/strong&gt; - the regular cantorPair uses DECIMALs, which can be  slow.  If you know the final value will fit in a BIGINT, this version  should be a little bit faster.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;cantorUnpairBI&lt;/strong&gt; - same as above but for unpairing&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;uniquenessSpace(key, spaces, space_index)&lt;/strong&gt; - this is useful for when  you need to UNION tables which each have their own PKs, but you want all  of the rows to also have their own PKs.  It is a super-simple function  (key * spaces + space_index), but it is helpful because people can  better see what/why you are doing things.  So, for instance, if we had  an employees tables and a customers table, but wanted a people view that  had a unique PK, we can do:&lt;/p&gt;
&lt;pre&gt;CREATE VIEW people AS 
     SELECT uniquenessSpace(employee_id, 2, 0), employee_name from employees
     UNION ALL
     SELECT uniquenessSpace(customer_id, 2, 1), customer_name from customers;&lt;/pre&gt;
&lt;p&gt;To retrieve the original ID, use &lt;strong&gt;uniquenessUnspace&lt;/strong&gt;:&lt;/p&gt;
&lt;pre&gt;select * from employees where employee_id = uniquenessUnspace(person_id, 2, 0); -- use same arguments as used on uniquenessSpace&lt;/pre&gt;
&lt;p&gt;These are both horrid names, and I am open to renaming them.&lt;/p&gt;
&lt;p&gt;I am currently working on another uniquenessSpace, which doesn't  require the number of tables to be known, only the index.  However, this  function is problematic because it relies on exponentials.  The current  version doesn't work because I need a prime filter.  However, the goal  is to overcome the problem in the previous example that if the number of  tables change (i.e. we add on an additional supplier table or  something), then all of the generated keys have to change (because there  are more tables, which affects the second parameter).  In an ideal  setting, you will be able to do:&lt;/p&gt;
&lt;pre&gt;CREATE VIEW people AS 
     SELECT uniquenessSpace(employee_id, 0), employee_name from employees
     UNION ALL
     SELECT uniquenessSpace(customer_id, 1), customer_name from customers;&lt;/pre&gt;
&lt;p&gt;And then add on additional tables as necessary, without ever having  to worry about changing keys.  This can work by generating a key which  is p0^employee_id, and p1^customer_id, where p0 is the first prime (2)  and p1 is the second prime (3).  As you can see, this gets out of hand  pretty quickly, but PostgreSQL is surprisingly accomodative to this.   Anyway, this is probably a generally bad idea, but I thought it should  be included for completeness.  I should probably rename this function as  well.&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Wed, 31 Jul 2013 05:13:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/374</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/374</guid>
    </item>
    <item>
      <title>Knowing When to Start Over</title>
      <description>&lt;p&gt;A friend of mine shared this following quip on FB:&lt;/p&gt;
&lt;p style=&quot;padding-left: 30px;&quot;&gt;Quinn's design tip o' the day: You can't iterate your way out of local maxima. In other words, no amount of horse breeding will produce a Model T.&lt;/p&gt;
&lt;p style=&quot;padding-left: 30px;&quot;&gt;&lt;br style=&quot;color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 12.800000190734863px; line-height: 13.600000381469727px;&quot; /&gt;Sooner or later, you just have to throw it all away and start over.&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Thu, 27 Jun 2013 15:03:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/372</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/372</guid>
    </item>
    <item>
      <title>Adding a &quot;Copy&quot; context menu to a disabled UITextfield in iOS</title>
      <description>&lt;p&gt;I have a project which has a lot of fields which, at any moment, may be enabled or disabled. &amp;nbsp;However, even when they are disabled, I want to show a context menu. &amp;nbsp;It turns out that no one has a solution, so I hacked one together for myself. &amp;nbsp;This code is adapted from a working project, but I have not tested the version presented here, but let me know if you have problems. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;The general problem you run into is this: if your UITextField is disabled, then it cannot receive touch events. &amp;nbsp;Therefore, it cannot fire the menu, even if you try to do so explicitly using Gesture recognizers. &amp;nbsp;The normal answer is to simply not allow any editing on the field. &amp;nbsp;However, while this prevents you from editing the field, it still *draws* the textfield as active. &amp;nbsp;We want it to *look* inactive as well, which you only get by disabling it.&lt;/p&gt;
&lt;p&gt;So, what I did was to create a subclass of UITextField (JBTextField) which has a subview (a specialized subclass of UIView - JBTextFieldResponderView) that has a gesture recognizer attached. &amp;nbsp;We override hitTest on JBTextField to do this: if JBTextField is disabled, then we delegate hitTest to our JBTextFieldResponderView subclass.&lt;/p&gt;
&lt;p&gt;As I said, this is from another project, which had a whole bunch of other stuff mixed in. &amp;nbsp;I have tried to separate out the code for you here, but I don't guarantee that it will work out-of-the-box.&lt;/p&gt;
&lt;pre&gt;@interface JBTextFieldResponderView : UIView
@property (strong, nonatomic) UIGestureRecognizer *contextGestureRecognizer;
@end

@interface JBTextField : UITextField
@property (strong, nonatomic) JBTextFieldResponderView *contextGestureRecognizerViewForDisabled;
@end&lt;/pre&gt;
&lt;pre&gt;@implementation JBTextFieldResponderView
@synthesize contextGestureRecognizer = _contextGestureRecognizer;

-(id) initWithFrame:(CGRect)frame {
  self = [super initWithFrame:frame];

  // Add the gesture recognizer
  self.contextGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressGestureDidFire:)];
  [self addGestureRecognizer:self.contextGestureRecognizer];

  return self;
}

// First-level of response, filters out some noise
-(IBAction) longPressGestureDidFire:(id)sender {
  UILongPressGestureRecognizer *recognizer = sender;
  if(recognizer.state == UIGestureRecognizerStateBegan) { // Only fire once
    [self initiateContextMenu:sender];
  }
}

// Second level of response - actually trigger the menu
-(IBAction) initiateContextMenu:(id)sender {
  [self becomeFirstResponder]; // So the menu will be active.  We can't set the Text field to be first responder -- doesn't work if it is disabled
  UIMenuController *menu = [UIMenuController sharedMenuController];
  [menu setTarget:self.bounds inView:self];
  [menu setMenuVisible:YES animated:YES];
}

// The menu will automatically add a &quot;Copy&quot; command if it sees a &quot;copy:&quot; method.  
// See UIResponderStandardEditActions to see what other commands we can add through methods.
-(IBAction) copy:(id)sender {
  UIPasteboard *pb = [UIPasteboard generalPasteboard];
  UITextField *tf = (UITextField *)self.superview;
  [pb setString: tf.text];
}

// Normally a UIView doesn't want to become a first responder.  This forces the issue.
-(BOOL) canBecomeFirstResponder {
  return YES;
}

@end

@implementation JBTextField
@synthesize contextGestureRecognizerViewForDisabled = _contextGestureRecognizerViewForDisabled;

/* Add the recognizer view no matter which path this is initialized through */

-(id) initWithCoder:(NSCoder *)aDecoder {
  self = [super initWithCoder:aDecoder];
  [self addDisabledRecognizer];
  return self;
}

-(id) initWithFrame:(CGRect)frame {
  self = [super initWithFrame:frame];
  [self addDisabledRecognizer];
  return self;
}

// This creates the view and adds it at the end of the view chain so it doesn't interfere, but is still present */
-(void) addDisabledRecognizer {
  self.contextGestureViewForDisabled = [[JBTextFieldResponderView alloc] initWithFrame:self.bounds];
  self.contextGestureViewForDisabled.userInteractionEnabled = NO;
  [self addSubview:self.contextGestureViewForDisabled];
}

-(void) setEnabled:(BOOL) enabled {
  [super setEnabled:enabled];
  self.contextGestureViewForDisabled.userInteractionEnabled = !enabled;
}

// This is where the magic happens
-(UIView *) hitTest:(CGPoint)point withEvent:(UIEvent *)event {
  if(self.enabled) {
    // If we are enabled, respond normally
    return [super hitTest:point withEvent:event];
  } else {
    // If we are disabled, let our specialized view determine how to respond
    UIView *v = [self.contextGestureViewForDisabled hitTest:point withEvent:event];
  }
}

@end&lt;/pre&gt;
&lt;p&gt;Now, in interface builder, we can enabled copy on disabled fields just by setting the class to JBTextField, or, if built programmatically, by replacing [UITextField alloc] with [JBTextField alloc].&lt;/p&gt;
&lt;p&gt;I hope this helps!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Additional Resources&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://developer.apple.com/library/ios/#documentation/uikit/reference/UIControl_Class/Reference/Reference.html&quot; target=&quot;_blank&quot;&gt;UIControl Class Reference&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/event_delivery_responder_chain/event_delivery_responder_chain.html#//apple_ref/doc/uid/TP40009541-CH4-SW2&quot; target=&quot;_blank&quot;&gt;Event Handling Guide for iOS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/AddingCustomEditMenuItems/AddingCustomEditMenuItems.html#//apple_ref/doc/uid/TP40009542-CH13&quot; target=&quot;_blank&quot;&gt;Displaying and Managing the Edit Menu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIResponderStandardEditActions_Protocol/UIResponderStandardEditActions.html#//apple_ref/occ/cat/UIResponderStandardEditActions&quot; target=&quot;_blank&quot;&gt;UIResponderStandardEditActions Protocol Reference&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://stackoverflow.com/questions/4961386/event-handling-for-ios-how-hittestwithevent-and-pointinsidewithevent-are-r&quot; target=&quot;_blank&quot;&gt;hitTest vs pointInside&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://blogs.captechconsulting.com/blog/john-szumski/getting-started-uimenucontroller-ios-5&quot; target=&quot;_blank&quot;&gt;Custom Menu Items&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://developer.apple.com/library/ios/#documentation/iPhone/Reference/UIMenuController_Class/UIMenuController.html#//apple_ref/occ/instm/UIMenuController/setMenuVisible:animated:&quot; target=&quot;_blank&quot;&gt;UIMenuController Class Reference&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://developer.apple.com/library/ios/#documentation/uikit/reference/UIResponder_Class/Reference/Reference.html&quot; target=&quot;_blank&quot;&gt;UIResponder Class Reference&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Here is &lt;a href=&quot;http://stackoverflow.com/questions/6250538/non-editable-uitextfield-with-copy-menu&quot; target=&quot;_blank&quot;&gt;a simpler solution using shouldChangeCharactersInRange&lt;/a&gt;, but this does not give the field a disabled &quot;look&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Wed, 29 May 2013 16:28:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/371</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/371</guid>
    </item>
    <item>
      <title>My Beef with Model Validators in Rails</title>
      <description>&lt;p&gt;When I first started using Rails, it was a dream come true. &amp;nbsp;I estimate that I reduced the amount of code I was writing by 60-75%. &amp;nbsp;This is probably still true. &amp;nbsp;However, as I've gotten to know the platform better, there are some philosophical issues that I have with Rails. &amp;nbsp;Sometimes it is more the Rails community and its conventions rather than rails itself, but nonetheless, it continually manifests itself.&lt;/p&gt;
&lt;p&gt;My current beef - validators! &amp;nbsp;Having written lots and lots of code that interacts with lots and lots of systems, I have to say that you should never, ever, ever put in model validators. &amp;nbsp;Ever. &amp;nbsp;Validation is a process issue, not a data one. &amp;nbsp;In theory it should be a data issue, but it never ever works out that way.&lt;/p&gt;
&lt;p&gt;Here's what happens. &amp;nbsp;Let's say I have a telephone number validator for a model. &amp;nbsp;It makes sure the numbers are in the format (918) 245-2234. &amp;nbsp;If not, it gives a nice error message. &amp;nbsp;However, now let's connect that same model to an external system. &amp;nbsp;Let's now say that the author of the external system was not as picky about phone number formats. &amp;nbsp;What happens now? &amp;nbsp;Well, every record that gets migrated from that system that isn't formatted according to your desires will now get kicked out! &amp;nbsp;And it might not even show up during testing! &amp;nbsp;In addition, your pretty error messages mean practically nothing on system-&amp;gt;system communication. &amp;nbsp;So, what you have is the system randomly breaking down.&lt;/p&gt;
&lt;p&gt;This causes even more problems in long-term maintenance. &amp;nbsp;I've had many bugs pop up because someone added a validator that broke several processes. &amp;nbsp;It worked in all of their tests, but they weren't thinking about all of the ways the system was used. &amp;nbsp;For instance, we decided to lock down the characters used in our usernames a little more. &amp;nbsp;The programmer decided to implement it as a validator. &amp;nbsp;Well, the problem is that several users already had usernames that didn't match the validator. &amp;nbsp;So what happened? &amp;nbsp;Those records just stopped saving. &amp;nbsp;Not just when there was someone who was at the terminal, where they could see the error message, but every job started erroring out because of users who had faulty names.&lt;/p&gt;
&lt;p&gt;Because of these issues, I *always* do validation in my controller, and *never* in the model. &amp;nbsp;It is true that there are probably workarounds for all of these issues, but the point is that they are *not* that exceptional! &amp;nbsp;They are everywhere! &amp;nbsp;What would be nice is to have validators which could be run optionally, in specific situations. &amp;nbsp;So, a controller could declare that it was using :data_entry validations, and then the model would only run those validators. &amp;nbsp;So, it would look something like this:&lt;/p&gt;
&lt;p&gt;In the model:&lt;/p&gt;
&lt;pre&gt;validates_presence_of :email, :for =&amp;gt; [:data_entry]&lt;/pre&gt;
&lt;p&gt;In the controller:&lt;/p&gt;
&lt;pre&gt;uses_validators :data_entry&lt;/pre&gt;
&lt;p&gt;One of the issues I have found with dynamic languages such as ruby is that errors arise when &quot;magic&quot; is sprinkled in unexpected places. &amp;nbsp;Ruby magic is awesome, but when I do something simple and it won't save, it is sometimes hard to even locate where the error is. &amp;nbsp;Explicitly declaring which validator set you are using allows programmers to more easily see what they are doing, and only apply magic code where it goes.&lt;/p&gt;
&lt;p&gt;Someday I'll write a package like this --- when I get extra time :)&lt;/p&gt;</description>
      <author>JB</author>
      <pubDate>Thu, 09 May 2013 15:06:00 +0000</pubDate>
      <link>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/369</link>
      <guid>http://www-old.bartlettpublishing.com/site/bartpub/blog/3/entry/369</guid>
    </item>
  </channel>
</rss>
