Monday, March 29, 2010

pancakes

After buying pancake mix for a while, and finding it expensive, I got a recipe for pancake mix from my mother, and an extremely tolerant recipe at that.

  • First take two cups (500 ml) of flour, white or whole wheat works, rice flour does not work well, but 1/4 rice flour mixed with the rest being white or whole wheat works well.
  • Add two table spoons (30 ml) of baking powder, add more to get fluffier pancakes, less to get flatter ones.
  • Add two table spoons (30 ml) of sugar, I currently use Turbinado Brown sugar (raw spun sugar cane), but any sugar works.
  • Add a bit of salt (1 ml), optional.
  • Mix well.

Now you have pancake mix.

To make the batter just mix it with equal parts fluid including 1/8 part oil, increase the liquid to get thinner pancakes, decrease the fluid to get thicker pancakes. I usually use water for the fluid, but milk works well too, even part milk. I haven't tried rice milk in the batter yet, but it should work fine as well.

Bring a frying pan to medium heat, so that a drop of water boils on contact, and pour the mix onto the pan and cook, flipping when the bottom half is cooked.

Personally I have a few common variations that I prepare.
  • Add raisins to the pancake batter, or other fruit, such as blueberries.
  • Add coco to the mix, for chocolate pancakes.
  • Replace a shot of the fluid with hard liquor for spiked pancakes, they go well at some parties.
  • Combination of above.
  • Leave out the sugar for deep fry batter.

Enjoy.

Sunday, March 28, 2010

algebraic fallacy, 2 = 1

Using only basic algebraic manipulation, and trying to not skip any steps, I am going show that 2 = 1 .

a = b

we can do whatever we want to an equation as long as we do the same thing to both sides, so first add a

a + a = b + a

simplify

2a = b + a

subtract 2b

2a - 2b = a + b - 2b

group like terms

2a - 2b = a + (1-2)b

simplify

2a - 2b = a + (-1)b

adding a negative number is the same as subtracting

2a - 2b = a - b

factor out (a - b)

2(a - b) = 1(a - b)

divide by (a - b)

\frac{2(a - b)}{a-b} = \frac{1(a - b)}{a-b}

re-factor to isolate the one

2\left(\frac{a - b}{a-b}\right) = 1\left(\frac{a - b}{a-b}\right)

reduce the one

2(1) = 1(1)

simplify

2 = 1

where did it go wrong? The answer will be given in a later post.

My class was given this puzzle in high school one day, and I was not the first one to see the mistake, but it was quite memorable.

Saturday, March 27, 2010

identifying multiples of 9 (nine)

I was given a simple method to identify multiples of 9 in grade school.

Given a number, it is a series of digits d_1d_2d_3...d_n.

Add up all the digits \sum_{i=1}^nd_i.

If the resulting number is a multiple of nine (repeat the process if it has more than one digit), or is nine, then the original number is a multiple of nine.

For example, take 81, it is the digits 8 and 1, add the digits, 8 + 1, the result is 9, therefore 81 is a multiple of 9.

For another example, take 123456, it is the digits 1, 2, 3, 4, 5, and 6, add the digits, 1 + 2 + 3 + 4 + 5 + 6, the result is 21, which is multiple digits, add the digits, 2 + 1, the result is 3, therefore 123456 is not a multiple of 9.

minimal Apache HTTPD WebDAV configuration

I recently decided to see what the minimal configuration Apache HTTPD needed to allow MacOSX to attach using webdav, as in the minimal configuration to make a HTTP based file server with Apache HTTPD.

The environment:
  • MacOSX client and server
  • The Apache HTTPD modules installed at /usr/libexec/apache2/
  • A working directory at /Users/happy/2010-03-23-dav
  • A data directory at /Users/happy/2010-03-23-dav/data
  • Apache HTTPD version Apache/2.2.13
The minimal configuration ended up being:

# start with "apachectl -f /Users/happy/2010-03-23-dav/httpd.conf -k start"

ServerRoot "/Users/happy/2010-03-23-dav"
Listen 8090

LoadModule dav_module /usr/libexec/apache2/mod_dav.so
LoadModule dav_fs_module /usr/libexec/apache2/mod_dav_fs.so

