2013-06-06

Emacs: Stop Cursor Going into Minibuffer Prompt

Perm URL with updates: http://ergoemacs.org/emacs/emacs_stop_cursor_enter_prompt.html

in emacs minibuffer prompt, when you presses the left arrow key, the cursor will move back all the way over the prompt text. This is annoying because user often will hold down 【Alt+b】 to move back by word to edit, and when user starts to type something, emacs will say “This is read-only”. Then you have to manually move cursor out of the prompt. You can try it now by calling query-replace or shell-command.

Here's how to set the cursor not going into prompt:

;; don't let the cursor go into minibuffer prompt
(setq minibuffer-prompt-properties (quote (read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)))

2013-06-05

Tech Geeking: Ruby Rails Mongrel Thin Zed Shaw

Perm URL with updates: http://xahlee.info/comp/ruby_rails_mongrel_thin_zed_shaw.html

Mongrel (web server) is a thin web server, written in Ruby, by Zed Shaw.

Here's a interesting characteristic:

… It is used to run Ruby web applications and presents a standard HTTP interface. This makes layering other servers in front of it possible using a web proxy, a load balancer, or a combination of both, instead of having to use more conventional methods employed to run scripts such as FastCGI or SCGI to communicate.

This is made possible by integrating a custom high-performance HTTP request parser implemented using Ragel.

Mongrel was the first web server used by Twitter, and inspired Node.js according to Ryan Dahl [2]

Shaw subsequently created Mongrel2, an open-source “language agnostic” web server and the successor to Mongrel server.

After the original author Zed Shaw left the Ruby on Rails-scene[4] the releases of Mongrel stopped. The current release 1.1.5 is no longer able to install in Ruby versions higher than 1.9.2 …

A new and maintained server, called Thin,[6] uses the Mongrel parser.

“Thin”, home page at 〔http://code.macournoyer.com/thin/

The guy, Zed Shaw, seems quite a colorful character. He is all pissed at the Ruby community, and left the Ruby community, and started Mongrel2 webserver, and one of its specific mantra, burned into its official doc, is “language agnostic”.

TechCrunch reports: 〔Zed Shaw Puts The Smack Down On The Rails Community By Michael Arrington. @ techcrunch.com…

Zed has removed the article. It's quite scathing. Here's a local copy saved from web archive: Rails_Is_A_Ghetto_by_Zed_Shaw_2007-12-31.txt. A very entertaining read, as well as getting you into some of the guts of Ruby community.

Zed's website: http://www.zedshaw.com/

2013-06-04

Tech Jargon of the Day: shard

A database shard is a horizontal partition in a database or search engine. Each individual partition is referred to as a shard or database shard.

Horizontal partitioning is a database design principle whereby rows of a database table are held separately, rather than being split into columns (which is what normalization and vertical partitioning do, to differing extents). Each partition forms part of a shard, which may in turn be located on a separate database server or physical location.

source: Shard (database architecture)

2013-06-03

Sqlite and libssl-dev Install Problem

Perm URL with updates: http://xahlee.info/linux/linux_ruby_sqlite_install_error.html

Sqlite and libssl-dev Install Problem

Summery. If you are trying to install Ruby on Rails on Ubuntu, and you got this error:

The following packages have unmet dependencies:
 libsqlite3-dev : Depends: libsqlite3-0 (= 3.7.9-2ubuntu1) but 3.7.9-2ubuntu1.1 is to be installed
 libssl-dev : Depends: libssl1.0.0 (= 1.0.1-4ubuntu5.8) but 1.0.1-4ubuntu5.9 is to be installed
 sqlite3 : Depends: libsqlite3-0 (= 3.7.9-2ubuntu1) but 3.7.9-2ubuntu1.1 is to be installed
E: Unable to correct problems, you have held broken packages.

The problem is probably because you disabled one of the repository source in update-manager.

To fix, start update-manager &, then in the “settings” button at bottom, in “Updates” tab, make sure you check box the “Recommended updates (precise-updates)”.

linux update-manager screenshot 2013-06-03
linux update-manager screenshot

Manual Fix Using 「dpkg」

If you search the web, you might find a few page that tries to tell you how to fix it by using dpkg. For example, these:

That would work, but is very dangerous and error-prone. If the problem is a turned-off source repository, you better turn it back on, else you'll need to manually fix lots of other packages.

If the problem is not repository source, here's how you can fix it manually.

  • First, go to Ubuntu package site http://packages.ubuntu.com/, and find the package you want. Be sure the Ubuntu version and 32/64 bits architecture matches yours.
  • Download the 32bits and 64 bits “.deb” packages.
  • Force remove the packages on your system, by, for example, sudo dpkg --force-depends --purge libsqlite3-0. WARNING: dangerous. This better not be a production system, unless you know what you are doing.
  • Install the ones you downloaded. Like this: sudo dpkg --install /home/xah/Downloads/libsqlite3-0_3.6.22-1_i386.deb. You might need to install both 32bits and 64bits versions, i'm not sure.

See also: Linux: Package System {dpkg, apt-get} Tutorial.

Microsoft Natural keyboard discontinued

The classic Microsoft Natural keyboard is discontinued. Get a few of them while they are still out there.

Chances are, in a year or two, you'll see the price rise to a few hundred. That's usually the case with good but discontinued products.

In my 5 years experience of using this and the Microsoft 4000, i think this is actually better. The 4000 got stiff space bar problem.

2013-06-02

cygwin git push error: “error setting certificate verify locations”

when using cygwin, doing git push, you get this error:

error: error setting certificate verify locations:

Solution: install “ca-certificates” in cygwin.

Linux: Setting Default App

In Ubuntu Linux 12.04, running xfce, to set default app, just right click on a file, select “Properties”, then choose the app you want.

Or, you can edit this file ~/.local/share/applications/mimeapps.list

the global one is at /usr/share/applications/defaults.list

Python: format number in human readable way

Example:

# -*- coding: utf-8 -*-
# python 3

print("{:,}".format(78515573)) # 78,515,573

This is available in both python 2.7 and 3. Detail: Python 3: Formatting String

Linux desktop idiocy: eject drive warning

Perm URL with updates: http://xahlee.info/linux/linux_eject_usb_drive_warning.html

Sometimes you hear people comparing Linux desktop with Microsoft Windows or Mac. What have they been smoking?

Witness Linux Showstopper Episode #28824:

USB drive is supposed to be hot-pluggable. That is, you just plug-in or unplug without worrying. But in practice, not really so. You are advertised to eject first. This is so on Microsoft Windows.

So, in Linux, i also wanted to play nice and eject first. But, when you eject, you get this message:

linux xfce eject usb drive screenshot 2013-06-01
Linux xfce warning when ejecting a USB drive.

This message is completely useless, because, the drive is ejected (dismounted) anyway. What am i supposed to do after seeing this message? Am i supposed to wait? Is it now safe to unplug my drive or not??

See also: Is Linux Desktop Ready for Mom & Pop?

Dropbox tip: add folder outside of dropbox

Dropbox tip. To sync files outside the Dropbox folder, just create a soft link. On Linux or Mac Os X, do like this:

ln -s ~/web ~/Dropbox/mywebsite

On Mac, creating a file alias should also work.

On Microsoft Windows, creating a file shortcut should work. If not, please let me know.