Eternal Bash History

Sometimes you need your bash history to store more than the default few hundred commands. Changing the

HISTSIZE

variable allows you to set the amount of lines you want to store in your history. There are a few other variables you can use to customise but you can find them Here

Changing HISTSIZE to an empty string will allow the history to go on and on and on….

# Eternal bash history.
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="[%F %T] "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.bash_eternal_history
# Force prompt to write history after every command.
# http://superuser.com/questions/20900/bash-history-loss
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"

RE: http://stackoverflow.com/questions/9457233/unlimited-bash-history

MacOS New finders default Folder

Theres nothing more annoying than opening a new finder window and having the “All my files” show. Well, there is a lot more things that are worse; its just annoying.
I had been looking for the setting to change and must have overlooked it.

Anyway, open up a new finder window
Goto Preferences (Cmd + ,)
General Tab (default)
At the bottom you will see “New finder windows show:” then a dropdown.

Your free to change to whatever you see fit.

screen-shot-2016-12-01-at-13-21-17

Ubuntu auto start ssh server

Having to setup an Ubuntu server recently, all the CentOS commands had to get thrown out the Window.
Before i could put the server into the rack i had to make sure sshd started if the server ever reset.
Below is the following command to add ssh to the default startup.

It actually updates the rc.d scripts so probably also adds shutdown scripts to the unneeded run levels

sudo update-rc.d ssh defaults

Resolving local networks with Xip.io

I recently stumbled upon a brilliant service. Developing locally always involves editing the /etc/hosts file to resolve a domain to your local host and then having to setup DNS servers to be able to check on my mobile or tablet.
Xip.io seems to have solved this issue by creating a custom DNS service that allows you to resolve a custom domain to an internal ip address so when any other device does a lookup it resolves correctly.

For example; your machine is on 10.0.0.10 and you need to check it on your mobile. You don’t want to upload it to your sever, setup a host, setup the database and all that. If you set the host on your local machine as

www.10.0.0.10.xip.io

when your mobile tries to do a DNS lookup the remote DNS server extracts the 10.0.0.10 from the Domain name and returns that back as the IP.

You can use any precursor to the ip address;

host1.10.0.0.10.xip.io
host2.10.0.0.10.xip.io
shop.10.0.0.10.xip.io

Brilliant idea!

Bash Profile

I find myself working in iTerm a lot. Well to be honest i prefair a terminal over a Finder window any day.
So i find myself running the same commands over and over, {{ git status }} over and over to check if any files have changed.
Checking which branch i’m currently on.

I spent a lot of time altering my bash profile to enable colours by default, changing the prompt layout, setting up aliases etc.
I finally found a brilliant template online by Jacob Tomlinson at Terminal Piperita Theme

The prompt integrates into git, so if git is enabled in the current directory it will add the current branch to the prompt and tell me if there have been any changes made. It’ll give me the user my terminal is logged in as and the hostname of the machine along with the current folder all with some pretty colours that change if i am logged in as root too. Continue reading

PHP 5.6 CentOS 6

One of the bad things with the default repos on CentOS is that the PHP releases are really dated.
I recently needed a later version of PHP on one of my servers so did some digging to find the following webtatic repo for all the latest PHP and module releases.

rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

That will install the yum repository for you so you can do the magical yum installs
The usual and basic modules for PHP 5.6 are as follows;

yum install php56w php56w-mysql php56w-xml
Continue reading

Percona Repo for CentOS 6

I have been wanting to use the Percona MySQL drop-in replacement for a while now. When trying CentOS 7, Percona is already into repos as the replacement for Mysql Server.

Below is the command to add the Percona repos into your yum repos lists.

yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm

Then to install Percona 5.7 for example

yum install Percona-Server-server-57 Percona-Server-client-57

As we know, its a drop-in replacement for MySQL so the rest works as before; Don’t forget to optimize and use the mysql_secure_installation to remove the test database and setup root passwords.

NOTE: 57 setups a temporary root password, to find this check the /var/log/mysqld.log file for the following line
2016-02-27T14:49:11.247553Z 1 [Note] A temporary password is generated for root@localhost: rS:+xxxxxx