Wednesday, April 6, 2011

Vim Visual Selection Tricks





# VISUAL SELECTION TRICKS:
# You can use filters and vim's execution mode.to do some powerful things.
# A filter is any standard UNIX program (sort, awk, grep, cut, paste, sed ...) that can read from stdin and write to stdout.
# Vim's execution mode lets you read in or replace text with the output of a program. If you make a visual selection (say,
# using V or C-V), and hit :, your command prompt will immediately be :'<,'>, which means "Apply whatever command follows
# to the lines included in the visual selection." At this point, you can write !foo to replace the text with the output of
# program foo.

# For example, to sort the text by the python column, select it, hit :, and enter !sort -k5. The whole command will look like
:'<,'>!sort -k5
# Running it will produce:

a b cd 1 p
b b cd 2 y
c b cd 3 t
d b cd 4 h

# Results in:

d b cd 4 h
a b cd 1 p
c b cd 3 t
b b cd 2 y

# For more complex tasks, awk is your friend. A command like
:'<,'>!awk '{ print $1, $3, $2, $4, $5 }'

a cd b 1 p
b cd b 2 y
c cd b 3 t
d cd b 4 h

# will flip the second and third columns (but note that inter-column spacing is collapsed).
# To do maths on a column, try something like
:'<,'>!awk '{ sub($4, $4*2+1); print }'

a b cd 3 p
b b cd 5 y
c b cd 7 t
d b cd 9 h

# Could get the same result with perl if there is only one column of numbers:
:'<,'>!perl -pe 's/\d+/$&*2+1/e'

# To flip the visual selection just select the rows and then:
:'<,'>!tac

d b cd 4 h
c b cd 3 t
b b cd 2 y
a b cd 1 p

# This pipes the lines through the unix 'reverse cat' program.






These ideas were taken from here:


Sand here:

Saturday, March 5, 2011

My switch from the 3Gs iPhone to Android (Samsung EPIC on Sprint)

I just got my first android phone, the Samsung EPIC 4G through Sprint. There are many reasons why I chose this specific Android phone but here were a few of my requirements:
  • Physical keyboard (although I am also very impressed with Swype)
  • Front facing camera which will allow for video conferencing
  • At least a 1Ghz processor (The GPU helps out a lot as well)
  • AMOLED screen (Not technically a requirement but if you have ever seen it you will understand)
  • Android OS 2.2 (Froyo) -- Sprint actually just retracted this update but it should be back soon.
  • Faster network (4G)
  • Stop paying any more Apple taxes
Some may wonder why I didn't go with the new iphone. Well, I wanted a physical keyboard and I wanted the ability to create scripts on my phone so that I could get my phone to do exactly what I wanted it to do. Sprint seems to be a much better user experience so far as well, with or without 4G. As it turns out my wife was already on Sprint so our cash flow will also be much improved ($0.20 per text? c'mon AT&T).

I was tempted to wait for this summer as to let my contract with AT&T lapse. There will certainly be newer phones introduced by then as well, but I figured life is too short. Also the fees for ending the contract were not that bad and Sprint had some pretty good incentives that more than made up for it.

Is there anything I will miss about my iPhone? Honestly I don't think so. Some may miss iTunes but I never really got into iTunes that much anyway. I almost always stream my music (Slacker) anyway so the network is much more important to me.

Upside surprises

  • The network just seems much much snappier than AT&T even when I am on 3G.
  • The screen is amazing when I set it next to my old phone the iPhone seems downright dull. When I look at my Picasa pictures on the EPIC using there "gallery" app it is like looking at the pictures for the first time. I have never seen my pictures looking so good!
  • Integration with all the Google tools is excellent.
  • Swype virtual keyboard is much more usable than I ever thought it could be. It makes me question my requirement for a physical keyboard it is that good. If you are not planning to write scripts on your phone you may really not need the physical keyboard, maybe.
Downside surprises

  • The keyboard keys are a little bit too flush. I wish everyone that made physical keyboards would use the raised keys like on Blackberry's. I find myself looking at the keys a bit too much trying to find where my fingers are exactly. I was thinking about adding a dot of super glue to all the keys so that I could really feel them but I am not sure there is enough clearance.
  • I wish the four buttons at the bottom of the phone were physical keys as well so I wouldn't have to look at them to push them.
  • I find it a bit frustrating to get help with things. For instance one of the reasons I got the phone was so that I could send certain incoming calls directly to voice mail (you know who you are, jk :). If you search the intertubes you can find lots of people talking about it, but it seems like my phone does not have the option. I am not sure if it is the Android OS 2.1 or Sprints front end or what but the slight differences are a bit frustrating. On the other hand I know that eventually I will get it working where as with the iPhone I would never be able to fix it because of the closed nature of the phone.
My following posts will describe in more details my attempts to script up my phone.

