<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Orangescale</title>
  <subtitle>Faith, dev, &amp; photography blog.</subtitle>
  <id>http://nybblr.com/</id>
  <link href="http://nybblr.com/"/>
  <link href="http://nybblr.com/feed.xml" rel="self"/>
  <updated>2012-12-09T00:00:00Z</updated>
  <author>
    <name>Jonathan Martin</name>
  </author>
  <entry>
    <title>How Santa Claus Stole Christmas</title>
    <link rel="alternate" href="/2012/12/09/how-santa-claus-stole-christmas/"/>
    <id>/2012/12/09/how-santa-claus-stole-christmas/</id>
    <published>2012-12-09T00:00:00Z</published>
    <updated>2012-12-09T00:00:00Z</updated>
    <author>
      <name>Jonathan Martin</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;em&gt;This blog is taken from a newsletter I wrote a couple years ago. Somewhere along the lines I failed to post it, so it has remained in the solitary confinement of my email database. So just pretend you’re the recipient so I don’t have to butcher the text to make it audience generic!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It’s hard to believe it’s already that time of year!&lt;/strong&gt; Thanks to classes, work, and Christmas events — pageant, formals, and “parties for hosting” — I’d quite forgotten how quickly Christmas snuck up. However this is a welcome turn, as it is far better than the countdown squeeze I normally regret.&lt;/p&gt;

&lt;p&gt;I wish to lavish you all with my deepest affections, but I shall adequately grace you all after I take my little “pulpit” and try to add a little meaning to this newsletter — or rather, address something in relation to this timeless season.&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;This blog is taken from a newsletter I wrote a couple years ago. Somewhere along the lines I failed to post it, so it has remained in the solitary confinement of my email database. So just pretend you’re the recipient so I don’t have to butcher the text to make it audience generic!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It’s hard to believe it’s already that time of year!&lt;/strong&gt; Thanks to classes, work, and Christmas events — pageant, formals, and “parties for hosting” — I’d quite forgotten how quickly Christmas snuck up. However this is a welcome turn, as it is far better than the countdown squeeze I normally regret.&lt;/p&gt;

&lt;p&gt;I wish to lavish you all with my deepest affections, but I shall adequately grace you all after I take my little “pulpit” and try to add a little meaning to this newsletter — or rather, address something in relation to this timeless season.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Inevitably you should have seen it coming — what with the prior newsletter concerning Halloween from a Christian perspective; the invaluable observations I formed on that haunted night have helped to shape (besides my assessment of the common American intellect — ranting aside) my perception of Christmas.&lt;/p&gt;

&lt;p&gt;Indeed, the great irony of discussing the two celebrations in the same paragraph! And yet, an interesting situation was posed to me on Halloween night. In my feeble (but I pray led by God!) attempts to help raise aware of Halloween’s satanic meaning, I was challenged by a neighbor with his attempt at logical discourse: &lt;em&gt;how is Christmas any different?&lt;/em&gt; After all, Christmas has lots of pagan roots and traditions, and it’s highly commercialized — how can you hypocritically stand there and criticize a pagan celebration, yet hold to Christmas?&lt;/p&gt;

&lt;p&gt;This question was hardly clever, nor adequately informed, but seeing that his mind was made up and hardly acquainted with logical discourse, I’ve realized that he was simply a representative sample of our “Christian” American population — perhaps his observations are viable, but his assessment is troubling. To adequately dissect this comparison, let us take the old school English approach of compare-and-contrast.&lt;/p&gt;

&lt;h2 id="comparison-christmas-vs-halloween"&gt;Comparison: Christmas vs. Halloween&lt;/h2&gt;
&lt;p&gt;What are the similarities? Consider first the assessment, that both are highly commercialized; commercialization tends to “mask” and “morph” the root meaning. Yes, commercialization has taken Halloween, which is inherently a satanic celebration (yes I’m making that assumption as per my last newsletter — bear with me) to a seemingly innocent game of dress-up and handing out candy…perhaps even some creepy symbols of death, decay, debauchery, etc. The average American puts up with Halloween because its commercial height has taken it to seemingly “innocent” proportions — I mean, what is inherently wrong with wearing a costume? Handing out candy? Hanging up spider webs?&lt;/p&gt;

&lt;p&gt;Similarly, the commercialized meaning of Christmas has waned significantly; as USA Today heretically dared to put it (but in a sense they are right), Christmas is a “secular” holiday. While the author of that article proceeds to claim that Christmas itself is secular, it is rather the “celebration” of Christmas that is secular. What does Christmas entail? Buy lots of gifts, write a list to Santa Claus, sing about reindeer and elves, etc. Inherently, this is indeed a secular “celebration” — however, the holiday itself is undeniably contrary.&lt;/p&gt;

&lt;p&gt;But enough of commercial height; the most interesting comparison is that of pagan roots — why celebrate Christmas and not Halloween if both have pagan roots? Christmas draws from many pagan holidays, namely the Roman Saturnalia and Scandinavian Winter Solstice Festival. Consider the Christmas tree: derived from the German god Thor, whose very existence was deified in the form of a great oak tree. I would be the first to say that Christmas has several symbols taken from pagan festivals.&lt;/p&gt;

&lt;h2 id="contrast-christmas-vs-halloween"&gt;Contrast: Christmas vs Halloween&lt;/h2&gt;
&lt;p&gt;Moving on, let us discuss the more important component of our little essay discussion: the contrast.&lt;/p&gt;

&lt;p&gt;While commercialization can mask the meaning of a celebration, it should not determine the merit of the holiday itself. For example, commercialization has effectively “toned-down” the overwhelmingly satanic message of Halloween — we’ve made dabbling in demonic powers an innocent attraction! But now consider Christmas: we’ve watered down the meaning of Christmas — that of undeserved hope, life, and salvation through our Savior’s incarnation — to Santa Claus, his elves, reindeer, and there “earned” craftsmanship.&lt;/p&gt;

&lt;p&gt;But already the difference is clear; the Christmas holiday is inherently of God — why shouldn’t we celebrate the Father’s Gift? Halloween on the other hand is the celebration of that which Christ defeated: death and sin, vanquished by the power and mercy of our Lord!&lt;/p&gt;

&lt;p&gt;So while one might make the case that the two celebrations are similar, the contrast irrefutably voids the judgement that Christmas is “no better” than Halloween. Indeed, for our sake all claims of hypocrisy are cleared, &lt;strong&gt;provided we remember and celebrate what Christmas really is.&lt;/strong&gt; In short, you determine to celebrate a holiday based on its root, not it’s deviation! And to further protect your integrity, abstain from those symbols which are foreign or contrary to the heart of that holiday.&lt;/p&gt;

&lt;p&gt;I should also add that many of the traditions we take from pagan holidays are actually symbols of conversion — again, consider the Christmas tree. In Germany, a mighty tree was the sacred symbol of the god Thor; when Saint Winfred attempted to convert the Scandinavians to Christianity, he audaciously felled the tree to prove that Thor did not exist — beneath the shrouds of the fallen oak was found a little fern tree, and Winfred proclaimed that it should be a symbol of the Christ child’s birth and the life He bought.&lt;/p&gt;

&lt;h1 id="santa-baby-the-star-or-the-chimney"&gt;Santa Baby: The Star or the Chimney?&lt;/h1&gt;
&lt;p&gt;Could you not perceive this next bunny trail?&lt;/p&gt;

&lt;p&gt;But jesting aside, the issue of Santa Claus in the Christian church has become as close an issue to me as Halloween. What could you expect from someone whose letters need only slight rearrangement to spell “satan”?&lt;/p&gt;

&lt;p&gt;As I do not wish to discolor the character of the real Nicholas, let me precede my discussion with a brief biography of this man.&lt;/p&gt;

&lt;p&gt;Nicholas was born to Epiphanus and Johanna, who were followers of the Orthodox tradition. The boy observed all the religious requirements with great fervor, but felt he had not grasped the real significance of Christianity; in an attempt to discover this meaning, he traveled to Palestine. During his stay, his parents died in an epidemic, and at his return, Nicholas found himself rich. However, he was deeply sorrowed by this inheritance, for he felt that the follower of Christ was better off poor than rich. Consequently, he gave his wealth out as acts of charity; perhaps the most famous of these acts was his anonymous gift of gold to three prospective brides as payment for their dowries.&lt;/p&gt;

&lt;p&gt;As the story passed over cultural borders, the narrative changed and expanded — Saint Nicholas became Sinterklaas (from the Dutch tradition) and eventually Santa Claus. However, the tradition has become firmly rooted in America, especially with the search for “secular” figures to celebrate in place of Christ.&lt;/p&gt;

&lt;p&gt;Now that we’ve had our dose of history, I ask a simple question: how should Christians react to Santa Claus? Or Dasher and Prancer and Rudolph?&lt;/p&gt;

&lt;h2 id="santa-claus-to-pretend-or-not-to-pretend"&gt;Santa Claus: To Pretend, or Not to Pretend&lt;/h2&gt;
&lt;p&gt;I think a few things say it best; America’s children have developed an increasingly voracious consumer mentality: “I want this, I want that.” What is Santa teaching our toddlers? Write down a list to Santa, and he’ll get you everything you want — not because he’s a giving man, but because you’re a deserving little one.&lt;/p&gt;

&lt;p&gt;The second thing is perhaps a little bit more disturbing — recently, my mother had the unique displeasure of overhearing a phone call that went something like this, “Can you believe it? (muffled Peanuts voice on the other end) Yeah they started going to church, and now they’re going to tell their son about Santa Claus, something about having to tell the truth. Seriously?! What is wrong with them!”&lt;/p&gt;

&lt;p&gt;I make my first case on why you shouldn’t celebrate Santa Claus, nor should you subscribe to the American Dream and play make-believe with your kids about Santa. First, it promotes the wrong attitude — that we “earned” presents by being good, and that a gift is given out of necessity. We know this to be absolutely false — a gift is an undeserved act of love, sometimes presented in material gain, but also lavished in immaterial “goods.”&lt;/p&gt;

&lt;p&gt;But let me make a more important observation: if we’re going to preach Santa Claus to our kids, what about Jesus? I know little ones that have (understandably) muddled the identities of Santa and Jesus, and consequently muddle the character of Christ in disturbing ways. Is it possible for us to proclaim Santa to the little ones and still convince them that the Season is all about Christ? How can we; their minds are wrapped around the presents and magical characters of the North Pole — they are unlikely to care nearly as much about that miraculous birth in Bethlehem two millenniums years ago. Perhaps it seems overrated, but I firmly believe we undermine and damage our children’s faith by meddling with Santa.&lt;/p&gt;

&lt;p&gt;Finally, I present a third and quite convicting point (hang in there!). Eventually our children will grow out of Santa — what will they walk away with? An ungratifying childhood memory of fakery, courtesy of their well-meaning parents. Consider this — a survey of a representative sample of children yielded the number one thing they wanted from their parents: to be told the truth. Although it is outside the scope of this discussion, I’ve read some enlightening articles that shed some light on what those “little white lies” to your children yield — some bigger white lies in return and general distrust. While I would quickly counter that telling lies is not something you have to be trained in (due to the sin nature), we still can encourage distrust in our children through those little lies we tell them.&lt;/p&gt;

&lt;p&gt;What is most disconcerting about this behavior is how it affects the faith of the child — when we tell our children that Santa Claus is real (in the sense of an overweight chap clad in red who drives a flying sleigh), we are undoubtedly lying to them. While some would argue in favor of the memory benefits, I would like to point out the dire consequences — as per the survey, telling those little lies encourages children to distrust or perhaps more readily dismiss things as “fairy tales.” Namely, if Santa proved to be something my parents made up, why not Jesus? What makes Jesus any more real than Santa? This observation is hardly academic — kids outgrow Santa, but they may also “outgrow” Jesus and the cute little manger with animals, hay, and shepherds in bath robes. This same phenomenon is becoming rampant with other Bible “stories,” like the Great Flood (which is quite another fascinating scientific topic). When do we start telling kids the truth?&lt;/p&gt;

&lt;p&gt;I have been unfortunate enough to read accounts of children raised in Christian homes who still believe in Santa, but no longer believe in God. They outgrew Christ because something else choked it: the symbol of consumerism replaced the author of giving. One day they will also outgrow Santa, but not because he gets choked out — they’ve learned that their parents and our culture fabricated him, “as they did with the One they call Jesus.”&lt;/p&gt;

&lt;p&gt;Anytime I bring up this subject with parents, I anticipate the usual, “oh, but it’s all fun and innocent, and the kids will make great memories.” But they take away the same from Halloween: memories, “innocent fun,” and a lesson learned — let’s make sure the lesson they take away from any holiday is Christ centered.&lt;/p&gt;

&lt;h1 id="on-that-final-note"&gt;On that final note…&lt;/h1&gt;
&lt;p&gt;I hope you all will consider these (lengthy) considerations I have lain on the subject of commercial symbols in Christmas — obviously, there are other symbols in Christmas which would diminish its true meaning, but the same logic applies; consider the root of the holiday, and if its cause is Christ honoring, then let us celebrate it with all fervor and cheer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wishing you the Merriest of Christmases in all the season’s blessings and riches!!!&lt;/strong&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>The cobwebs are here. What is the most frightening thing you can do this Halloween?</title>
    <link rel="alternate" href="/2011/10/31/the-scariest-thing-you-can-do-this-halloween/"/>
    <id>/2011/10/31/the-scariest-thing-you-can-do-this-halloween/</id>
    <published>2011-10-31T00:00:00Z</published>
    <updated>2011-10-31T00:00:00Z</updated>
    <author>
      <name>Jonathan Martin</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;em&gt;Last year, I wrote a newsletter to friends and family concerning Halloween. For myself personally, this has always been an important oversight by the Christian populace, and consequently I felt strongly compelled to share my “unpopular” take on Halloween. This is a message every Christian and non-Christian alike needs to read before getting out the Halloween decorations.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The neighbor’s houses, Cracker Barrels, Walmarts, etc. have all donned the marks of Halloween (in the case of Cracker Barrel, since the beginning of September!) — the cobwebs, deviously smiling pumpkins, haunting black figures hanging from the tree limbs…Halloween is the second highest grossing “holiday” ever, second only to Christmas. I do not wish to spoil the remainder of this blog, but I find it greatly ironic that Christmas — the celebration of the Incarnation, Sacrifice, and Santification of our Dear Savior — is followed in revenue by Halloween — the celebration of all that is dead and decaying. But as I said, I would like to follow with a more informative discussion of this “holiday” we know as Halloween.&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;Last year, I wrote a newsletter to friends and family concerning Halloween. For myself personally, this has always been an important oversight by the Christian populace, and consequently I felt strongly compelled to share my “unpopular” take on Halloween. This is a message every Christian and non-Christian alike needs to read before getting out the Halloween decorations.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The neighbor’s houses, Cracker Barrels, Walmarts, etc. have all donned the marks of Halloween (in the case of Cracker Barrel, since the beginning of September!) — the cobwebs, deviously smiling pumpkins, haunting black figures hanging from the tree limbs…Halloween is the second highest grossing “holiday” ever, second only to Christmas. I do not wish to spoil the remainder of this blog, but I find it greatly ironic that Christmas — the celebration of the Incarnation, Sacrifice, and Santification of our Dear Savior — is followed in revenue by Halloween — the celebration of all that is dead and decaying. But as I said, I would like to follow with a more informative discussion of this “holiday” we know as Halloween.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h1 id="pumkins-lanterns-andcatholicism"&gt;Pumkins, lanterns, and…Catholicism?&lt;/h1&gt;

