Wednesday, April 13, 2016

Modifying Vim to be able editing crontab in Mac OS X Yosemite

Get the solution from Vim Wikia post here, already tried this by myself and worked like a charm :)

If you ever get this error while trying to add cron entries:
crontab: temp file must be edited in place
Then the solution is very simple. You just need to create ~/.vim/ftplugin/crontab.vim and add this one line:
set backupcopy=yes
Save the file and you can try to add cron entry again.

Mutt+Offlineimap Error while using it to access Gmail IMAP

The solution came from this forum

Upon Offlineimap version 6.6.0, you'll get an error when accessing Gmail IMAP, something like this:
XOAUTH2 authentication failed: AUTHENTICATE command error: BAD ['Client aborted AUTHENTICATE command. q205mb46565077wmb']. Data: MFNB2 AUTHENTICATE XOAUTH2

The solution is very simple, you just have to add one line to your .offlineimaprc file, in the [Repository YOUR_ACCOUNT-remote] section:
auth_mechanisms = LOGIN

referring to config line: #auth_mechanisms = GSSAPI, CRAM-MD5, XOAUTH2, PLAIN, LOGIN

Save the file and run your offlineimap to check that the error is already gone. Voila! :)

Setup Wi-Fi on your Raspberry Pi via the Command Line

The complete guide for this can be checked here

1. Boot up your Pi
2. Connect ethernet cable to your Pi
3. SSH into it (You can check the IP from your wireless router DHCP client list)
4. Open up /etc/network/interfaces:
$ sudo vim.tiny /etc/network/interfaces
You'll see few lines of basic configuration:
auto lo
iface lo inet loopbackiface eth0 inet dhcp
allow-hotplug wlan0iface wlan0 inet dhcpwpa-conf /etc/wpa_supplicant/wpa_supplicant.confiface default inet dhcp
5. Then open up /etc/wpa_supplicant/wpa_supplicant.conf:
$ sudo vim.tiny /etc/wpa_supplicant/wpa_supplicant.conf
Just copy and paste below script inside that file:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdevupdate_config=1network={ssid="YOURSSID"psk="YOURPASSWORD" 
# Protocol type can be: RSN (for WP2) and WPA (for WPA1)proto=WPA 
# Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)key_mgmt=WPA-PSK 
# Pairwise can be CCMP or TKIP (for WPA2 or WPA1)pairwise=TKIP 
#Authorization option should be OPEN for both WPA1/WPA2 (in less commonly used are SHARED and LEAP)auth_alg=OPEN 
Change ssid, psk, proto, key_mgmt, pairwise and auth_alg according to your wireless router setup.

6. And after you finished, reboot the pi:
$ sudo reboot
7. Upon booting, unplug ethernet cable and try to access your Pi via wireless connection (check the IP from your wireless router DHCP client list)

Just repeat the steps if you still haven't seen your Pi in the DHCP client list.

Tuesday, April 12, 2016

Mutt Integration With Abook in Mac OS X

This post assume that you already have Mutt running on your Mac OS X.

I choose Abook to manage my address book because it's very simple and suitable for my need.

If you don't have Abook yet, you can install it. I'm using MacPorts, so just execute this command:
$ sudo port install abook

And then, add these lines to your .muttrc config file:
set query_command = "abook --mutt-query '%s'"macro generic,index,pager \ca "<shell-escape>abook<return>" "launch abook"macro index,pager A "<pipe-message>abook --add-email<return>" "add the sender address to abook" 
A little explanation for above script:
1. set query_command (pressing ctrl-t) on Mutt - Compose view, will execute abook to look for match address based on the few letter(s) you already type in.
2. pressing ctrl-a on Mutt, will execute abook to input manually
3. pressing shift-a (or A capital) on Mutt - Index view, will add the sender from any highlight email

Just save your .muttrc and reload the config on Mutt, and you're good to go :)

*full reference see here

Backup and Restore Your Raspberry Pi SD Card Using Mac OS X

For the credit and full-complete writing about this post, you can check it here and here, I only made some modification to make it even simple.

This was done by me when I tried to expand SD capacity from 8 to 16 GB. It's very simple and practical. After this backup-restore process done, you need to expand the file system so you can acquire full 16 GB on new SD card. So, let's begin..

1. Turn off RPi
2. Put SD card into card reader slot
3. Open up 'Terminal' app (from Application -> Utilities -> Terminal)
4. Type:
$ sudo bash
5. Type in your password
6. Type these in sequence:
# mkdir -p ~/rpi/backups
# cd ~/rpi/backups
 7. Check where your SD card is listed (e.g.: mine is listed as /dev/disk2s1)
# df -h
8. Eject your SD card:
# diskutil unmountDisk /dev/disk2s1
9. Backup your SD card to image file: (please note that you have to add 'r' before 'disk')
# dd if=/dev/rdisk2 of=~/rpi/backups/backup-today-rpi.img bs=1M
10. When complete: (again, add 'r' before 'disk')
# diskutil eject /dev/rdisk2 

1.  Put new SD card into card reader slot
2.  Check where your SD card is listed (e.g.: mine is listed as /dev/disk2s1)
# df -h
 3. Eject your SD card:
# diskutil unmountDisk /dev/disk2s1
4. Restore your image to new SD card:
# dd bs=1M if=~/rpi/backups/backup-today-rpi.img of=/dev/rdisk2
5. When complete:
# diskutil eject /dev/rdisk2

Expand Filesystem
1. Powering up your Raspberry Pi
2. Execute this command:
$ sudo raspi-config
3. Choose 'Expand Filesystem"
4. Reboot

And you're done! :)