Dec 22

vim vi snow leopardThe default vim is  pretty bland and unimpressive. I would share a few of the settings I have found or plundered from Linux installations in order to make vim more usable.

This can go in your .vimrc or in a global location such as /usr/share/vim/vimrc.
I would be interested in what other command line and vim users do to improve Snow Leopard.

step 1. Add following code to /usr/share/vim/vimrc

set nocompatible " Use Vim defaults
set bs=2 " backspacing over everything in insert mode
set ai " Auto indenting
set history=100 " keep 100 lines of history
set ruler " show the cursor position

set viminfo='20,\"200 " keep a .viminfo file

syntax on " syntax highlighting
set hlsearch " highlight the last searched term

filetype plugin on " use the file type plugins

" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif

step 2. Make alias vi = vim

open ~/.bash_profile and add following code

alias vi=vim
tags: syntax, vim

Nov 04

basndwidth-throttleAdvanced OS X users know that Darwin comes with ipfw, which can be used to set up a custom firewall. IPFW’s flexibility, very targeted bandwidth limiting rules can be made in only a few lines. This same service however can be used to also limit bandwidth on specific ports.

The following ipfw rules will limit connections from Mac to ISP’s mail server to 100K per second only for outgoing smtp connections:

sudo ipfw pipe 1 config bw 100Kbit/s
sudo ipfw pipe 1 tcp from me to smtp.west.cox.net 25

Obviously, the rate can be tailored to anything you like, and the rule is specific enough not to get in the way of any other connections going on.
to remove the pipe from the port

sudo ipfw delete 1

Another example could be for webdevelopers

You should see how long it takes modern sites to load on 56k…

Create a pipe that only allows up to 15KB/s

sudo ipfw pipe 1 config bw 15KByte/s

Attach that pipe to the outgoing traffic on port 80

sudo ipfw add 1 pipe 1 src-port 80

Delete the pipe when finished

sudo ipfw delete 1
tags: net

Oct 27

I could say -  I always write code that’s valid and “Apply Source Formatting” as Adobe Dreamweaver CS4 does it , but the truth is I’m a hack.
I get things to work with spit and chewing gum, and my code is a sloppy mess. Tidy Service to the rescue!

Tidy Service is a OS X Service that cleans up markup using the powerful HTML Tidy library originally created by  Dave Raggett. The version of HTML Tidy used in this build corresponds to the binary version released on February 11th, 2007.

HOW DO INSTALL IT?

  1. Download Tidy Service
  2. Copy TidyService.service file to /Users/<your home directory>/Library/Services/
    Note: You may need to create the directory “Services” if it does not already exist.
  3. Logout and then login  again (or restart systyem).
    Note: Tidy Sevice will not appear in the Services menu until you logout, then login
  4. Create settings for TidyService.
    create /Users/<your home directory>/TidyService.conf
    and insert following settings to TidyService.conf

    indent: yes
    indent-spaces: 4
    wrap: 72
    markup: yes
    output-xml: no
    input-xml: no
    show-warnings: no
    numeric-entities: no
    quote-marks: yes
    quote-nbsp: yes
    quote-ampersand: no
    break-before-br: no
    uppercase-tags: no
    uppercase-attributes: no
    doctype: omit
    show-body-only: yes
    output-html: yes
    tidy-mark: no
    

    A detailed listing of options can be found at http://tidy.sourceforge.net/docs/quickref.html

  5. Set a shortcut to easy access to Tidy Service. Open Leopard -> System Preferences -> Keyboard -> Keyboard Shortcuts. Select Services in left box and set find “Tidy Markup” in list.
    system.preference.keyboard

HOW TO USE

Tidy Service can be used to clean up HTML markup in any application that supports services by selecting (Coda, SubEthaEdit, Tumult HyperEdit, or TextWrangler) the markup in question and choosing one of the Tidy menu items from the Services menu.
tidy_service
Currently, there are two processing options: Tidy Markup and Tidy to XHTML. Tidy to XHTML instructs the Tidy engine to  generate valid XHTML, while Tidy Markup does not.

tags: Development, HTML, Text Editor