&lt;h2 id="history"&gt;History&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Halloween&lt;/strong&gt; means hallowed or holy evening — an alternate name for the Roman Catholic holiday called All Hallow’s Eve, which is the day before the traditional All Saint’s Day. However, the roots of the holiday are actually based in the practices and traditions of the Celtics — an Irish people led by the Druids. The Druids were a league of witch priests who gave the country spiritual “guidance” through sorcery, witchery, divination, and seances (communication with the dead through mediums).&lt;/p&gt;

&lt;p&gt;On November the 1st, the Druids ordained a celebration of the dead known as the Samhain, which culminated with the order to quench all fires in the land; the Druids then built what was to be the largest bonfire in the land as a symbol of the power of the Celtic deities. During this time, it was believed that the souls of the dead from the otherworld were able to mingle with the living — the dead, demons, and spiritual entities were unleashed.&lt;/p&gt;

&lt;p&gt;When Catholic missionaries to Ireland attempted to Christianize the nation, they met with little success as a result of the influence of the Druids. Consequently, the Pope advised that the Catholic holidays be made to coincide with the Celtic holidays, and that the Celtic deities and traditions be made to vaguely resemble Catholic customs. The result was our modern day Halloween; in effect, the only Catholic part of the “holiday” is the date — the customs were virtually unmodified, and only a few Catholic elements were added to the celebration.&lt;/p&gt;

&lt;p&gt;From the Samhain, we inherit the Halloween customs: the “sacred” black cat was believed to have been a human who was punished for offenses to the deities; the Jack o’ Lantern was a ghostly figure who was kept out of the Celtic “Hell” for trickery and remained to haunt the earth. Needless to say, the witches, demons, ghosts, etc. came from the Druid practices of witchery, divination, and demonic possession.&lt;/p&gt;

&lt;h2 id="traditions"&gt;Traditions&lt;/h2&gt;
&lt;p&gt;Now that we have some historical context, let us observe some popular modern day traditions that make up the celebration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trick or Treating:&lt;/strong&gt; this popular activity is loosely derived from the Catholic tradition of Souling, when Catholic families would prepare a form of shortbread, called “Soul bread,” and gift it to the beggars who would go door to door. The beggar would plead for the bread, and in turn would pray blessings on the household and a shorter period in purgatory.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“Soal, a soal, a soal cake, please good missus a soul cake. An apple, a pear, a plum, a cherry, Any good thing to make us all merry, One for peter, two for paul, three for him who made us all.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The modern origin of the term is quite simply based in the phrase: a trick, or a treat. Halloween was once a dangerous (physically!) celebration because pranksters and mischievous individuals would go from house to house requesting a treat from the household. If they were refused, they threatened terror and damage to the property of the unrelenting household. Not long after the celebration became popular in the US, it was not uncommon to behold serious damage — in some cities, the police were necessarily on duty to help prevent arson and property damage. There was also risk for the tricksters — on occasion, the “treats” were poisoned or laden with razors, pins, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Costumes and Masks:&lt;/strong&gt; next to trick or treating, this is perhaps the most common element of Halloween. Fundamentally, it is rooted in the Celtic Samhain — in an attempt to ward off the spirits and demons who were able to mingle with the living on the Samhain, the people would disguise their identity as creatures, spirits, and ghosts with the aid of costumes and masks. It was believed that these disguises prevented the dead from recognizing the bearer as a former enemy or human.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bonfires:&lt;/strong&gt; perhaps not as popular as the aforementioned tradition, but the term tends to generically refer to a large outdoor gathering around a fire. The bonfire is of course from the Celtic Samhain — on that night, the souls of those who had died that year were to join their companions in the otherworld; to encourage the spirits to take their leave and simultaneously ward off the demons that came back to haunt the living, the people would build bonfires and sacrifice dead animals in them.&lt;/p&gt;

&lt;p&gt;Even now, bonfires are an important custom in Wicca, the leading organization for the witchcraft community. Nine types of wood are used to represent nine fundamental “powers” in paganism and burned as a symbol of consecration.&lt;/p&gt;

&lt;h1 id="the-bottom-line"&gt;The Bottom Line&lt;/h1&gt;
&lt;p&gt;As Christians, how should we approach Halloween? When I look at the origins, customs, symbols, and meaning of Halloween, I understand severals concepts: worship death, glorify decay, lavish in debauchery, and dabble in demonic influence.&lt;/p&gt;

&lt;p&gt;To be frank, there is no redeeming element in the symbols of Halloween — the black cat and carved pumpkin symbolize Celtic damnation; trick or treating and costumes (even costumes that don’t involve skeletons or witchcraft) represent fear of the demons and their unconquerable influence and the custom of hiding from them; skeletons, spiders, ghosts, cobwebs, zombies, tombstones, witchcraft, barren land, darkness — these all glorify fear and death, and ultimately the lover of death: Satan himself!&lt;/p&gt;

&lt;p&gt;Whereas Christmas is the celebration of Life in Christ, Halloween is the worship of death in Satan. Why consider joining the world in this ultimately pagan, hopeless, unredemptive, Satanic revelry?&lt;/p&gt;

&lt;p&gt;Halloween is literally a sacred night…but not for Christians. Wicca and other witchcraft organizations around the world gather to “pray” over the evening — Halloween is not just a day to them; there is spiritual warfare on that night!&lt;/p&gt;

&lt;p&gt;As such, let us resist and rebuke the demons of Hell which the Satanically influenced incant on us! Let us be branded with the Fear of God on that night, and worship the only One who offers us Life!&lt;/p&gt;

&lt;h2 id="the-alternative"&gt;The Alternative&lt;/h2&gt;

&lt;p&gt;There is a Godly alternate holiday that unfortunately has been laid wayside over the years. October 31st is significant in the life of Christians for a hope-filled reason!&lt;/p&gt;

&lt;p&gt;On October 31st, 1517 the German professor and monk Martin Luther posted on the Wittenberg church door his Ninety-Five Theses, a series of essays debating the Biblicality of a number of Catholic doctrines. We now know this date as the start of the Reformation, from which came the Protestant Church.&lt;/p&gt;

&lt;p&gt;Such an important event in church history ought to be celebrated as such. This year, celebrate October 31st as the start of new life through Christ and the revelation of Himself through the unequivocal Word of the Living God!&lt;/p&gt;

&lt;h2 id="what-you-can-do"&gt;What You Can Do&lt;/h2&gt;

&lt;p&gt;You can share this information with your friends, family, and neighbors through word-of-mouth, or with the handy informational sheet I have made available for download. Last year, I went door to door and gave the neighbors this informational sheet. It’s a little nerve racking, but you might be surprised how many neighbors will discuss it with you.&lt;/p&gt;

&lt;p&gt;However, be prepared for a few to get angry or just downright cold. I had my share of cold shoulders and irrational outbursts just from mentioning the informational sheet. The public at large is not taught to civilly discuss sensitive issues.&lt;/p&gt;

&lt;h2 id="conclusion"&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;I hope you all have an awesome and blessed Reformation Day — if you have any comments, suggestions, or stories of what you do for Reformation Day, let me know! I’d love to hear your ideas as well.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>ENGL 1101: Etymology and the Sway of Time</title>
    <link rel="alternate" href="/2011/09/01/etymology-and-the-sway-of-time/"/>
    <id>/2011/09/01/etymology-and-the-sway-of-time/</id>
    <published>2011-09-01T00:00:00Z</published>
    <updated>2011-09-01T00:00:00Z</updated>
    <author>
      <name>Jonathan Martin</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;em&gt;As if 2010 was not far enough back for you, I now present a research essay from 2009 that I coauthored with my brother Joshua (so if you notice a difference in writing styles, it has nothing to do with my schizophrenia) concerning the unusual history of some common words: &lt;strong&gt;idea&lt;/strong&gt;, &lt;strong&gt;rhetoric,&lt;/strong&gt; &lt;strong&gt;tawdry,&lt;/strong&gt; and &lt;strong&gt;guy.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2 id="flippantly-invoked-vocabulary"&gt;Flippantly Invoked Vocabulary&lt;/h2&gt;
&lt;p&gt;In today’s culture, words tend to morph to the context in which they are most used. Over mere centuries, vocabularies with deep roots and connotations are reduced to flippantly invoked words. Words that once frolicked in lush definitions are steadily watered-down to common usage and association. As Salman Rushdie laments, “[n]ames, once they are in common use, quickly become mere sounds, their etymology being buried, like so many of the earth’s marvels, beneath the dust of habit” (Rushdie). Among such words are comprised idea, rhetoric, guy, and tawdry.&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;As if 2010 was not far enough back for you, I now present a research essay from 2009 that I coauthored with my brother Joshua (so if you notice a difference in writing styles, it has nothing to do with my schizophrenia) concerning the unusual history of some common words: &lt;strong&gt;idea&lt;/strong&gt;, &lt;strong&gt;rhetoric,&lt;/strong&gt; &lt;strong&gt;tawdry,&lt;/strong&gt; and &lt;strong&gt;guy.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2 id="flippantly-invoked-vocabulary"&gt;Flippantly Invoked Vocabulary&lt;/h2&gt;
&lt;p&gt;In today’s culture, words tend to morph to the context in which they are most used. Over mere centuries, vocabularies with deep roots and connotations are reduced to flippantly invoked words. Words that once frolicked in lush definitions are steadily watered-down to common usage and association. As Salman Rushdie laments, “[n]ames, once they are in common use, quickly become mere sounds, their etymology being buried, like so many of the earth’s marvels, beneath the dust of habit” (Rushdie). Among such words are comprised idea, rhetoric, guy, and tawdry.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Perhaps one of the most philosophically cumbersome of these words is “idea.” It has come to mean “a thought or suggestion as to a possible course of action; a concept or mental impression; an opinion or belief; a feeling that something is probable or possible” (“idea” New Oxford). However, the word’s introduction originally invoked much stronger philosophic thought. “Idea” is directly derived from the Greek &lt;em&gt;idea&lt;/em&gt;, meaning “ideal prototype,” and literally translates “look or form” (“idea” Online Etymology). It originated with the advent of Platonic thought; Plato (428/427 – 348/347 BC), Socrates’ renowned pupil, compiled perhaps his most famous work entitled the &lt;em&gt;Republic&lt;/em&gt;. In the seventh book, Plato introduced the Theory of Forms (his equivalent of ideas) — he presented the Cave, an allegory that imagines two worlds: the first sensible, and the second intelligible.&lt;/p&gt;

&lt;p&gt;The Cave analogy examines a scene in which prisoners are chained in front of a wall, unable to turn away from the stone slab before them. Further, in the distance behind them are figures who walk in front of a fire with objects, and thus cast shadows on the wall which the prisoners are made to stare at. Plato proposes that these prisoners form generic ideas to describe like shadows so that they may communicate with each other; however, the objects that cast the shadow (or the “perfect” representation) are not fully realized — they are merely identified by vague notions of similar shadows. Similarly, what humanity terms “ideas” are in reality abstract perfections (also termed the “ideal state”) that exist separately from the objects associated with them. Therefore, in Platonic thought, an idea is “an eternally existing pattern of which individual things in any class are imperfect copies” (“idea” New Oxford). From this ancient definition is derived “ideal,” which closely models the original tone of idea: “Existing only in the imagination; desirable or perfect but not likely to become a reality — representing an abstract or hypothetical optimum” (“ideal” New Oxford).&lt;/p&gt;

&lt;p&gt;Plato elaborates further on the characteristics of an idea through the Analogy of the Divided Line. The narrator depicts a line divided into two equal proportions, of which the first half represents the intelligible realm, and the second constitutes that which is visible; further, the two subdivisions are subdivided into a certain number of equal constituents. Plato states that the subdivisions in the visible realm (representing objects) may serve as starting points for determining the length of or relationship to (characteristics) other divisions (other objects). Further, he reasons that humanity forms ideas (which are of the intelligible realm) through deduction — ideas are deduced from objects (subdivisions in the visible realm), provided the objects are closely represented by those ideas (subdivisions in the intelligible) that they correspond with.&lt;/p&gt;

&lt;p&gt;Less philosophically involved — but nonetheless relevant to the selection — is the term rhetoric. The word has technically retained its proper definition: “the art of effective or persuasive speaking or writing, esp. the use of figures of speech and other compositional techniques” (“rhetoric” New Oxford). However, in modern day culture it is more commonly used in a negative connotation, and thus carries sarcastic tone: “language designed to have a persuasive or impressive effect on its audience, but is often regarded as lacking in sincerity or meaningful content” (“rhetoric” New Oxford).&lt;/p&gt;

&lt;p&gt;The academic meaning of rhetoric is derived from the Greek &lt;em&gt;rhetorike techie,&lt;/em&gt; which translates “the art of the orator” (“rhetoric” Online Etymology). While seemingly vague, rhetoric once held great respect in the political and philosophical arenas. Perhaps one of the better known partially historical examples of ancient rhetoric was Brutus’ fictional speech to the witnesses of Caesar’s brutal murder.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“Romans, countrymen, and lovers! Hear me for my cause, and be silent that you may hear. Believe me for mine honor, and have respect to mine honor that you may believe. Censure me in your wisdom, and awake your senses that you may the better judge. If there be any in this assembly, any dear friend of Caesar’s, to him I say that Brutus’ love to Caesar was no less than his. If then that friend demand why Brutus rose against Caesar, this is my answer: not that I loved Caesar less, but that I loved Rome more” (Shakespeare, Julius Caesar 3.2.13-25).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Rhetoric in modern culture has come to be regarded as a political tactic to influence the masses without legitimate logical or significant content — often it indicates unintelligible speech or writing due to unnecessarily complex wording, similar to “gobbledygook.” Rarely (except perhaps within the academic realm) are well executed speeches referred to as “rhetoric,” since they are usually associated with unscrupulous reasoning.&lt;/p&gt;

&lt;p&gt;Academic words are not the only class of vocabularies that have seen significant change. The word “guy” could be considered one of the most generic and overused words of American pop culture — to the typical citizen it simply means a fellow, a man, and (in the plural form) a group composed of either genders. When it originated in England as a result of a failed conspiracy, it carried the meaning of “a person of grotesque appearance or dress” (Sos). Not until this word reached the United States did it become a neutral method of address.&lt;/p&gt;

