Sunday 7 December 2014

Some observations on the current trend of UI design

Desktop application

Compared to the UI in Mac OSX, the UI of Linux applications is usually not very attractive, but there are still some UI elements that make the applications a bit better.
  • Minimal border thickness: borders are useful to separate out areas of different functionality. Over the years, we can see a trend of decreasing border thickness to just a line.
    For example, the Arduino application on Linux has no border thickness between the tool bar and the tab pane. It has a border between the editor the status bar, which, in my opinion, could be reduced. 
    The Chrome app is another example with thin lines as borders.

Tuesday 24 June 2014

Tibetan Dance

Thursday 24 April 2014

Sparse coding

An ordinary least square regression does not apply regularization on the parameters we try to estimate. Often we regularize the optimization problem. This practice is know as shrinkage in statistics. The classic regularizer is the squared \(l_2\) norm of the parameters to estimate. This results in the familiar ridge regression problem.

Lasso stands for "Least Absolute Shrinkage and Selection Operator." It replaces the 2-norm in ridge regression with a 1-norm. Lasso is often used in sparse coding because it provides a sparse solution in the sense that many parameters are zero for large enough regularization factor.

References:
http://pages.cs.wisc.edu/~jerryzhu/cs731/regression.pdf

Wednesday 26 March 2014

CRF and HMM

CRF formulation

  • A CRF model consists of
    • F = \(<f_1, \ldots, f_k>\), a vector of "feature functions"
    • \(\bf{\theta} = <\theta_1, \ldots, \theta_k>\), a vector of weights for each feature function
  • Let O = \(<o_1, \ldots, o_T>\) be an observed sequence
  • Let A = \(<a_1, \ldots, a_T>\) be the latent variables
$$p(A = y | O) = \frac{\exp (\theta \cdot F(y, O))}{\sum_{y'} \exp (\theta\cdot F(y', O))}$$


Reference
http://knight.cis.temple.edu/~yates/cis8538/sp11/slides/conditional-random-fields.ppt

Sun protection

Sun protection products experience

  • Kiehl's Vital Sun Protection: has Avobenzone which can produce radicals under photolysis. But this ingredient is very common in other products that are based on chemical sun projection, like La Roche-Posay sun screen with SPF 60. So far, I quite like Kielh's sun protection products be it the moisturizer with SPF15 or the pure sun screen. The biggest plus of Kiehl's sun screens is that it's not very oily.

How to choose/use sun protection products

  • Better to use none oily and nonacnegenic products
  • Need UVB and UVA broad spectrum protection.
  • SPF indicates the time you can stay under the sun without getting a skin burn. Normally it takes 20 minutes to produce redness on a light skinned individual. Multiply this number by the SPF of your product. Example: with an SPF 15 x 20 minutes of sun time = 300 … is how many minutes you can stay in the sun without burning. 300 minutes divided by 1 hour of 60 minutes = 5 hours of sun protection without a sunburn. So SPF 15 seems to be enough for a normal day for sun exposure on the way to work. If you go out during the middle of the day, maybe you can reapply some sun screen. SPF 25 will give 8 hours of sun protection which is enough for a day. 
  • The amount to apply is important as well. The SPF is determined based on 2mg/cm^2 usage. This is roughly the size of a coin for face. Japanese brands are usually more liquid, so usually we need 2 times the size of a coin for the face.
  • Too much sun screen, can cause burden to the skin as well: clogging the pores if the product is thick and oily. Seems like using moisturizer with SPF 15 is OK in winter and SPF 25 is necessary in the summer. If you are going outdoor for a longer time, use SPF30+.
  • Sun screen active ingredients:

Recommended products


  • Neutrogena Pure & Free Baby Sunblock Lotion SPF 60+ with PureScreen
婴儿用品,成份属于物理性防晒。通常物理性防晒产品都有过于厚重油腻的嫌疑,是我们综合/油性皮肤的大忌,于是我直接取了一点,抹在我全脸最油腻的地方---鼻子和额头,一开始,感觉很厚很白,就像一般的物理性防晒霜一样。。。心里大叫不好。。。但不出30秒后,它居然就神奇般的被彻底吸收了,我再摸了摸鼻子和额头,居然比涂抹之前更干爽!而且除了一丝干爽的味道,没有任何异味和油腻的痕迹。但作为一只身经百战的白鼠,我依旧不放心,一直在脸上留了近6个小时,油腻的变化不大,而且摸起来的手感很柔软,我觉得是隔离的作用。再看了看成份表,居然还含有适合敏感肌的燕麦与芦荟,真够有心的~

