Chrome Ad Block

Keeping Chrome Clean 'n' Pure

If you use Google's browser, Chrome, and you find the ads getting a little over-bearing, there is a way to block the ads.

An earlier way was to use Ad-Sweep, but it seems that's no longer functioning.

Another way to do it is to use a hosts file.

Host file began life on Unix systems, for finding other hosts on the network. Unix and Linux (in fact any system using TCP/IP protocol) checks its hosts file for entries before it sends a DNS request for a resource address.

By adding entries to your hosts file they effectively become blocked.

Pull down the latest host file available from:

http://someonewhocares.org/hosts/zero/

And add it to your hosts file.

On Unix/Linux systems its normally in:

/etc/hosts

Windows places it in a most obscure location. Something like:

C:\Windows|system32\drivers\etc\hosts

Down load the file and save it with no extension. A html hosts file which was hosts.html or hosts.htm become hosts.

Then start surfing and you should see little or no ads.

You can add further entries to the end of the hosts file for any ads that sneak through.

If you want to go back to surfing the web with ads, rename the hosts file to something like hosts.temp.txt, and your ads will automagically appear. Simple really.

And a big thank you to the folks over at someonewhocares.org for compiling and sharing their hosts file with the world.

Emacs Dot File

Emacs Init File

Here's a copy of my minimal dot.emacs file.

;
; Patrick's .emacs init file
; 2009-12-18
;

