Sunday, February 22, 2015

Compiling Z3py on Windows

1. git clone Z3.
2. Install Python. (Either 2.x or 3.x is fine.)
  • Note that you have to install 64bit/32bit Python runtime on a 64bit/32bit machine; for otherwise the Z3py library would not initialize (would show a "dll not found" message).
3. Install Visual Studio Community if you don't have Vitual Studio installed. Add the command-line tools of VS to your PATH environment variables.
4. Install Windows SDKs for libraries.
5. Setup environment variables in Cygwin for nmake.
  • On my computer, I set these two:
    LIBPATH="C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib"
    INCLUDE="C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include"
    
6. Configure and nmake Z3
  • I have to remove BOM in file z3\src\api\dotnet\Properties\AssemblyInfo to resolve a decoding problem.
7. Done.

Thursday, February 19, 2015

Implementations of MapReduce

Bash
Node.js
Scala

Sunday, February 8, 2015

Pitfalls for Scala beginners --- Part 2

Functions vs. methods. A method m can be converted to a function using m _. Note that one can't convert the other way around. The two practical differences between functions and methods are 1) Functions cannot be generic. 2) You cannot return from a function. For example,
def foo = {
  val f = () => { return }
  f()
  println("hello") // never printed
}
Also, when you use this inside a function body, it refers to the closure where the function literal is evaluated, while this inside a method body refers to the closure where the method is defined.

Monday, February 2, 2015

Add disk space to the root directory on a VM

# Suppose the second disk is /dev/sdb
fdisk /dev/sdb

### In the fdisk shell ###
# Create a new partition using command 'n' (default options are fine)
# Set its type with command 't' as '8e' (for making it 'Linux LVM')
# Write and exit shell with command 'w'

# Format the partition you require using mkfs command
mkfs -t ext4 -c /dev/sdb1

# Now you can mount /dev/sdb1 on a directory. Go on if you want to
# merge it into the root logic volume
# create LVM & merging it into root, first creating physical volume
pvcreate /dev/sdb1

# Look up the name of the root Volume Group using vgdisplay
vgdisplay

# Add the newly created physical volume into logical volume group
vgextend /dev/<vg_name> /dev/sdb1

# extend it (<logical_volume> is usually 'lv_root')
lvextend /dev/<vg_name>/<logical_volume> /dev/sdb1

# resize it
resize2fs /dev/<vg_name>/<logical_volume>

# Done!