Other resources

http://www.douban.com/note/154595195/

Tuesday 25 March 2014

Sunday 16 February 2014

How to stay young and beautiful

Good habits

Food

Lycopene

Benefits: provides antioxidants, prevents sun burn, good for skin and prevents wrinkles.
Source: tomato paste, tomato sauce, ketchup

http://www.youtube.com/watch?v=bTUKs2d1nVs

Polyphenols

Benefits: good for heart
Source: red wine

Anthocyanin

Source: berries


Benefits: eye
Source: kale, spinach, raw is better 

Sunday 26 January 2014

Triple boot MacBook Pro late 2013

Install Ubuntu

Follow instructions here.
How to solve some issues.

Install Windows 7

Making USB ports work

The main challenge of installing Windows 7 on a MacBook Pro with only USB 3.0 ports is that the Windows 7 installer does not have USB 3.0 drivers. Initially I tried to bypass using Bootcamp to install Windows because I've already partitioned the disk and the Bootcamp doesn't work with partitioned hard disk. I tried several methods, including slip streaming USB 3.0 drivers to the Windows installer, but it didn't work. The mouse and keyboard wouldn't work so I couldn't progress in the installation process. Finally as the last resort, I deleted all the partitions including the Recovery HD, so that Bootcamp can work again.

Before deleting the Recovery partition though, I tried to copy it to a USB stick (just to be safe). However, I had a lot of trouble backing up the Recovery HD partition to a USB stick. It turned out that the main reason was that the size of my USB stick was not big enough. It requires a USB of 2GB+ memory.

