Saturday, 26 January 2013

Biblical Topic: Resurrection

These are some notes I've put together about the resurrection and the immortality of the soul. All of the quotes are from the ESV unless otherwise noted, but please have a Bible ready to look verses up in, because I have not included the text of every quote. For many people, considering this may not be easy, but we know from Proverbs 25:2 that "It is the glory of God to conceal things, but the glory of kings is to search things out." Jesus also, knowing God, did the same and spoke in parables.

Having said that, if you will listen further, here are some things to consider:

Why did Martha say what she did, after Lazarus died?

John 11:23-26: Jesus said to her, "Your brother will rise again."  Martha said to him, "I know that he will rise again in the resurrection on the last day."  Jesus said to her, "I am the resurrection and the life. Whoever believes in me, though he die, yet shall he live, and everyone who lives and believes in me shall never die. Do you believe this?"

There is a resurrection, at the last day. Jesus' comfort to her is not that he is still alive, but in heaven, but that he will rise again. Even though Lazarus died, "yet shall he live". And, everyone who lives and believes in Jesus shall never die - the Bible tells us about God's and Jesus' understanding of that here:

Matthew 22:31-32: And as for the resurrection of the dead, have you not read what was said to you by God: 'I am the God of Abraham, and the God of Isaac, and the God of Jacob'? He is not God of the dead, but of the living."

By Jesus' words, we know that when God said that He is the God of Abraham, Isaac and Jacob, He was referring to the resurrection of the dead. So we understand God's power - he remembers them (Abraham, Isaac and Jacob), and will raise them up on the last day. The resurrection is a key Bible theme and worthy of study. If this all seems strange, perhaps Acts 17:30-32 will be reassuring. For further places to look, read of Abraham sacrificing Isaac in Genesis 22:1-18, taking note of verses 5 and 10 and comparing with Hebrews 11:17-19, and please read 1 Corinthians 15:12-19-23 - however the whole chapter is worth close study, especially about the resurrection. Also, a Bible search on "resurrection" will show many matches and will give a feel for the subject in the New Testament.

The Old Testament is not silent on this subject, indeed, it helps us understand the resurrection. One of the key areas are the promises to Abraham. For example:

Genesis 13:14-17: The LORD said to Abram, after Lot had separated from him, "Lift up your eyes and look from the place where you are, northward and southward and eastward and westward, for all the land that you see I will give to you and to your offspring forever.  I will make your offspring as the dust of the earth, so that if one can count the dust of the earth, your offspring also can be counted.  Arise, walk through the length and the breadth of the land, for I will give it to you."

So we see that God promises two things: eternal life for Abraham and his offspring, and a location to have eternal life in - he and his descendants will have the land forever. Indeed, not just the land of Israel, but ALL of the earth will be filled with the glory of the Lord (Numbers 14:21, Habakkuk 2:14). By the Habakkuk quote, it is people that fill the earth with God's glory. All of us, resurrected believers, in Christ, sinless, worshiping God and glorifying Him. I would not say that is the only place we will ever go once we are resurrected (it will not be a jail), but we will be immortal, and be given the land. Our Lord, Christ will reign over the world forever:

Revelation 11:15: Then the seventh angel blew his trumpet, and there were loud voices in heaven, saying, "The kingdom of the world has become the kingdom of our Lord and of his Christ, and he shall reign forever and ever."
and
2 Samuel 7:12-13: When your days are fulfilled and you lie down with your fathers, I will raise up your offspring after you, who shall come from your body, and I will establish his kingdom.  He shall build a house for my name, and I will establish the throne of his kingdom forever.
and
1 Chronicles 17:9-14: And I will appoint a place for my people Israel and will plant them, that they may dwell in their own place and be disturbed no more. And violent men shall waste them no more, as formerly, from the time that I appointed judges over my people Israel. And I will subdue all your enemies. Moreover, I declare to you that the LORD will build you a house.  When your days are fulfilled to walk with your fathers, I will raise up your offspring after you, one of your own sons, and I will establish his kingdom.  He shall build a house for me, and I will establish his throne forever.  I will be to him a father, and he shall be to me a son. I will not take my steadfast love from him, as I took it from him who was before you, but I will confirm him in my house and in my kingdom forever, and his throne shall be established forever.'"
and
Isaiah 9:7: Of the increase of his government and of peace there will be no end, on the throne of David and over his kingdom, to establish it and to uphold it with justice and with righteousness from this time forth and forevermore. The zeal of the LORD of hosts will do this.

