Wednesday, December 21, 2011

The Christmas Story & Prophecy

The Christmas story, from the Bible...

Luke 2:1-21:
In those days Caesar Augustus issued a decree that a census should be taken of the entire Roman world. (This was the first census that took place while Quirinius was governor of Syria.) And everyone went to their own town to register. So Joseph also went up from the town of Nazareth in Galilee to Judea, to Bethlehem the town of David, because he belonged to the house and line of David. He went there to register with Mary, who was pledged to be married to him and was expecting a child. While they were there, the time came for the baby to be born, and she gave birth to her firstborn, a son. She wrapped him in cloths and placed him in a manger, because there was no guest room available for them.

And there were shepherds living out in the fields nearby, keeping watch over their flocks at night. An angel of the Lord appeared to them, and the glory of the Lord shone around them, and they were terrified. But the angel said to them, “Do not be afraid. I bring you good news that will cause great joy for all the people. Today in the town of David a Savior has been born to you; he is the Messiah, the Lord. This will be a sign to you: You will find a baby wrapped in cloths and lying in a manger.”

Suddenly a great company of the heavenly host appeared with the angel, praising God and saying,
“Glory to God in the highest heaven,
and on earth peace to those on whom his favor rests.”

When the angels had left them and gone into heaven, the shepherds said to one another, “Let’s go to Bethlehem and see this thing that has happened, which the Lord has told us about.”

So they hurried off and found Mary and Joseph, and the baby, who was lying in the manger. When they had seen him, they spread the word concerning what had been told them about this child, and all who heard it were amazed at what the shepherds said to them. But Mary treasured up all these things and pondered them in her heart. The shepherds returned, glorifying and praising God for all the things they had heard and seen, which were just as they had been told.

On the eighth day, when it was time to circumcise the child, he was named Jesus, the name the angel had given him before he was conceived.


Matthew 2:1-2,9-12:
After Jesus was born in Bethlehem in Judea, during the time of King Herod, Magi from the east came to Jerusalem and asked, “Where is the one who has been born king of the Jews? We saw his star when it rose and have come to worship him.”
...
After they had heard the king, they went on their way, and the star they had seen when it rose went ahead of them until it stopped over the place where the child was. When they saw the star, they were overjoyed. On coming to the house, they saw the child with his mother Mary, and they bowed down and worshiped him. Then they opened their treasures and presented him with gifts of gold, frankincense and myrrh.


I recently read some prophecies in Isaiah that describe or foreshadow these events. Here is one example.
The following passage was written over 500 years before Jesus' birth about the restoration of Israel. When you read it, think of it from the perspective of God the Father speaking to his Son about his birth in Bethlehem. I've highlighted and numbered parts of it that were fulfilled in the Christmas story accounts in Matthew and Luke above.

Isaiah 60
“Arise, shine, for your light has come,(1)
and the glory of the LORD rises upon you.
See, darkness covers the earth and thick darkness is over the peoples,
but the LORD rises upon you and his glory appears(2) over you.
Nations will come to your light, and kings to the brightness of your dawn.
“Lift up your eyes and look about you: All assemble and come to you; (3)
your sons come from afar, and your daughters are carried on the hip.
Then you will look and be radiant, your heart will throb and swell with joy;
the wealth on the seas will be brought to you, to you the riches of the nations will come. (4)
Herds of camels will cover your land, young camels of Midian and Ephah.
And all from Sheba will come, bearing gold and incense and proclaiming the praise of the LORD.
(5)
All Kedar’s flocks will be gathered to you, the rams of Nebaioth will serve you;
(6) they will be accepted as offerings(7) on my altar, and I will adorn my glorious temple.

“Who are these that fly along like clouds, like doves to their nests? (8)
Surely the islands look to me; in the lead are the ships of Tarshish,
bringing your children from afar, with their silver and gold,
to the honor of the LORD your God, the Holy One of Israel,
(9) for he has endowed you with splendor.


Just a quick explanation on each one:
1) "Light of the World" is another name for Jesus.
2) This was the appearance of the Lord.
3) The magi and shepherds (and presumably the servants and animals of the magi) assembled to see the baby Jesus. The magi, who were from eastern nations, probably Persia, came by following the light of a bright star.
4) Camels may likely have been the mode of transportation used by the magi and much of their caravan.
5) Gold and (frank)incense were given to Jesus in acts of worship.
6) Shepherds (and possibly their flocks?) were the first to come to Jesus.
7) The gifts were accepted, and Mary treasured all these things in her heart.
8) "These that fly along like clouds" may refer to the angels who gave the message to the shepherds.
9) Once again, the mention of the assembly of many people and the gifts to honor Jesus.


If you can, take some time to explore the many Messianic prophesies scattered around the latter half of the book of Isaiah. There are quite a few, many relating to his death, resurrection, and second coming.

