I gotta have my orange juice.

Jesu, Juva

1 Samuel

with one comment

Chapter summaries in 1 Samuel.

1 Samuel 1 – Hannah prays for a son; Eli blesses her; Hannah presents Samuel to the LORD.
1 Samuel 2 – Hannah prays in praise to God; Samuel ministers to the LORD. Eli’s sons are evil; Eli rebukes them and is himself rebuked by God.
1 Samuel 3 – God calls Samuel in the night and prophesies of Eli’s punishment for not restraining his sons; Samuel grows and is established as a prophet.
1 Samuel 4 – Eli’s sons die in battle with the Philistines and the ark of the covenant is captured; Eli dies upon hearing the news.
1 Samuel 5 – God wreaks havoc on every Philistine city that keeps the ark of the covenant.
1 Samuel 6 – The Philistines return the ark of the covenant.
1 Samuel 7 – The ark remains at the house of Abinadab and his son Eleazar. Samuel judges Israel; God defeats the Philistines for Israel.
1 Samuel 8 – Samuel’s sons pervert justice; the people reject God as king and seek a king; Samuel warns Israel of the consequences of a king.
1 Samuel 9 – Saul seeks Samuel’s counsel; God chooses Saul as king.
1 Samuel 10 – Saul is anointed, prophesies, and is proclaimed as king.
1 Samuel 11 – Saul delivers Jabesh-Gilead from the Ammonites; Israel confirms Saul as king.
1 Samuel 12 – Samuel reminds Israel of God’s goodness to them in spite of their faithlessness; he warns Israel of the consequences of rebelling against God instead of fearing and serving him.
1 Samuel 13 – Saul impatiently offers an unlawful sacrifice; Israel faces the Philistines in battle.
1 Samuel 14 – Jonathan kills 20 Philistines; the LORD confuses the Philistines, and Israel rises up and defeats them. Saul curses anyone who eats food, but Jonathan is spared. Saul battles Israel’s enemies.
1 Samuel 15 – Saul disobeys the LORD by not devoting spoil to destruction. The LORD rejects Saul as king of Israel.
1 Samuel 16 – God chooses David as king; Samuel anoints David and the Spirit of the LORD rested on him; David serves Saul as armor-bearer and musician.
1 Samuel 17 – Goliath taunts Israel; David kills Goliath “that all the earth may know that there is a God in Israel, and . . . the LORD saves not with sword and spear.” Israel plunders the Philistines.
1 Samuel 18 – Jonathan loves David; David has great success in battle; Saul tries to kill David, and is in fearful awe of him; David marries Michal for a bride-price of 200 Philistine foreskins.
1 Samuel 19 – Saul seeks to kill David; David flees; Saul’s messengers, and Saul himself, seek David but prophesy before Samuel instead.
1 Samuel 20 – Jonathan warns David that Saul intends to kill him.
1 Samuel 21 – Ahimelech the priest gives David and his men holy bread; David and his men flee to Gath and David pretends to be mad.
1 Samuel 22 – David gathers 400 men to himself; Saul kills the priests at Nob for giving aid to David.
1 Samuel 23 – David saves the city of Keliah from the Philistines, and escapes Saul; Saul continues to pursue David.
1 Samuel 24 – David spares Saul when he enters a cave; Saul returns home.
1 Samuel 25 – Samuel dies; Nabal spurns David, but Abigail blesses David and averts his vengeance. God puts Nabal to death, and David takes Abigail and Ahinoam as wives.
1 Samuel 26 – David enters Saul’s camp and takes his spear and jar, sparing Saul; Saul returns home.
1 Samuel 27 – David lives among the Philistines in Ziklag, secretly making raids against other nations but pretending to have raided Israel.
1 Samuel 28 – Philistia goes to war against Israel; Saul visits a medium, who summons Samuel, who predicts Saul’s defeat and the death of Saul and his sons.
1 Samuel 29 – The lords of the Philistines send David home; the Philistine army goes up to Jezreel.
1 Samuel 30 – The Amalekites take David’s wives and property; David pursues and defeats them, restoring all his men’s family and property, even to those who were too exhausted to help. David sends gifts to the leaders in Judah.
1 Samuel 31 – The Philistines kill Saul’s sons; Saul is wounded and kills himself.

Written by Scott Moonen

March 11, 2008 at 3:57 am

Posted in Bible Chapter Summaries

Tagged with ,

Computer monster

with one comment

