Wednesday, September 5, 2012

Tech Jobs Across America

Interesting article and statistics on tech job distribution across American.

Tuesday, September 4, 2012

A Chinese poem processor

A lot of language games can be done. I am also thinking of doing some Natural Language Processing stuff later.
The code below can be improved significantly in the data processing part. For example, on things such as 1) length of poem sentence, 2) position of target character, 3) tone (平仄), 4) semantic analysis so the mood matches.
More poem source files can be added.
The only tricky thing here so far is handling UTF8 characters.
#
# This script reads Chinese poems and store the sentences into a repository,
# then find poem sentences that start with letters in the given target sentence.
#
# This can be used for some language games, 
# such as forming a poem for somebody's birthday in the form of a "藏头诗".
#
# This script should be saved in utf8 format. 
#
# http://ahinea.com/en/tech/perl-unicode-struggle.html
# http://stackoverflow.com/questions/519309/how-do-i-read-utf-8-with-diamond-operator
# http://stackoverflow.com/questions/9574198/comparing-two-unicode-strings-with-perl
# 
# Chinese poems:
# http://www.shuku.net/novels/mulu/shici.html
#
# 藏头诗 generator: http://www.zhelizhao.com/cangtoushi/
#
# By: HomeTom
# Created on: 2012/09/04
#

require Encode;
use utf8;
use strict;

##################
# Change setting here.
##################

# Data source
my @files = ("tang300.txt", "song100.txt");
# Target sentence
my $target = ("小明生日快乐");

##################

my $cnt = 1;
my $len;
my @chars;
my @first = (); # first char.
#my $char;
my $DEBUG1 = 0;
my $DEBUG2 = 0;
#print "hi\n";

#binmode STDIN, ":utf8";
binmode STDOUT, ":utf8";

##################
# Read data.
##################

my @lines = ();
my @lines2;

foreach my $file (@files) {
  open FILE, $file or die $!;
  @lines2 = <FILE>;
  close FILE;
  push(@lines, @lines2);
}

##################
# Process and analyze data.
##################

foreach my $line (@lines) {
  chomp($line);
  $line = trim($line);
  $line = Encode::decode_utf8($line);
  @chars = split //, $line;

  if ($DEBUG1) { 
    print "$cnt: $line\n"; 
    print "$cnt: "; 
    print "$_." foreach (@chars); 
    print "\n"; 
  }

  #if ($chars[0] ne "") 
  {
    push (@first, $chars[0]);
  }

  $cnt ++;
}

if ($DEBUG2) {
  print "$_\n" foreach (@first);
}

$len = @first;


##################
# Search poem sentences for each word in the target sentence.
##################

my @words = split //, $target;

foreach my $w (@words) {
  print "==$w==\n";
  getLetterLines($w);
}


1;


##################
# Subroutines
##################

sub getLetterLines() {
  my $i;
  my $c;
  my $letter = shift;
  for ($i = 0; $i < $len; $i ++) {
    $c = $first[$i];
    if ($c eq $letter) { print "$i: $lines[$i]\n"; }
  }
  #print "\n";
}


#
# Trim functions, from: http://www.somacon.com/p114.php
#

# Perl trim function to remove whitespace from the start and end of the string
sub trim($)
{
  my $string = shift;
  $string =~ s/^\s+//;
  $string =~ s/\s+$//;
  return $string;
}
# Left trim function to remove leading whitespace
sub ltrim($)
{
  my $string = shift;
  $string =~ s/^\s+//;
  return $string;
}
# Right trim function to remove trailing whitespace
sub rtrim($)
{
  my $string = shift;
  $string =~ s/\s+$//;
  return $string;
}

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学生解惑真经

Blog Archive

Followers