Thursday, February 24, 2011

How to skip page number for a cover page in Word

Running
- Mac OSX 10.6.6 (Snow Leopard)
- Microsoft Word 2008 v12.2.8

What we're trying to do
- Have a cover page.
- Add page numbering in the footer, starting at the second page.
- Have the first page number (on 2nd page) start at 1.

How to do it
- Go to Format > Document (for Mac) or File > Page Setup (for PC) and go to the Layout tab.
- Check the box under Headers and Footers that says "different first page" and click OK.
- Put in some placeholder text for your cover page and either a page break or a bunch of returns, so the next page appears.
- Double-click on the footer area of the 2nd page to edit the footer.
- Hit Ctrl-F9 (for PC) or Cmd-F9 (for desktop Mac) or Cmd-Fn-F9 (for MacBook). This should insert a gray pair of curly braces with a space in between. These are very magical curly braces. If you just type the curly brace characters { }, it won't work.
- Put your cursor in between curly braces and type an equal sign (=).
- Then hit the command keys again to insert another pair of curly braces after the equal sign.
- Put your cursor in between the inner curly braces and type the word PAGE.
- Now move your cursor between the two right curly braces (}) and type - 1.
- By this point, you should see this: {={PAGE}-1}. Remember, you can't just type the curly braces. They should show up when you hit that F9 combination.
- Now let's test it out. Go to File > Print Preview, and take a look. You should see nothing on the cover page's footer and "1" on the second page's footer.

Commentary
You can also add the number of pages in a similar way (i.e. "Page 1 of 5"). After completing the above, add " of {={NUMPAGES}-1}".

In Word 2007 and later, you can also choose to add a template cover page. For Mac, Go to View > Elements Gallery > Cover Pages. However, if you add page numbering to this, it will start the 2nd page with "2" instead of "1".

The following Microsoft help articles may also be helpful:
Field codes: = (Formula) field
Remove the page number from the first page

Tuesday, January 4, 2011

Villain Rave

I created this techno song with my sister Lorri mostly at my parents' house over Christmas break. I hope you enjoy it.



It was all recorded with GarageBand. Here's a breakdown of the tracks:
1) Vocal effects
2) Soft synth (Yamaha YPG 625)
3) Saw synth (some old Casio midi keyboard)
4) Rhythm electric guitar (Les Paul + Boss BD2 + Boss DD7)
5) Lead electric guitar (same as rhythm)

I hope to have more songs of various genres coming. Eventually, they might become an album.

Saturday, December 18, 2010

How to fix Wii Virtual Console "black screen" issue

For:
- Wii (system Version 4.3U)
- component cables for A/V

Problem:
When trying to play downloaded SNES or NES games, the screen goes black and you may eventually be sent back to the home screen. When hitting the "home" button on your controller, you can see the game in the background behind the menu options.

Solution:
Make sure your Wii's screen resolution is set to 480p, not 480i.
- Wii Settings > Screen > TV Resolution > EDTV or HDTV (480p)

Friday, December 3, 2010

Two new haikus

ミシガンに
寒くなってる
初雪だ

大学は
期末試験が
迫り来る


Readings:
mishigan ni
samukunatteru
hatsuyuki da

daigaku wa
kimatsushiken ga
semarikuru


English translations:
In Michigan
It's getting cold
The first snow

College
Has final exams
Looming

Wednesday, July 21, 2010

SQL Server strange string lengths


I just thought I would document some very unintuitive behavior of SQL Server to watch out for. It's well known that SQL Server is not well-suited to string processing. This is one of the reasons why.

The LEN built-in function returns the length of a given string, however, it has quirks about the way it handles whitespace:


Command Result
SELECT LEN('abc') 3
SELECT LEN('') 0
SELECT LEN(NULL) NULL
SELECT LEN(' ') --one space 0
SELECT LEN('       ') --multiple spaces 0
SELECT LEN(' ') --one tab 1
SELECT LEN('
') --one newline
2
SELECT LEN('ABC ')3
SELECT LEN(' ABC')4


I tested these behaviors in SQL Server 2005.

I think the reason for this is because old string types like char are fixed-width, using spaces to fill in unused portions of the string. For example, if I wanted to store 'Hello world' into a char(20), SQL Server would actually store 'Hello world         '. Then, when you want the length of the string, you just want the length of the part before all the trailing spaces. However, I'm not sure why this is still the dominant behavior, since nvarchar and varchar are much more commonly used these days than char, and they don't use all the trailing spaces.

As the the newline, it uses two characters: carriage return (13) and newline (10).

Wednesday, July 14, 2010

Japanese Internet slang: w's

Japanese use their own kinds of Internet and texting slang, so today I'm highlighting one that puzzled me for a while. The w's.

You'll see it at usually the end of sentences and often several in a row: wwww.

"w" is actually short for the Japanese word 笑う "warau", which means to laugh. Sometimes you'll also see just the 笑 character by itself or ~笑 or ~笑う or something like that. It's kind of the equivalent of "lol" in English. The more w's, the more they're laughing, just like some crazy kids type "lololololol" in English :) .