Speaking of Sesame Street (see my last post), below is a funny video of a proto-Cookie Monster eating a computer. This monster is a little bigger than Cookie Monster and has fangs. Unlike Cookie Monster, he has a hole in his mouth and actually consumes some of what he destroys. Apparently he was the origin of Cookie Monster. My favorite part is the Jabberwocky reference. What’s yours?

HT: Jeffrey Meyers

Written by Scott Moonen

March 3, 2008 at 9:24 am

Richard Scarry and hexadecimal

with 2 comments

When you read a hexadecimal number out loud, how do you pronounce the letters?

At my workplace, I’ve grown used to our custom of pronouncing the letters using the Joint Army/Navy Phonetic Alphabet standardized in 1941. The letter digits are pronounced Able, Baker, Charlie, Dog, Easy and Fox. Under this scheme, the hexadecimal number 0x7F8D3BC0 would be pronounced “Seven Fox Eight Dog Three Baker Charlie Zero.” This was disorienting to me at first, but after eight years this is now so natural that this is how I pronounce the digits in my mind even if I’m not speaking them.

We’ve started collecting Richard Scarry’s children’s books. Richard Scarry writes with a degree of detail and whimsy that holds an adult’s interest — much like old-school Sesame Street. (How far it has fallen — modern-day Sesame Street is much too postmodern, pluralistic, saccharine and juvenile for my taste. I console myself by searching for old Sesame Street clips on Youtube.) Recently I was amused and pleased to discover that one of Richard Scarry’s characters is named Able Baker Charlie! What a strange juxtaposition of worlds for me — programming and children’s books.

Able Baker Charlie is a mouse. He is a baker, and assists Baker Humperdink, a pig. Despite his small size, Able Baker Charlie is capable assisting with any step of the baking process, from stoking the oven, to mixing the dough, to putting loaves in the oven, and even delivering bread around Busytown. Below you may see a picture of Able Baker Charlie ably distributing French baguettes to Louie’s Restaurant.

Richard Scarry served in the U. S. Army during World War II. No doubt this is the source of the Able Baker Charlie aptonym. It still gives me a chuckle every time we read it.

Written by Scott Moonen

March 1, 2008 at 7:46 pm

Ends and beginnings and faith

leave a comment »

 Peter Leithart writes about faith:

Ruth begins with death – the death of the land in famine, the death of exile, the death of Elimelech, the death of Naomi’s sons, the death of Naomi’s future. Naomi goes out full, and comes back empty. Ruth 1 is a perfect tragic story, a story of endings and emptyings.

But it is chapter 1, and the author wants us to realize that this series of deaths is not an end. The end of chapter 1 is a beginning, as Naomi and Ruth return to Bethlehem “at the beginning of the barley harvest” (v. 22). The author makes his point with a touch so light as to be nearly imperceptible, but the import of that “beginning” is as weighty as anything in Scripture.

“In the beginning” and “once upon a time” make rational sense as the beginning of a story. But recognizing a beginning on the other side of an end is an act of faith.

Mark Dever makes a similar point in his treatment of Ruth. To human eyes, all is despair at the beginning of this book. But the writer of Ruth gives us a glimpse of what a sovereign and good God is planning and working behind the scenes. You can listen to Dever preach on the whole book of Ruth, and also on Ruth chapter 1 specifically.

See also William Cowper’s hymn, God Moves in a Mysterious Way.

Written by Scott Moonen

February 7, 2008 at 10:01 am

Programming Fonts

with 4 comments

I’ve long been dissatisfied with Courier New as a programming font; I’ve found the characters to be bulky and the serifs distracting.  For the past year or so I’ve settled on the beautiful Lucida Console as my favorite font to code in.  Lucida Console is bundled with Windows XP and Windows Vista, and unfortunately it doesn’t seem to be available for free redistribution.  However, you can find some other aesthetically pleasing fixed-width programming fonts, some of which are available for free download, at Hamstu’s Typography of Code.

HT: Woot

Written by Scott Moonen

February 4, 2008 at 7:36 pm

Python generators – saving time and memory

leave a comment »

Python version 2.2 introduced support for generator functions. A generator is a function that returns something kind of like a list. You can think of a generator as a function that gets to return more than once; each time it returns, it produces a new item in the list. Here is a simple example of a generator:

def mygen() :
  print "calling generator"
  for x in [1, 2, 3, 4] :
    print "yielding next value"
    yield x

for item in mygen() :
  print item

This example prints the following:

calling generator
yielding next value
1
yielding next value
2
yielding next value
3
yielding next value
4

