This questions are mainly from internet.
vim4Lin: A Super Smooth Vim Configuration for Linux
Recently I forked a project on Github.com, and renamed it to vim4Lin which is a vim configuration. The project can be used to help to synchronize the configuration files of vim on multiple machines. However, I intentionally want to focus its experiences on Linux, such as Ubuntu. The project you can find in this following url: https://github.com/bfeng/vim4Lin
Overview
This is another vim configuration, which I normally use under terminal. So default theme is changed to molokai
, which is optimized for C under terminals.
Vim related settings are in plugin/settings/Settings.vim
, and other plugins’ settings are in plugin/settings
corresponding directories.
Two vimrc files:
vimrc
, standard version vimrc.gvimrc
, same as vimrc, but added some features only available in GUI mode.
you can link your ~/.vimrc
to any one of them as you wish :)
It’s a screenshot of the up-to-date configuration:
The content above is from http://flask.pocoo.org/snippets/5/
Installation and Update
BACKUP your
.vim
directory and.vimrc
first.(IMPORTANT!)cd ~
to change directory to your home directory.Clone files to your home directory:
git clone https://github.com/bfeng/vim4Lin.git
cd to
vim4Lin
directory and execute theupdate.sh
to get latest version modules:cd vim4Lin ./update.sh
make a symbolic link
.vim
tovim4Lin
that you just cloned, or just rename it to.vim
also be fine:ln -s vim4Lin .vim
link the vimrc to
ln -s .vim/vimrc .vimrc
if you use GUI version VIM, such as MacVim or GVim, you can also link to
.gvimrc
:ln -s .vim/gvimrc .gvimrc
change directory to
~/.vim
and execute./update.sh
script, it should do all the updates automatically.
Features and Key Mappings
Resize splited windows automatically, so that you get a bigger editing room if you’re working with a smaller screen. (stole from Gary Bernhardt)
Toggle between working mode and presentation mode by
\``z
, but only work in GUI version Vim. You can check here to see how it looks like. (stolen from Mike Skalnik)some usually used key mappings in normal mode:
<F1>
to toggle a Calendar window on and off.<F2>
to toggle NERDTree on and off.<F4>
to toggle Taglist window.<F5>
is the script runner, according to it’s filetype, it will run Ruby(.rb) ,Python(.py) or Javascript(.js) file(SpiderMonkey is needed), even CoffeeScript(.coffee, but you may have to install CoffeeScript first). If the filetype is VimScript,<F5>
will run:source %
for you.<F7>
to switch to previous tab, and<F8>
to the next tab.hit
<ctrl>p
will launch a quick window to match keywords from your current working directory, not only file name, but also path name. And<ctrl>w u
will match from your MRU(Mostly Recent Used) files, which is also frequently used.hit
\
twice to toggle comment on and off.<tab>
and<shift><tab>
to increase and decrease the syntax indentation. By default,<tab>
will invoke the code-completion prompt. If you need to input a real<tab>
into text, hit<ctrl>v
and<tab>
.\``v
to open.vimrc
in a new tab.\``0
to edit or createREADME.md
in current working directory.
Remove tailing whitespace automatically while saving.
- Exuberant Ctags is recommended for the executable of ctags.
Reference
This work was forked from Eddie Kao’s eddie-vim. Thanks!
Some modules, such as which support flex
and css colors, are moved out, and add some modules which support latex
are added in.
The molokai
theme is now supported as the main coding theme and vim-airline
replaces the obsolte vim-powerline
. Much work were done to focus on the compatibility between the GUI mode and the console mode.
Install Cuda 5 on Ubuntu 12.10
By default the cuda is not working on Ubuntu. You may not want to crash your system. Please do exactly follow the instruction step by step. If you are brave enough like me or you are still OK to handle the problem properly even if only the Linux kernel and SSH are working fine, there is no need to backup your system at first.
- Go to the CUDA official website and download the Getting started guide for your system
- Read the installation guide from Cuda official website
- install all the prerequisites for your system
- Download Cuda 5 installation
- typically it’s a cuda5.run file
- Remove the existing nvidia driver from Ubuntu official reposistory
- $ sudo apt-get remove –purge nvidia
- Change tty to anyone without gui:
- eg. ctrl + alt + F1
- Stop the default dm:
- eg. $ sudo service lightdm stop
- Install gcc and change the default gcc to gcc-4.4:
- sudo apt-get install gcc gcc-4.4
- sudo update-alternatives –remove-all gcc ( if you have previous configuration )
- sudo update-alternatives –config gcc ( if you have previous configuration )
- sudo update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-4.4 20
- gcc –version
- gcc 4.4.* or something like that should be printed out
- Run installation:
- chmod +x <cuda>.run
- sudo ./<cuda>.run
Play Cuda With Python
Introduction
This article is to introduce you PyCUDA, which is a python framework allows you write NVidia’s GPU program in a pythonic way. This framework is consisted of two major parts. The first part is a cuda source code compiler, which compiles the embedded cuda code in python at runtime. The second part is to do the computing by leveraging the numpy, which is also a famous python library for scientific computing.
Start with your first Pycuda program
This website gives out the PyCUDA’s documentation.
Here is an example from the above.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
In this example, the SourceModule
is used to create a python Module
from the cuda source code. This involves the Just-in-time compilation. Then, get_function
is used to extract the function from that compiled module, hence the following program can directly call the function like a normal python function.
pycuda.driver
helps to copy-in and copy-out the data between the main memory and the GPU memory. drv.Out
function wraps the variable, which is used in the main memory, in contrast if the variable will be used in GPU memory, use drv.In
. Other parameters, like block
and grid
are the same as used in the normal c cuda program. This blog post gives nice explanation about them: http://www.resultsovercoffee.com/2011/02/cuda-blocks-and-grids.html.
Conclusion
With the help of the some libraries, such as numpy, scipy and etc., PyCuda gives us another handful method to do the scientific computing. By leveraging the GPU computing power, we can not only process and analyze data sets but also do it efficiently.
Joli OS: A Chrome-book Like OS
For a long time, I really envy those who have Chrome book, whose OS is not a normal Linux distribution (of course), but a browser based OS. Chrome OS is a cool way to use computers. However if you want to try it, you can try install it on a virtual machine or if you don’t care about money you can buy one.
But if you just want to taste a Chromebook-like experience, worn out of trying it in a virtual machine and don’t want to waste money to buy a real one and the most is that you happened to have an old laptop like mine (the one I’m typing on), you can try to install Joli OS.
A Brief Look for the Jfxtras
Pencil: A Charming Prototype Tool
I was looking for a free, nice prototype tool for web and mobile design for a long time. It’s actually not hard to find an useful prototype or mock-up tool, but it’s not easy to find a one which is free and easy to use on laptop and desktop which means the software is natively installed.
So, yes, Pencil did the right thing. It is also an add-on for firefox here: https://addons.mozilla.org/en-us/firefox/addon/pencil . And also the home page here: http://pencil.evolus.vn/
Let’s talk about its features. Although the on-line editing tools are so popular today, sometimes we just want to memorize the quick responsiveness of native apps. Facilitated by Mozilla’s xulrunner, the project provides cross-platform installations. This is very cool feature if you needs to work on different types of operating systems.
It’s a nice and easy to use tool for web design. It meant a not so complicated web but good enough for prototyping.
It has the latest Android interface mockups. This is a very cool feature that most Android developers would love, because this tool could create an almost exact the same UI for Android mobiles and tablets. In addition, of course, to make this tool a strong competitor, this tool also supports iOS wireframes and GUIs.
Create a Virtual Ubuntu Cluster on VirtualBox
- Create a virtual machine
- Change the network to bridge mode
- Install Ubuntu Server OS
- Setup the hostname to something like “node-01”
- Boot up the new virtual machine
- Remove some network rules
sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules
- Clone the virtual machine
- Initialize with a new MAC address
- Boot up the cloned virtual machine
- Edit /etc/hostname: change “node-01” to “node-02”
- Edit /etc/hosts: change “node-01” to “node-02”
- Reboot the cloned virtual machine
- Repeat step 7 to 13 until there are enough nodes
Note: the ip address of each node should start with “192.168.” unless you don’t have a router.
Even Though Nokia Is Sinking, Qt Is Still Great
Today I watched a video of porting Qt application into Android. It looks so fantastic that more and more platforms are emerging, iPhone, Android, Windows, and some others flying on netbooks with touch capabilities. Let’s call them smart mobile devices.
The typical problem developers are being solving is to make an application and port it to more available platforms. However, porting is so frustrated to programmers because it is like a progress of copying yourself. In contrast, DRY (don’t copy yourself) is the first principle of programming.
Other technologies which can help to do porting seems great. At least this one looks so.
Why Writing a Unit Test Is So Necessary for Me?
The simplest answer to this question is that I am too lazy.
The more, I’m always doing refactoring until I can’t tough them. But it’s obvious that I don’t want to test the code again and again, not to mention testing manually. So unit testing is great to keep me safe that I wouldn’t crash the whole system after refactoring.