Have a great day! ww

Tuesday, June 1, 2010

JavaScript: functions as objects vs. functions as functions


I ran into this interesting behavior today. I was passing a function to a list of functions to execute later, and I kept getting an error in firebug that said when it came to execute it that it "is not a function", but proceeded to completely successfully execute it as one anyway, doing exactly what I wanted it to. I wanted to get rid of the error message, since it was behaving properly.


Come to find out, it was listed as an object instead of a function. In short, the difference is that if you declare a function like this: function() { ... }, it will be returned as a function. If you declare it like this: new function() { ... }, it will be returned as an object. I just needed to take out the word "new" I had used.


I created the following simple HTML page to demonstrate this behavior. Feel free to try it out for yourself and tinker around with it:

<html>
<head>
<script type="text/javascript">
//setup
var tests = new Array();
tests[0] = new function() { return 'A is the best!'; };
tests[1] = function() { return 'B is better!'; };

var message = 'tests:';
for (var i = 0; i < tests.length; i++)
{
message += '\ntest[' + i + ']: ' + tests[i];
}
alert(message +'\n\nNext, we\'ll try to execute these as functions...');
</script>
</head>
<body>
<div id="divResults"></div>
<br />
<div id="divStatus">Testing...</div>
</body>
<script type="text/javascript">
//run the tests
var resultsDiv = document.getElementById('divResults');
for (var i = 0; i < tests.length; i++)
{
resultsDiv.innerHTML += 'test[' + i + ']\'s result: ';
try { resultsDiv.innerHTML += tests[i](); }
catch(ex) {resultsDiv.innerHTML += '<span style="color:red;">Test failed: ' + ex.message + '</span>'; }
resultsDiv.innerHTML += '<br />';
}

//we're done
document.getElementById('divStatus').innerHTML = 'The test is done. Reload this page to run the test again.';
</script>
</html>


I have confirmed this behavior in Firefox 3.6.3, IE 7.0, Chrome 5.0, Safari 4.0.5, and Opera 10.53.

Monday, February 8, 2010

Resolved: "uninitialized constant DBI::DBD::ODBC" in Ruby for Windows

Running:
  • Windows 2003 Server SP2
  • Ruby 1.8.6 patchlevel 383, i386-mingw32 (from RubyInstaller)
  • dbd-odbc 0.2.4
  • dbi 0.4.3
Problem:
I created a Ruby class that can run arbitrary SQL queries on remote databases of various kinds. It was working fine for a while, but then something changed so that whenever I would try to use it to execute some SQL, I'd get the following error:

DBI::InterfaceError (Unable to load driver 'ODBC' (underlying error: uninitialized constant DBI::DBD::ODBC)):
dbi (0.4.3) lib/dbi.rb:300:in `load_driver'
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
dbi (0.4.3) lib/dbi.rb:242:in `load_driver'
dbi (0.4.3) lib/dbi.rb:160:in `_get_full_driver'
dbi (0.4.3) lib/dbi.rb:145:in `connect'
...

Resolution:
Make sure you have the dbd-odbc and dbi gems installed correctly.
For me, a couple of associated files were missing from C:\Ruby\lib\ruby\1.8\i386-mingw32: odbc.so and odbc_utr8.so. I had these files in my working Dev installation, so I just copied them from Dev to Prod, and it fixed the problem.

Commentary:
This comes from DBI trying to do a require dbd/odbc and not finding that file. When I googled around about the error, mostly people said to make sure you had the dbd-odbc gem installed, which I already did. I tried reinstalling the gem, as well as the dbi gem. This had no effect. The problem was happening on Prod, but I had the same thing set up on Dev, which was working. So, I checked to see what paths require uses like so:

C:\...>irb
irb(main):001:0> $LOAD_PATH
=> ["C:/Ruby/lib/ruby/site_ruby/1.8", "C:/Ruby/lib/ruby/site_ruby/1.8/i386-msvcr
t", "C:/Ruby/lib/ruby/site_ruby", "C:/Ruby/lib/ruby/1.8", "C:/Ruby/lib/ruby/1.8/
i386-mingw32", "."]

I checked through those directories to see what .rb files looked like ODBC-related things that were in Dev but not in Prod. That's how I found those two files. After I copied them to Prod, I tested it in IRB like so:

irb(main):004:0> require 'odbc'
=> true

After that, everything worked fine again. I hope this anecdote can help you! Good luck!

Friday, January 22, 2010