# Embedding Spotify

This is a test post for embedding spotify playlist in my blog:

And also youku:

# An Easier Vim User Guide for XX

Yesterday My friend XX asked me what he should use with python and latex, and of course as an extensive vim user I applied “Vim!”. This passage is not technically a guide but rather a collections of tools and guides for beginner vim user.

# Introduction

Vim is a wonderful text editor. Since programming is almost all about text editing. A productive editor can help you save a lot of time. There are a lot of competitor out there, but two of them are oldest and have most fans. Every serious programmer have heard their names, Emacs and Vim. They both have a long history back up to the very beginning of computer science and although there is tons of debate online about which one is better, there is no absolute conclusion. To me, they are all quite good but I choose Vim over Emacs because it just fits me better. As a beginner I encourage you to give both of them a try and see which one works for you better. However here I will stick to Vim since it’s my favorite.

# Installation

Look at this page:Vim Installation, If you are not using any rare operating system, you will be fine with this. This gives you an GUI version of Vim. And if you are using *nix systems(Linux/Unix), and you would like a terminal version of Vim, you can compile it by your own(also on that page) or using a package control system to do that for you. For mac user I recommend Homebrew and for Ubuntu or other Debian Linux distributions the apt-get can do the job for you.

# Basic Usage

If you have installed the software. The first step is to have a look at vimtutor. It’s a short tutorial on how to use vim. In *inx system this can be done by typing vimtutor in command line if you have installed the command line version of vim. If you are using a GUI version of vim then have a look at the vim folder. If you cannot find it, If you cannot find it, use this page, open your vim and do every step on your own. It won’t take you long and After this you will get the basic knowledge of how vim work.

# Plugins

Vim can be highly customized and you should learn how to set up your own Vim. In a *nix system. In your ~ folder you will have a hidden file named .vimrc and a hidden folder .vim, the .vimrc file is a configuration file that Vim will read every time when it starts. The .vimrc folder on the other hand, contains all the plugins, themes and other useful files needed by your vim. For Chinese reader there is a very good blog about .vimrc file. Read it here. And for plugins, I used to manage them by hand. But now there is a plugin that can help you managing other plugins, its called vundle. Read through the page and install it by yourself. If you have questions, feel free to ask me.

Here is my .vimrc file: my .vimrc file You can see I am using a lot of plugins, here is a list of part them:

• taglist.vim–show the tags(function names, marcos…) of a file.
• SuperTab–help with autocomplete
• powerline–show the status of a file in a fancy way
• nerdtree–a file browzer inside vim
• The-NERD-Commenter–comment a block of code sexily
• a.vim–fast .h/.c file switch

And there are a lot of more to explore. For Chinese reader this page is worth reading (although it is a little outdated) and this pageis suitable for English reader(I highly rely on this one).

# 我为什么很少谈论中国政治了

1. 我相信民主是能给一个国家的国民带来幸福的，民主能够提升一个民族的整体思想水平，因为它允许所有人参与到关于公共事务的讨论中来，让所有人决定一个群体的命运， 而不是一部分人被另一部分人主宰。
2. 自由是中国先当下最需要的东西，开放网禁、言禁不仅有利于民主的推进，更有利于政府改善自身，适应当下社会。
3. 但是，中国社会没有坏到要为民主自由说谎。我极力反对用一些阴谋手段推动民主自由。社会的变革不再一朝一夕，我真诚希望能在合理合法的框架下，看到中国一步一步地改变。追求民主自由的脚步永远不可能停歇（不只在中国，全人类都不应放弃、自满）。民主自由是一种理想状态，我们不可能一下达到。但要以其作为我们对自身，对政府的要求。

# Java and Python:pass by Reference or Pass by Value?

I am a confident C programmer because I am quite sure how C will work, I mean, I like pointers, I rarely got confused by them. However, it turns out that most people don’t like dealing with *something, so they wrapped it into something else in higher level programming languages like java and python. This time they got me confused how would they work. After some investigation, I found the following fact about them:

In java, all things are passed by reference(except for primitive variables like int or float), however the reference is passed by value to the callee, it means if you assign a new “address” to it, it would not effect the caller. A example is list below:

In python, the model is more complicated, in my understanding, all objects in python is passed by reference(like in java this reference is also passed by value). In this context it seems to be possible to change an object inside a function, however, it is not true. There are some certain objects that is not for you to manipulate them inside a function. They are called immutable objects. Strings, tuples and numbers are immutable but others are all mutable.

I am not sure that I am 100% right about this. If you spot any mistake, please let me know.

# Tweet After Blog With Octopress

There is no tweet-after-blog built-in in Octopress but a easy way to achieve this is use IFTTT, I have shared my recipe, its here: My Recipe.

# How to Login to Pi via SSH Without Entering a Password

Raspberry Pi can be accessed via SSH if you have enabled it. But entering the password every time can be annoying. So there is a simple way to get Pi to trust your PC/Mac and here is how to do it on a Linux/Unix machine.

First on your machine:

Now you copy the content of the file ~/.ssh/idpsa.pub and go to your Raspberry Pi, and do this:

Now you’re done with it.

# Amazon Interview

I had an interview with Amazon UK about half a month ago. The position I applied for is 2013 Summer Software Engineering Internship based in Slough which is a small town near London. Here is a summary of the interview and hopefully it will help not only me but also you with the other interviews waiting ahead.

The first question is about a project I listed in my CV. A java GUI game project that I did last year when I was taking the Objected Oriented and Functional Programming. The interviewer asked about the difficulty of the project and How I managed to get through them. The hint here is you should be familiar with your projects, the best way is to have a review of them before the interview.

The second one is about coming up an algorithm in a short time. The question is: we have 199 numbers which lies in between [0,99], every number may or may not have a duplicate but only one is along, try find it.

It is not difficult to come up with a naive way to solve this. Here is a python function that should do the work.

I have not test it in the real world but the idea of it is clear. However, have an algorithm is not enough, the interviewer will not stop here, he will change his needs a little bit and you have to modify your code to accommodate them. So practice your programming skills is quite important because that’s what rally matters here.

After that the interviewer start asking about OO design and analysis, you should be able to explain to him the concept of class, object and when to use inheritance. He also asked something about composition but since I have no experience on that I was confused on that question.

Then comes up the data structure part, the interviewer asked about how to design a set (hash table or associateve array would seem right here), and then he continues with what is a binary tree and what is a balaced tree. How do you convert a binary tree into a balanced tree( rotating ). Finally he asked me how to reverse a linked list(I will provide some c code here later).

You are inveited to ask some questions at the end of the meeting, but I am not sure if it is a part of the assesemnts. Anyway it’s the first time ever I was interviewed by someone and show my technical skills. I think my English is a issue here because I may not be able to express myself clearly. But it is a good practice for my future carrer.

My CV can be found at http://www.cs.bris.ac.uk/~bf1891/bobfang.pdf. If you are interested, Please contact me.