Monday, July 26, 2010

Emacs: Different fonts in different modes


I love monospaced fonts (such as Terminus or Consolas / Inconsolata), but they can be harder to read when it comes to documentation or simple conversation.


So, let's make Emacs use different fonts (monospaced and variable) depending on the mode we're in (eg: Info and ERC should not be monospaced), and let's add some shortcuts to change font type /size easily. You can do something like this with a bit of elisp in your init.el / .emacs.


;; Insidious Black Magic Bits:

;; Use variable width font faces in current buffer
(defun my-buffer-face-mode-variable ()
"Set font to a variable width (proportional) fonts in current buffer"
(interactive)
(setq buffer-face-mode-face '(:family "DejaVu Sans" :height 100 :width semi-condensed))
(buffer-face-mode))

;; Use monospaced font faces in current buffer
(defun my-buffer-face-mode-fixed ()
"Sets a fixed width (monospace) font in current buffer"
(interactive)
(setq buffer-face-mode-face '(:family "Consolas" :height 100))
(buffer-face-mode))

;; Set default font faces for Info and ERC modes
(add-hook 'erc-mode-hook 'my-buffer-face-mode-variable)
(add-hook 'Info-mode-hook 'my-buffer-face-mode-variable)

;; Control + scroll to change font type
(global-set-key [C-mouse-4] 'my-buffer-face-mode-fixed)
(global-set-key [C-mouse-5] 'my-buffer-face-mode-variable)

;; Shift + scroll to change font size
(global-set-key [S-mouse-4] 'text-scale-increase)
(global-set-key [S-mouse-5] 'text-scale-decrease)


And the results:

Note that you can also Shift + Left Click on a window to set fonts / font sizes.

Sunday, July 18, 2010

Converting Perforce depots to Mercurial repositories with hg convert

Converting Perforce to Mercurial repositories is fast (4-5 seconds for a 500MB repository with 300 revisions).

You'll also want to start p4d and log into P4V before, so it caches credentials.

1. Setup your p4 client:
export P4PORT=localhost:1666
export P4CLIENT=your_client_here

2. Enable hg converter by adding to ~/.hgrc
[extensions]
hgext.convert=

3. Start p4d
./p4d &

4. Convert the depot:
You need to specify a revision. Look it up in the p4 client (depot-details-revision). @all might also work.
hg convert //depot/...@307 converted-perforce path/to/hg-repo

5. Look at the history
hg history

6. Look at diffs and history with a graphical tool. This should give you a better idea of branches and such.
hgview

7. Clone your repository
hg clone /path/to/hg-repo

8. Publish your repository via the web interface
hg serve

9. Browse around
http://localhost:8000/


Additional notes:
Keep an eye on:

Sunday, July 11, 2010

Memory Scanner and Editor for Linux

If you're familiar with ArtMoney, MemEdit or Cheat Engine on Windows, then you know what it's used for :-).


Basically, it lets you search for variables in the memory of a running process, then refine the search further (eg: give higher, lower or fixed values). You can use this basically to cheat at games. Look for the health, money or mana values, refine the search, then freeze or set the value to whatever you want.

ScanMem is a simple commandline tool on Linux that lets you do the same. There are other uses, but this one is the most common...