Installing mariadb for CentOS

Reference commands for install and setup of mysql / mariadb on red hat distros like CentOS.

The below commands install the server, enable the database service to start on boot, setup the database service and finally start the service.

yum install mariadb-server mariadb

systemctl enable mariadb.service

mysql_secure_installation

systemctl start mariadb.service

Install SVN from source

I’ve been having problems recently with SVN not being kept up to date on a company repo. So I installed SVN from source so that I could use a modern GUI.

(smartsvn has a free version which I opted to use but once it had upgraded my repos they no longer worked with the command line client – so that needed updating)

Installing from source

yum update
yum groupinstall "Development tools"
yum groupinstall "Additional Development"
wget https://archive.apache.org/dist/subversion/subversion-1.8.9.tar.gz
tar zxvf subversion-1.8.9.tar.gz
cd subversion-1.8.9
./get-deps.sh
./configure
make
make check
sudo make install

If APR and APRUTIL cannot be found

If you find that it complains about APR and APRUTIL missing during the configure command then run this line instead:

./configure --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr/

Rotate a point around another point code

If you need to rotate a point around another point in 2D then here is a nice function. The below is in C#.

/// <summary>
/// Rotates 'p1' about 'p2' by 'angle' degrees clockwise.
/// </summary>
/// <param name="p1">Point to be rotated</param>
/// <param name="p2">Point to rotate around</param>
/// <param name="angle">Angle in degrees to rotate clockwise</param>
/// <returns>The rotated point</returns>
public Point RotatePoint(Point p1, Point p2, double angle) {

    double radians = ConvertToRadians(angle);
    double sin = Math.Sin(radians);
    double cos = Math.Cos(radians);

    // Translate point back to origin
    p1.X -= p2.X;
    p1.Y -= p2.Y;

    // Rotate point
    double xnew = p1.X * cos - p1.Y * sin;
    double ynew = p1.X * sin + p1.Y * cos;
    
    // Translate point back
    Point newPoint = new Point((int)xnew + p2.X, (int)ynew + p2.Y);
    return newPoint;
 }

 public double ConvertToRadians(double angle) {
     return (Math.PI / 180) * angle;
 }

Enjoy 🙂

Robot Prototype 2 chassis

The previous robot prototype chassis did not work very well on high friction surfaces (carpets, grass etc.). Thus prototype 2 was born.

The problems were caused by 2 things as far as I can tell, trying to skid all 4 wheels and also having 4 motors that did not have enough torque. This lead to Prototype 1 stalling frequently when rotating.

Continue reading Robot Prototype 2 chassis

Using windscreen wiper motors for a robot

A DC motor is a DC motor…. right? No, it’s not always that simple.

windscreenwiper-motor

Windscreen wiper motors are fairly cheap when bought second hand from a scrap yard (where I got mine from) and give very good torque for larger robotics projects. You’ve just got to be aware of a couple of things before getting started.

Continue reading Using windscreen wiper motors for a robot

Test internet connectivity from bash script

Ensure you have curl installed and then you can use the following bash code in your scripts to test for internet connectivity.

 

#!/bin/bash

echo "Testing connection..."

curlOutput=$(curl -I http://google.com)

# Possible cases, there are more but here we cover:
# 407 which can mean bad proxy details,
# 200 which means everything is OK,
# 302 which is a redirection but for us that's OK too.

if [[ $curlOutput == *"407"* ]]
then
 echo "No internet connection, bad proxy username / password";
 return
fi

if [[ $curlOutput == *"200"* ]]
then
 echo "internet connection OK";
 return
fi

if [[ $curlOutput == *"302"* ]]
then
 echo "internet connection OK";
 return
fi

 

Enjoy 🙂

Google now allows up to 50,000 songs to be uploaded to your Google account

As you may be aware Google Music allows user to both buy music but also upload any music files they already have to their Google account. This means you can then listen to your music from any device or browser, with the added ability to cache or ‘pin’ content locally so you don’t rinse your mobile data limit.

Google has now increased the limit of uploadable songs from 10,000 to 50,000 so all of you with huge music collections can now really listen to all of your music anywhere you go on any device!

Script to set http_proxy without password stored in history

When working in an environment that has a proxy it is often very useful and sometimes completely necessary to set your http_proxy system variable so that your Linux machine can access the internet.

But there is a problem with just setting it manually. Take the following example.

You and your team are setting up a Linux machine for dev work and you all know the root credentials and are logging in as root just to set everything up. You want to install a package but can’t get though the proxy. Now here is the problem, you have to set http_proxy to a certain string that will contain your username and password  for you entire network account (email, PCs etc.). If you set the system variable straight from the command line your password will be saved for the rest of your team (or whoever has root access to that Linux machine) to view.

To get around this problem I created a very simple bash script that will set your http_proxy setting for your session and ensure there are no details left behind in the command line history file.

You will need to amend the script where I have highlighted in red.

Ensure you run this with source

(source executes the content of the file in the current shell thread)

source ./proxy_script.sh

Now to the script

#!/bin/bash

echo "Set http_proxy? y/n"
read yesOrNo

if [ $yesOrNo != "y" ]; then
return
fi

# Read username
echo -n Username:
read username

# Read password
echo -n Password:
read -s password

echo

histPath=$HISTFILE
unset HISTFILE

http_proxy="http://$username:$password@yourproxydomain:8080"
export http_proxy

export HISTFILE=$histPath

echo "Testing connection..."

curlOutput=$(curl -I http://google.com)

if [[ $curlOutput == *"407"* ]]
then
echo "No internet conenction, bad username / password";
return
fi

if [[ $curlOutput == *"200"* ]]
then
echo "internet connection OK";
return
fi

if [[ $curlOutput == *"302"* ]]
then
echo "internet connection OK";
return
fi