&lt;p&gt;In England, the sixteen hundreds were marked by persecution of the Catholics under King James I; when James began exiling the Jesuits, an especially incensed group of Catholic worshipers concocted a scheme to obliterate both James and Parliament (Sos). The aptly named Gunpowder Plot was led by conspirators Robert Catesby, Thomas Percy, John Wright, Thomas Wintour, and Guy Fawkes, among others (Herber).&lt;/p&gt;

&lt;p&gt;Complications consistently delayed the execution of their plan, but by 1605, they finally gained possession of a cellar beneath Parliament in which they stored thirty-six barrels of gunpowder. In mid-October, three of the conspirators began discussing how to avoid destroying select Catholics in the explosion. The result was a letter — the famed Mounteagle Letter — sent to discourage William Parker IV Baron Mounteagle from attending Parliament on the fifth of November, the date when the plot was to be executed. Guy Fawkes was set in charge of guarding and detonating the ammunition, and in his occupation was completely ignorant of the suspiciously vague letter. All except he had arranged for a safe escape from England. On November 5, 1606, Fawkes was brought to King James when investigators, alarmed by the letter, found him in the cellar. January 27, 1606 marked the day of his execution, along with his fellow conspirators (Herber; Sos).&lt;/p&gt;

&lt;p&gt;The fifth of November quickly turned into a national holiday — Guy Fawkes Day. Children would carry ragged effigies called “guys” and ask spectators for “a penny for the guy” before throwing the effigies into the fire; predictably, “guy” came to refer to “a person of grotesque appearance or dress” (Sos). “Guy” is used in this sense in an English novel entitled &lt;em&gt;The Last Chronicle of Barset:&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;When, therefore, Mrs. Van Siever entered the room, [t]he old woman stood for a moment holding the open door in her hand. “You fool!” she said, “what are you doing there, dressed up in that way like a guy?” Then Clara got up from her feet and stood before her mother in Jael’s dress and Jael’s turban. Dalrymple thought that the dress and turban did not become her badly. Mrs. Van Siever apparently thought otherwise (Trollope Ch. LX).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When the word migrated to America in the late eighteen hundreds, it was naturally altered to mean “a fellow” or “a man” — possibly because the affiliated English holiday was insignificant to American society. Finally, by the nineteen forties, the term “guy” began to encompass women in its dynamic definition (Sos); this explains why a group of both genders may be labeled collectively as “guys.” Few would have imagined that such a hackneyed title originated from three dozen barrels of gunpowder.&lt;/p&gt;

&lt;p&gt;Another word that has experienced startling transformation is the adjective “tawdry;” it may not be among the most well-known of vocabulary, but its history is far from dull. Though its modern meaning is “gaudy, showy, and cheap,” it emerged from the benevolence of a dedicated Catholic saint (“tawdry”). As the objects most associated with her sank in quality, the word mimicked their deterioration and eventually assumed its negative definition (Morris).&lt;/p&gt;

&lt;p&gt;Saint Aethelthryth (rendered Audrey), daughter of King Anna of East Angles, lived during the Anglo-Saxon period. When her father arranged for her marriage to Prince Tonbert, ruler-to-be of the South Gyrwas, she reluctantly agreed on the condition that she would retain her virginity. Tonbert soon died, and she married Egfrid, son of King Oswy of Northumberland — under the same vow of virginity. He concurred with her terms for a time, but he soon demanded that Queen Audrey fulfill her wifely duties; she instead fled to Ely in present-day mid-eastern England (McNamara).&lt;/p&gt;

&lt;p&gt;She spent the conclusion of her life as a nun and abbess in the “double monastery” she had founded. Though she was recognized for her benevolence and wisdom, she was also known for her obsession with scarves and necklaces. When she was stricken with a throat tumor in 679, she considered it God’s punishment for her vanity (McNamara; Morris).&lt;/p&gt;

&lt;p&gt;Since then, an annual fair at Ely, held on the seventeenth of October, sold a neck tie labeled “St. Audrey’s Lace,” which was later shortened to “Tawdry’s Lace” in 1548. At first, “tawdry” denoted “refined,” but the deteriorating quality of the iconic lace demoted the term to “gaudy, showy, and cheap” (McNamara; Morris).&lt;/p&gt;

&lt;p&gt;Words are clearly dynamic. While they rarely vary in like progression, they unanimously demonstrate a common trend — that as words pass on through centuries and cultures, they lose their initial vitality. There are several reasons for this — foremost, some words carry specific meaning in a culture, but when they are bequeathed to foreign hands, their esoteric meanings are dismissed. Other words are tied to objects — thus, as the objects change in quality or significance, their associated words morph in parallel fashion. Still, other words change due to reverence for education. In earlier centuries, when education of the majority was unheard of, words were reverenced, and stray fragments of information became the “talk of the town.” In today’s television culture, where most citizens receive some form of education, learning is a switch to be fled; vocabulary is thus carelessly bruised, rather than preserved. Therefore, unless an academic resurgence or revival in the public interest in retaining proper definitions transpires, the English language will continue its trend into more culturally suitable definitions. Words are comparable to clay sculptures — as time and culture handle them perpetually, their fine details are slowly eroded until delicate curves and careful textures become smudges.&lt;/p&gt;

&lt;h2 id="works-cited"&gt;Works Cited&lt;/h2&gt;

&lt;p&gt;Herber, David. “Guy Fawkes: A Biography.” Britannia History. Britannia, n.d. Web. 30 Nov. 2009.&lt;/p&gt;

&lt;p&gt;“idea.” Online Etymology Dictionary. Online. 1 Dec. 2009.&lt;br /&gt;
&lt;a href="http://www.etymonline.com/index.php?term=idea"&gt;http://www.etymonline.com/index.php?term=idea&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;“idea.” The New Oxford American Dictionary, Second Edition. 2005. Oxford University Press. Software. 1 Dec. 2009.&lt;/p&gt;

&lt;p&gt;“ideal.” The New Oxford American Dictionary, Second Edition. 2005. Oxford University Press. Software. 1 Dec. 2009.&lt;/p&gt;

&lt;p&gt;McNamara, Robert. “St. Etheldreda (Audrey).” Irondequoit Catholic Communities. Saints Alive and All God’s Children, 19 Nov. 2008. Web. 30 Nov. 2009.&lt;/p&gt;

&lt;p&gt;Morris, Evan. “Accelerating into Oblivion.” Word Detective. N.p., 9 Nov. 1999. Web. 30 Nov. 2009.&lt;/p&gt;

&lt;p&gt;“rhetoric.” Online Etymology Dictionary. Online. 1 Dec. 2009.&lt;br /&gt;
&lt;a href="http://www.etymonline.com/index.php?term=rhetoric"&gt;http://www.etymonline.com/index.php?term=rhetoric&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;“rhetoric.” The New Oxford American Dictionary, Second Edition. 2005. Oxford University Press. Software. 1 Dec. 2009.&lt;/p&gt;

&lt;p&gt;Rushdie, Salman. “Etymology Quotes.” ThinkExist.com Quotations Online. Online. 1 Dec. 2009.
&lt;a href="http://thinkexist.com/quotes/with/keyword/etymology/"&gt;http://thinkexist.com/quotes/with/keyword/etymology/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Shakespeare, William. Julius Caesar. Ed. A. R. Braunmuller. Rev. ed. Harmondsworth, England: Penguin Classics, 2005.&lt;/p&gt;

&lt;p&gt;Sos, John. “The Maven’s Word of the Day: guy.” WORDS@RANDOM. Random House, Inc., 1 Nov. 2000. Web. 30 Nov. 2009.&lt;/p&gt;

&lt;p&gt;“tawdry.” Dictionary.com Unabridged. Random House, Inc. 8 Dec. 2009. Web. 30 Nov. 2009.&lt;/p&gt;

&lt;p&gt;Trollope, Anthony. The Last Chronicle of Barset. Classic Reader. Web. 8 Dec. 2009.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Short and Sweet: Why You Should Use Ancestry</title>
    <link rel="alternate" href="/2011/06/28/why-you-should-use-ancestry/"/>
    <id>/2011/06/28/why-you-should-use-ancestry/</id>
    <published>2011-06-28T00:00:00Z</published>
    <updated>2011-06-28T00:00:00Z</updated>
    <author>
      <name>Jonathan Martin</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;em&gt;I know I know, it’s been close to a month since I last blogged — that’s because I’ve been working and feeling hobby-lazy on the weekends, and I’m still in the middle of writing an approximately 6–8 page (single spaced!) essay, so I’m a little preoccupied…&lt;/em&gt;&lt;/p&gt;

&lt;h2 id="okay-whats-the-deal-with-ancestry"&gt;Okay, what’s the deal with Ancestry?&lt;/h2&gt;
&lt;p&gt;First off, it’s a slick and polished gem — strike one. Second, it addresses a very common need — strike two. Finally, it is Rails 3 savvy and efficient — home run!&lt;/p&gt;

&lt;p&gt;In all seriousness, Ancestry is perhaps one of the handiest gems I’ve used of late. Typically, setting up trees with ActiveRecord is relatively easy — but as the model logic grows, the ease of use/implementation fails. Query calls increase recursively with every layer of the tree, and scopes have to be manually called at each layer.&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;I know I know, it’s been close to a month since I last blogged — that’s because I’ve been working and feeling hobby-lazy on the weekends, and I’m still in the middle of writing an approximately 6–8 page (single spaced!) essay, so I’m a little preoccupied…&lt;/em&gt;&lt;/p&gt;

&lt;h2 id="okay-whats-the-deal-with-ancestry"&gt;Okay, what’s the deal with Ancestry?&lt;/h2&gt;
&lt;p&gt;First off, it’s a slick and polished gem — strike one. Second, it addresses a very common need — strike two. Finally, it is Rails 3 savvy and efficient — home run!&lt;/p&gt;

&lt;p&gt;In all seriousness, Ancestry is perhaps one of the handiest gems I’ve used of late. Typically, setting up trees with ActiveRecord is relatively easy — but as the model logic grows, the ease of use/implementation fails. Query calls increase recursively with every layer of the tree, and scopes have to be manually called at each layer.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h2 id="whats-the-problem"&gt;What’s the Problem?&lt;/h2&gt;
&lt;p&gt;Take a simple example: setting up a comment model. Each comment &lt;code&gt;has_many :comments&lt;/code&gt; through the &lt;code&gt;parent_id&lt;/code&gt;; in addition, a comment might have a status of pending, published, or rejected. Pretty quickly this useful setup turns into a coding disaster: although it’s relatively easy to setup a recursive partial to render the comment tree, we break a major rule of Rails convention — performing recursive queries from within the view layer. For large systems, this can result in hundreds of separate SQL queries for a single page view; first signal that we need a better solution.&lt;/p&gt;

&lt;p&gt;Second, what if you want visitors to only see published comments? Simple enough, you can make a custom scope; but child comments rendered in the recursive partial know nothing about that scope, and ideally shouldn’t — likely you’ll want to see pending comments inline by logging in as a moderator. With minimal complexity, we’ve already had to introduce scope duplication and too much controller behavior into the view. Yuck!&lt;/p&gt;

&lt;h2 id="and-how-exactly-am-i-supposed-to-fix-this"&gt;And How Exactly Am I Supposed to Fix This?&lt;/h2&gt;
&lt;p&gt;Very easily: add &lt;code&gt;gem 'ancestry'&lt;/code&gt; to your Gemfile, run &lt;code&gt;bundle install&lt;/code&gt;, and execute &lt;code&gt;rails g migration add_ancestry_to_[model] ancestry:string&lt;/code&gt;. After you add &lt;code&gt;has_ancestry&lt;/code&gt; to your model, you can call a slew of methods, such as &lt;code&gt;ancestors&lt;/code&gt; to fetch the entire tree “limb,” or &lt;code&gt;children&lt;/code&gt; to nab all the direct descendants. The neatest part about the ancestry gem however is that most of the methods are simply specialized scopes — which means you could fetch all of the comments from the controller without having to worry about the scope being applied to every layer of the tree.&lt;/p&gt;

&lt;h2 id="sweet-but-too-short-----where-do-i-go-now"&gt;Sweet, But Too Short — Where Do I Go Now?&lt;/h2&gt;
&lt;p&gt;Checkout the &lt;a href="https://github.com/stefankroes/ancestry"&gt;ancestry repository at github&lt;/a&gt; for more sweets. Happy coding!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Just so you know, this is my definition of “short,” but for my readers’ sakes I shall try to shorten my posts even more when appropriate. Got a shorty you want my take on? Let me know in the comments, or &lt;a href="&amp;#109;&amp;#097;&amp;#105;&amp;#108;&amp;#116;&amp;#111;:&amp;#109;&amp;#101;&amp;#064;&amp;#110;&amp;#121;&amp;#098;&amp;#098;&amp;#108;&amp;#114;&amp;#046;&amp;#099;&amp;#111;&amp;#109;"&gt;shoot me an email&lt;/a&gt; with your request.&lt;/em&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>10 Tips for College Freshmen</title>
    <link rel="alternate" href="/2011/05/30/ten-tips-for-college-freshmen/"/>
    <id>/2011/05/30/ten-tips-for-college-freshmen/</id>
    <published>2011-05-30T00:00:00Z</published>
    <updated>2011-05-30T00:00:00Z</updated>
    <author>
      <name>Jonathan Martin</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;em&gt;&lt;a href="http://thoughtsofjoy17.blogspot.com"&gt;LaJoie Ward&lt;/a&gt; and &lt;a href="http://jameslex.com"&gt;James Lex&lt;/a&gt; put together a nice list of &lt;a href="http://thoughtsofjoy17.blogspot.com/2011/05/graduating-50-dos-donts-and-random.html"&gt;50 Dos and Don’ts&lt;/a&gt; for college students (primarily prospective/current freshmen) — I had some thoughts of my own on the topic, so I have compiled my little list of advice.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Although it was two years ago, I remember well the sense of insecurity that loomed in the weeks preceding my first taste of college.&lt;/p&gt;

&lt;p&gt;Most of the anxiety died after the first couple days of class, but there was still much unfamiliarity with the system that kept my caution index high. Thanks in particular to a dear friend and a double-portion of God’s grace, I have managed to survive both my freshman and sophomore years.&lt;/p&gt;

&lt;p&gt;So, what have I learned from these past four semesters? Arc length, line integrals (curve more like), basic quantum mechanics, why electromagnetic waves propagate at the speed of light, the role of quantized energy states and the Schrodinger equation in preventing the collapse of the atom, why the capitalistic model is efficient, how not to cite an email conversation, …&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;&lt;a href="http://thoughtsofjoy17.blogspot.com"&gt;LaJoie Ward&lt;/a&gt; and &lt;a href="http://jameslex.com"&gt;James Lex&lt;/a&gt; put together a nice list of &lt;a href="http://thoughtsofjoy17.blogspot.com/2011/05/graduating-50-dos-donts-and-random.html"&gt;50 Dos and Don’ts&lt;/a&gt; for college students (primarily prospective/current freshmen) — I had some thoughts of my own on the topic, so I have compiled my little list of advice.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Although it was two years ago, I remember well the sense of insecurity that loomed in the weeks preceding my first taste of college.&lt;/p&gt;

