I recently bought a somewhat old convertible tablet PC for $65 USD on eBay. The Fujitsu LifeBook P1630, which was originally sold for more than $2,000 USD back in 2008, is a small laptop/tablet PC with a 1.2GHz Intel Core 2 Duo and an 8.9" resistive touchscreen display (1280x768). Size-wise it is similar to the netbooks (like the Asus Eee PC) that were starting to get popular at the time, but it is definitely much more powerful than the early netbooks (and also much more expensive at the time of its release). Although it was originally sold with Windows Vista (and mine came with Windows XP Tablet PC Edition), I immediately decided that I would put Linux on it, partially because I was curious about how well Linux would work with a touchscreen (Android doesn't really count). Speaking of Android, the P1630 is a bit different from modern tablets: Like other older tablet PCs it has a resistive touchscreen instead of the capacitive touchscreen found in smartphones and most post-iPad tablets. This means that the touchscreen can only be used with sharp objects, like the plastic stylus that comes with it (or fingernails, but that feels a bit awkward).
The unit I got was in pretty much perfect condition, and doesn't have any visible scratches or marks on the case. It certainly doesn't look like an 8 year old computer, so it probably hasn't been used much. The only problem listed in the eBay listing was a BIOS password unknown to the seller. I decided to buy it despite the BIOS password, since I assumed it could be reset one way or another (and I was right). It also didn't come with an AC adapter, so I had to throw in another $10 for an unoriginal AC adapter from China.
Ever wanted a simple calculator within Vim? Since vimscript is already a fully featured programming language, you've already got it! For instance you can type :echo 2 + 5 in normal mode and get the result 7. You can also enter Ex-mode by typing Q in normal mode. In Ex-mode you can type commands without first typing :, however you still have to type echo to print the result of expressions. When in insert mode you can also press <c-r>= (an equals sign should appear in the bottom left corner) followed by a vimscript expression. This inserts the result of the expression at the current cursor position.
To get a proper read–eval–print loop (REPL) for vimscript expressions, I've added the following function to my .vimrc:
let expr = input('> ', '', 'expression')
if expr == 'q' | break | endif
if expr != ''
if expr =~ '='
execute 'let ' . expr
let ans = eval(expr)
nnoremap <leader>c :call Repl()<cr>
You start it by pressing <leader>c in normal mode (or :call Repl()). I use space as my leader (let mapleader = " "), so by pressing space followed by "c" a prompt displays at the bottom of the window. To exit the REPL, you type "q" and then press enter. Any expression you type while in the REPL is evaluated. The result of the expression is printed and saved in the ans-variable, so that it can be reused in the next expression.
> 25 - 5
> ans * 5 / 2
> ans / (2 + 3)
If the input contains an equals sign it is interpreted as a let-command. This can be used to easily define variables:
> a = 2
> b = 4
> c = pow(a, b)
When Vim is compiled with floating point support (:echo has('float') returns 1), you can also do floating point arithmetic.
> 3 / 2
> 3 / 2.0
The following mathematical functions are built into vimscript (when compiled with floating point support):
Today, I replaced the home-cooked CMS (Jivoo CMS), which this blog was running on, with a home-cooked static site generator (with a web-based GUI similar to a CMS) that I'm working on. I also changed the design a bit… Considering it's been around 15 months since my last post, I guess I just find it easier to work on the technical parts of a blog rather than the actual content. I do however have a number of shorter posts planned for the near-future.