DAVLockDB logs/DAVLock
<Directory "/Users/happy/2010-03-23-dav/data">
DAV On
</Directory>

DocumentRoot "data"

PidFile logs/httpd.pid
LockFile logs/accept.lock 

This configuration does no authentication or access control, and runs the server as the user that launched it (I launched it as a regular user).

After also doing the same on a Linux machine, the only change was path names, I found that it is the network link rather than the protocol that is limiting my file transfer speed between the two computers.

Friday, March 26, 2010

setting up blogger to format latex expressions

I want to be able to post mathematical expressions and have them formatted nicely.

After some searching I found yourequations.com which had a nice little script to do the job, and did some digging on how Google Docs was doing the rendering of the expressions.

From there I found Google Chart Tools.

After gathering all that information I wrote up a script block to add to the blog template.

To install this just add it to a Blogger layout block after the Blog Posts layout block.

<script type="text/javascript">
var tags = [ "pre", "code" ];
for(var i = 0; i < tags.length; i++) {
  var eqn = document.getElementsByTagName(tags[i]);
  for (var j = 0; j < eqn.length; j++) {
    var e = eqn[j];
    if (e.getAttribute("lang") != "eq.latex") { 
      continue;
    }
    if (e.innerHTML.match(/<img.*?>/i)) {
      continue;
    }

    var str = e.innerHTML.
      replace(/<br>/gi,"").
      replace(/<br \/>/gi,"").
      replace(/&lt;/gi,"<").
      replace(/&gt;/gi,">").
      replace(/&amp;/gi,"&");

    var url_str = escape(str).
      replace(/\+/g, "%2B");

    e.innerHTML = "<img " +
      "src=\"http://chart.apis.google.com/chart" +
      "?cht=tx&chf=bg,s,ffffff00" +
      "&chl=" + url_str + "\" " +
      "title=\"" + str + "\" alt=\"" + str + "\" " +
      "class=\"eq_latex\" align=\"middle\" " +
      "border=\"0\" />";
  }
}
</script>
After installing the layout block just enclose the expressions in <pre lang="eq.latex"> and </pre>, or <code lang="eq.latex"> and </code>. For example, <code lang="eq.latex">\int_{0}^{1}xdx</code> renders as \int_{0}^{1}xdx.

setting up blogger to format source code

I want to be able to post source code with basic syntax highlighting.

After some searching I found a JavaScript module that would do it using markup. After more searching I found a Google hosted copy of the script to use on blogger, in use on JQuery HowTo.

The software used to do this is google-code-prettify: syntax highlighting of code snippets in a web page. It keeps it simple and does what it says it does well.

To install the functionality I added the following block of code to a Blogger layout block after the Blog Posts layout block.

<!--
from: http://jquery-howto.blogspot.com/2009/02/new-code-highlighter-for-bloggercom.html
-->
<script src="http://www.gstatic.com/codesite/ph/2429932258724909799/js/prettify/prettify.js">
</script>
<script type="text/javascript">
prettyPrint();
</script>

<style type="text/css">

/* Pretty printing styles. Used with prettify.js. */

.str { color: #080; }
.kwd { color: #008; }
.com { color: #800; }
.typ { color: #606; }
.lit { color: #066; }
.pun { color: #660; }
.pln { color: #000; }
.tag { color: #008; }
.atn { color: #606; }
.atv { color: #080; }
.dec { color: #606; }
pre.prettyprint { padding: 2px; border: 1px solid #888; overflow:auto; }

@media print {
  .str { color: #060; }
  .kwd { color: #006; font-weight: bold; }
  .com { color: #600; font-style: italic; }
  .typ { color: #404; font-weight: bold; }
  .lit { color: #044; }
  .pun { color: #440; }
  .pln { color: #000; }
  .tag { color: #006; font-weight: bold; }
  .atn { color: #404; }
  .atv { color: #060; }
}
</style>

To use it in a post just involves wrapping the code in <pre class="prettyprint"> and </pre>, or <code class="prettyprint"> and </code>, and ensuring that the ampersands and angle brackets are properly escaped using &amp;, &lt;, and &gt;.

Update: Added automatic scroll bars for wide lines.

Introduction

I have decided that it is time for me to start a professional blog.  I plan to post easy to follow examples of things I can do in math, programming, and application configuration, among other topics that come up.