What then of our soul? We have been promised a resurrection - why are we given a body to live immortally when resurrected, as it says in 1 Corinthians 15:35-55?

Romans 6:23: For the wages of sin is death, but the free gift of God is eternal life in Christ Jesus our Lord.

Here we see the two options put before us. God has given you and me the gift of eternal life - living forever. We will live forever, but sinners will not - they are not given the gift of eternal life, and, they will die. The two preceding verses emphasise the same point:

Romans 6:21-22: But what fruit were you getting at that time from the things of which you are now ashamed? For the end of those things is death.  But now that you have been set free from sin and have become slaves of God, the fruit you get leads to sanctification and its end, eternal life.

So why are the wages of sin death? It started in Eden:

Genesis 2:16-17: And the LORD God commanded the man, saying, "You may surely eat of every tree of the garden, but of the tree of the knowledge of good and evil you shall not eat, for in the day that you eat of it you shall surely die."

We know from the Bible record, that Adam and Eve did not die that exact day - so what does verse 17 mean? The Hebrew in verse 17 for "shall surely die" is "mooth mooth" - two H4191's. H4191 is Strong's number for it. Strong says:

H4191
מוּת
mûth
mooth
A primitive root; to die (literally or figuratively); causatively to kill: -  X at all, X crying, (be) dead (body, man, one), (put to, worthy of) death, destroy (-er), (cause to, be like to, must) die, kill, necro [-mancer], X must needs, slay, X surely, X very suddenly, X in [no] wise.

The Hebrew word carries with it the meanings of death, kill, destroy, slay, suddenly, in no wise. So to "die die" emphasises that they would definitely die, be destroyed, surely and suddenly be no more. So in that day that they ate that fruit, Adam and Eve were destined to die and be no more.

Genesis 2:7: then the LORD God formed the man of dust from the ground and breathed into his nostrils the breath of life, and the man became a living creature.

We came from the dust, and had life breathed into us. We were formed by God.

Genesis 3:19: By the sweat of your face you shall eat bread, till you return to the ground, for out of it you were taken; for you are dust, and to dust you shall return."

We are dust, and to dust we return (see also Psalms 37:20; 49:12; 68:2). In a similar way, we, humans, are likened to grass that grows up, but perishes away quickly (Psalms 103:14-16; 37:2, Isaiah 40:6-8; 37:27, James 1:10, but also see Matthew 6:30). We were formed and given life by God, and He is who we should fear/respect and obey. Our souls, our lives are God's:

Ezekiel 18:4: Behold, all souls are mine; the soul of the father as well as the soul of the son is mine: the soul who sins shall die.
Ezekiel 18:20: The soul who sins shall die. The son shall not suffer for the iniquity of the father, nor the father suffer for the iniquity of the son. The righteousness of the righteous shall be upon himself, and the wickedness of the wicked shall be upon himself.

Indeed, God has no pleasure in a person's death (Ezekiel 18:23, Matthew 18:14) - even if they are wicked - God wishes us to obey Him and live. The soul will die - another way to look at it is given in Genesis 6:3, where it says God's Spirit will not abide in man forever:

Genesis 6:3: Then the LORD said, "My Spirit shall not abide in man forever, for he is flesh: his days shall be 120 years."

Without God we are nothing - he sustains everything by His power, so when someone dies, and God's Spirit leaves them. When we die, go to Sheol, return to dust, we will not think, or know, or do anything:

Ecclesiastes 9:10: Whatever your hand finds to do, do it with your might, for there is no work or thought or knowledge or wisdom in Sheol, to which you are going.

This is not an isolated quote; see also Psalms 112:9-10, Proverbs 10:28; 11:7. So, what is the result of all this? Even though we are weak and in many ways insignificant, we respect and love the God that loved us before we loved Him, and thank Him for His gift towards us of eternal life through His son, Jesus Christ, and obey Him - not from fear - but from respect and gratitude for all He has done for us.

For further reading, see Revelation 20:12-14, where we read of the book of life, and how the sea, death and hades/hell give up the dead in them, and they are judged. Why would hades/hell grouped with the sea, and death?

