Sunday, August 26, 2012

2001 A Space Odyssey

2001: A Space Odyssey (film).

This is the 1968 sci-fi film made by Stanley Kubrick and Arthur Clarke, famous for its pioneering depiction of technology, artificial intelligence, anthropology and human evolution etc. The supercomputer HAL 9000 is a famous figure of AI, which possess not just strong computational power, but also human-like emotions.

The story is centered around a sentinel rock found on Moon, which sent signal to Jupiter. A mission group is sent from early to investigate the signal destination on Jupiter. Of the crew of 5 humans and HAL, only HAL knew this true purpose. HAL killed 4 crew members in fear that they would shut him down and interfere with the trip mission. One crew survived, shut down HAL, and arrived at the Jupiter.

In my opinion, the 1968 movie is superb in its whimsical sense of sci-fi thoughts. The scenes setup both internally inside spacecraft and externally in the universe are still convincing today. But lack of dialogue and slow pace of storyline may not be liked by some people.

There are 4 episodes of the Space Odyssey series, published as 4 books. The first 2 were made into movies in 1968 (2001 A Space Odyssey) and 1984 (2010 Space Odyssey II). The later two are set in years 2061 and 3001. The 1968 movie is regarded as among the best movies in history. Before these 4 books, Clarke published a short story "The Sentinel" (PDF) in 1951, which he later expanded into the "2001 A Space Odyssey" in 1964, and further rewritten as a movie.

Arthur Clarke's books on the Space Odyssey series can be found here.

Wednesday, August 15, 2012

The magic squares

The matlab7 book I'm reading uses Durer's matrix as an example. This leads to my finding of the wiki page on magic squares. Sleek, or sick?

Another unrelated but similarly magical description on numbers encrypted in architectures: Secrets In Plain Sight - Art, Architecture & Urban Design, and here on youtube.

Saturday, August 11, 2012

Virtual machines

- VMware 
  - VMware server *: Virtualization on windows/linux, free
    - Step-by-Step VMware Server Setup Tutorial 
    - Support ended on 6/30/2011, replaced by:
      - VMware Player *: Free, support 1-2 virtual machines
      - VMware vSphere Hypervisor: Free, support buyable
      - VMware vSphere: 30-day evaluation. For cloud (e.g., >100 virtual servers)
  - VMware Workstation: 60-day evaluation. 
  - VMWare Fusion: Run windows on Mac, free to try, $49.99 to buy.
  - Comparison between VMware Workstation, Player and Server
- Bochs 

- QEMU 
 
- Oracle VirtualBox
 

Monday, August 6, 2012

Problems/Bugs with MSSQL server

There are some noticeable issues with MSSQL Server 2008.

- Cannot call function from remote machine.
- IDE issue: right click on a database, choose "Property -> Files", changes made to the Autogrowth dialog box sometimes cannot be saved. One has to repeat the steps several times before the change can take effect.
- Issues with extended property: 1) not included in replication synchronization process, and 2) no Information_Schema view is provided for extended properties. (from here)
- Also for extended property, I sometimes need to return extended properties of all the columns in a table, the order of returned list is un-deterministic and causes a headache when I want to display the columns in a certain order.

Thursday, August 2, 2012

Interesting blogs

== Good sites on compiler ==
Surely I Am Joking, 当然我在扯淡
Ying Wang @ Github
 
Book: Structure and Interpretation of Computer Programs (SICP), 2nd edition, H. Abelson and G. Sussman with J. Sussman

编译点滴 (Blog of a ICT student in compiler theory)

== Physics ==
The messenger series

== General suggestions ==
IT学生解惑真经

Friday, July 27, 2012

Some vbscript utilities

Here are some vbscript code examples.
--Table of contents--
1. Send email
2. Get computer name
3. Connect to database and execute query
4. Restart a windows service
5. Use of a log file
--

1. Send email

