Posts

Showing posts from May 16, 2010

emacs, copy and cut current line

Image
Perm url with updates: http://xahlee.org/emacs/emacs_copy_cut_current_line.htmlEmacs: How to Copy/Cut Current LineXah Lee, 2010-05-21Last month, i wrote Emacs: Shortcut to Delete Whole Line, because i find that deleting whole line is much frequently needed. But also, i didn't mention that i often find the need to copy the current line too. Usually, this meas moving the cursor to beginning of line, mark, move to end of line, then copy. This is 4 operations. The following code will make it just a single operation: (defadvicekill-ring-save (before slick-copy activate compile) "When called interactively with no active region, copy the current line." (interactive (if mark-active (list (region-beginning) (region-end)) (progn (message "Current line is copied.") (list (line-beginning-position) (line-end-position)) ) ) )) (defadvicekill-region (before slick-copy activate compile) "When called interactively with no active region, …

The Dvorak Keyboard Layout

Image
Perm url with updates: http://xahlee.org/comp/dvorak_keyboard_layout.htmlThe Dvorak Keyboard LayoutXah Lee, 2010-05-20This page shows you what Dvorak keyboard layout is, its advantages, and my personal experience in using it since 1994.The QWERTY LayoutThe QWERTY layout. The keyboard layout on our keyboard is called QWERTY, because that's the letters showing on the top row. This layout was designed together with the invention of typewriter, by Christopher Latham Sholes, in 1874.You might wonder why the letters are arrange that way, why not alphabetical? Originally, it was alphabetical. However, it was discovered that the keys would jam when people type too fast. So, the typewriter inventor re-arranged the letters, effectively slow down typing, so that typewriter wouldn't jam.Early typewriter key jam. The Dvorak LayoutIn 1936, Dr August Dvorak and Dr William Dealey studied and invented the Dvorak layout, designed for efficient typing.The Dvorak keyboard layout. Here's some maj…

Angel problem of John Horton Conway; converting math problem into formal language question

Perm url with updates: http://xahlee.org/math/math_problem_into_formal_language.htmlModeling Math Problem Into a Question in Formal LanguageXah Lee, 2010-05-19Learned of The angel problem of John Horton Conway. (solved in 2006)Here's a rephrasing of the problem, perhaps easier to understand than the one given in Wikipedia:On a chess board of infinite size, suppose we place a king, call him the angel. And there's a devil. The angel and devil take turns. When it's angel's turn, he can move the king 2 times. When it is devil's turn, he can delete one square at any place. When a square is deleted, the king/angel will not be able to land on it. If the devil can delete enough squares completely surrounds the angel and is more than 2 steps thick, so that the angel cannot get out, the angel loses. Else the angel win.The above is called 2-angel problem, because the angel can move 2 steps in each turn. If the angel can move n steps in each turn, that problem is called n-…

Launch Bar and Desktop files in Windows Vista

Perm url with updates: http://xahlee.org/mswin/Windows_start_menu_file_locations.htmlWindows Start Menu, Desktop, Quick Launch, File LocationsXah Lee, 2010-05-19Some Windows Vista tech details.Quick Launch ToolbarIn the Taskbar, you can turn on the Quick Launch toolbar. (right click on a empty area in Taskbar, then Properties, Toolbars tab.) When Quick Launch toolbar is on, you can drag any shortcut files to it. Also, each shortcut file also automatically creates keyboard shortcut for it, that's Win+1, Win+2, ..., corresponding to the order of the shortcuts in the Quick Launch bar. You can drag them around to change their order.The Quick Launch tool bar stores its files at: C:\Users\xah\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch DesktopIn Windows Vista, there are 2 folders that represents the Desktop. They are at: C:\Users\xah\Desktop C:\Users\Public\Desktop Anything in the public one will also automatically show in the user's one.Start MenuStart Menu app list is…

Chinese mathematicians...

Perm url with updates: http://xahlee.org/math/blog.htmlLearned of the Chinese mathematician Fan Chung (金芳蓉). Wife of Ronald Graham. Remember, Ronald is the mathematician who co-authored with Knuth the book Concrete Mathematics (amazon).In recent years, i learned quite a lot high powered mathematicians who are Chinese. Here's some list of Chinese mathematicians:Shiing-Shen Chern (陈省身) (b1911)Shing-Tung Yau (丘成桐) (b1949)Chuu-Lian Terng (滕楚蓮) (b ~1960)Terence Tao (陶哲轩) (b1975)Wikipedia actually has a list: Category:Chinese mathematicians. Chuu-Lian Terng is wife of Richard Palais. Richard i first met online in 1997, and them both in person in 2004, and has been personal friends since.Here's some mathematicians that i admire. Typically, it more has to do with their subjects. Geometry, discrete math, combinatorics.H S M Coxeter (b1907)Branko Grunbaum (b1929)John Horton Conway (b1937)Bill Gosper (b1943)Stephen Wolfram (b1959)Stephen i met in 1995.There are quite a few more but off-h…

emacs lisp function to decode url percent encoding?