So I ask again, why did Martha say "I know that he will rise again in the resurrection on the last day.", and not something else?

Saturday, 19 January 2013

Random Scripts in Various Languages

In the last few weeks of work, I've come across several different languages to perform different tasks. They were useful, so I've included them below.

PowerShell

The first one is PowerShell. We used it to extract data for a customer. It's a temporary measure - their business intelligence server will be able to do this for them soon. The idea was to automate calling some SQL queries on a server and exporting the results as CSV. Of interest is that I set the culture to get a specific datetime format (I know, I could get the same effect in SQL). Here is some cleansed parts of the script:

$startDate = "11 Oct 2012"$days = "1"

$prefix = "declare @StartDate datetime, @EndDate datetime set @StartDate = DATEADD(HH, -10, '$startDate')
set @EndDate = DATEADD(DD, $days, @StartDate)"$culture = [System.Globalization.CultureInfo]::InvariantCulture.Clone()
$culture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd"$culture.DateTimeFormat.LongTimePattern = "HH:mm"
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture [System.Threading.Thread]::CurrentThread.CurrentCulture =$culture

Write-Output "Extract $days day(s) worth of data from${startDate}:"

Write-Host "Extracting Performance Log data..."
$query = "$prefix

select Column_Names etc."

.....
$data = Custom-Call-SQL$query
Write-Host "Exporting CSV file..."
\$data | Export-CSV PerformanceData.csv -encoding ascii -notype

.....

To run a PowerShell script, put it in a file named something like "script.ps1", open a Powershell prompt (should be under Accessories in the Start menu), and enter the script file and path.

AutoHotkey

The next one was an unusual (to me) use for AutoHotkey. I say unusual, because I didn't think AutoHotkey would be great at working with large files, but it was. It combines the whole contents of several files from sub-folders "Day 2" to "Day 7" into one master file. The reason I went to AutoHotkey is that the files were too big for Notepad++. Here is the script:

#NoEnv
#SingleInstance force
SendMode Input
SetWorkingDir %A_ScriptDir%

OutputFile = PerformanceData.csv
Loop, 6
{
Day := A_Index+1
From = Day %Day%\%OutputFile%
CombineLines(From, OutputFile)
}
MsgBox, Finished copying content to %OutputFile%.
Return

CombineLines(fromfile, tofile)
{

;; The "to" file is open for the whole loop for efficiency when done this way.  Loop, Read, %fromfile%, %tofile%
{
FileAppend, %A_LoopReadLine%n
}
}

To run an AutoHotkey script like this one, copy the contents into a file like "script.ahk" and double click it (assuming you have AutoHotkey installed).

Unix Find and Grep

The next one is from my friend Michael Gleeson. It's a Unix command, and it searches the files in a directory for the <string>, and prints the file and matching line to standard output. It is:

find . -type f -print0 | xargs -0 grep <string>

Regular Expressions

The second last one is for (Perl compatible) regular expressions. Notepad++ was updated to use Perl compatible regular expressions as of version 6. Notepad++ can use regular expressions for "Find and Replace". Doing so is a great feature - it gives you great flexibility to not only find bits of text that match specific patterns, but to also intelligently rearrange or replace those bits of text. I used it recently to change date formats in some of the files I generated with the above scripts. The find text was "(\d{2})/(\d{2})/(\d{4})", and the replace text was "\2-\1-\3". The parentheses in the find text create variables you can use in the replacement text. In our case, we have created three variables. They are named \1, \2 and \3. In the replace text, I've swapped the variables around, because I am converting American Month-Day-Year format to an Australian Day-Month-Year format.

Performing a find and replace in Notepad++ with the above terms replaces "02/27/1900" with "27-02-1900", etc.

See also a post on Mark's Speechblog for more on Notepad++'s powerful find and replace (pre version 6). Also, I'm told that a Unix command, sed (stream editor) can do similar things, and a lot more (see here for a great page about sed).

Visual Basic

The last one is from Visual Basic. I use this in an Excel file, to find a single file. It opens a standard file selector dialog. It's a function, so you call it when you want a file. The function returns a Boolean indicating whether a file was successfully selected, and it puts the file name into the ByRef argument. Here it is:

Function GetAFileName(ByRef FileName As String) As Boolean
' Actually browse for a file to import.
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogOpen)
fd.AllowMultiSelect = False
GetAFileName = (fd.Show = -1)
If GetAFileName Then
FileName = fd.SelectedItems(1)
End If
Set fd = Nothing
End Function

