Building OpenJDK 9 on a OSX (or any linux)

This is a tiny tutorial on how to build your own copy of OpenJDK 9 from the current sources.


├─Install a package system
├─Install ccache
└─Command Line Tools
Download OpenJDK 9
Build OpenJDK 9
├─JTREG: The variables
└─Running tests


Install a package system

Install brew or macports. I prefer brew. Both are package systems for OS X.

Install ccache

ccache is a compiler cache - speeds up the build.

$ brew install ccache

Command Line Tools

We need them so we have a C compiler and other tools.

Install Xcode Command Line tools ( you don't need the whole Xcode, only the command line tools)

Download OpenJDK 9

Get the sources, in the console type:

$ mkdir jkd9
$ cd jdk9
$ hg clone jdk9.hg

Takes 10-20 secs. This downloads basically a couple of scripts that we will execute to get the actual sources.

Now we execute the script we downloaded:

$ cd jdk9.hg
$ chmod u+x
$ ./

The last command can can take 10-20 minutes depending on the connection speed.

Build OpenJDK 9

$ chmod u+x configure
$ ./configure
$ make clean images

The second command took a bit less than 20 minutes. The first command is fast.

The result: we have this created:  build/macosx-x86_64-normal-server-release/images/jdk/ - this is the built OpenJDK 9 - SUCCESS.


jtreg is a "testing harness" (whatever that means) made specially for OpenJDK. We need it to run the tests written for the OpenJDK

Download from (not the Snapshot version, the other one).

unzip in jdk9, so we have jdk9/jtreg.

JTREG: The variables

The official instructions suggest we edit ~/.bashrc. I don't like changing global (for your user) settings, so we can put these settings in jdk9/.bashrc

$ nano .bashrc

Add the following lines:

export SOURCE_CODE=/Users/steve/jdk9/
export PRODUCT_HOME=$SOURCE_CODE/jdk9.hg/build/macosx-x86_64-normal-server-release/images/jdk
export PATH=$PATH:$PRODUCT_HOME/bin:$JT_HOME/linux/bin/

NOTE: Change /Users/steve/jdk9/ with your folder on the top line.
NOTE: Check the correctness of PRODUCT_HOME too.

To execute this file, do:

$ source .bashrc

Running tests

$ cd jdk9.hg/test
$ make jdk_util


Webrev crawls over your changes to generate a set of web-based views of the differences in your code. The different views allow reviewers to easily look at your proposed changes, selecting the appropriate difference format based on the type of file, the type of change, and their own preferences.

webrev.ksh is a 70kb kshell script. Pretty weird.

Go to jdk9.hg and:

jdk9.hg# wget
jdk9.hg# chmod u+x webrev.ksh

To prepare a webrev, make some changes. For example in the jaxp folder. Then we commit locally in the mercurial repo.

jdk9.hg# cd jaxp
jaxp# hg commit -m "BGJUG: Fix compiler warnings in jaxp repository"
jaxp# ../webrev.ksh

It will prepare a webrev/ dir and The folder is then uploaded somewhere and sent to the appropriate mail list inside openjdk. Example:

Note: execution times come are measured on a pretty recent Macbook Air.


[] Building Valhalla and using primitives as generic arguments

Project Valhalla will probably be part of Java 10 (expected 2018). Among other things it allows using primitives as generic arguments.

Building Valhalla

On a linux/unix/osx box we start with:

hg clone
cd valhalla
bash  #this one takes some time
bash configure
make clean images # this one takes some cpu


We can have a class like this:

public class Program  {
	public static void main(String[] args) {
		// this one still doesn't work, List not updated to List
//		List l = new ArrayList();
//		l.add(5);
//		System.out.println(l.get(0));
		Box b = new Box(6);
class Box {
    private final T t;
    public Box(T t) { this.t = t; }
    public T get() { return t; }


Running javap gives

$ javap -c Program.class gives:
[openjdk@localhost bin]$ ./javap -c Program.class 
Compiled from ""
public class Program {
  public Program();
       0: aload_0
       1: invokespecial #1                  // Method java/lang/Object."":()V
       4: return
  public static void main(java.lang.String[]);
       0: new           #2                  // class "Box${0=I}"
       3: dup
       4: bipush        6
       6: invokespecial #3                  // Method "Box${0=I}"."":(I)V
       9: astore_1
      10: getstatic     #4                  // Field java/lang/System.out:Ljava/io/PrintStream;
      13: aload_1
      14: invokevirtual #5                  // Method "Box${0=I}".get:()I
      17: invokevirtual #6                  // Method java/io/PrintStream.println:(I)V
      20: return

Running our pretty simple app gives:

[openjdk@localhost bin]$ ./java Program
Specializing Box${0=I}; searching for Box.class (not found)
Specializing Box${0=I}; searching for Box.class (found)
[openjdk@localhost bin]$

Notes: List is still not parameterized with because ... issues.

USB over IP - connect directly to a remote usb device

Problem1: My printer's scanner does not work over the wire with OSX. So the scanner part works by cable only. Well what if I put the usb cable over the wi-fi? Well, now I have a wireless scanner.

Problem2: I have a remote backup drive that I want to keep bootable and encrypted. Was it possible before this? I couldn't make it work. Is it possible now? I think so.

VirtualHere is a commercial software. For free it allows one simultaneous device, if you disconnect the first, you can use the second. It works flawlessly.

Its server has builds for most linuxes plus OpenWrt. The client is very simple, builds for osx, win, linux.

There are FOSS alternatives. If anyone has tried them, please share some info.

Airport Utility protocol port: tcp:5009

Sometimes I need to access an Airport Extreme router (Apple's own wi-fi router) that's hidden behind a NAT.

There is a way to do that with Bonjour, but I haven't made it work.

I do that with local port forwarding via ssh, and the port is 5009 (add -L5009:, and then open The airport utility and click File->Configure Other... and then enter localhost as the address, and type your password.

Screen Shot 2014-11-22 at 3.14.45 PM

Finder: new text file?

AppleScript to the rescue again:

on run {input, parameters}
	tell application "Finder" to make new file at (the target of the front window) as alias
	return input
end run

Screen Shot 2014-11-17 at 6.46.00 PM


Save it as an Automator Application, then while holding the Command, drag to Finder toolbar to add as a button.

Macbooks: powerered usb ports?

So sometimes you want to charge something from the usb of a macbook while the macbook is closed (sleeping, or whatever this functionality is called nowadays). Other manufacturer like ASUS have one usb port that is always powered, while the rest are not.

This is what I found.
With macbooks that's not the case. If the macbook is closed, all the ports are unpowered.
If you start charging something while the macbook is open, and then close it, it will continue to charge it while closed. Which is a really cool, because initially I thought all the ports are unpowered.

This is a bit annoying, because if closed, you have to open the macbook first.

Tested on the latest MBA.

qbit links to the wrong library

Qbit depends on openssl, but the one installed from macports.

If you see:
Dyld Error Message:
Library not loaded: /opt/local/lib/libcrypto.1.0.0.dylib
Referenced from: /Applications/
Reason: image not found

Fix it with:
sudo cp /Applications/ /opt/local/lib/

or with:

sudo port install openssl

macports vs. homebrew

&gt;sudo port install imagemagick

Goes for 40 min, still not done, I got bored and stopped. And my laptop was overheating.

&gt;brew install imagemagick

Done in 15 seconds.

The reason is that macports compiles everything and the ports are very granularized, while with homebrew most items are less granularized and are precompiled.

Talk smtp to gmail with openssl s_client

Here are the basic commands to talk smtp to gmail.

We will send email from to
The gmail password of is "my secret password".


To authenticate, we need our user/pass in base64 format:
base64("") = c2VuZGVyQGdtYWlsLmNvbQ0K
base64("my secret password") = bXkgc2VjcmV0IHBhc3N3b3Jk

To get the base64 encoded string, google "base64 online encoder" and click on any of the online encoder/decoders.

If you're using Gmail's two-step authentication

Go to and get a one-time password.

Ending the DATA of the email.

To end the DATA part, we need to press dot (".") and then Enter (which should send CRLF).

Important NOTE: I'm on a macbook, and the terminal client sends LF when I press enter. When I want to send CRLF, I press Ctrl+V, Enter. If you don't know what I'm talking about, after the dot (".") if it doesn't work with dot and Enter, press [dot, Ctrl+V, Enter].

The commands

We will use S_client which is like telnet, but supports SSL (encrypted telnet). You will need OpenSSL for that purpose.

[mihail@arch ~]# openssl s_client -connect -starttls smtp
[a lot of text will be printed - ssl info. For simplicity ignore it.]
auth login
334 VXNlcm5hbWU6
334 UGFzc3dvcmQ6
235 2.7.0 Accepted
250 at your service
mail from:<>
250 2.1.0 OK dc8smxxxxwib.7 - gsmtp
rcpt to:<>
250 2.1.5 OK dc8smxxxxwib.7 - gsmtp
354 Go ahead dc8smxxxxwib.7 - gsmtp
subject:manual smtp with gmail
some text as the body of the email
more lines of text

250 2.0.0 OK 1414600919 dc8smxxxxwib.7 - gsmtp
221 2.0.0 closing connection dc8smxxxxwib.7 - gsmtp
[mihail@arch ~]#




If you want to use SSL 465, the command is:
#openssl s_client -connect -tls1

(here you need to start with HELO, and then AUTH LOGIN - I don't know why)


Also, some accounts fail with:

3073894076:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:598:

I don't know why. It seems like it wants to fall back to ssl3.

TRIM suppport in OS X Maverics

Check System Information on TRIM support, should say No

sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original
sudo perl -pi -e 's|(^\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage
sudo touch /System/Library/Extensions/


Check System Information on TRIM support, should say Yes


Update: my writes went from ~333mb/sec to 400-475 mb/sec on blackmagic disk speed test

Wineskin vs. PlayOnMac vs. WineBottler vs. CrossOver for Microsoft Office on a Mac



Microsoft Office is a de-facto standard. The discontinued version for OS X has an appalling interface, is not very interoperable and lacks the Ribbon interface. The iWorks is not a good solution if most of the people you work with use .docx, and ppt and .xsl.

Office 2010 and 2013 are not well supported on wine (just now a preview with 2013 was shown on wine on linux). So Office 2007 is used.

My criteria: how well it works, how well it integrates, can it print directly, can it use the keyboard layout of the OS X.

All the softwares shown are wrappers of wine.

PlayOnMac (ver. 4.2.2) FREE

  • installation wasn't easy
  • when installing office, it downloads .net, fonts and stuff automatically
  • printing on an HP printer (first install the printer on the mac, then it appears AFAIK only if default drivers in windows exist) - prints, but crashes the app.
  • couldn't find a way to add new keyboard layouts
  • bad support
  • open with - no actual info, couldn't make it work
  • MS Word works pretty good
  • Excel took a while to open a 5mb file
  • Overall: works but not sufficient for me

WineBottler (ver. 1.7.11) FREE

  • straight forward interface.
  • presets available
  • most of the built-in installers (IE6, Opera, Firefox...) don't work. Some of them do.
  • Uninstaller on the Q&A page. Doesn't work. You can delete stuff manually.
  • Installing MS Office fails for some reason (Please insert volume 'OFFICE12' (needed for package 'office2007pro')). I don't have a solution:


  • Overall: I can't make it work


Wineskin Winery (ver. 1.7) FREE

  • installation is not very straight-forward
  • fails to install - most of the offices tested fail to initialize, one started  but didn't finish
  • no presets on microsoft office - probably that's why it doesn't work
  • Overall: can't make it work at all

CrossOver (ver. 13.0.1) $50

  • installation with presets
  • Has a preset for Microsoft Office 2010 that works.
  • Supports the keyboard layout of the host.
  • Sees printers installed with the host (I don't know if drivers are needed).
  • "Open with" works by default.
  • Overall: unfortunately the only one that works fine.

Bootable USB with OS X Mountain Lion

Find the InstallESD.dmg
- either from App Store (Start installing Maverics (even if you are already on Maverics) and the location to the file is: /Applications/Install OS X
- you can also extract it from the Recovery Partition

Note: do not use the iso version and don't try to convert it. You will fail.

Then download and follow the instructions.

Really simple stylus (pen) for the iPhone

I have a friend with really long nails trying to play this game:


So she needs a stylus. How can I make her a DIY stylus for the iPhone?

There are these DIY clips online that require telescopic antennas, conductive sponges, glue and so on. How many of you have these things at home?

He're my solution:

I need a paperclip, a rubberband and cotton. That's it. The end result is this:

photo 3

  • Cotton can be substituted with toilet paper or a very small piece of sponge. (We need that in order to not scratch the screen).
  • The cotton has to be MOIST (WET). When it dries out it stops working.
  • The paperclip has to be unshielded with rubber. We need to conduct electricity for the capacitive touchscreen of the iPhone.
  • The cotton tip should be wider than the tip of a pen, otherwise it's not going to work.

How Apple distributes new versions of iOS: hashing, nonces, encryption


Apple distributes new versions of iOS by encrypting it. Before installation, the ECID (id) of the phone plus the hash of several files have to be signed by Apple's TSS service (a hashing service with a special Apple-owned private key). The signature is called a SHSH.

Jay Freeman, aka saurik is the developer behind Cydia an open source repository for iOS devices (iPhones).


The bootrom (correct me if I'm wrong) of the phone allows installation of new OS versions only if the phone's ECID matches the one in the SHSH, and the hash of the new installation (the hash of several files actually) matches the one in the SHSH. The problem here is that Apple's TSS only signes current versions.
The bootrom hasn't been broken yet, so this SHSH mechanism cannot be avoided. It exists since iOS v.2.0

How can we install older versions of iOS?

Well, Mr. Freeman here created a database that caches all the SHSH's for all the phones that want that service for all the files in all the versions of iOS. A huge database. Apple limited the caching TSS service of Saurik (Mr. Freeman) - by IP filtering for example - and he distributed it, by putting the extraction of the SHSHs in the Cydia itself and then Cydia uploads them to this database.

The caching is possible, because the SHSH is monolithic.


This is the new signature algorithm. It adds a slight but very significant change - a nonce. The nonce is a piece of garbage text (i.e. "fb*&h") that is added to the request the iPhone makes to the Apple's TSS service. For every new installation/update/restore of iOS, a new nonce is created (it's unique) and sent to TSS. Thus caching becomes pointless.

Why hasn't Apple used nonce all along?

It's hard to believe that Apple doesn't know how the SHSH caching can be fixed. I (not Saurik) assume that Apple wants to allow jailbreaking because the community demands it. They just want to delay it after every initial release of new device/OS. Jailbreaking brings open source, but it also brings pirated software and music.

Why I shared this?

A very detailed explanation on how to distribute securely desktop software with the help of encryption and a very sturdy (unbreakable) ROM on the phone itself.

The full article is here:


Force Boot Camp into using an ISO image of Windows to create the USB flash drive (for Mountain Lion with updated Boot Camp)

Note: Check the comments section - there seems to be a very live Q&A discussion on the topic.

Boot Camp Assistant requires an Optical Drive with Windows installation in it so it can install Windows.

For Macbook Air and others it supports an ISO option and it creates an usb installer.

This is how you can force Boot Camp Assistant to support the latter option for Macbooks that are supposed to have optical drives but you don't or can't use it:

Get the following strings from System Information:

Screen Shot 2013-04-22 at 2.01.57 PM


Get the selected one and the second line also (MacBookPro8,2).

Save a backup:

sudo cp /Applications/Utilities/Boot\ Camp\ /Applications/Utilities/Boot\ Camp\

Edit with root permissions (either change the permissions of the file or sudo vi) the following file:

sudo nano /Applications/Utilities/Boot\ Camp\

add your string (mine is MBP81.0047.B27):


Then find the following:


REMOVE the "Pre" from the and add your computer as a string, mine is MacBookPro8,2:


Save and exit with <Ctrl+X>, Y, <Enter>

Change url file associations in OS X

There are many custom protocols where a command can be an URI.
For example ical://some_new_event or or magnet://
There are system wide associations in OS X, but there's no interface that can edit them. Only some applications can do that, but then the control is not in your hands. Here's how:

Download RCDefaultApp - this is a preference pane for System Preferences:

Screen Shot 2013-04-10 at 11.21.17 PM

The last one, when opened, looks like this:

Screen Shot 2013-04-10 at 11.21.46 PM

Change and save!

Can I watch 1080p torrents while they are still downloading on OS X? — YES (ver.2)

This is ver1 of this manual. Ver2 is updated with a better torrent client.

A 1080p movie is around 4 -8GB in size. Downloading this takes a while even on 50mbit connection.

What if it is possible to watch while downloading? So watching starts right away.

  • We need a torrent client that can download the movie file parts in order, not randomly.
  • We need a player that supports playing incomplete files.
  • We need a connection that is faster than the movie's bitrate.

The torrent client

Previously I used BitThief. It is developed by a technology institute in Zurich. It didn't have a polished GUI and took a little bit too much CPU while downloading.

The new client I found thanks to diimdeep. It is called qbittorrent and it is awesome.

Screen Shot 2013-03-17 at 9.24.31 PM

You can see that while downloading it downloads as a normal torrent client - the parts are downloaded randomly:

Screen Shot 2013-03-17 at 9.27.38 PM

But there is an option:

After that we can see that the rest of the file is being downloaded sequentially (blue - downloaded, green - requested):

The connection speed

How can we tell if the speed is good enough? By the estimated time of arrival (ETA):

If the movie is 1.5 hours and the ETA is 17 minutes, then the speed is sufficient.

The player

The player is and always has been mplayer. I use MplayerX because it comes with a nice OSX gui. Download and associate movie files with mplayer (avi, mkg):

Screen Shot 2013-03-17 at 9.45.59 PM

The final step is to to play the file after the downloading started:

That's it.

Screen Shot 2013-03-17 at 9.41.25 PM

Happy watching.

Reset the "Open with" database on OS X

Sometimes there are a lot of VMware Fusion items left over in the "Open with" dialog.

Here's how to rebuild the "Open with" database:

dude$ /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
dude$ killall Finder

Make a bootable USB from ISO on OS X Mountain Lion 10.8 without any extra apps

Plugin the USB, then:

Screen Shot 2013-02-17 at 3.28.33 PM




mf$ hdiutil convert -format UDRW -o BT5R2-GNOME-64.img BT5R2-GNOME-64.iso
mf$ diskutil list /dev/disk2 #(careful here)
mf$ dd if=./BT5R2-GNOME-64.img.dmg of=/dev/rdisk2 bs=1m


Note: that bs=1m (without it the speed is going to be less than 1mb/sec, with it it's 10mb/sec)

Note2: we're using rdisk2 instead of disk2, again this way it's faster.

Iodined - how to use free internet on airports

How to get internet connectivity on an open wi-fi access point that requires a credit card without actually paying:


  • OpenWRT router
    • public ip, not necessarily static
  • account on
  • OS X laptop

Iodine on OpenWRT and installation on a OS X

On the OpenWRT:

  • opkg install iodined
  • update /etc/init.d/iodined to:

[dropdown_box expand_text="code" show_more="Show" show_less="Hide" start="hide"]

#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011


start_instance () {
local section="$1"
config_get address  "$section" 'address'
config_get password "$section" 'password'
config_get tunnelip "$section" 'tunnelip'
config_get tld      "$section" 'tld'

service_start /usr/sbin/iodined -l "$address" -c -s -P "$password" $tunnelip "$tld" &
sleep 1
ifconfig dns0 $tunnelip netmask

start() {
config_load 'iodined'
config_foreach start_instance 'iodined'

stop() {
service_stop /usr/sbin/iodined


  • so that it starts automatically
/etc/init.d/iodined enable
  • edit /etc/config/iodined (because there' s a bug on openwrt)
    • change address to
config iodined
 option address ''
 option password ''
 option tunnelip ''
 option tld ''
  • Make sure the openwrt router has a static ip address ( provides dyndns updates)
  • Make a dns zone: ns ->
    • has a dyndns update
  • port forward 53 (tcp and udp) from first router to second router (or just open 53 on the openwrt)

osx client

  • (tuntap)
  • script:

[dropdown_box expand_text="code" show_more="Show" show_less="Hide" start="hide"]


# are we root?
if ! [ $UID == 0 ] ; then
  echo "IODINE SETUP: use 'sudo $0'";
  exit 0;

#$1 says whether we use clearcode or
if [ -z $1 ] ; then
  echo 'IODINE SETUP: first param must be 1( or 2(';
  exit 0;

if [ $1 == 1 ] ; then

if [ $1 == 2 ] ; then

# get the first dns from resolv.conf and use it.
abused_nameserver=`cat /etc/resolv.conf | grep nameserver | head -1 | awk '{print $2}'`
echo ">>>>>>>>>>>>>>>>>>>USING DNS: $abused_nameserver"

# kill iodine if any and remove old routes
killall iodine
route delete > /dev/null
route delete > /dev/null

# get the default gateway for iodine
default_gateway=`netstat -rn | grep default | awk '{print $2}'`

#when I die, restore the default gateway, use trap to get Ctrl+C
function disconnect() {
  # kill the process with id coming as a parameter
  kill -9 $1;
  route add default $default_gateway;
#disconnect and exit
function cleanup() {
  disconnect $(pgrep iodine);
  exit 0;
trap "cleanup" SIGINT

#dns query types
dns_query_types="TXT CNAME NULL"

function connect() {
  # start iodine (possible dns types are CNAME, TXT, NULL), -F puts a pid file with the processId inside
  iodine_output=$(./iodine -T CNAME -r -P "peshev sucks" -F /var/run/ $abused_nameserver $endpoint_domain 2>&1 | tee /dev/tty)

  #remote_net from iodine_output
  remote_net=$(echo $iodine_output | grep -o "Adding route [0-9\.]*/[0-9]\{1,2\} to [0-9\.]*" | awk '{print $3}')  

  #remote_net is something like and should be
  remote_net=$(./ipcalc -nb $remote_net | grep Network | awk '{ print $2}')

  #tunX_ip (tunX_ip) from iodine_output
  tunX_ip=$(echo $iodine_output | grep -o "Adding route [0-9\.]*/[0-9]\{1,2\} to [0-9\.]*" | awk '{print $5}')

  #remote_gateway (gateway on iodine) from iodine_output
  remote_gateway=$(echo $iodine_output | grep -o "Server tunnel IP is [0-9\.]*" | awk '{print $5}')

  # route to nameserver to be abused
  route add -host $abused_nameserver $default_gateway
  # route to remote network via tunX_ip (necessary because my mac sucks)
  route add -net $remote_net $tunX_ip
  # change default gateway from system default to iodine 
  route delete default
  route add default $remote_gateway

  # time to download 100kb file in seconds (1.34). We remove the dot for easy comparison (1.34 -> 134)
  t=$( { time -p curl -s; } 2>&1 )
  seconds=$(echo $t | awk '{ print $2;}' | tr -d . );
  echo SECONDS: $seconds;


while true; do sleep 10000; done;


  •  add ipcalc because the script needs it: ipcalc


Some testing found out speeds like 7-15 kb/s, sometimes less on and With local DNS servers the speeds are like 100kb/s. More testing is necessary.

Force Integrated graphics on VMware Fusion (and probably other apps) on OS X 10.8 Mountain lion (avoid discrete graphics)

With OS X 10.8 gfxCardStatus is no longer capable of enforcing Integrated Graphics card only.

When one uses VMWare Fusion, the discrete graphics card is enforced, which drains the battery too fast.

I have not found any solution online to fix this. But I managed (thanks to PePe) to discover one.

How to use Integrated Graphics Card with VMware Fusion on OS X 10.8:

  • Install gfxCardStatus
  • Before launching VMware Fusion, click on Integrated only (click it several times until it has the checkbox on the Integrated only):

Screen Shot 2013-02-15 at 2.05.32 PM

  • Then launch VMWare Fusion, start whatever virtual machine. And don't do anything inside. Leave it idle.
  • There's a BackTrack 5 R3 with the integrated graphics card:

Screen Shot 2013-02-15 at 2.08.15 PM

  • There's a BackTrack 5 R3 VM and a Windows XP (both idle) with the integrated graphics card:

Screen Shot 2013-02-15 at 2.12.34 PM

  • I'm using iStatMenus to check my power consumption. Here's my power consumption with the two VMs:

Screen Shot 2013-02-15 at 2.07.10 PM

  • Cody Krieger (the creator of gfxGraphicsStatus) says that even if it says that the Integrated is being used, the Discrete (NVidia) is still being powered on, which invalidates the whole exercise.
  • How do I know that I'm saving power? Well, let's go to Discrete and check the power consumption:

Screen Shot 2013-02-15 at 2.16.56 PM -> discrete

  • Now, let's check what the consumption is (the same two idle VMs):

 Screen Shot 2013-02-15 at 2.20.26 PM


  • So instead of having 3:27 hours left, I now have 1:22 hours left. My consumption 2.5 Amp, instead of 1.1 Amp.
  • I can't directly go back though:

Screen Shot 2013-02-15 at 2.27.07 PM

  • What I have to do is to stop VMware completely (Cmd + Q), go to Integrated only again and restart all the VMs
  • This is something that I discovered today. So it may not be working as expected, but for now it seems it is.
  • My setup:
    • OS X 10.8.2 on a Macbook Pro 8.2 (A1286, Quad Core i7 2.3 Ghz, 16gb RAM, 256gb OCZ Vertex 3, AMD Radeon HD 6750M 1GB)
    •  VMware Fusion 5.0.1 with 2 VMs - Windows XP Pro and Backtrack 5 R3 (both were idle during this setup).


HP Director, HP Scan for OS X do not support cyrillic

Scanning a document in HP Scan (part of HP Director - the drivers for my printer in OS X) is tricky - the document cannot be saved in a folder with a long name, name in cyrillic; filename must be <24 chars long, cannot contain cyrillic. I spent 10 minutes trying to guess where the problem is. I am disappointed. This is for future reference. I know I will forget about this eventually, but I hope I will be smart enough to check here for the solution

OS X adding extra dictionaries

OS X has a three-finger feature that translates or explains (depending on the dictionary) any word in any text. It has english dictionary by default plus wikipedia.

Bulgarian dictionary:



  1. 20mb This is far too insufficient.
  2. integrated 600mb This has a lot more words. Also "lookup online" feature that goes to

Dictionaries are installed either in /Library/Dictionaries or in /Users/<UserName>/Library/Dictionaries.

Can I watch 1080p torrents while downloading on OS X? -- YES

Updated tutorial with better torrent client here.

Most large torrent files (8-20 gb) take quite a while to download. Is there software for Mac OS X that allows me to watch them while downloading?

The solution

I tried all (I mean all) torrent clients for OS X that I could find.

There were people before me who wanted the same feature and have asked the most popular clients (uTorrent and Transmission) whether they would support serial downloading. Developers replied that that would defeat the purpose of torrent protocol (it would seem that uTorrent changed their minds and have such a feature for windows).

Finally I found one that could download file parts in order. It's called BitThief. It's a research project and has an awful interface. But it works, and most importantly downloads serially.

-> -> ->

After the file is put for downloading, the speed must be good enough for watching. For example, if the movie is 1:30h long, I check the ETA time to be less than that.

To watch the movie I use MplayerX (an OS X GUI for mplayer). It can be downloaded for free from OS X App Store. Mplayer is light, can play EVERYTHING, and navigation is done with the arrow keys. Mplayer automatically regenerates the index (the thing that allows using the progress bar). The OS X gui is awesome and supports the Lion's full-screen view.

There's always a chance that things could go wrong - low speed or high speed in the beginning and then low speed (which is even worse).

Keep in mind that in order to watch a 1:30h long movie that is 20gbytes, you have to download with ~3.7mbytes/sec.

Update: tested with 700mb AVIs, 2gb, 6gb, 8gb, 20gb MKVs (was lazy to check the codec, h264 mostly I guess).

Update 2012.07.02: This solution has been serving me quite good. Still here are the issues: BitThief is not very optimized and while other torrent clients can utilize my whole bandwidth, BitThief fails from time to time, probably because it is downloading sequentially. Also magnet links are not supported and the interface sucks so much.

Update 2012.08.16: A fix for utilizing magnet links: magnet->torrent converter. Utilizing magnet links allows this process to work for and other sites utilizing the new magnet url technology.

Update 2013.02.04: The newest version of BitThief now supports Magnet URIs. They're saying that a new look and feel is also coming.

RAR files with cyrillic inside on OS X

Most rar extractors on OS X (B1FreeArchiver and SimplyRAR) cannot extract files with cyrillic in the name. The files have a weird name and the extensions get completely messed up:


Share a folder with a Windows XP VM, use WinRAR to extract directly in the shared folder (it is not a problem to use a shared folder directly). And voila the files have the correct names and extensions.

Stuff to do when reinstalling OS X Lion

  • Update, update, update
  • Set up iCloud.
  • Add Bulgarian Phonetic, change the Cmd+Space for langs, Alt+Cmd+Space for spotlight.
  • Add Bulgarian to Dict. There's a blog article for that.
  • Add Trackpad settings, switch off "Natural scrolling".
  • link the laptop with a cable to the TimeMachine.
  • Copy mihail.stoynov/
  • Set up wi-fi sync in iTunes for music and photos only.


Apps to install:

  • Chrome, log in with account.
  • iStat menus (paid)
  • uTorrent
  • iPhoto, GarageBand (from iLife) (paid).
  • Carbon Copy Cloner
  • CleanMyMac (paid)
  • Disk Inventory X
  • Dropbox
  • Filezilla
  • Firefox
  • gfxCardStatus
  • NO Ez7Z
  • Gruml
  • Mactrackr (appstore)
  • Maltego
  • MplayerX (appstore)
  • OmniDiskSweeper
  • Remote Desktop Connection 2.1 (requires admin rights to install?)
  • Skype
  • TeamViewer
  • Tomato Torrent
  • TorBrowser
  • Transmission
  • Transmit
  • Twitter (appstore)
  • VirtualBox (+extension pack)
  • VLC
  • VMWare Fusion
  • aMule
  • B1 Free Archiver for Mac
  • TunesText widget
  • GAget widget for graph


Cool new features in OS X Lion. The trackpad.

The coolest thing here is the dictionary - double-tap with three fingers. Adding extra dictionaries is not very straight-forward, but go to this guy:

You can link the dictionary with wikipedia (even the bg version of it). It is amazing.

Another very cool thing is the three finger drag.

Screen 2 - smart zoom, but it doesn't work everywhere.

When OS X Lion came out, the three-finger horizontal drag (swipe) was for switching between screens. In the previous versions it was four-finger. In the latest update they went back to four-fingers, since the three-finger swipe is for dragging windows.

I wouldn't trade a macbook just for the trackpad. I stopped using a mouse since my first one. I am so used to it that when I get back to a normal trackpad it looks like I'm back in the stone age.

Default contact group on iPhone

My iPhone downloads my contacts from gmail. Whenever I click on 'Add new contact' I want this new contact to be uploaded to gmail. Unfortunately that is not the default behaviour. The new contact goes to iCloud, even though my default mail and contacts account is gmail.

Here's how to fix this:


Remove the iCloud contacts sync. This will completely remove the iCloud contacts group:


Problem solved

Notes on keeping the SSD clean (more free disk space)

I have one of the fastest SSD drives, but unfortunately didn't have the heart to buy the 240Gb, but the 120GB version. Now, 120GB is definitely enough, but this is my primary machine, and I'm doing several different kinds of things on it, so I need space for all the projects.

How do I keep it clean:


First I run automatic tools like CleanMyMac (free):

It definitely will find stuff that you missed.

Disk Inventory X

This is another type of program - it says how much disk is used by any folder, so it's easy to find the bigger users of space:

With it I found the /private/var/vm/sleepimage file (8gb) - keeps the data when the laptop goes to sleep. I can safely use the 8gb space until my laptop goes to sleep.

It is free.


Same as the former, but all is textual.

Windows XP

I have a Windows XP vm. Keeping it clean is not easy. I use Free Disk Analyzer. It works similarly to OmniDiskSweeper and Disk Inventory X:

System Volume Information

Last time I saved 2.79 GB from this folder. My Computer -> Preferences -> System Restore (there's a slider in XP).

Compacting VirtualBox (.vdi) VMs

VirtualBox is great, because it it's free, but it has many quirks - not that good integration on copy/paste, files, shortcuts and so on. The biggest issue is that compacting the image is weirdly done

  • Defragment the VMs drive (this step is always important regardless of the virtualization software)
  • Zero out the free space. Now this is unnecessary with VMWare and Parallels. It is done with sdelete - a free windows software by SysInternals (you remember these guys? Mark Russinovich?).
    • command is "sdelete -c -z c:\"
  • Compacting the virtual disk (.vdi) is done with this command (the command comes with VirtualBox) (case-sensitive):
    • "VBoxManage modifyhd /fullpath/to/windowsdisk.vdi --compact"

Other concerns

  • I always delete the Windows update files - today I saved 500mb.
  • No swap file for windows - too slow. Few gigs.
  • Now I have no swap for OS X too (500mb).
  • 7GB from compacting the VM
  • Moved some stuff to the Time Machine (20GB)
  • Deleted a lot of temp files and swap files (20 GB)
So now I have a lot more free space. I have spent only an hour for it. Next time it will just take a few minutes.
Wow, the 240GB Vertex 3 now costs as much as I paid for the 120GB less than a year ago. Crap.