Instead of return, we used the yield statement inside our generator. yield returns an item from the generator, but marks that point in the code so that we continue processing when we go back to the generator to fetch the next item in the pseudo-list. Notice how the generator is only called once, but the yield points are interleaved with the print statements in the calling code. Each time the generator needs to produce a new value, it picks up from the previous yield point. When the generator reaches the end of the function, no more values are produced. You cannot use return within a generator.

Let’s look at some code where the use of generators might help us. The following code instantiates a list of objects and then creates HTML to display them. We’ll assume the existence of a database API to execute queries and retrieve results:

def get_objects() :
  result = []
  query = db_execute("...")
  row = query.fetchrow()
  while not row is None :
    result.append(MyObject(row))  # Build object from DB, append to result
    row = query.fetchrow()
  return result
. . .
for object in get_objects() :
  print object.getHTML()

This code creates the entire list of objects before it can print any of them. There are two problems with this — first, there is a huge delay to create all of the objects before any progress is made in printing; this means that the user’s browser has no partial results to display. Second, all of the objects must be held in memory at the same time; if there are many objects, this can cause significant overhead.

Generators allow us to attack both of these problems. Since a generator produces items one at a time, on demand, it avoids both of these problems. We don’t have to wait to construct all of the objects in the list before we use the first one. And once we are done using an object, the Python garbage collector is now free to immediately clean it up. Here’s how we might rewrite the above code to use generators:

def get_objects() :
  query = db_execute("...")
  row = query.fetchrow()
  while not row is None :
    yield MyObject(row)    # Build object from DB, yield to caller
    row = query.fetchrow()
. . .
for object in get_objects() :
  print object.getHTML()

With a small change we have now significantly improved our code’s memory footprint — all of the objects do not need to be held in memory at the same time. And we are now producing the output for each object as we create it, without needing to wait for all the objects to be instantiated first. This is a significant improvement!

We can also build a chain of generators. Let’s assume that we need to modify the code above to optionally display only those objects that have an “active” flag set. Ordinarily, if we use Python’s filter function to accomplish this, it needs to create the entire list all at once. But if we use a generator to perform the filtering, then we can still keep our optimizations since we are only ever creating and filtering one object at a time. Here’s an example:

my_objs = get_objects()         # This returns a generator object

if display_active_only :
  def active_filter(objects) :  # A filtering generator
    for object in objects :
      if object.active :
        yield object

  my_objs = active_filter(my_objs)

for object in my_objs :
  print object.getHTML()

A generator function doesn’t produce a real list; instead, it produces a generator object that behaves like something called an iterator. You can’t write either of the following statements for a generator or iterator:

print len(get_objects())
print get_objects()[3]

The for statement is smart enough to traverse a generator, and it will probably be sufficient for your needs. Perhaps you can get the count of objects by other means, such as executing an SQL COUNT request. If you absolutely need to access a generator as a list, you can coerce it to a list as follows:

objlist = list(get_objects())

But be aware that this removes all of the advantages that we’ve discussed here, since this causes all of the objects returned by the generator to be created at once and stored in the list. If you find yourself needing to do this, you should consider rewriting your code so that you don’t need to do so. Or perhaps generators aren’t the right solution for your particular problem.

Written by Scott Moonen

February 1, 2008 at 10:22 am

They preach

with one comment

We shared the Lord’s Supper on Sunday morning.

When we speak scripture to one another, and when our pastors preach, we know that, by the Holy Spirit, Christ himself is speaking to us and preaching to us. We listen intently and we search our hearts because we long to hear our Lord. He comforts and strengthens us with promises and sends us out with commands.

When we take the Lord’s Supper it is easy to be aware of what we ourselves are doing — examining, remembering. But, no less than in preaching, Christ is speaking to us in the Lord’s Supper, comforting and strengthening us with promises and sending us out with commands. The Lord’s Supper preaches to our hungry hearts. What are some of the promises that we will hear our Savior saying if we are attentive?

  • Are you condemned? You are forgiven! I have washed and cleansed you with my blood.
  • Are you ashamed? You are accepted! You come before God in me.
  • Are you afraid or anxious? I drank the cup of God’s wrath so that you can enjoy mercy and grace and peace.
  • You are adopted. I have made you a part of God’s family.
  • I love you. Receive my lavish gifts of bread, wine, my body, and my blood.
  • You belong to me; I bought you with my own blood.
  • I have provided for your greatest and most costly need, and I will surely provide for all of your needs.
  • I will keep you safe to the end; we will feast like this together in heaven.

And what commands is he giving to us?

  • Believe in me!
  • Find your satisfaction in me. You will not find lasting satisfaction anywhere else.
  • Find your joy in me. You will not find lasting joy anywhere else.
  • Hear my great promises, receive my great gifts, and then give thanks, celebrate, feast and rejoice!
  • See, you are all my body. Love one another, care for one another, provide for one another.
  • You belong to me, and you feed on me for your life. Become more like me.

