.htaccess: Redirect old site to new one

When you move your website to a new domain, you may wanna redirect people to the new domain, so you don’t have to build your traffic all over again.

Add this to your .htaccess on your old website:

RewriteEngine on
RewriteCond %{REQUEST_URI} !http://brand-new-website.com/
RewriteRule $ http://brand-new-website/ [R=301,L]

Git::Basic settings

Add .git_completion.sh to your home directory, and add this to your .bash_profile:

 

source ~/.git_completion.sh

function parse_git_dirty {
  [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}

function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}

export PS1='\h:\W$(__git_ps1 "[\[\e[0;32m\]%s\[\e[0m\]\[\e[0;33m\]$(parse_git_dirty)\[\e[0m\]]")$ '

Linux: Runlevel configuration tool to start service on Ubuntu/Debian

Under Debian or Ubuntu based distro, use the runlevel configuration tool to manage services run levels

To turn on mongodb service, use the following command:

update-rc.d mongodb defaults

you may to sudo:

sudo update-rc.d mongodb defaults

To remove service, use

update-rc.d mongodb defaults

or using sudo:

sudo update-rc.d mongodb defaults

Windows 7: Emulate CD/DVD Media on your machine.

Windows 7: Emulate CD/DVD Media on your machine.

I have been happy with Virtual CloneDrive for quite a while now. Today I stumbled upon a .NRG image that it won't mount as a drive and I wanted to have that image in a more popular format.

After some hunting, I decided to go for Daemon Tools, as they offer a free-for-personal-no-comercial license for their lite version of the product.

http://www.daemon-tools.cc/eng/downloads

Make Firefox 4 remember your session like it did before

Go to its config:

about:config

and search for “showQuitWarning

change the setting to “true” and you’re done!

 

source: http://support.mozilla.com/en-US/questions/790426

Linux:: SSH configuration file

To save some typing you can create aliases to the servers you frequently access via ssh. This can be accomplished by either editing the global file ( /etc/ssh/ssh_config ), if you’re root and and to make changes for all the users, or your own config file ( $HOME/.ssh/config ).

Follow the example, and remember to customize to your needs

Host *
Compression yes
Port 22
ForwardAgent yes

Host sample
HostName host.sample_of_a_very_long_host_name.com
User joe
ForwardAgent yes
Port 22
Compression yes

Now you can ssh into that server using:

ssh sample

Squeeze: Setting up compiz on Debian Squeeze

My laptop has a nVidia Geforce 8660M GT, so I’m installing nVidia drivers

follow this: http://wiki.debian.org/NvidiaGraphicsDrivers

apt-get install module-assistant nvidia-kernel-common
m-a auto-install nvidia-kernel${VERSION}-source

Let’s go for the eye candy

sudo apt-get install compiz compizconfig-settings-manager compiz-fusion-plugins-main

Follow this:

http://wiki.debian.org/Compiz

PHP 5: Mass Virtual Hosting points $_SERVER[‘DOCUMENT_ROOT’] to wrong folder

When I set up mass virtual hosting for my servers, it seems PHP won’t get the right $_SERVER[‘DOCUMENT_ROOT’]

Here’s the solution I found:

1.Edit your php.ini (the file location depends on  how you have PHP setup)

2. Edit this section

; Automatically add files before PHP document.
; http://php.net/auto-prepend-file
auto_prepend_file = /home/httpd/prepend.php

3. Create the prepend file:

<?php
$_SERVER['DOCUMENT_ROOT'] = str_ireplace($_SERVER['SCRIPT_NAME'], '', $_SERVER['SCRIPT_FILENAME']);

4. Restart your httpd server. I have done this for both Apache 2 and NGINX. (It probably doesn’t matter as it’s a PHP issue)