; Tell Emacs where elisp .el files reside then load-path
; (add-to-list 'load-path "~/.elisp")
; (add-to-list 'load-path "~/pager.el")

; Get rid of startup message
(setq inhibit-startup-message t)

; Scrap initial scratch message
; (setq initial-scratch-message nil)

(when window-system
(mwheel-install) ; Enable mousewheel support
(tool-bar-mode nil) ; Get rid of the toolbar
(menu-bar-mode nil) ; Get rid of the menu bar
(scroll-bar-mode nil)) ; Get rid of the scroll bar
; (set-scroll-bar-mode 'right) ; Set scroll bar on right
; Set initial window size
(setq initial-frame-plist '(top 0 left 0 width 300 height 300))

; Enable line number in mode line
(line-number-mode 1)

; Show column number on mode line
(column-number-mode t)

; Display time on mode line
(display-time)

; Display 24-hour format
(setq display-time-24hr-format t)

; Disable blinking cursor
(blink-cursor-mode nil)

; Color settings to make Emacs look pretty
(set-background-color "white")
(set-foreground-color "black")
;(set-background-color "#dfdfdf")
(set-face-background 'modeline "#4377B6")
(set-face-foreground 'modeline "#FFFFFF")
(set-face-background 'region "orangered")
(set-face-background 'highlight "white")
(set-cursor-color "blue")

; Set default font to Consolas
(set-default-font
"-outline-Consolas-normal-r-normal-normal-13-99-96-96-c-*-iso8859-1")

; Disable beep. Flash on error
(setq visible-bell t)

; Highlight incremental search
(setq search-highlight t)

; Highlight fonts - M-x describe-mode font-lock-mode for info
(global-font-lock-mode t)

; Highlight Parenthesis
(show-paren-mode t)
;(setq blink-matching-paren t)

; Typed text replace highlighted
(delete-selection-mode t)

; Color selected region
(setq-default transient-mark-mode t)

; Highlight during query
(setq query-replace-highlight t)

; Scroll faster
(setq lazy-lock-defer-on-scrolling t)

; Disable scroll jump
(setq scroll-step 1)

; Make y and yes both work
(fset 'yes-or-no-p 'y-or-n-p)

; End file with a newline
(setq require-final-newline t)

; Use spaces instead of tabs
(setq-default indent-tabs-mode nil)

; Spaces instead tabs
(setq default-tab-width 4);

; M-g runs the goto-line function.
(global-set-key "\M-g" 'goto-line)

; Delete auto-save files
; (setq delete-auto-save-files t)

; Disable file backup
(setq make-backup-files nil)

; Disable file saves
;(setq auto-save-list-file-name nil)

; Ctrl-h to delete left instead of help
(keyboard-translate ?\C-h ?\C-?)


; *********************************************
; Following from Steve Yegge's blog on Emacs
; Used some ideas and suggestions
; *********************************************

; Invoke M-x without Alt Key
(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key "\C-c\C-m" 'execute-extended-command)

; Ctrl-w replace <-Backspace for backward delete
; C-w normally deletes whole region now reset to C-x C-k
(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)

; Alt-n & Alt-p for page scrolling
(global-set-key "\C-[p" 'down-one)
(global-set-key "\C-[n" 'up-one)

; Re-Map M-<>
(global-set-key (kbd "C-x t") 'beginning-of-buffer)

; Re-Map M-> to Ctrl-x e
(global-set-key (kbd "C-x e") 'end-of-buffer)

; Steve Yegge entries end *********************


; *********************************************
; Word Count Function ; 'count-words-buffer
; Source: Programming in Emacs Lisp tutorial
; http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/recursive_count_words.html#recursive_count_words
; Source: Tutorial Contents Page
; http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/

; Final version: while
(defun count-words-region (beginning end)
"Print number of words in the region."
(interactive "r")
(message "Counting words in region ... ")

; 1. Set up appropriate conditions.
(save-excursion
(let ((count 0))
(goto-char beginning)

; 2. Run the while loop.
(while (and (< (point) end)
(re-search-forward "\\w+\\W*" end t))
(setq count (1+ count)))

; 3. Send a message to the user.
(cond ((zerop count)
(message
"The region does NOT have any words."))
((= 1 count)
(message
"The region has 1 word."))
(t
(message
"The region has %d words." count))))))

; Count the words in the entire document
(defun count-words-buffer ()
"Count all the words in the buffer"
(interactive)
(count-words-region (point-min) (point-max) )
)

; Bind count-words-buffer to Ctrl-c Ctrl-c
(global-set-key "\C-c\C-c" 'count-words-buffer)

; End of Word Count function
; *********************************************

; End of file.

Emacs Word Count


How Many?

A function that's missing from Emacs which is sometimes needed is "Word Count". If you have to submit an article and it needs to be a minimum or precise number of words, Emacs won't help you.

You could save the piece and run "wc" in unix or linux, but that's a pain. We need a function inside Emacs to carry out this task.

I found an Emacs Lisp function at Gnu's website:

;;; Final version: while

(defun count-words-region (beginning end)
"Print number of words in the region."
(interactive "r")
(message "Counting words in region ... ")

;;; 1. Set up appropriate conditions.
(save-excursion
(let ((count 0))
(goto-char beginning)

;;; 2. Run the while loop.
(while (and (< (point) end)
(re-search-forward "\\w+\\W*" end t))
(setq count (1+ count)))

;;; 3. Send a message to the user.
(cond ((zerop count)
(message
"The region does NOT have any words."))
((= 1 count)
(message
"The region has 1 word."))
(t
(message
"The region has %d words." count))))))

;; Count the words in the entire document
(defun count-words-buffer ()
"Count all the words in the buffer"
(interactive)
(count-words-region (point-min) (point-max) )
)


(global-set-key "\C-c\C-c" 'count-words-buffer)

To bind the function, use

(global-set-key "keystroke" 'function)

Here we'll bind it to Ctrl-c Ctrl-c

(global-set-key "\C-c\C-c" 'count-words-buffer)

To launch the function in Emacs, use:

Ctrl-c Ctrl-c

. . .

Emacs Fedora 12 Install

The Gnu Editor

Fedora 12 does not have Emacs installed after install. To add Emacs to your machine is fairly simple. Open a Terminal as root user and do:

# yum install emacs

Enter 'y' for yes when prompted and emacs will auto-install.

To start Emacs, you can click using the mouse or do:

Alt-F2 emacs

To launch Emacs.

. . .