After restoring the hard disk to 1 partition, Bootcamp works again and the keyboard and mouse works during the Windows installation process. However, after I booted into Windows 7, the USB ports still didn't work so I couldn't access all the Windows support drivers (network adapters, graphic card drivers etc) downloaded in the USB stick. As the network was not working either, I couldn't access the Internet either. Finally, I solved the problem by install VMware Fusion and created a virtual machine from the BootCamp partition. Then I did the following:

  1. Share the driver folders from the host OS to the guest OS (BootCamp and $WinPEDriver$ folders) and copied these folders into the Windows partition.  
  2. Reboot into Windows and install the drivers using the "setup.exe" file in the BootCamp folder (Note that you can't do the setup in the virtual machine because the setup program will report that the computer is not compatible with the drivers).

Other standard steps

  1. If haven't already done son, install rEFInd boot manager. After downloading the program, just go to its folder and run
    $ ./install.sh
    Every time after a major OS update, the program seems to be affected and you need to install the program again.

Resources:
http://clc.its.psu.edu/UnivServices/itadmins/mac/blastimageconfig/createasrrecoveryhdimage10.7
http://lifehacker.com/5823096/how-to-burn-your-own-lion-install-dvd-or-flash-drive
http://www.iclarified.com/entry/?enid=2672
Add triple boot OSes to virtual machines: https://www.youtube.com/watch?v=zNYXWEdVivo

Friday 24 January 2014

Accessing a server running in VirtualBox

I ran Ubuntu in VirtualBox on a Windows 7 host. When I started a Unicorn HTTP server in the guest Ubuntu OS, it reported as listening on address 0.0.0.0. To access this web server in the Windows host browser, you can check the IP address of the virtual machine using ifconfig and use that IP address in the host browser.

Events and delegates in C#

Delegates

A delegate is a reference type, but instead of referring to an object, a delegate refers to a method. In other words, a delegate is a type that represents references to methods with a particular parameter list and return type.  This is called encapsulating the method. When you create the delegate, you specify a method signature and return type; you can encapsulate any matching method with that delegate. It is like a function pointer in C++ but are type safe (the method passed needs to conform to the method signature).
You create a delegate with the delegate keyword, followed by a return type and the signature of the methods that can be delegated to it, as in the following:
public delegate int FindResult(object obj1, object obj2);
class MediaStorage {
  public delegate int PlayMedia();
  public void ReportResult(PlayMedia playerDelegate)
  {
    if (playerDelegate( ) == 0)
    {
        Console.WriteLine("Media played successfully.");
    }
    else
    {
        Console.WriteLine("Media did not play successfully.");
    }
  }
}
public class AudioPlayer
{
    private int audioPlayerStatus;

    public int PlayAudioFile( )
    {
        Console.WriteLine("Simulating playing an audio file here.");
        audioPlayerStatus = 0;
        return audioPlayerStatus;
    }
}

MediaStorage myMediaStorage = new MediaStorage( );
// instantiate the delegates
// PlayAudioFile conforms to the PlayMedia delegate signature
MediaStorage.PlayMedia audioPlayerDelegate = new
                   MediaStorage.PlayMedia(myAudioPlayer.PlayAudioFile);
myMediaStorage.ReportResult(audioPlayerDelegate);
Events and Delegates
class Clock {
// Define the SecondChangedHandler delegate type. This delegate will encapsulate any method that
// returns void and that takes two parameters. 
public delegate void SecondChangeHandler(
    object clock, TimeInfoEventArgs timeInformation);
// Create an instance of the delegate
public SecondChangeHandler SecondChanged;
}
class DisplayClock {
public void Subscribe(Clock theClock)
{
  theClock.SecondChanged +=
    new Clock.SecondChangeHandler(WriteLogEntry);
}
}
The problem with the above code snippet is that other methods can call SecondChanged directly and this is not normally the original class intends..  For example:
Console.WriteLine("Calling the method directly!");
System.DateTime dt = System.DateTime.Now.AddHours(2);
TimeInfoEventArgs timeInformation =
    new TimeInfoEventArgs(  dt.Hour,dt.Minute,dt.Second);
theClock.SecondChanged(theClock, timeInformation);
To prevent external calls to the delegated method directly, one can make the delegate private, but then this will prevent clients from registering with the delegate at all. What's needed is a way to say, "This delegate is designed for event handling: you may subscribe and unsubscribe, but you may not invoke it directly."


To fix your program, change your definition of SecondChanged from:
public SecondChangeHandler SecondChanged;
to the following:
public event SecondChangeHandler SecondChanged;
Adding the event keyword fixes both problems. Classes can no longer attempt to subscribe to the event using the assignment operator (=), as they could previously, nor can they invoke the event directly, as was done in the preceding example. Either of these attempts will now generate a compile error.

There are two ways of looking at SecondChanged now that you've modified it. In one sense, it is simply a delegate instance to which you've restricted access using the keyword event. In another, more important sense,SecondChanged is an event, implemented by a delegate of type SecondChangeHandler. These two statements mean the same thing, but the latter is a more object-oriented way of looking at it, and better reflects the intent of this keyword: to create an event that your object can raise, and to which other objects can respond.
You can also assign this delegate by writing the shortened version:
theClock.SecondChanged += TimeHasChanged;
Reference:
http://msdn.microsoft.com/en-us/library/orm-9780596521066-01-17.aspx
http://msdn.microsoft.com/en-us/library/ms173171.aspx

Tuesday 14 January 2014

Linux

X Window System (X11) is the windowing system for bitmap display, common on UNIX-like OSes. X provides the basic framework for a GUI environment. It does not mandate the user interface - this is handled by individual programs, such as window managers. A window manager controls the placement and appearance of application windows. Examples of window managers include GNOME 2, KDE and Awesome.

Friday 10 January 2014

Installing OpenAFS on MacOS X 10.9

The latest OpenAFS for MacOS is only for 10.8. If you try to install this version on 10.9, the installer will say the required version is 10.8 and you can't continue. However you can still install it through the command line and it works.

I followed the instructions on this website. No restart was needed. I wasn't able to configure the default cell through the OpenAFS preference setting. It may be due to the permission issue. So I manually edited ThisCell file in /var/db/openafs/etc with sudo privilege.

Thursday 9 January 2014

TeXlipse pdf viewer syncing

On Windows, SumatraPDF works well with TeXlipse pdf viewer syncing. On a 64-bit Windows 7, we need 64-bit SumatraPDF for the inverse search to work. The following website gives details on how to configure both TeXlipse and SumatraPDF:
http://joerglenhard.wordpress.com/2011/12/29/texlipse-and-sumatrapdf/

For the pdflatex.exe setting, the following works:
-synctex=1 -interaction=nonstopmode --src-specials %input
-synctex=1 means zipping the synctex file. The synctex file enables synchronization between the source file and the pdf output file.