Image
Perm url with updates: http://xahlee.org/js/url_encoding_unicode.htmlURL Percent Encoding and UnicodeXah Recommends:

Amazon Kindle. Read books under the sun. Review Xah Lee, 2010-05-24This page discuss some issues about what characters should be percent encoded in url, and how different browsers behave.Browser BehaviorSome test on browser's behavior on url encoding/decoding. Apparently, some browsers automatically decode parts of the percent encoding.Copy this line: http://en.wikipedia.org/wiki/St._Jerome_in_His_Study_(Dürer) then go to browser, open a new tab or window. 【Alt+d】 to select the url field, 【Ctrl+v】 to paste in. Enter to go to the page.Then, 【Alt+d】 to select url field, 【Ctrl+a】 to select all, 【Ctrl+c】 to copy. Then, paste in a text editor. Here are the results: • Google Chrome http://en.wikipedia.org/wiki/St._Jerome_in_His_Study_(D%C3%BCrer) • Safari http://en.wikipedia.org/wiki/St._Jerome_in_His_Study_(Dürer) • Firefox http://en.wikipedia.org/wiki/St._Jerome_in_His_…

Disable Ctrl+Alt+S of HP Support Information

Image
Perm url with updates: http://xahlee.org/mswin/disable_hp_support_info_key.htmlDisable Ctrl+Alt+S of HP Support InformationXah Lee, 2010-05-18Am pissed yesterday to have to spend a hour to be able to disable a global shortcut key in Windows, caused by a pre-installed software from HP.If you bought your PC from HP/Compaq, then when you press “Ctrl+Alt+s”, it'll pop up the HP Support Information window.HP Support Information window. This is a pain in the ass, because Ctrl+Alt+s is used in Second Life Emerald Viewer virtual world software, and the 3D modeler Blender, and Emacs, all i use daily. All these 3 are major software, with extensive keyboard shortcuts.So, how do you disable it?Disable the Hotkey for HP Support InformationOpen your Start menu, and look for the folder named “PC Help & Tools”, right click the “HP support information”, then chose Properties.The HP support info software in Start menu. Click on the Shortcut tab, then the Shortcut key field, then just delete it …

camelCase and Source Code Formatting

Perm url with updates: http://xahlee.org/UnixResource_dir/writ/camelCase_code_formatting.htmlcamelCase and Source Code FormattingXah Lee, 2010-05-18Xah Lee wrote:(in emacs) Sometimes you want to delete the file of the current buffer. How do you do it? Here's a simple command that does it. (defundelete-current-file () "Delete the file associated with the current buffer." (interactive) (let (currentFile) (setq currentFile (buffer-file-name)) (when (yes-or-no-p (concat "Delete file: " currentFile)) (kill-buffer (current-buffer)) (delete-file currentFile) (message (concat "Deleted file: " currentFile)) ) ) ) Thomas Munro wrote:Why use CamelCaseI find that using camelCase is a good way to distinguish my own symbol names from built-in ones.Especially because emacs's emacs-lisp-mode's syntax coloring is flawed in that it only color about 10 or so keywords, rather against its own conventions in syntax co…

new Xah Particle Maker manual

Image

pen spinning video

Perm url with updates: http://xahlee.org/vofli_bolci/pen_spinning.htmlPen SpinningXah Lee, 2010-05-17Nice pen twirling For some detail, see: Pen spinning.

emacs command to delete current file

A new convenient elisp function.Sometimes you want to delete the file of the current buffer. How do you do it? Here's a simple command that does it. (defundelete-current-file () "Delete the file associated with the current buffer. Delete the current buffer too. If no file is associated, just close buffer without prompt for save." (interactive) (let (currentFile) (setq currentFile (buffer-file-name)) (when (yes-or-no-p (concat "Delete file?: " currentFile)) (kill-buffer (current-buffer)) (when (not (equal currentFile nil)) (delete-file currentFile) ) ) ) ) Perm url with updates: Emacs Lisp Examples

AutoHotKey Syntax Problems

Perm url with updates: http://xahlee.org/mswin/autohotkey_problems.htmlAutoHotKey Syntax ProblemsXah Lee, 2010-05-16The AutoHotKey language syntax are bad, from a pure design point of view. This page gives some examples.If you add a blank line in the wrong place, it is a compiler error. For a example, the following compiles fine:;;; make the numpad star “*” key to do next tab $NumpadMult:: WinGet, myProcName, ProcessName, A If ( WinActive("ahk_class Chrome_WindowImpl_0") OrWinActive("ahk_class MozillaUIWindowClass") OrWinActive("ahk_class gdkWindowToplevel") ) { Send ^{PgDn} } ElseIf (WinActive("ahk_class IEFrame") OrWinActive("ahk_class OpWindow") or (myProcName = "safari.exe") ) { Send ^{Tab} } Else { Send {NumpadMult} } ReturnBut if the line:If ( WinActive("ahk_class Chrome_WindowImpl_0") has a newline after the paren like this:If ( WinActive("ahk_class Chrome_WindowImpl_0") The compiler genera…