Sub sendEmail(ByRef text)
  Dim objMessage
  Set objMessage = CreateObject("CDO.Message")
  objMessage.Subject = "..."
  objMessage.From = "..."
  objMessage.To = "...@..."
  objMessage.TextBody = "...text..."

  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 
  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "..." 
  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =25 
  objMessage.Configuration.Fields.Update

  objMessage.Send
End Sub

2. Get computer name

Dim objShell, strComputer
Set objShell = CreateObject("WScript.Shell")
strComputer = objShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
Set objShell = nothing

3. Connect to database and execute query

Option Explicit

on error resume next
Set objShell = CreateObject("WScript.Shell")

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB.1;Data Source=localhost;Initial Catalog=<db>","<username>","<password>"

if err.number <> 0 then
    WScript.Echo "error " & hex(err.number) & ": " & err.description 
else
    WScript.Echo "value = " & getVal()
    objConnection.close
end if
on error goto 0

Set objConnection = Nothing

Set objShell = nothing
WScript.Quit(0)

Function getVal()
    Dim sql, strWatchFile
    sql = "select val from table"
    set strWatchFile = objConnection.Execute( sql )
    if err.number <> 0 then
        WScript.Echo hex(err.number) & vbcrlf & err.description 
        getVal = -1
        Exit Function
    else
        getVal = strWatchFile(0).value
        strWatchFile.close
    end if
    set strWatchFile=nothing
End Function

4. Restart a windows service (by calling the batch file below)

objShell.Run "restart.bat ""<service name>""", 0, true

The three parameters are:
  1) string: shell command, a batch file in this case (plus its parameter).
  2) int: 1 - show window, 0 - hide window.
  3) boolean: true - wait until the shell command ends, false - do not wait.

5. Use of a log file

Dim objFileSystem, objLogFile, logFileName, useLog

useLog = True
logFileName = "C:\mylog.log"
Set objShell = CreateObject("WScript.Shell")

openLog()
writeLog("hello world")
closeLog()

Set objShell = nothing
WScript.Quit(0)

Sub openLog()
  If NOT useLog Then Exit Sub
  Const OPEN_FILE_FOR_APPENDING = 8
  Set objFileSystem = CreateObject("Scripting.fileSystemObject")
  If NOT objFileSystem.FileExists(logFileName) Then
    Set objLogFile = objFileSystem.CreateTextFile(logFileName, TRUE)
  Else
    Set objLogFile = objFileSystem.OpenTextFile(logFileName, OPEN_FILE_FOR_APPENDING)
  End If
End Sub

Sub writeLog(txt)
  WScript.Echo txt
  If useLog Then objLogFile.WriteLine(date & " " & time & ": " & txt)
End Sub

Sub closeLog()
  If NOT useLog Then Exit Sub
  objLogFile.Close
  Set objLogFile = Nothing
  Set objFileSystem = Nothing
End Sub

Restart windows service in a batch file

::
:: usage: restart.bat <service name>
:: Note quotation marks can be used if the service name contains space.
::
:: This batch script restarts a windows service (given as a parameter of the batch file).
:: It does this by:
:: 1) issue a stop command;
:: 2) check the status of the service, go back to 1) if it is not stopped yet;
:: 3) when the service has been stopped, restart it.
::
:: Note: the provided service MUST exist, otherwise it will get into an infinite loop.
::
:: References:
:: [1] http://serverfault.com/questions/25081/how-do-i-restart-a-windows-service-from-a-script
:: [2] http://boards.straightdope.com/sdmb/showthread.php?t=458812
:: [3] http://www.robvanderwoude.com/errorlevel.php
::
::

@ECHO OFF

if [%1]==[] goto end

:stop
sc stop %1

rem cause a ~2 seconds sleep before checking the service state
ping 127.0.0.1 -n 2 -w 1000 > nul

sc query %1 | find /I "STATE" | find "STOPPED"

if errorlevel 1 goto :stop
goto :start

:start
sc start %1

:end

Blog Archive

Followers