When I implement time input feature for 19wu (an open source ticket sale system), I want to split the datetime into date and time parts, so JavaScript date picker and time picker can be used. This post introduces two methods I found.

Compound datetime input

composed_of utilizes assign_multiparameter_attributes trick like datetime_select, and fields_for mocks an association.

The github repository doitian/rails-compound-input-demo contains demos for both methods.

There are two TAB’s in Emacs, (kbd "TAB") (\t, [9]) and (kbd "<tab>") ([tab]). If modes like yasnippet and auto-complete want to bind on TAB, their trigger key must be the same with the original Tab command. Since Emacs binds indent-for-tab-command on (kbd "TAB"), so it’s better to use it as the trigger key. Yasnippet binds to it by default, It is also easy to setup auto-complete to trigger using Tab.

;; trigger using TAB and disable auto start
(custom-set-variables
 '(ac-trigger-key "TAB")
 '(ac-auto-start nil)
 '(ac-use-menu-map t))

But in some modes (ruby-mode, markdown-mode, org-mode), the command is bind to (kbd "<tab>"), when the real Tab key is typed, the function bind on (kbd "<tab>) has higher priority, so yasnippet and auto-complete are not invoked. It is easy to fix by moving the keybinding:

(defun iy-tab-noconflict ()
  (let ((command (key-binding [tab]))) ; remember command
    (local-unset-key [tab]) ; unset from (kbd "<tab>")
    (local-set-key (kbd "TAB") command))) ; bind to (kbd "TAB")
(add-hook 'ruby-mode-hook 'iy-ac-tab-noconflict)
(add-hook 'markdown-mode-hook 'iy-ac-tab-noconflict)
(add-hook 'org-mode-hook 'iy-ac-tab-noconflict)

Yasnippet tries functions in yas/prompt-functions when it needs user to select one choice, such as selecting snippets with the same trigger key, such as helper method yas/choose-value.

popup is a visual popup interface library extracted from auto-complete by its author. It has better look and feel than all the built-in yas/prompt-functions. Also it is easy to customize, and its isearch mode is very efficient, the items are filtered on-the-fly when typing.

Many editor can wrap a line that reaches the window width and show an indicator in the margin, for example, Emacs.

Emacs line wrap with bent arrow in fringe

I want to add such line wrap indicators to the code block in HTML. It is easy to add indicators as background image in CSS. But the indicators should only be shown when the line is wrapped. And from the figure, the wrap indicator is not displayed on the last line in the right margin, and not on the first line in the left margin. There’s a :first-line pseudo element selector, there’s no :last-line. However, it can be achieved by using :before and :after with position trick.

You can check the result in this jsfiddle: http://jsfiddle.net/fbDKQ/6/ . Resize the result panel to see the line wrap indicators. Following is a detailed explanation.

Not fully tested, let me know if it mess up your buffer.

Pow is a zero-config Rack server for Mac OS X. Here I steal its idea to build a zero-config system based on Nginx with Passenger.

RVM has since moved to using .profile, so just put the “cd .” in .profile and it will work

— Mikael Wikman commented below

Original Article

Tmux is a terminal multiplexer. I switched to Tmux from GNU Screen recently.

I work on several Ruby projects. I use RVM to manage gem set for different projects, and use rvmrc file to switch gem set automatically. I usually start a Tmux session for a project in its root directory, so all the windows and panes in the session use the project root as default directory. The problem is, the new created shell in the session does not load .rvmrc in the root directory. I have to force loading the file using “cd .

Mendeley is a research management tool for desktop & web. It has clients for Linux, Mac, Windows and iPhone and a Web interface. Mendeley can manage any documents, but is better to work with PDF. The file meta data are synchronized though Mendeley server. The attached files (PDF or any other formats) can also be synchronized, but the free account has a quota of 500MB. However, the attached files directory and underlying sqlite database can be synchronized manually.

This article demonstrates how to quickly switch to a window using gpicker and wmctrl. You type significant letters of workspace name, application name or title and gpicker provides a list of windows you most likely mean to pick.

@miloyip has published a post recently which motioned the Alias Method to generate a discrete random variable in O(1). After some research, I find out that it is a neat and clever algorithm. Following are some notes of my study on it.