Tuesday, May 25, 2010

Is DropBox a usefull tool?

hmm.... In a word, yes! I feel like I am a little late to this party but what a productivity booster DropBox can be. The greatest thing about Dropbox is that it acts like a folder on your drive and everything you put in there gets synced. Now you might not think that is so great since you would have to store all your configuration files in some random folder but all you really have to do is move your important files to the sync folder and then create a symbolic link to them from the original location. Pretty darn simple and very effective. Now I can have one .vimrc file, one plugin directory, one .alias file and all my different machines can use it!

Here is a snippet from my notes that shows you how simple this really is:

SYNCING MY FILES VIA THE CLOUD (DROPBOX)
Once dropbox is installed I ran these commands on my myth box and things were backedup and synced
mv hlp Dropbox/HOME
ln -s ~/Dropbox/HOME/hlp/ hlp
mv bin Dropbox/HOME
ln -s ~/Dropbox/HOME/bin/ bin
mv web Dropbox/HOME
ln -s ~/Dropbox/HOME/web/ web
mv .vimrc Dropbox/HOME
ln -s ~/Dropbox/HOME/.vimrc/ .vimrc
mv .tcshrc Dropbox/HOME
ln -s ~/Dropbox/HOME/.tcshrc/ .tcshrc
mv .alias Dropbox/HOME
ln -s ~/Dropbox/HOME/.alias/ .alias
On other linux machines I will have to diff these files and see if there is any way to easily merge them
tkdiff ~/Dropbox/HOME/hlp/ hlp
tkdiff ~/Dropbox/HOME/bin/ bin
tkdiff ~/Dropbox/HOME/web/ web
tkdiff ~/Dropbox/HOME/.vimrc/ .vimrc
tkdiff ~/Dropbox/HOME/.tcshrc/ .tcshrc
tkdiff ~/Dropbox/HOME/.alias/ .alias

Use this link to sign up and you get an additional 250MB of storage.

Saturday, May 8, 2010

Chaning startup programs on windows 7

Through System Configuration

NOTE: Using the Selective Startup option in System Configuration (msconfig), you can enable or disable startup programs. You will need to be logged into an administator account, or provide the administrator password to open System Configuration.
1. Open the Start Menu.
A) In the search line, type msconfig and press Enter. (See screenshot below)
Startup Programs -  Change-start_menu_msconfig.jpg
B) Go to step 3.
OR

2. Open the Control Panel (All items view) and click on the Administrative Tools icon, then click on System Configuration. Close the Control Panel and Administrative Tools windows.

3. If prompted, click on Continue for the UAC prompt, or type in the administrator's password.

4. Click on the Startup tab. (See screenshot below)
Tip Tip
If you look under the Location column for the Start Item, you will see the registry location for it that you can use to remove the startup item using METHOD FOUR below instead.
Startup Programs -  Change-system_configuration_startup_tab.jpg
5. To Disable a Startup Program -
A) Select a listed startup program and uncheck it. (See screenshot above)

B) Repeat to disable anymore listed startup programs.
6. To Enable a Startup Program -
A) Select a listed startup program and check it. (See screenshot below step 4)

B) Repeat to enable anymore listed startup programs.
7. To Disable All Listed Startup Programs -
A) Click on the Disable all button. (See screenshot below step 4)

B) Go to step 9.
8. To Enable All Listed Startup Programs -
A) Click on the Enable all button. (See screenshot below step 4)
9. Click on Apply. (See screenshot below step 4)

10. Click on the Boot tab, then check the Make all boot settings permanent box and click on OK. (See screenshot below)
Startup Programs - Change-boot-1.jpg
11. Click on Yes. (See screenshot below)
Startup Programs - Change-boot-2.jpg
12. Click on the Restart button to apply. (See screenshot below)
WARNING: This will restart your computer immediately. Save and close anything that you are working on first.
Startup Programs - Change-restart.jpg

Monday, March 29, 2010

VIM TIPS

VIM TIPS
 
  You can substitute the search string for upper and lower case ( http://vim.wikia.com/wiki/Switching_case_of_characters ):
    :%s/\(foobar\)/\L\1/gc
 
 

PERFORCE TIPS:

PERFORCE TIPS:
 
 
# USEFULL ALIASES:
  # PERFORCE SHORTCUTS
  alias p4_client echo `p4 info | perl -ne 's/Client name: (.*)$/print $1/e'`
  alias p4_changes p4 changes -c `p4_client`
  alias myp4v p4v -c `p4_client` -u ${USER} -p ${P4PORT}


Monday, January 18, 2010

Microsoft is sooo 1980s....

I mean really how come one of the oldest email clients around (outlook) does not even include instant messaging??? Yah know... I mean ... Really is it that difficult? I mean whateva... Microsoft rocks... NOT!