&lt;p&gt;Most of the anxiety died after the first couple days of class, but there was still much unfamiliarity with the system that kept my caution index high. Thanks in particular to a dear friend and a double-portion of God’s grace, I have managed to survive both my freshman and sophomore years.&lt;/p&gt;

&lt;p&gt;So, what have I learned from these past four semesters? Arc length, line integrals (curve more like), basic quantum mechanics, why electromagnetic waves propagate at the speed of light, the role of quantized energy states and the Schrodinger equation in preventing the collapse of the atom, why the capitalistic model is efficient, how not to cite an email conversation, …&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h1 id="how-about-some-useful-advice"&gt;How about some useful advice?&lt;/h1&gt;
&lt;p&gt;You mean you really weren’t interested in integration over a vector field? Too bad. I fear my tips are less witty than &lt;a href="http://thoughtsofjoy17.blogspot.com/2011/05/graduating-50-dos-donts-and-random.html"&gt;LaJoie and James’ compilation,&lt;/a&gt; but I shan’t go so far as to say it is less useful. So here they are: my top ten snippets of useful advice.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;Find/form a Christian peer group&lt;/em&gt; (friends, other church family, etc.) and try to setup consistent weekly times and locations to socialize — it will help and encourage an otherwise dull week.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;Always double check your tests&lt;/em&gt; if you have remaining time — we all make careless errors. Double checking has consistently saved me as much as 30% on test grades!&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;Try to get on a friendly name basis with your professor,&lt;/em&gt; especially if they are difficult or have attitude problems — they will give you much more respect and take notice of the effort you exert; believe me it’s not as hard as it sounds! Just be extra cautious in how you address the professor (tone plays a critical role) and make it a point to say hello if you meet him/her outside of class — this enforces familiarity on the professor’s part, so if you have an unusual name, this tip is also for you!&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;Get a hobby&lt;/em&gt; (if you don’t already have one); it’s invaluable to have something you can enjoy to take your mind off school when you’re needlessly fretting or stressed. &lt;em&gt;A word of caution:&lt;/em&gt; don’t let the hobby swallow up school time!&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;Go to bed on time!&lt;/em&gt; I had morning classes everyday at 8 AM, so losing sleep every night builds up…you will feel more miserable every morning (and start nodding off in that dreaded 3–4:45 class).&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;Get some exercise&lt;/em&gt; by walking/jogging across campus as much as possible (without being late of course) — your endurance will increase exponentially the larger the campus.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;Don’t carry a lot of books&lt;/em&gt; — you can cause back and shoulder damage, and your posture will suffer. If you have a locker, use it! Stuff every book you don’t need for the next class in there. If your car is available, store non-valuable items in the trunk (out of view is the most important part). If you carry around few enough materials, consider a messenger bag: they’re light, useful outside school, and easier to swap materials in and out of.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Do your lab partner(s) a favor and &lt;em&gt;come to class showered&lt;/em&gt; and presentably dressed — you just might make a friend if you don’t scare them off with unpleasant odors…&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;Hold on to those award letters&lt;/em&gt; — most car insurance companies will lower your rates if you have proof of exceptional grades!&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;Request an official copy of your transcript&lt;/em&gt; every semester before tossing all of your homework/graded tests. The school can make mistakes and ruin your grades, so keep tangible, official proof of your grades…then toss all the tests.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id="another-fifty-anyone"&gt;Another fifty anyone?&lt;/h1&gt;

&lt;p&gt;This was certainly a partial list, but should get you off to a good start if you’re just getting ready to jump into the college workflow. Be sure to check out &lt;a href="http://thoughtsofjoy17.blogspot.com/2011/05/graduating-50-dos-donts-and-random.html"&gt;50 Dos and Don’ts&lt;/a&gt; for a more lighthearted (but nonetheless invaluable) bag of tips!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Rails 3: Forcing SSL</title>
    <link rel="alternate" href="/2011/05/17/rails-3-forcing-ssl/"/>
    <id>/2011/05/17/rails-3-forcing-ssl/</id>
    <published>2011-05-17T00:00:00Z</published>
    <updated>2011-05-17T00:00:00Z</updated>
    <author>
      <name>Jonathan Martin</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;em&gt;Once again, I found myself beating my way through a website todo, and again I painfully managed to complete the task. Perhaps I can spare you some of that pain with this discussion of SSL.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A nice convenience with the price of two late nights spent forcing my way through the seemingly most ridiculous bugs. What objective snatched away those precious hours of sleep?&lt;/p&gt;

&lt;p&gt;Forcing SSL. That’s it. I implemented an administrator interface to my blog so I can easily post, comment, etc. (or else I’d never get time to write) however I was bugged every time I saw the basic http auth dialog with its warning: &lt;strong&gt;Your password will be sent unencrypted.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Naturally, I’m a conspiracy theorist and anticipate some foreign nation overtaking my blog and using it to bring about the end of the world (ok not really). However, having to type in &lt;code&gt;https://&lt;/code&gt; every time I want to securely do my magic jumbo gets really irritating, and too many times have I authenticated without SSL. Way too many times.&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;Once again, I found myself beating my way through a website todo, and again I painfully managed to complete the task. Perhaps I can spare you some of that pain with this discussion of SSL.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A nice convenience with the price of two late nights spent forcing my way through the seemingly most ridiculous bugs. What objective snatched away those precious hours of sleep?&lt;/p&gt;

&lt;p&gt;Forcing SSL. That’s it. I implemented an administrator interface to my blog so I can easily post, comment, etc. (or else I’d never get time to write) however I was bugged every time I saw the basic http auth dialog with its warning: &lt;strong&gt;Your password will be sent unencrypted.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Naturally, I’m a conspiracy theorist and anticipate some foreign nation overtaking my blog and using it to bring about the end of the world (ok not really). However, having to type in &lt;code&gt;https://&lt;/code&gt; every time I want to securely do my magic jumbo gets really irritating, and too many times have I authenticated without SSL. Way too many times.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h2 id="initial-solution"&gt;Initial Solution&lt;/h2&gt;
&lt;p&gt;It was time to forcefully redirect to SSL sessions…sounds simple enough. I started out (well, actually this was after a few revisions) with the following skeleton-code for the application controller.&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ApplicationController&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="ss"&gt;ActionController&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;.&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;

  &lt;span class="kp"&gt;private&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;authenticate&lt;/span&gt;
    &lt;span class="k"&gt;unless&lt;/span&gt; &lt;span class="n"&gt;require_ssl&lt;/span&gt;
      &lt;span class="n"&gt;authenticate_or_request_with_http_basic&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
        &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:admin&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;user&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;secret&amp;#39;&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kp"&gt;false&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;require_ssl&lt;/span&gt;
    &lt;span class="c1"&gt;# SSL needs to be forced if the server is in production and the request is not already SSL&lt;/span&gt;
    &lt;span class="n"&gt;ssl_required&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Rails&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;production?&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ssl?&lt;/span&gt;

    &lt;span class="n"&gt;flash&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keep&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ssl_required&lt;/span&gt;
    &lt;span class="n"&gt;redirect_to&lt;/span&gt; &lt;span class="ss"&gt;:protocol&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;https://&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ssl_required&lt;/span&gt;
    &lt;span class="n"&gt;ssl_required&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;I was already calling &lt;code&gt;before_filter :authenticate&lt;/code&gt; in my controllers, so it seemed sensible to extend that before filter with an SSL redirect. However, by the first night I could not get past the dreaded “Too many redirects” error. I checked the code logic, and all seemed well — in fact, all was! But after probing the return value of &lt;code&gt;request.ssl?&lt;/code&gt;, I found it never returned true. Why? After some searching, I found the code definition for the ssl? qualifier:&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1
2
3
4&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;# File actionpack/lib/action_dispatch/http/url.rb, line 20&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;ssl?&lt;/span&gt;
  &lt;span class="vi"&gt;@env&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;HTTPS&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;on&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="vi"&gt;@env&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;HTTP_X_FORWARDED_PROTO&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;https&amp;#39;&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;h2 id="passenger-and-ssl"&gt;Passenger and SSL&lt;/h2&gt;
&lt;p&gt;So that was useless…until I did some Googling. I deploy all my apps with Passenger (which up until now has been awesome) however there is an active bug that seems to spring up every other version in which SSL headers are not transferred from Apache to the Rails app via Passenger — which means my app keeps trying to redirect to SSL, but never gets feedback that it is in SSL. So with a little more research, I found temporary fix that modified the &lt;code&gt;ssl?&lt;/code&gt; method:&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;# lib/url.rb&lt;/span&gt;
&lt;span class="k"&gt;module&lt;/span&gt; &lt;span class="nn"&gt;ActionDispatch&lt;/span&gt;
  &lt;span class="k"&gt;module&lt;/span&gt; &lt;span class="nn"&gt;Http&lt;/span&gt;
    &lt;span class="k"&gt;module&lt;/span&gt; &lt;span class="nn"&gt;URL&lt;/span&gt;
      &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;ssl?&lt;/span&gt;
        &lt;span class="vi"&gt;@env&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;SERVER_PORT&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;].&lt;/span&gt;&lt;span class="n"&gt;to_s&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;443&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="vi"&gt;@env&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;HTTPS&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;on&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="vi"&gt;@env&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;HTTP_X_FORWARDED_PROTO&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;https&amp;#39;&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;I was pretty sure the Rails app was getting the port number, and SSL is typically handled over port 443, so I rewrote the method to take that into account. Admittedly it’s a less than ideal solution, but it was the best I could do without messing up all my clean Application.rb code. So I uploaded, did a &lt;code&gt;touch tmp/restart.txt&lt;/code&gt;, and…&lt;/p&gt;

&lt;h2 id="final-adjustment"&gt;Final Adjustment&lt;/h2&gt;
&lt;p&gt;…I still got the dreaded too many redirects error! That was too much for one night, so I picked it back up the next day, this time probing the output of the &lt;code&gt;ssl_required&lt;/code&gt; evaluation. To my astonishment, &lt;code&gt;Rails.env.production? and not request.ssl?&lt;/code&gt; always evaluates to true! Obviously, the first operand is working properly on the production server, but after probing just the &lt;code&gt;request.ssl?&lt;/code&gt; part, it appears to be working correctly as well.&lt;/p&gt;

&lt;p&gt;Of all things, it appears Ruby 1.9.2 has some boolean bug, because I rewrote the &lt;code&gt;ssl_required&lt;/code&gt; evaluation:&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1
2
3
4
5&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;ssl_required&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Rails&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;production?&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ssl?&lt;/span&gt;

&lt;span class="c1"&gt;# ...to...&lt;/span&gt;

&lt;span class="n"&gt;ssl_required&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ssl?&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="no"&gt;Rails&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;production?&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;Essentially, I dropped the more readable “and not” syntax and went back to the more terse “!” operator. After a restart, bingo! I am still befuddled as to why my original syntax doesn’t work properly, but in the meantime I am quite satisfied to have working SSL redirection.&lt;/p&gt;

&lt;h2 id="concluding-remarks"&gt;Concluding Remarks&lt;/h2&gt;
&lt;p&gt;The initial SSL markup was pretty easy to implement, but if you’re looking for a gemified way to setup SSL requirements, I recommend the &lt;code&gt;ssl_requirement&lt;/code&gt; gem. The gem’s approach is almost identical to the mine, however it has some “prettier” methods you can call. As I already had some basic authentication in place and have not migrated to full user accounts yet, I needed a custom solution that would automatically be called alongside the authenticate filter.&lt;/p&gt;

&lt;p&gt;Also, the &lt;code&gt;request.ssl?&lt;/code&gt; override I wrote will not load automatically in Rails 3 since it is a core class — to autoload lib files, take a look at the &lt;code&gt;auto_require&lt;/code&gt; post to auto-override the core &lt;code&gt;ssl?&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;Finally, if anyone has any insight on the syntax quirk or quick/easy solutions to get Passenger 3.0.7 to pass along the SSL headers, you are welcome to enlighten me in the comments.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>ENGL 1102: Insatiable Desire</title>
    <link rel="alternate" href="/2011/05/13/insatiable-desire/"/>
    <id>/2011/05/13/insatiable-desire/</id>
    <published>2011-05-13T00:00:00Z</published>
    <updated>2011-05-13T00:00:00Z</updated>
    <author>
      <name>Jonathan Martin</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;em&gt;Time for essay recap no. 2! I wrote this essay in February for an english assignment examining that peculiar (pesky more like!) characteristic of human nature: insatiable desire (that means you never are satisfied). Being a secular school, all the non-believers had their work cut out for them — as for myself, I had a head start on the topic!&lt;/em&gt;&lt;/p&gt;

&lt;h2 id="insatiable-desire-romantic-depiction-cultural-demands-or-realistic-nature"&gt;Insatiable Desire: Romantic Depiction, Cultural Demands, or Realistic Nature?&lt;/h2&gt;
&lt;p&gt;Parents are well acquainted with the phenomenon — the week after Christmas their young toddlers and pre-teen kids, who had already enjoyed a spoilsome season, are forthwith drawn into the never-ending cycle of “if I get that toy, I’ll be happy forever.” Adults as well are befuddled by their ravenous desire for alternative (typically “better” to their understanding) circumstances and possesions. Yi-Fu Tuan verbalizes this peculiar trait of human nature: “Human beings have been and continue to be profoundly restless. For one reason or another, they are not content with being where they are. They move, or if they stay in one place, they seek to rearrange that place.”&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;Time for essay recap no. 2! I wrote this essay in February for an english assignment examining that peculiar (pesky more like!) characteristic of human nature: insatiable desire (that means you never are satisfied). Being a secular school, all the non-believers had their work cut out for them — as for myself, I had a head start on the topic!&lt;/em&gt;&lt;/p&gt;

