Sunday, August 16, 2009

Reload current file in VIM


# To reload current file in Vim
:edit or :e

# To reload and discard modifications
:edit! or :e!

# To autoload every time file gets modified
:set autoread

Bluetooth tethering your iPhone to Ubuntu (works on multiple machines too)

1. Check out your iPhone bluetooth address

hcitool scan

2. Edit "/etc/default/bluetooth"

PAND_ENABLED=1
PAND_OPTIONS="--listen --role=PANU --devup /etc/bluetooth/pan/dev-up --devdown /etc/bluetooth/pan/dev-down"

3. Create directory "/etc/bluetooth/pan"

4. Create file "/etc/bluetooth/pan/dev-up"

#!/bin/bash
ifup bnep0

5. Create file "/etc/bluetooth/pan/dev-down"

#!/bin/bash
ifdown bnep0

6. Install pand & create PAN connection

sudo apt-get install bluez-compat
sudo pand -c IPHONE BLUETOOTH ADDRESS

7. Assign IP address to iPhone

sudo dhclient3 bnep0

8. To disconnect tethering

sudo pand -K

You can use the same method to tethering to multiple machines at the same time.

Thursday, August 13, 2009

Common regular expresssions








Taken from http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/

Cucumber > 0.3.7 freezes hash table and changes loading of shoulda


diff --git a/config/environments/test.rb b/config/environments/test.rb

-config.gem "thoughtbot-shoulda", :lib => "shoulda/rails", :source => "http://gems.github.com"
+config.gem "thoughtbot-shoulda", :lib => "shoulda", :source => "http://gems.github.com"


diff --git a/features/step_definitions/enrollment_steps.rb b/features/step_definitions/enrollment_steps.rb

- enrollments.hashes.each do |hash|
+ enrollments.hashes.each do |h|
+ hash = h.dup # Hash is frozen by cucumber. Not sure why.

Wednesday, August 12, 2009

Tech user groups, websites, events and calendars in Singapore

Dev Communities

Singapore Ruby Brigade
http://groups.google.com/group/singapore-rb
http://singaporerubybrigade.pbworks.com

Malaysia Ruby Brigade
http://groups.google.com/group/malaysia-rb

Singapore Perl Mongers
http://groups.google.com/group/singapore-pm

Singapore Google Tech User Group
http://groups.google.com/group/sgtug
http://sg-gtug.org/

Java Meetup Singapore
http://groups.google.com/group/java_meetup_singapore
http://www.meetup.com/JUG-Singapore

Singapore Linux User Group
http://www.meetup.com/sg-linux/

Linux NUS
http://linuxnus.org/

Singapore Flex User Group
http://fug.sg/

Ph.P Society (PHP User Group)
http://www.php.org.sg/

Cocoaheads Singapore
http://www.facebook.com/group.php?gid=29368309964

Code Android (Android User Group)
http://www.codeandroid.org/

SgDotNet (.Net User Group)
http://www.sgdotnet.org/Pages/Default.aspx

Python User Group Singapore
http://www.facebook.com/group.php?gid=20088734289

WebSG (Web Standards User Group)
http://websg.org/

Hackerspace SG
http://www.facebook.com/group.php?gid=121463986679

Dev Related Communities

e27
http://www.e27.sg/

SG Entrepreneurs
http://sgentrepreneurs.com/

Mengcubator
http://groups.google.com/group/mengcubator/

Websites

SIGINT (Hacker News)
http://sigint.sg/

Events

Geekcamp SG
http://geekcamp.pbworks.com

Calendars

Patrick Haller's google calendar (it's got most of the events here)
http://www.google.com/calendar/embed?src=95mcn1nlh3lv9lkn8rcgj8ujf8%40group.calendar.google.com&ctz=Asia/Singapore

Shortcut key maps for Vim in normal mode

Just created for myself a bunch of shortcut keys to access commands that I commonly use in VIM.

## Entries in my ~/.vimrc

:nmap tt :tabnew
:nmap tn :tabnext
:nmap tp :tabprevious
:nmap tf :tabfirst
:nmap tl :tablast
:nmap t1 :tabnext 1
:nmap t2 :tabnext 2
:nmap t3 :tabnext 3
:nmap t4 :tabnext 4
:nmap t5 :tabnext 5
:nmap t6 :tabnext 6
:nmap qq :q!
:nmap ww :w
:nmap zz :wq
:nmap ff
:nmap gg
:nmap ;w :set wrap
:nmap ;nw :set wrap!
:nmap ;;as :e ~/projects/aims
:nmap ;;jt :e ~/projects/jtab
:nmap ;;rs :e ~/projects/rsvp-api

Tuesday, August 11, 2009

Smarter visual highlight in VIM

I know one can expand a visual highlight using

"vw" or "ve"

But it doesn't work if you wanna highlight between underscored words.

Eg.
this_is_made_up_of_underscored_words

So to expand highlight use the following

'this_is_made'
"v/_" then cycle thru with "n"