Have you got any random scripts of your own? Please share them below.

Saturday, 12 January 2013

Ignoring Arguments in Anonymous Functions

Anonymous functions are a useful (hmm, that's an understatement) feature of Common Lisp. I use them a lot. While using them, sometimes I want to ignore some arguments that are required by the consumer of the anonymous function. For example, here is an example of collecting the keys in a hash-table into a list:
(let (result)
(maphash (lambda (key value)
(declare (ignore value))
(push key result))

hash-table)

result)
In this situation, the anonymous function is quite simple, and the ignore advice is swamping it. I wrote a small macro (named fn) to make ignoring arguments in anonymous functions easier. It's included and used extensively in the MathP code. To ignore an argument, use an underscore for it in the argument list. For example, the above code becomes:
(let (result)
(maphash (fn (key _) (push key result))

hash-table)
result)
Because the code is that much shorter, I find it that much easier to read. Here is the macro that does the magic:
(defmacro fn (args &body body)
(let (arg-list ignores)
(loop for arg in args
if (string= (symbol-name arg) "_")
do (let ((sym (gensym)))

(push sym arg-list) (push sym ignores))
else do (push arg arg-list))
(lambda ,(nreverse arg-list) (declare (ignore ,@ignores)) ,@body)))

I hope the above code is useful to you; Use it however you want. I accept no responsibility for problems arising from it's use, but if you do find it useful, I'd be tickled pink to hear from you.

Saturday, 5 January 2013

Syntax for Lambda-Lift/Positional-Lambda

I've checked out the clever Lambda-Lift library by Hexstream, and I like it. It's a library that provides a succinct way to write positional lambdas. Having recently used implemented a reader macro, I decided to try one out for it. Almost immediately afterwards, I read the Reddit announcement, which mentioned that not using a reader macro was a good idea.

It seems that wanting to use reader macros for small things is a common weakness in Common Lisp programmers. Uses of dispatching macro character pairs to shorten code can actually make the code harder to read. This is more likely for people who don't know what the associated dispatch function does (or even sometimes where it came from). The tendency towards reader macros may arise from the desire for a more concise way to write Lisp code. This may be more of an issue if you are used to writing very terse code, such as Perl of Mathematica.

The issue with reader macros for general consumption is that they provide another layer to understand. While definitely not insurmountable, effort is still required to investigate and understand what the reader macro does or produces. In effect, reader macros use syntax to compress Lisp code.

The most Lispy way to compress code is probably to use higher order functions and macros. I think the benefit of using macros is that building macros upon macros is easier because of the uniform syntax. When macros are the right choice, you can benefit from their rich support in Common Lisp.

Anyway, here's my attempt. Use or leave it.

(declare (ignore char))
(let* ((next (peek-char nil stream))
(n (or n (and (digit-char-p next)

#.(char-code #\0)))))
(next (peek-char nil stream))
(rest (and (char-equal next #\r) next))
(next (progn (when rest (read-char stream))

(peek-char nil stream)))
(body (if (member next '(#\Space #\Tab #\Newline nil #\)))
'() (,(read stream nil nil t)))))
(lambda-lift:lift ,@(when n (,(intern (format nil "~D" n) '#:keyword)))
,@(when rest (&rest ,(read-from-string (string rest))))
,@body)))

The above code is released into the Public Domain the same as the Lambda-Lift library. Here are some examples of it:

'#L3           ;== (lift :3)
'#L3(print :2) ;== (lift :3 (print :2))
'#L2r          ;== (lift :2 &rest r)
'#L3r(print r) ;== (lift :3 &rest r (print r))
'#L3:2         ;== (lift :3 :2)
'#L2rr         ;== (lift :2 &rest r r)
(funcall #L5
'one 'two 'three 'four 'five) ;== FIVE
(funcall #L5:3          'one 'two 'three 'four 'five) ;== THREE
(funcall #L5(string :1) 'one 'two 'three 'four 'five) ;== "ONE"
(funcall #L5(reverse (string :4)) 'one 'two 'three 'four 'five) ;== "RUOF"
(funcall #L2rr 'one 'two 'three 'four 'five) ;== (THREE FOUR FIVE)