&lt;h2 id="insatiable-desire-romantic-depiction-cultural-demands-or-realistic-nature"&gt;Insatiable Desire: Romantic Depiction, Cultural Demands, or Realistic Nature?&lt;/h2&gt;
&lt;p&gt;Parents are well acquainted with the phenomenon — the week after Christmas their young toddlers and pre-teen kids, who had already enjoyed a spoilsome season, are forthwith drawn into the never-ending cycle of “if I get that toy, I’ll be happy forever.” Adults as well are befuddled by their ravenous desire for alternative (typically “better” to their understanding) circumstances and possesions. Yi-Fu Tuan verbalizes this peculiar trait of human nature: “Human beings have been and continue to be profoundly restless. For one reason or another, they are not content with being where they are. They move, or if they stay in one place, they seek to rearrange that place.”&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Insatiable longing is the subject of nearly all the classic literary works, whether thematically or not. The protagonist’s desire for what he delights in (e.g. homeland, scenic country, or loved one) consistently clashes with those of the antagonist and Fate itself. Shakespeare’s sonnet 129 serves as an excellent instance of this perception:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“The expense of spirit in a waste of shame&lt;br /&gt;
Is lust in action; and till action, lust&lt;br /&gt;
Is perjured, murderous, bloody, full of blame,&lt;br /&gt;
Savage, extreme, rude, cruel, not to trust,&lt;br /&gt;
Enjoy’d no sooner but despised straight,&lt;br /&gt;
Past reason hunted, and no sooner had&lt;br /&gt;
Past reason hated, as a swallow’d bait&lt;br /&gt;
On purpose laid to make the taker mad;&lt;br /&gt;
Mad in pursuit and in possession so;&lt;br /&gt;
Had, having, and in quest to have, extreme;&lt;br /&gt;
A bliss in proof, and proved, a very woe;&lt;br /&gt;
Before, a joy proposed; behind, a dream.&lt;br /&gt;
All this the world well knows; yet none knows well&lt;br /&gt;
To shun the heaven that leads men to this hell.”&lt;br /&gt;
(from Shakespeare’s Sonnets, #129)  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Such common portrayal has inevitably caused the modern audience to reject these notions and instead dismiss them as classical Romanticism. While it may be admitted that humanity’s longing has been and continues to be immortalized, the validity of such pivotal human nature need not be questioned merely on account of exaggeration.&lt;/p&gt;

&lt;p&gt;Although one might not dismiss insatiability entirely as purely Romantic, he might be further inclined to suggest that the unquenchable “I want” of modern culture may be attributed to the materialistic hype that the marketing profession flagrantly encourages. Admittedly, culture has contributed largely to promoting this general attitude of dissatisfaction; again however, cultural influence cannot entirely explain mankind’s unhealthily voracious appetite for materialistic wealth — it would seem that humanity naturally yearns for more or better possessions, barring outside influences.&lt;/p&gt;

&lt;p&gt;If insatiable desire is neither the sole responsibility of Romantic depiction nor cultural pressure, what is the core motivator behind such an irrepressible passion? If it is indeed an “instinctive” behavior, the source of such craving varies according to one’s religion — to the atheist or agnostic, lust for materialistic wealth is an outgrowth of animalistic roots. In contrast, the Scriptures — primarily through the observations Christ and the Old Testament poets conferred — attribute materialistic hunger to man’s natural depravity as the consequence of original sin. Although Scripture clearly denounces materialism, the Protestant work ethic is also enforced; therefore, the boundaries which differentiate simple longing for improved circumstances from insatiable lust for worldly substance must be determined based on the motives behind those desires. One must ultimately consider the role of wealth in his priorities as compared with those Scripture emphasizes.&lt;/p&gt;

&lt;p&gt;Indeed, the plight of humanity is to suffer at the whim of want; mankind’s materialistic addiction has often been at the center of grave conflictions — however, one must assess its cause for a proper diagnosis. If insatiability is merely the subject of the great Romantic authors or classicalism, materialistic behavior is elaborated at least and non-existent at best. However, thoroughly advertised cultural expectations easily contributes to the influx in aspiration — still, there is yet another culprit in cahoots with the commercial industry. Human nature, according to Biblical principles, is utterly corrupt and refuses to be contented with present circumstances, for which reason Christ prompts humanity to seek satisfaction and refuge in Him, rather than life’s fleeting pleasures.&lt;/p&gt;

&lt;h2 id="works-cited"&gt;Works Cited&lt;/h2&gt;
&lt;p&gt;Shakespeare, William. Shakespeare’s Sonnets. Ed. G. Blakemore Evans. Cambridge: Cambridge UP, 1996.&lt;/p&gt;

&lt;p&gt;Tuan, Yi-Fu. “Earth: Nature and Culture.” Making Sense. 2nd ed. Ed. Bob Coleman. Boston: Houghton Mifflin Company. 2006. (582-594). Print.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Ruby on Rails: Top 10 Gems</title>
    <link rel="alternate" href="/2011/05/06/ruby-on-rails-top-ten-gems/"/>
    <id>/2011/05/06/ruby-on-rails-top-ten-gems/</id>
    <published>2011-05-06T00:00:00Z</published>
    <updated>2011-05-06T00:00:00Z</updated>
    <author>
      <name>Jonathan Martin</name>
    </author>
    <summary type="html">&lt;p&gt;After developing a number of Rails 3 apps, I’ve come to build up a list of “prerequisite” gems that I must install before I decide to include anything else.&lt;/p&gt;

&lt;p&gt;Without further ado, here are my top 10 must have gems for RESTful, DRY development.&lt;/p&gt;

&lt;h2 id="simpleform"&gt;simple_form&lt;/h2&gt;
&lt;p&gt;Let’s face it: as awesome as Rails is, form building is not exactly its forte. That’s why I recommend &lt;code&gt;simple_form&lt;/code&gt;, a gem that makes form partials a breeze to customize, generate, and understand. With support for native I18n, inline validations, nested models, extensive options, and unbeatable customization, &lt;code&gt;simple_form&lt;/code&gt; is a serious deal for forms.&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;After developing a number of Rails 3 apps, I’ve come to build up a list of “prerequisite” gems that I must install before I decide to include anything else.&lt;/p&gt;

&lt;p&gt;Without further ado, here are my top 10 must have gems for RESTful, DRY development.&lt;/p&gt;

&lt;h2 id="simpleform"&gt;simple_form&lt;/h2&gt;
&lt;p&gt;Let’s face it: as awesome as Rails is, form building is not exactly its forte. That’s why I recommend &lt;code&gt;simple_form&lt;/code&gt;, a gem that makes form partials a breeze to customize, generate, and understand. With support for native I18n, inline validations, nested models, extensive options, and unbeatable customization, &lt;code&gt;simple_form&lt;/code&gt; is a serious deal for forms.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;With some bundle magic, turn your forms:&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;form_for&lt;/span&gt; &lt;span class="vi"&gt;@post&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:html&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;:multipart&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;category_id&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Category&amp;quot;&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;category_id&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;Category&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;all&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;collect&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;:include_blank&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="x"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;date&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Date&amp;quot;&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;date_select&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;date&amp;quot;&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="x"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Title&amp;quot;&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text_field&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;title&amp;quot;&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="x"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;photo&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Upload a photo&amp;quot;&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;file_field&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;photo&amp;quot;&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;Into a creative outlet.&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1
2
3
4
5
6&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;simple_form_for&lt;/span&gt; &lt;span class="vi"&gt;@post&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:html&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;:multipart&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;association&lt;/span&gt; &lt;span class="ss"&gt;:category&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:include_blank&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt; &lt;span class="ss"&gt;:date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:as&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="ss"&gt;:date&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt; &lt;span class="ss"&gt;:title&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt; &lt;span class="ss"&gt;:photo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:label&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Upload a photo&amp;quot;&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;h2 id="paperclip"&gt;paperclip&lt;/h2&gt;
&lt;p&gt;Dead simple file attachments. Seriously easy. Next to &lt;code&gt;simple_form&lt;/code&gt;, this is literally the second installed gem in all of my apps. If you are using any other attachment gem, you’re old school — paperclip is pure joy in clean, DRY code haven.&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1
2
3
4
5
6
7
8&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;# /models/post.rb&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Post&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="ss"&gt;ActiveRecord&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;
  &lt;span class="n"&gt;has_attached_file&lt;/span&gt; &lt;span class="ss"&gt;:photo&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;.&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="c1"&gt;# /views/posts/show.html.erb&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;image_tag&lt;/span&gt; &lt;span class="vi"&gt;@post&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;photo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vi"&gt;@post&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;photo?&lt;/span&gt; &lt;span class="o"&gt;%&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;h2 id="jquery-rails"&gt;jquery-rails&lt;/h2&gt;
&lt;p&gt;When I first started rails, my only complaint was the prototype library integration…to me, prototype is unintuitive, bloated, and too nitty-gritty. When Rails 3 shipped out with a resounding move towards framework independence, I was only too happy to accommodate the gap with jQuery. But it was a pain to install, and none of the remote options worked unless I were to write up my own scripts.&lt;/p&gt;

&lt;p&gt;Thanks to &lt;code&gt;jquery-rails&lt;/code&gt;, the power of jQuery is united with Rails (an excellent combo!) with a simple generator command. Just add the gem to your gemfile, bundle install, and run &lt;code&gt;rails g jquery:install&lt;/code&gt; or pass the &lt;code&gt;-j jquery&lt;/code&gt; option when you are creating a new app.&lt;/p&gt;

&lt;h2 id="kaminari"&gt;kaminari&lt;/h2&gt;
&lt;p&gt;When it came time to find a pagination gem for posts, I naturally checked out &lt;code&gt;will_paginate&lt;/code&gt;. However, either because of the gem’s age or name, it wasn’t exactly my dream pagination gem — that’s when I came across kaminari, a modern Rails 3 only gem with a simple interface and excellent customizability. In addition to being natively built for Rails 3, kaminari also takes advantage of the new Rails queries by making the page method accessible via a scope relation. Customize the text with I18n, restyle the page selector template, and continue to take full advantage of ActiveRecord Relations.&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;# /app/models/post.rb&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Post&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="ss"&gt;ActiveRecord&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;
  &lt;span class="n"&gt;paginates_per&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;.&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="c1"&gt;# /app/controllers/posts_controller.rb&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PostsController&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationController&lt;/span&gt;
  &lt;span class="vi"&gt;@posts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Post&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;published&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:page&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;.&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="c1"&gt;# /app/views/posts/index.html.erb&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;paginate&lt;/span&gt; &lt;span class="vi"&gt;@posts&lt;/span&gt; &lt;span class="o"&gt;%&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;h2 id="nokogiri"&gt;nokogiri&lt;/h2&gt;
&lt;p&gt;Slick HTML parsing — these descriptors are normally exclusive outside the webkit render engine, but Ruby is the exception thanks to nokogiri, which unites the power of jQuery DOM traversing with a standards built HTML/XML core. This powerful plugin powers my HTML truncation method, which you can check out at &lt;code&gt;Ruby Extension: HTML Truncation&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id="highvoltage"&gt;high_voltage&lt;/h2&gt;
&lt;p&gt;Rails is great for a web app, but more than once I’ve needed to build a “semistatic” page — like an about me page that still needs the application layout, view helpers, and maybe very limited database access, but then again building an entire controller for it makes no sense since it is not a resource or database backed.&lt;/p&gt;

&lt;p&gt;Enter &lt;code&gt;high_voltage&lt;/code&gt;, made by the same guys who developed Paperclip (#2 on the list!). With it, you can get RESTful static pages that won’t leave you in programmer’s depression. This gem turns those nasty static pages into their own “resources” so you can give even your “about me” page that Rails sparkle.&lt;/p&gt;

&lt;h2 id="cancan"&gt;cancan&lt;/h2&gt;
&lt;p&gt;Authentication…one of those topics that causes the typical Rails developer to squirm and whine. Well, that was before &lt;code&gt;cancan&lt;/code&gt;; I’m quite impressed by how well Ryan Bates was able to separate such a central part of a web app into a virtually “no strings attached” gem. CanCan is a wonderfully minimalistic solution to managing resource access, without all the customization and security headaches typically encountered with other intrusive security gems.&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;# /app/models/ability.rb&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Ability&lt;/span&gt;
  &lt;span class="kp"&gt;include&lt;/span&gt; &lt;span class="ss"&gt;CanCan&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Ability&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;||=&lt;/span&gt; &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="c1"&gt;# guest user (not logged in)&lt;/span&gt;

    &lt;span class="n"&gt;can&lt;/span&gt; &lt;span class="ss"&gt;:read&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:all&lt;/span&gt;
    &lt;span class="n"&gt;can&lt;/span&gt; &lt;span class="ss"&gt;:manage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;User&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:id&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;

    &lt;span class="n"&gt;can&lt;/span&gt; &lt;span class="ss"&gt;:read&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:status&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Active&amp;quot;&lt;/span&gt;
    &lt;span class="n"&gt;can&lt;/span&gt; &lt;span class="ss"&gt;:manage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;:id&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="c1"&gt;# /app/controllers/posts_controller.rb&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ResumesController&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationController&lt;/span&gt;
  &lt;span class="c1"&gt;# Tell CanCan that this is a protected resource, and needs to be loaded through the author&lt;/span&gt;
  &lt;span class="n"&gt;load_and_authorize_resource&lt;/span&gt; &lt;span class="ss"&gt;:user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:find_by&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="ss"&gt;:handle&lt;/span&gt;
  &lt;span class="n"&gt;load_and_authorize_resource&lt;/span&gt; &lt;span class="ss"&gt;:resume&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:through&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="ss"&gt;:user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:shallow&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1
2
3
4
5
6
7
8&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="x"&gt;# /app/index/posts/show.html.erb&lt;/span&gt;
&lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;can?&lt;/span&gt; &lt;span class="ss"&gt;:create&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="vi"&gt;@user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;posts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;build&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;link_to&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Create a new post&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;new_user_post_path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="vi"&gt;@user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;

&lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;unless&lt;/span&gt; &lt;span class="n"&gt;cannot?&lt;/span&gt; &lt;span class="ss"&gt;:edit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="vi"&gt;@post&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="x"&gt;  &lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;link_to&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Edit this post&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;edit_user_post_path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="vi"&gt;@user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="vi"&gt;@post&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;span class="cp"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="x"&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;h2 id="bcrypt-ruby"&gt;bcrypt-ruby&lt;/h2&gt;
&lt;p&gt;Of course, if you’re going to be handling authentication in your app, it might be useful to have a hash library handy. Perhaps the most popular gem out there for cryption related methods is the bcrypt-ruby implementation. The interface is reasonably easy to use, but since I mostly use this library for really basic secure password hashing, I haven’t used its more interesting capabilities.&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;bcrypt&amp;#39;&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="ss"&gt;ActiveRecord&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;
  &lt;span class="kp"&gt;include&lt;/span&gt; &lt;span class="no"&gt;BCrypt&lt;/span&gt;

  &lt;span class="c1"&gt;# Returns hashed password&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;password&lt;/span&gt;
    &lt;span class="vi"&gt;@password&lt;/span&gt; &lt;span class="o"&gt;||=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;Password&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;password_hash&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;unless&lt;/span&gt; &lt;span class="n"&gt;password_hash&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;blank?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;

  &lt;span class="c1"&gt;# Hashes password and records it in the database&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="vi"&gt;@password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Password&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;password_hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="vi"&gt;@password&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;h2 id="mechanize"&gt;mechanize&lt;/h2&gt;
&lt;p&gt;Sometimes websites don’t provide an HTTP accessible API (why they wouldn’t set aside several business days worth of billable work to develop an API is beyond me). With mechanize, this problem turns into an enjoyable coding session — with this gem, you can interact with a website as though you were using a browser; submit forms, follow links, screen scrape, etc. all from an intuitive Nokogiri powered API.&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;# Initialize new mechanizer&lt;/span&gt;
&lt;span class="n"&gt;agent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Mechanize&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;

&lt;span class="c1"&gt;# Load google homepage and grab the search form&lt;/span&gt;
&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;http://google.com&amp;#39;&lt;/span&gt;
&lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;forms&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;

&lt;span class="c1"&gt;# Set the search query and submit&lt;/span&gt;
&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;nybblr&amp;#39;&lt;/span&gt;
&lt;span class="n"&gt;search_page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;submit&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;h2 id="oh-and-one-last-jewelrails"&gt;Oh, and one last jewel…&lt;strong&gt;rails&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;How could I possibly discuss all of these gems without mentioning that Ruby on Rails itself is a &lt;em&gt;whopping&lt;/em&gt; gem of its own? If you’re not using &lt;code&gt;rails&lt;/code&gt; as your web development framework, you should. Run &lt;code&gt;gem install rails&lt;/code&gt; right now and start riding the rails!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>ENGL 1102: Reading Practices and Comprehensive Depth</title>
    <link rel="alternate" href="/2011/05/03/reading-practices-and-comprehension/"/>
    <id>/2011/05/03/reading-practices-and-comprehension/</id>
    <published>2011-05-03T00:00:00Z</published>
    <updated>2011-05-03T00:00:00Z</updated>
    <author>
      <name>Jonathan Martin</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;em&gt;I wrote this essay last year as an ENGL 1102 assignment, and as it seems a waste not to put my old essays to some use, I will be starting a series that pulls from my more interesting assignments. Not too much red ink please, or I may relapse into essay revision stress disorder!&lt;/em&gt;&lt;/p&gt;

&lt;h2 id="reading-practices-and-their-relationship-to-comprehensive-depth"&gt;Reading Practices and Their Relationship to Comprehensive Depth&lt;/h2&gt;
&lt;p&gt;Inevitably, the method or procedure through which reading comprehension is accomplished directly affects its retention and inward understanding. Additionally, depending on the context, the audience may strive for particular excellence in certain aspects while ignoring others. Obviously the purpose of reading will consequently determine the manner in which the composition is approached and noted. Multiple generic instances of this variability present themselves as prime candidates for observation.&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;I wrote this essay last year as an ENGL 1102 assignment, and as it seems a waste not to put my old essays to some use, I will be starting a series that pulls from my more interesting assignments. Not too much red ink please, or I may relapse into essay revision stress disorder!&lt;/em&gt;&lt;/p&gt;

&lt;h2 id="reading-practices-and-their-relationship-to-comprehensive-depth"&gt;Reading Practices and Their Relationship to Comprehensive Depth&lt;/h2&gt;
&lt;p&gt;Inevitably, the method or procedure through which reading comprehension is accomplished directly affects its retention and inward understanding. Additionally, depending on the context, the audience may strive for particular excellence in certain aspects while ignoring others. Obviously the purpose of reading will consequently determine the manner in which the composition is approached and noted. Multiple generic instances of this variability present themselves as prime candidates for observation.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;First, consider the average student gleaning through his textbook — he is hardly concerned with insightful comprehension of the text’s material, much less the circumstances or alterior influences which altered the textbook’s content. His primary concern is locating the pertinent facts, opinions, dates, definitions, or names, and commiting them to memory. While he may gain an elementary understanding of the book’s context, his lack of enthusiasm or incentive to appreciate more than bullet points reduces the book’s overall effectiveness in encouraging its propaganda. Thus, such a scenario equates more to ‘managing information’ rather than comprehending the overall ‘truth’ of the work.&lt;/p&gt;

&lt;p&gt;Another notable example could be that of rhetorical essays, whose inherent detail is entrenched in rich, but altogether difficult vocabulary. In such cases, the author approaches the essay with the singular purpose of communicating a truth, which can only be understood at depth an incomprehensive skim could not afford. Sven Birkert’s essay, entitled ‘The Owl has Flown,’ serves as a prime example of rhetorically significant composition. Birkert argues that the reading audience has progressed from narrow, in-depth comprehension of literary works to broad, superficial understanding. While the essay cites historical instances as its support, his primary purpose is to argue the progression of reading practices — therefore, the important ‘truth’ behind his essay can only be comprehended through the process of thought, discourse, and brief analyzation. This instance is therefore rooted in comprehension, rather than memorizing facts, and is remembered as an entire or generically communicated concept.&lt;/p&gt;

&lt;p&gt;The typical novel serves well as an instance of purely pleasureful motives. One might peruse the classic The Lord of the Rings with the primary object of passing the time enjoyably — in such circumstances the reader intends to glean the general mood and plot as it is expressed over a span of a couple thousand pages; there is little, if any, need to analyze the events or background to the same degree as a rhetorical essay: not only is the ‘truth’ stretched out in detail gradually, but relevant facts are steadily enforced through repetition. In summary, novels are read with the purpose of enjoyment, but are written in such a way that they communicate both relevant ‘truth’ and pertinent facts over lengthy spans.&lt;/p&gt;

&lt;p&gt;The manner in which the classic literary works are approached largely depends upon the purpose that drives their observation, the type of work, and general scholarly proclivities the reader may or may not possess. An educational resource is read primarily for the express purpose of factual information, rather than an overall theme or ‘truth.’ In direct contrast, the strength in a rhetorical essay is primarily the overall truth it establishes, and merely uses facts as a method of support. Finally, the novel most often entertains and engages the reader, but demands little logical incentive on his part. There are several additional forms of literary works, such as instructional, Scriptural, and counsel-oriented — however, they are all elastically defined, and the method of reading practiced cannot be fixed to the work’s genre.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Ruby Extension: HTML Truncation</title>
    <link rel="alternate" href="/2011/05/02/ruby-extension-html-truncation/"/>
    <id>/2011/05/02/ruby-extension-html-truncation/</id>
    <published>2011-05-02T00:00:00Z</published>
    <updated>2011-05-02T00:00:00Z</updated>
    <author>
      <name>Jonathan Martin</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;em&gt;Another tip (err hurdle) I came across during the production of this blog — truncating an HTML string. Easy, right?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It seems simple enough: shorten some basic text content from a long entry. It’s extremely popular in blogs, catalogs, portfolios, etc. and with good reason — the average browser wants to find content through screening, not mass scrolling.&lt;/p&gt;

&lt;p&gt;But a good trimmer must keep a few things in mind.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Don’t split words&lt;/li&gt;
  &lt;li&gt;Recognize/respect HTML tags&lt;/li&gt;
  &lt;li&gt;Parse HTML according to standards&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These add up to some pretty terse requirements once you actually get to coding. First, unless we want to manually parse HTML, we’ll have to use some standards based parser and loop through all the elements, until the specified number of characters/words (excluding tags!) is exceeded, at which point we append a user-defined tail and discard all other tags.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; &lt;em&gt;the latest version of this handy widget is now available as a gem! Check it out at &lt;a href="http://rubygems.org/gems/butter"&gt;rubygems.org/gems/butter&lt;/a&gt; or bundle it with gem install butter.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;Another tip (err hurdle) I came across during the production of this blog — truncating an HTML string. Easy, right?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It seems simple enough: shorten some basic text content from a long entry. It’s extremely popular in blogs, catalogs, portfolios, etc. and with good reason — the average browser wants to find content through screening, not mass scrolling.&lt;/p&gt;

&lt;p&gt;But a good trimmer must keep a few things in mind.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Don’t split words&lt;/li&gt;
  &lt;li&gt;Recognize/respect HTML tags&lt;/li&gt;
  &lt;li&gt;Parse HTML according to standards&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These add up to some pretty terse requirements once you actually get to coding. First, unless we want to manually parse HTML, we’ll have to use some standards based parser and loop through all the elements, until the specified number of characters/words (excluding tags!) is exceeded, at which point we append a user-defined tail and discard all other tags.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; &lt;em&gt;the latest version of this handy widget is now available as a gem! Check it out at &lt;a href="http://rubygems.org/gems/butter"&gt;rubygems.org/gems/butter&lt;/a&gt; or bundle it with gem install butter.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h2 id="first-attempt"&gt;First attempt&lt;/h2&gt;
&lt;p&gt;Solution 1 came from a blog, and was then heavily modified to make it work with a more modern interface.&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;rexml/parsers/pullparser&amp;#39;&lt;/span&gt;
&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;htmlentities&amp;#39;&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;
  &lt;span class="c1"&gt;# Truncate strings containing HTML code&lt;/span&gt;
  &lt;span class="c1"&gt;# Usage example: &amp;quot;string&amp;quot;.truncate_html(50, :word_cut =&amp;gt; false, :tail =&amp;gt; &amp;#39;[+]&amp;#39;)&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;truncate_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;opts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{})&lt;/span&gt;
    &lt;span class="n"&gt;opts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="ss"&gt;:word_cut&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:tail&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;amp;hellip;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;opts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ss"&gt;REXML&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Parsers&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;PullParser&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;coder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;HTMLEntities&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;
    &lt;span class="n"&gt;tags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;new_len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;len&lt;/span&gt;
    &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;has_next?&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;new_len&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
      &lt;span class="n"&gt;p_e&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pull&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;p_e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;event_type&lt;/span&gt;
      &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="ss"&gt;:start_element&lt;/span&gt;
        &lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;push&lt;/span&gt; &lt;span class="n"&gt;p_e&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;lt;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;last&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;attrs_to_s&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_e&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&amp;quot;&lt;/span&gt;
      &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="ss"&gt;:end_element&lt;/span&gt;
        &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;lt;/&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&amp;quot;&lt;/span&gt;
      &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="ss"&gt;:text&lt;/span&gt;
        &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;coder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_e&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;new_len&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;opts&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:word_cut&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
          &lt;span class="n"&gt;piece&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39; &amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;new_len&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;
          &lt;span class="n"&gt;piece&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_len&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;end&lt;/span&gt;
        &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;coder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;piece&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;new_len&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;
      &lt;span class="k"&gt;else&lt;/span&gt;
        &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;lt;!-- &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;p_e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inspect&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; --&amp;gt;&amp;quot;&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="n"&gt;tags&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
      &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;lt;/&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&amp;quot;&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;opts&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:tail&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;html_safe?&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
      &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html_safe&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;
      &lt;span class="n"&gt;results&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;

  &lt;span class="kp"&gt;private&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;attrs_to_s&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attrs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;attrs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;empty?&lt;/span&gt;
      &lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;
      &lt;span class="n"&gt;attrs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to_a&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="kp"&gt;attr&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="sx"&gt;%{&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="kp"&gt;attr&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sx"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="kp"&gt;attr&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sx"&gt;&amp;quot;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39; &amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;This worked great…at first. All went well in development, but once I launched into production and started using slightly more complex HTML, it completely crashed the index pages. What was the cause? An &lt;code&gt;&amp;lt;em&amp;gt;&lt;/code&gt; tag. Why? I have no clue, but I know where the problem occured: the REXML parser. On top of being an outdated parser (I suppose that includes choking on em tags), it is one of the &lt;strong&gt;slowest&lt;/strong&gt; parsers out there. So it looked like my nice little online script was about useless, and frankly it seemed way too complex/inelegant for our modern gem-based apps.&lt;/p&gt;

&lt;h2 id="final-attempt"&gt;Final attempt&lt;/h2&gt;
&lt;p&gt;Thankfully though, with some more searching I found an elegant solution using Nokogiri (the best parser gem by far!) and some creative word boundary logic. The bulk of this code (and comments) was designed by &lt;a href="http://github.com/Eleo"&gt;Eleo&lt;/a&gt;, but I modified the interface a bit (instance method instead of class method) and added a few other tweaks.&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;nokogiri&amp;#39;&lt;/span&gt;
&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;htmlentities&amp;#39;&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;truncate_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_words&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;opts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{})&lt;/span&gt;
    &lt;span class="n"&gt;opts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="ss"&gt;:word_cut&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:tail&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;amp;hellip;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;opts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tail&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;HTMLEntities&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;opts&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:tail&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ss"&gt;Nokogiri&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:HTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;
    &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;
      &lt;span class="c1"&gt;# we found a text node&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_a?&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;Nokogiri&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:XML&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;
        &lt;span class="c1"&gt;# we reached our limit, let&amp;#39;s get outta here!&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;num_words&lt;/span&gt;
        &lt;span class="n"&gt;previous&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;

      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="c1"&gt;# this node has children, can&amp;#39;t be a text node,&lt;/span&gt;
        &lt;span class="c1"&gt;# lets descend and look for text nodes&lt;/span&gt;
        &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;
      &lt;span class="k"&gt;elsif&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nil?&lt;/span&gt;
        &lt;span class="c1"&gt;#this has no children, but has a sibling, let&amp;#39;s check it out&lt;/span&gt;
        &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;
      &lt;span class="k"&gt;else&lt;/span&gt;
        &lt;span class="c1"&gt;# we are the last child, we need to ascend until we are&lt;/span&gt;
        &lt;span class="c1"&gt;# either done or find a sibling to continue on to&lt;/span&gt;
        &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_a?&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;Nokogiri&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:HTML&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nil?&lt;/span&gt;
          &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt;
        &lt;span class="k"&gt;end&lt;/span&gt;

        &lt;span class="c1"&gt;# we&amp;#39;ve reached the top and found no more text nodes, break&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_a?&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;Nokogiri&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:HTML&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
          &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;
          &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;
        &lt;span class="k"&gt;end&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;num_words&lt;/span&gt;
      &lt;span class="k"&gt;unless&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;num_words&lt;/span&gt;
      &lt;span class="n"&gt;new_content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;

      &lt;span class="c1"&gt;# If we&amp;#39;re here, the last text node we counted eclipsed the number of words&lt;/span&gt;
      &lt;span class="c1"&gt;# that we want, so we need to cut down on words.  The easiest way to think about&lt;/span&gt;
      &lt;span class="c1"&gt;# this is that without this node we&amp;#39;d have fewer words than the limit, so all&lt;/span&gt;
      &lt;span class="c1"&gt;# the previous words plus a limited number of words from this node are needed.&lt;/span&gt;
      &lt;span class="c1"&gt;# We simply need to figure out how many words are needed and grab that many.&lt;/span&gt;
      &lt;span class="c1"&gt;# Then we need to -subtract- an index, because the first word would be index zero.&lt;/span&gt;

      &lt;span class="c1"&gt;# For example, given:&lt;/span&gt;
      &lt;span class="c1"&gt;# &amp;lt;p&amp;gt;Testing this HTML truncater.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;To see if its working.&amp;lt;/p&amp;gt;&lt;/span&gt;
      &lt;span class="c1"&gt;# Let&amp;#39;s say I want 6 words.  The correct returned string would be:&lt;/span&gt;
      &lt;span class="c1"&gt;# &amp;lt;p&amp;gt;Testing this HTML truncater.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;To see...&amp;lt;/p&amp;gt;&lt;/span&gt;
      &lt;span class="c1"&gt;# All the words in both paragraphs = 9&lt;/span&gt;
      &lt;span class="c1"&gt;# The last paragraph is the one that breaks the limit.  How many words would we&lt;/span&gt;
      &lt;span class="c1"&gt;# have without it? 4.  But we want up to 6, so we might as well get that many.&lt;/span&gt;
      &lt;span class="c1"&gt;# 6 - 4 = 2, so we get 2 words from this node, but words #1-2 are indices #0-1, so&lt;/span&gt;
      &lt;span class="c1"&gt;# we subtract 1.  If this gives us -1, we want nothing from this node. So go back to&lt;/span&gt;
      &lt;span class="c1"&gt;# the previous node instead.&lt;/span&gt;
      &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;num_words&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;new_content&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
      &lt;span class="n"&gt;new_content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new_content&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;.index&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new_content&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39; &amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;tail&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;
        &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;previous&lt;/span&gt;
        &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;tail&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;

      &lt;span class="c1"&gt;# remove everything else&lt;/span&gt;
      &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_a?&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;Nokogiri&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:HTML&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nil?&lt;/span&gt;
          &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;
        &lt;span class="k"&gt;end&lt;/span&gt;
        &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;

    &lt;span class="c1"&gt;# now we grab the html and not the text.&lt;/span&gt;
    &lt;span class="c1"&gt;# we do first because nokogiri adds html and body tags&lt;/span&gt;
    &lt;span class="c1"&gt;# which we don&amp;#39;t want&lt;/span&gt;
    &lt;span class="n"&gt;truncated&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inner_html&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;html_safe?&lt;/span&gt;
      &lt;span class="n"&gt;truncated&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html_safe&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;
      &lt;span class="n"&gt;truncated&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;I’ve been really happy with the success of this particular implementation. In addition to using Nokogiri, the code is easier to understand and allows for the input of a number of words, rather than number of characters.&lt;/p&gt;

&lt;h2 id="future-additions"&gt;Future additions&lt;/h2&gt;
&lt;p&gt;One of the tweaks I made was the options hash, as I foresee eventually adding more options to the truncate operation, such as using a character count as the length, ability to split before the word boundary, etc. For the moment however, this approach has worked really well. Remember to add this code to &lt;code&gt;string.rb&lt;/code&gt; in your lib directory, and include it with &lt;code&gt;auto_require&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;As always, if you guys have any other options you think might be useful to the &lt;code&gt;truncate_html&lt;/code&gt; method, or alternate solutions for that matter, mention it in the comments!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Will, Predestination, and Calvinism</title>
    <link rel="alternate" href="/2011/04/30/will-predestination-and-calvinism/"/>
    <id>/2011/04/30/will-predestination-and-calvinism/</id>
    <published>2011-04-30T00:00:00Z</published>
    <updated>2011-04-30T00:00:00Z</updated>
    <author>
      <name>Jonathan Martin</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;em&gt;Figures, I wanted to reply to a comment and ended up writing a four-page essay! As that is certainly a little lengthy for a reply, I decided to expand it into an article so I could more fully (though it is still severely incomplete) address the topics of Calvinism, free will, predestination, etc.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I’ve been surprised by the amount of discussion generated by &lt;a href="/2011/04/24/two-sinners-and-a-saint"&gt;Two Sinners and a Saint;&lt;/a&gt; I think however the discussion should be turned from a Calvinism/Arminianism to a more relevant discussion of that article topic, as the purpose of this blog and the comments is not to be a forum that trails off on side topics.&lt;/p&gt;

&lt;p&gt;That being said, I would like to “throw my hat in the ring” with my thoughts on the subject.&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;Figures, I wanted to reply to a comment and ended up writing a four-page essay! As that is certainly a little lengthy for a reply, I decided to expand it into an article so I could more fully (though it is still severely incomplete) address the topics of Calvinism, free will, predestination, etc.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I’ve been surprised by the amount of discussion generated by &lt;a href="/2011/04/24/two-sinners-and-a-saint"&gt;Two Sinners and a Saint;&lt;/a&gt; I think however the discussion should be turned from a Calvinism/Arminianism to a more relevant discussion of that article topic, as the purpose of this blog and the comments is not to be a forum that trails off on side topics.&lt;/p&gt;

&lt;p&gt;That being said, I would like to “throw my hat in the ring” with my thoughts on the subject.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;I really enjoyed reading Wesley’s sermons on the topic; the language is a little bit “involved” (a great mental exercise) but it is a great read nonetheless. My favorites are &lt;a href="http://new.gbgm-umc.org/umhistory/wesley/sermons/128/"&gt;Sermon 128&lt;/a&gt; and &lt;a href="http://new.gbgm-umc.org/umhistory/wesley/sermons/58/"&gt;Sermon 58.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I should also like to speak myself on the subject with some of my observations. Let me preface this discussion by emphasizing that, though I disagree with Calvinism, I do not wish alienate myself from those who hold to his postulates; if we love, serve, and put our faith in the same Lord, then we are rather allies than enemies, and as such I hope that addressing these topics will only strengthen and mature our faith.&lt;/p&gt;

&lt;h1 id="the-basic-premises"&gt;The basic premises.&lt;/h1&gt;

&lt;h2 id="does-god-desire-that-all-would-be-saved"&gt;Does God desire that all would be saved?&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;The Lord does not delay and is not tardy or slow about what He promises, according to some people’s conception of slowness, but He is long-suffering (extraordinarily patient) toward you, not desiring that any should perish, but that all should turn to repentance. — 2 Peter 3:9&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This first “stepping stone” reminds us that God desires that all would be saved, and wants no one to go to Hell; that’s His love. However, our God is a just God, and as such His desire that all would be saved conflicts with His just nature, and consequently He must give us our due reward or punishment. Thus, we are reminded that God’s desires are not necessarily His actions. However, perhaps this seems to be a hasty conclusion, which I will elaborate on.&lt;/p&gt;

&lt;p&gt;For the purpose of argument, I will momentarily assume the mindset of Calvinism: that God, irregardless of a person’s free will and character (which is presumed irrelevant since they are preordained) irrevocably chooses some for salvation and others for Hell. On this premise then, God created humanity with the desire and action (in Calvinism the two are equated with each other), of destining all to Hell apart from salvation. We must conclude that God therefore created the earth and willed (both in desire and action) that it be fallen and bound to curse. History and the Bible tell us that God sent Christ for our salvation, but in predestining the world to condemnation, did He not also will (desire and action) that His Son be humiliated, tormented, scorned, separated from the Father, made an object of ridicule, crucified, and made to take on all the sins of the world? Have we not made God a tyrant who condemns His own Son simply because he willed that the world be bound to corruption irregardless of the free will (which is presumed irrelevant) of the condemned?&lt;/p&gt;

&lt;p&gt;From the Scriptures, we find that Jesus (the incarnation of God) did not wish to be crucified. Yet He was crucified, because He said “not my will (Strong’s 2307: to desire, to want, etc.) but your will (same word) be done.” In effect, Christ (God Himself!) said, “I do not want to be tortured, separated from you, and crucified; but Father, I know that it is your desire that man be reconciled to you, and in consequence I must lay down my life so that your desire of reconciliation can be realized.” Have we not a contradiction of two wills? We therefore are reminded yet again that desire does not correlate to effect.&lt;/p&gt;

&lt;h2 id="how-are-we-predestined"&gt;How are we predestined?&lt;/h2&gt;

&lt;p&gt;Having discerned that God desires that all be saved (I may endeavor to write further on the topic of Will vs Action), let us move on to another stone: that of God’s predestination.&lt;/p&gt;

&lt;p&gt;Romans 9 is a wonderful exercise in context. Through vs. 27, Paul speaks of God predestining the footsteps of all, so that His glory might be revealed. Then in vs. 30, Paul reminds us of the purpose of this discussion:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;What shall we say, then? That Gentiles who did not pursue righteousness have attained it, that is, a righteousness that is by faith; but that Israel who pursued a law that would lead to righteousness did not succeed in reaching that law. Why? Because they did not pursue it by faith, but as if it were based on works. They have stumbled over the stumbling stone. — Romans 9:30–32&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Paul has directly summarized all that was said before: God did not decide on a whim that certain people only would be saved, irregardless of free will; he ordains our footsteps (or our purpose, such as that of Pharaoh) in order that He may be glorified. And he reminds us that Israel was (is) an instrument of salvation; that Israel “isn’t not” entirely saved because they were not “chosen.” For indeed, they are called God’s chosen people! It is because they did not pursue salvation by faith. Thus, we see that God has not forcibly chosen whether we will be saved or condemned; rather, he has lain out the course of the universe, using all as instruments in His grand plan according to their rejection or acceptance of Him.&lt;/p&gt;

&lt;p&gt;I am hardly as eloquent as Wesley was in sermon 58, so therefore I encourage the reader to read it for himself; but nonetheless I will attempt to summarize the “how” of predestination.&lt;/p&gt;

&lt;p&gt;God is not confined to time, and as such His knowledge is timeless. Consequently, He knows if we reject or accept him of our will (I speak in present tense because tense makes little sense to describe God), and as such (as per the previous point) he predestines the paths of all such that His glorious plan may come to pass. It helps to think of non-custom machinery parts; it takes time to assemble the pieces, but the builder knows what He wants the end result to be, and as such He uses a number of parts (which he did not necessarily custom make) which already have shape and form, to accomplish that end. Admittedly, it is a very limited analogy, but useful nonetheless.&lt;/p&gt;

&lt;p&gt;Elaborating, recall Romans 8:28–30:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;And we know that in all things God works for the good of those who love him, who have been called according to his purpose. For those God foreknew he also predestined to be conformed to the likeness of his Son, that he might be the firstborn among many brothers. And those he predestined, he also called; those he called, he also justified; those he justified, he also glorified. — Romans 8:28–30&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I would like to here borrow from Wesley’s excellent summary – as stated earlier, God is not confined by time-based observation, and knows our choices before we are forced to make them. In consequence, he knows us, as though before we know Him, which in human terms is called foreknowledge. However, this is perhaps a limited term since God does not have foreknowledge, being outside of time.&lt;/p&gt;

&lt;p&gt;Thus, those whom God knew – those who of their own will commit their life to Christ – he did also predestine (set their paths such that their will to serve God would be fabricated into His grand scheme), and those whom he predestined he called, etc. Therefore, we see that those who are glorified to salvation are those whom God knows (in human terms, “foreknew”). Here I will quote Wesley’s analogy (though I have endeavored not to poorly recount his incredible dissertation):&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;But observe: We must not think [those who are saved] are because he knows them. No: he knows them because they are. Just as I (if one may be allowed to compare the things of men with the deep things of God) now know the sun shines: Yet the sun does not shine because I know it, but I know it because he shines. My knowledge supposes the sun to shine; but does not in anywise cause it. In like manner, God knows that man sins; for he knows all things: Yet we do not sin because he knows it, but he knows it because we sin; and his knowledge supposes our sin, but does not in anywise cause it. In a word, God, looking on all ages, from the creation to the consummation, as a moment, and seeing at once whatever is in the hearts of all the children of men, knows every one that does or does not believe, in every age or nation. Yet what he knows, whether faith or unbelief, is in nowise caused by his knowledge. Men are as free in believing or not believing as if he did not know it at all. — John Wesley, Sermon 58&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id="reasoning-in-light-of-calvinistic-consequence"&gt;Reasoning in light of Calvinistic consequence&lt;/h2&gt;

&lt;p&gt;Granted, God’s ways are high above ours, but it is not from fallen nature that we derive logic. Rather, logical reasoning is a gift, and error comes to those who erroneously form their arguments. And as such, it is not wrong that we logically attempt to discuss the things of God, as long as we realize the limits of our knowledge if we are to include such limited observations as premises.&lt;/p&gt;

&lt;p&gt;Bearing this in mind, I will proceed with what a logical mind must surmise about the characteristics of God.&lt;/p&gt;

&lt;p&gt;If we are indeed chosen irregardless of our will, for what reason ought we to endeavor to seek salvation, or to encourage the spread of the Gospel, or to witness? Have we not in fact nullified God’s purposes in mission work? Again, why is the New Testament so concerned with warning the church to cling to Christ, if it makes no difference in the salvation “distribution?” For indeed, we do not do good things unless we have some reward or purpose in them; our reward in faith is salvation from the punishment we deserve, and our reward in good works (besides the rewards God promises us in Heaven) is seeing others come into salvation freely.&lt;/p&gt;

&lt;p&gt;Ought we not to conclude that there is indeed some usefulness here on earth in spreading the Gospel and encouraging one another to faithfulness in devotion?&lt;/p&gt;

&lt;h1 id="final-remarks"&gt;Final remarks&lt;/h1&gt;

&lt;p&gt;I regret that I have not time to complete this already lengthy dissertation on Calvinism, grace, predestination, free will, etc. but in the meantime I encourage you to read Wesley’s sermons on these topics (&lt;a href="http://new.gbgm-umc.org/umhistory/wesley/sermons/128/"&gt;Sermon 128&lt;/a&gt; and &lt;a href="http://new.gbgm-umc.org/umhistory/wesley/sermons/58/"&gt;Sermon 58&lt;/a&gt;); with fewer pages he has formulated easier to understand (even with his dialect!) treatise on these “touchy” theological questions.&lt;/p&gt;

&lt;p&gt;In consequence of the “touchiness” of this topic, comments will be closed, as I do not want them to inevitably turn into a hostile forum that heats up with every reply. However, I am certainly interested in hearing any additions you might have to this lengthy topic; feel free to email me, though I disclaim that my time is too limited to carry on lengthy email exchanges.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Rails 3: Action Mailer</title>
    <link rel="alternate" href="/2011/04/29/rails-3-action-mailer/"/>
    <id>/2011/04/29/rails-3-action-mailer/</id>
    <published>2011-04-29T00:00:00Z</published>
    <updated>2011-04-29T00:00:00Z</updated>
    <author>
      <name>Jonathan Martin</name>
    </author>
    <summary type="html">&lt;p&gt;As a result of designing this blog, I’ve come to appreciate the refinement of Rails 3, and the drudgery of a few “less than perfect” spots.&lt;/p&gt;

&lt;p&gt;ActionMailer (now powered by the Mail gem instead of TMail) is an incredible refactoring of the traditional Rails 2.x email system; frankly, before Rails 3, the email system was anything but elegant — besides the clunky API, none of the traditional view helpers were available, and multipart emails with attachments were hackish.&lt;/p&gt;

&lt;p&gt;The new system takes a huge step in the right direction by incorporating a sleek API interface and merge of ActionMailer with the traditional ActionController/ActionView. In essence, whereas before the mailer and controller/views were entirely separate entities, ActionMailer now inherits from these classes, and consequently acts much more like a traditional view. This approach &lt;strong&gt;hugely&lt;/strong&gt; simplifies the design process by recognizing the similarity between HTML webpages and HTML email.&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;As a result of designing this blog, I’ve come to appreciate the refinement of Rails 3, and the drudgery of a few “less than perfect” spots.&lt;/p&gt;

&lt;p&gt;ActionMailer (now powered by the Mail gem instead of TMail) is an incredible refactoring of the traditional Rails 2.x email system; frankly, before Rails 3, the email system was anything but elegant — besides the clunky API, none of the traditional view helpers were available, and multipart emails with attachments were hackish.&lt;/p&gt;

&lt;p&gt;The new system takes a huge step in the right direction by incorporating a sleek API interface and merge of ActionMailer with the traditional ActionController/ActionView. In essence, whereas before the mailer and controller/views were entirely separate entities, ActionMailer now inherits from these classes, and consequently acts much more like a traditional view. This approach &lt;strong&gt;hugely&lt;/strong&gt; simplifies the design process by recognizing the similarity between HTML webpages and HTML email.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;However,&lt;/strong&gt; I still have a few “nits to pick.” There are still a number of kinks in the ActionMailer, which I will address here.&lt;/p&gt;

&lt;h2 id="named-tofrom-addresses"&gt;Named to/from addresses&lt;/h2&gt;
&lt;p&gt;Admittedly, this isn’t a biggy, but it’d be a nice addition. Currently, if you want to include a name in the from/to address, you have to manually form the string.&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1
2&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;mail&lt;/span&gt; &lt;span class="ss"&gt;:to&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="se"&gt;\&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="vi"&gt;@name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\&amp;quot;&lt;/span&gt;&lt;span class="s2"&gt; &amp;lt;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="vi"&gt;@email&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="ss"&gt;:subject&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="vi"&gt;@name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; left a comment&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;For me, this is just difficult to read, and I easily crashed my application with misplaced quote/hash marks. I’d prefer something like:&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1
2&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;mail&lt;/span&gt; &lt;span class="ss"&gt;:to&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;:email&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="vi"&gt;@email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:name&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="vi"&gt;@name&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
     &lt;span class="ss"&gt;:subject&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="vi"&gt;@name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; left a comment&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;Perhaps it’s a little more text, but it is infinitely more readable for those of us that don’t enjoy mental text escaping.&lt;/p&gt;

&lt;h2 id="simpleformat"&gt;simple_format&lt;/h2&gt;
&lt;p&gt;To my knowledge, this is simply a 3.0.5 bug, but if you call simple_format from the email template (to render out line breaks), the behavior you get is terribly unusual, and it turns out this helper is overwritten with a private method.&lt;/p&gt;

&lt;p&gt;Until the private method is renamed in a later version, I had to make a custom helper method (basically a copy paste from the original &lt;code&gt;simple_format&lt;/code&gt; source) and called it &lt;code&gt;simpler_format&lt;/code&gt;.&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;simpler_format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;html_options&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{})&lt;/span&gt;
  &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html_safe&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nil?&lt;/span&gt;
  &lt;span class="n"&gt;start_tag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;p&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;html_options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sanitize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;unless&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:sanitize&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kp"&gt;false&lt;/span&gt;
  &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gsub!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/\r\n?/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                    &lt;span class="c1"&gt;# \r\n and \r -&amp;gt; \n&lt;/span&gt;
  &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gsub!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/\n\n+/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\n\n&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;start_tag&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 2+ newline  -&amp;gt; paragraph&lt;/span&gt;
  &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gsub!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/([^\n]\n)(?=[^\n])/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;\1&amp;lt;br /&amp;gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# 1 newline   -&amp;gt; br&lt;/span&gt;
  &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;start_tag&lt;/span&gt;
  &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html_safe&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;safe_concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;/p&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;But wait, how you do use custom helpers in an email template? Well, that’s next.&lt;/p&gt;

&lt;h2 id="custom-mailer-helpers"&gt;Custom mailer helpers&lt;/h2&gt;
&lt;p&gt;It turns out that helpers are not included by default for the ActionMailer views — while it may make sense not to do so simply because you don’t usually need the webpage helpers in emails, I found myself needing several of my helpers, simply because the emails I send out are meant to vaguely resemble the website. At any rate, it’s not a deal breaker, but I think Rails 3 could stand to have auto-generated helper files that are auto-included for each mailer. Finally, just for kicks the “helper” method ought to include the :all option that is available in ActionView.&lt;/p&gt;

&lt;p&gt;I made a module called MailHelper in the helpers directory, then included it with the classic “helper :name” command from the mailer model.&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1
2
3
4&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CommentMailer&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="ss"&gt;ActionMailer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;
  &lt;span class="n"&gt;helper&lt;/span&gt; &lt;span class="ss"&gt;:mail&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:layout&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;.&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;As you can see, I also included my layout helper, which has all of my convenient layout “yields” — these come in handy for webpages and HTML email.&lt;/p&gt;

&lt;h2 id="absolute-path-defaulthost-and-assethost"&gt;Absolute path: default_host and asset_host&lt;/h2&gt;
&lt;p&gt;I had a less than enjoyable time trying to get &lt;code&gt;link_to&lt;/code&gt;, &lt;code&gt;image_tag&lt;/code&gt;, and &lt;code&gt;post_url&lt;/code&gt; to output absolute urls instead of the traditional relative path. From what I had read, you simply have to add the following configuration to your environment.rb:&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="ss"&gt;ActionController&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;default_url_options&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:host&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;nybblr.com&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;That should do the trick, right? Well…no. That changed in Rails 3 with the move to ActionMailer, so now the config option is:&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="ss"&gt;ActionMailer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;default_url_options&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:host&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;nybblr.com&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;This seemed to work great for &lt;code&gt;link_to&lt;/code&gt; and &lt;code&gt;path_url&lt;/code&gt;, but when I tried &lt;code&gt;image_tag&lt;/code&gt;, I again was back to relative paths. Turns out there is yet another option for both ActionController and ActionMailer necessary for “asset” files (in case they are hosted on another server).&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;1
2
3&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;# Notice that the host must be prefixed with &amp;quot;http://&amp;quot; since it assumes the host is a full web URI.&lt;/span&gt;
&lt;span class="ss"&gt;ActionController&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;asset_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;http://nybblr.com&amp;#39;&lt;/span&gt;
&lt;span class="ss"&gt;ActionMailer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;asset_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;http://nybblr.com&amp;#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;So this seems to work, but frankly I hate hardcoding in host URLs — I wanted this to work in development and production &lt;strong&gt;regardless&lt;/strong&gt; of the host domain, so to do that I would have to call &lt;code&gt;request.host_with_port&lt;/code&gt;. However, since the request object is only available in the controllers/views, we need to set those configuration options before the actions. I accomplished this with a before filter:&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ApplicationController&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="ss"&gt;ActionController&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;
  &lt;span class="n"&gt;before_filter&lt;/span&gt; &lt;span class="ss"&gt;:configure_default_host&lt;/span&gt;

  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;.&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;

  &lt;span class="kp"&gt;private&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;configure_default_host&lt;/span&gt;
    &lt;span class="ss"&gt;ActionController&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;default_url_options&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:host&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;host_with_port&lt;/span&gt;
    &lt;span class="ss"&gt;ActionController&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;asset_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;http://&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;host_with_port&lt;/span&gt;
    &lt;span class="ss"&gt;ActionMailer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;default_url_options&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:host&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;host_with_port&lt;/span&gt;
    &lt;span class="ss"&gt;ActionMailer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Base&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;asset_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;http://&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;host_with_port&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;.&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;This worked perfectly; granted, I didn’t like having to clutter up my ApplicationController, but that is far better than manually rendering links/overwriting asset helpers in the email templates, hardwiring hosts, and cluttering up the view.&lt;/p&gt;

&lt;h2 id="so-now-that-im-done-bashing-actionmailer"&gt;So now that I’m done bashing ActionMailer…&lt;/h2&gt;
&lt;p&gt;ActionMailer really is a &lt;em&gt;huge&lt;/em&gt; relief compared to 2.x; I’d say it’s a pretty remarkable Rails achievement. It’s just shy of perfection.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Two Sinners and a Saint</title>
    <link rel="alternate" href="/2011/04/24/two-sinners-and-a-saint/"/>
    <id>/2011/04/24/two-sinners-and-a-saint/</id>
    <published>2011-04-24T00:00:00Z</published>
    <updated>2011-04-24T00:00:00Z</updated>
    <author>
      <name>LaJoie Ward</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;em&gt;Thanks to LaJoie Ward, a good friend of mine, you won’t have to listen to my ramblings alone. She’s an incredible Christian writer (her narratives are amazing!) and scholar. If you enjoy her work as much as I do, check out her personal blog &lt;a href="http://thoughtsofjoy17.blogspot.com"&gt;Thought of Joy.&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Your character is who you are inside; it’s created in the small moments but comes out when you’re under pressure.&lt;/p&gt;

&lt;p&gt;Judas and Peter were both with Jesus for three and a half years. They both heard his teachings, traveled with him, and did his bidding. And they both committed terrible betrayals against Jesus. But these men’s lives ended in drastically different ways. Judas, filled with guilt at the realization of what he had done, went out and hung himself. Peter, though he was sorrowful for having disowned his master and friend, was sincerely repentant, and was welcomed back by Jesus after the resurrection. What made the difference?&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;Thanks to LaJoie Ward, a good friend of mine, you won’t have to listen to my ramblings alone. She’s an incredible Christian writer (her narratives are amazing!) and scholar. If you enjoy her work as much as I do, check out her personal blog &lt;a href="http://thoughtsofjoy17.blogspot.com"&gt;Thought of Joy.&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Your character is who you are inside; it’s created in the small moments but comes out when you’re under pressure.&lt;/p&gt;

&lt;p&gt;Judas and Peter were both with Jesus for three and a half years. They both heard his teachings, traveled with him, and did his bidding. And they both committed terrible betrayals against Jesus. But these men’s lives ended in drastically different ways. Judas, filled with guilt at the realization of what he had done, went out and hung himself. Peter, though he was sorrowful for having disowned his master and friend, was sincerely repentant, and was welcomed back by Jesus after the resurrection. What made the difference?&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Peter and Judas had both been creating their character over the span of their lives. Both had made various choices that affected who they became. And both reaped the outcome of their choices when the going got tough.&lt;/p&gt;

&lt;p&gt;We read in several places that Judas had begun to make choices long ago to put something else as the master of his heart, though I believe he did have a genuine love for Jesus at one time. As Jesus said, no one can serve two masters. When it came down to the duel between Judas’ masters, Jesus lost.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“No one can serve two masters. Either he will hate the one and love the other, or he will be devoted to the one and despise the other. You cannot serve both God and Money.” — Matthew 6:24&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;“Then Mary took about a pint of pure nard, an expensive perfume; she poured it on Jesus’ feet and wiped his feet with her hair. And the house was filled with the fragrance of the perfume. But one of his disciples, Judas Iscariot, who was later to betray him, objected, “Why wasn’t this perfume sold and the money given to the poor? It was worth a year’s wages.’ He did not say this because he cared about the poor but because he was a thief; as keeper of the money bag, he used to help himself to what was put into it.” — John 12:3–6&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;“[Judas] asked, “What are you willing to give me if I deliver him over to you?’ So they counted out for him thirty pieces of silver.” — Matthew 26:15&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Judas, little by little, began to serve money, until at last it became his idol and his master. He finally realized what he had done, and who he had lost. He realized that he had made a terrible mistake, and that money had not been a worthwhile thing to live for. But rather than repenting, Judas let his remorse and guilt drag him into despair and drive him to his death.&lt;/p&gt;

&lt;p&gt;Peter, on the other hand, though he was far from perfect, was pursuing Jesus, his Lord. Though fear came between them, Peter ultimately went on to give up his life for Jesus. Early on, Peter recognized that Jesus was the single most important thing for which he could live.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“You do not want to leave too, do you?” Jesus asked the Twelve. Simon Peter answered him, “Lord, to whom shall we go? You have the words of eternal life. We believe and know that you are the Holy One of God. Then Jesus replied, “Have I not chosen you, the Twelve? Yet one of you is a devil!” (He meant Judas, the son of Simon Iscariot, who, though one of the Twelve, was later to betray him.)” — John 6:67–69&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Interestingly enough, just as Peter and the others are showing their commitment to following the Lord, Jesus singles out the betrayer as an exception. One of them is not following Him alone. But Peter was earnestly in pursuit of Jesus, and Jesus made all the difference in Peter’s life.&lt;/p&gt;

&lt;p&gt;What are you in pursuit of? What you choose each day to put first in your life is what you will run to when the going gets tough. And the only one strong enough to hold you in your darkest hour is the Lord. Choose Him today — choose Him every day.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Rails 3: Auto Require</title>
    <link rel="alternate" href="/2011/04/24/rails-3-auto-require/"/>
    <id>/2011/04/24/rails-3-auto-require/</id>
    <published>2011-04-24T00:00:00Z</published>
    <updated>2011-04-24T00:00:00Z</updated>
    <author>
      <name>Jonathan Martin</name>
    </author>
    <summary type="html">&lt;p&gt;During the process of coding my blog, I came across the need for a truncation feature (another post in and of itself). So I made a new file under the lib directory called string.rb which added a truncate_html function to the String class. Lo and behold, whenever I called the function, the console printed an error stating that no such function existed.&lt;/p&gt;

&lt;p&gt;In Rails 3, lib files are lazy loaded — this can be adjusted by adding the first line to the config/application.rb file. Restarted the server, but still I received the error.&lt;/p&gt;

&lt;p&gt;</summary>
    <content type="html">&lt;p&gt;During the process of coding my blog, I came across the need for a truncation feature (another post in and of itself). So I made a new file under the lib directory called string.rb which added a truncate_html function to the String class. Lo and behold, whenever I called the function, the console printed an error stating that no such function existed.&lt;/p&gt;

&lt;p&gt;In Rails 3, lib files are lazy loaded — this can be adjusted by adding the first line to the config/application.rb file. Restarted the server, but still I received the error.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Not only does Rails 3 no longer auto load the lib directory, but class extensions (as opposed to custom classes) are not auto required if the file name is that of a system class, which meant that the custom methods I defined for the String class are never added. To get around this, I made an initializer that simply auto requires any auto loaded files — &lt;code&gt;config/initializers/auto_require.rb&lt;/code&gt;.&lt;/p&gt;

&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;# config/application.rb&lt;/span&gt;
&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;autoload_paths&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/lib&amp;quot;&lt;/span&gt;

&lt;span class="c1"&gt;# config/initializers/auto_require.rb&lt;/span&gt;
&lt;span class="c1"&gt;# Cycles through autoload_paths and requires them so that class methods are loaded&lt;/span&gt;
&lt;span class="ss"&gt;Rails&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="ss"&gt;:Application&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;autoload_paths&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
  &lt;span class="no"&gt;Dir&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/*.rb&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;].&lt;/span&gt;&lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
      &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Auto-required &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
      &lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="nb"&gt;p&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;Simple concept, but very useful as most lib files tend to be extensions of the core classes. We’ll see an application of this handy script when I write up on HTML truncation.&lt;/p&gt;
</content>
  </entry>
</feed>