The elements preach to us. Hear our Savior speaking to you.

Crossposted to Reflections on Upchurch.

Written by Scott Moonen

January 8, 2008 at 6:21 am

Posted in Christ is Lord, Essays

Ruth

leave a comment »

Chapter summaries in Ruth.

Ruth 1 – Ruth follows Naomi back to Bethlehem after the death of their husbands, embracing Naomi’s people and God.
Ruth 2 – Ruth gleans in the field of Boaz and finds great favor with him.
Ruth 3 – Ruth seeks Boaz at his threshing floor and asks him to redeem her.
Ruth 4 – Boaz redeems Ruth, taking her as his wife. They have a son, Obed, the father of Jesse, the father of David.

Written by Scott Moonen

January 4, 2008 at 3:57 am

Posted in Bible Chapter Summaries

Tagged with ,

Judges

leave a comment »

Chapter summaries in Judges

Judges 1 – Further conquest by Judah, Simeon, Benjamin, Manasseh and Ephraim; failure to drive all Canaanites out of Manasseh, Ephraim, Zebulun, Asher, Naphtali and Dan.
Judges 2 – God preserves some Canaanites as a thorn for Israel. After Joshua’s death Israel pursues Baals and Ashtaroth; God sends judges to defeat their enemies but Israel repeatedly forsakes him.
Judges 3 – Othniel saves Israel from slavery to Mesopotamia; Ehud saves Israel from Moab, killing Eglon; Shamgar saves Israel from the Philistines.
Judges 4 – Deborah and Barak save Israel from Jabin and Sisera; Jael kills Sisera.
Judges 5 – Deborah and Barak sing of God’s mighty deliverance; Israel has rest for 40 years.
Judges 6 – Midian oppresses Israel; God calls Gideon; Gideon tears down the altar of Baal and gathers an army; God shows Gideon the signs of the fleece.
Judges 7 – God gives Gideon and his 300 men (once 32,000) victory over Midian.
Judges 8 – Gideon completes his victory, disciplines cities that would not help, makes and worships an ephod. After his death idolatry returns.
Judges 9 – Abimelech the son of Gideon rules with treachery and evil, killing his brothers and many others. After three years God brings his death.
Judges 10 – Tola and Jair judge Israel; God gives Israel into the hands of the Philistines and Ammonites.
Judges 11 – Jephthah challenges the Ammonites and defeats them, but makes a foolish vow and must offer his daughter to the LORD.
Judges 12 – Jephthah, Ibzan, Elon and Abdon judge Israel.
Judges 13 – God gives Israel into the hands of the Philistines; the LORD appears to Manoah and his wife and tells of Samson’s birth; Samson is born.
Judges 14 – Samson pursues a Philistine woman; she betrays him and he kills thirty Philistine men.
Judges 15 – Samson kills a thousand Philistine men, and judges Israel.
Judges 16 – Delilah betrays Samson; Samson kills three thousand Philistines at his death.
Judges 17 – Micah creates an idol and ordains one of his sons and a Levite as priests.
Judges 18 – The tribe of Dan captures land for themselves and takes the idol and the Levite for themselves.
Judges 19 – A Levite and his concubine are assaulted by the men of Gibeah; she is killed and the Levite sends pieces of her body to the twelve tribes.
Judges 20 – Israel defeats the tribe of Benjamin, who refuse to give up the men of Gibeah.
Judges 21 – Israel provides wives for the survivors of the tribe of Benjamin. There was no king in Israel; everyone did what was right in his own eyes.

Written by Scott Moonen

December 23, 2007 at 5:49 pm

Posted in Bible Chapter Summaries

Tagged with ,

Hospitality

leave a comment »

Peter Leithart writes of hospitality:

Feasting and care for the poor have been polarized in contemporary culture. If you’re a “conservative,” you’re in favor of free trade, consumption without guilt, festivity without concern for those who can’t join you, who probably deserve their poverty anyway. If you’re a “liberal,” you renounce festivity because other people are hungry and how dare you eat when someone else isn’t.

The Biblical prophets combine a promise of festivity with severe denunciation of greed, luxury, and oppression. But they combine the two seamlessly by emphasizing hospitality. The promise is a feast like the feasts of the Pentateuch, where the widow, stranger, and Levite are not forgotten but included as welcome guests.

Against both “conservative” indifference and liberal asceticism, the Bible presents the ideal of the hospitable society.