Disable postfix to send email to outside world

disabling postfix to send email to outside world is important especially in development environment. you don’t want client to receive emails when you are testing in the dev environment. Unless software is using external smtp server to send email, you can simply update postfix config (main.cf)

relayhost = 127.0.0.1

and restart postfix

CPanel exim unrouteable address

if exim is showing up errors like “unrouteable address”, it means that exim is trying to send mail locally. If your local dns is borked, you will get this error. The fix is to fix your local mx entry. If you have configured an external dns server, then you should go to

DNS functions -> edit dns zone -> email routing for -> check “remote mail exchanger”. That way, we are telling exim to use remote DNS server.

In the backend, it is the process of moving the domain entry from /etc/localdomain to /etc/remotedomain. But don’t edit the file locally because these files are versioned controlled via whm. Change them from Whm as per described above.

Creating Dev Environment

The idea is to have a production-like system within your system.

1. Download virtualbox.

2. Download a ready-to-go vm instance.

3. Expand the vm instance to desired size.

4. In instance, create a user and setup samba share.

5. In virtualbox host, create 2 network adapter, one “NAT” and one  “host only”, that way the centos instance can only share files to the host machine. Using vboxsf sharing option is way TOO SLOWWW.

6. Set up LAMP or any other web server in the vm instance. To access the sites in the vm instance, configure the host file in the host to point to the instance. To access the files in the vm instance, just connect to the vm via samba.

7. Now, there is a flexibility of development in host machine or vm (Up to the developer). The vm instance can run the httpd server while changes to the files can be done in any OS.

Virtualbox – samba share from linux guest

vboxsf sharing from virtualbox host to guest is way too SLOWWWWW.

Might as well get samba running in linux host and share it to the host.

To do that. Need to

1. Configure virtualbox to use NAT.

2. Add a second ethernet connection. Choose “host only”. To add the host in the dropdown. You have to create one in the virtualbox menu, not the vm menu. The guest vm should now have 2 ethernet cable.

3. Boot up the vm. the vm should have 2 eth.


eth1 Link encap:Ethernet HWaddr 08:00:27:2E:6C:AC
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe2e:6cac/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10383 errors:0 dropped:0 overruns:0 frame:0
TX packets:6942 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13362425 (12.7 MiB) TX bytes:476652 (465.4 KiB)

eth2 Link encap:Ethernet HWaddr 08:00:27:FD:D4:82
inet addr:192.168.56.101 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fefd:d482/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:249923 errors:0 dropped:0 overruns:0 frame:0
TX packets:162555 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:41877967 (39.9 MiB) TX bytes:132228351 (126.1 MiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2792 errors:0 dropped:0 overruns:0 frame:0
TX packets:2792 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:7643866 (7.2 MiB) TX bytes:7643866 (7.2 MiB)

The host can now connect to the guest samba share using 192.168.56.101

Remove dot underscore files in windows share

If you are using mac and have windows samba share mounted, mac creates the “dot underscore” ._ files everytime a file is created or .DS file when folder is browsed. Very ugly.

Easy fix:

1. open up terminal.

2. paste this in

“defaults write com.apple.desktopservices DSDontWriteNetworkStores TRUE

3. All done.

git pull – force overwrite your code with remote or local changes

Conflicts can be troublesome when you do a git pull or git merge. What if you are pretty sure that you want to use the remote version or your version of the code during a pull/merge conflict? no “git pull -f” doesn’t do it.

To do it really quickly, you can

git fetch
git reset --hard origin/master

To have closer control and do it file by file.

git pull
# assuming conflicts occur with style.css at this moment.
# this forces me to use the remote file. use --ours to use my version.
git checkout --theirs style.css
git add style.css
git commit

H264 video encoding and transcoding using winff in ubuntu

winff is the gui version of ffmpeg (now superseded by avconv). Its the perfect tool to convert, resize and manipulate your video files.

Installing winff is easy, if using ubuntu/debian, just do a “apt-get install winff h264enc libav-tools” in command line.

Step 1: use avconv instead of ffmpeg

now I want to use avconv instead of ffmpeg. After opening up winff under applications/sound and video, go to edit/preferences/linux change the ffmpeg exec field to /usr/bin/avconv and ffplay exec field to /usr/bin/avplay

Step 2: Add new h264 profile

None of the current presets look good for h264 encoding. Under edit/presets, Add a new preset name under the websites category. In the preset command, enter

// refer to "man avconv" documentation on the options to use
-f mp4 -acodec copy -vcodec libx264

Step 3: now back to the main panel, select “websites” category and “h264” profile. Then change the video, audio…etc settings accordingly. Click on “Convert” and you will see a pop up terminal. The popup terminal provides tonnes of information on the video stats and debugging information should you wish to google for solutions.

I really hope there would be more documentation in this area rather than bits and pieces everywhere.

transmageddon is also good and simple linux video transcoder alternative but lacked the flexibility that winff has.

vimeo also provides some good compression chart.

Good luck.

insufficient permission for adding an object to repository database .git/objects

If you do a “git add” or other commands and get this error “insufficient permission for adding an object to repository database .git/objects”, it means that you must have used other user to commit or make changes to the git repo before. The best fix is to manually change the user permission of the git objects in your repo, ie

cd your_git_repo/.git/objects
chown your_username:your_username -R *

linux: setting up traffic to go through proxy server

1. for browser: should be able to edit them via the preferences section.

2. command line:

export http_proxy="http://username:password@proxy:port/"
export https_proxy="ftp://username:password@proxy:port/"
export ftp_proxy="https://username:password@proxy:port/"

we should be able to automate this by adding to ~/.bashrc

3. apt:
In /etc/apt/apt.conf.d/80oproxy, add

Acquire::http::proxy "http://username:password@proxy:port/";
Acquire::ftp::proxy "ftp://username:password@proxy:port/";
Acquire::https::proxy "https://username:password@proxy:port/";