Search Console – Change of Address. 301 htaccess example

Moving to a new domain can smash your Google ranking – unless you tell Google about it. If you are a user of Google’s Search Console aka Webmaster Tools you have the option to use the “Change of Address” page which can be found in the settings.

Continue reading “Search Console – Change of Address. 301 htaccess example”


Swift and CocoaPods

Uh. XCode 6 is out in the developer preview version and Apple introduced Swift on the WWDC. We all love CocoaPods, but how to use the Pods in a new Swift project?

Let’s start with a normal Podfile for a test project called ‘cocoapods-test’

platform :osx, '10.10'
link_with 'cocoapods-test', 'cocoapods-testTests'
pod 'RaptureXML'

As you can see, I link also the test-target in my Podfile, because I want the Pods to also be available there.

Now lets execute the beloved

pod install
Successful included Pods
Successful included Pods

But now? We have a pure Swift project here, so how to I use the Objective-C resources in my target? The solution is already mentioned in the official Swift guide:

Fill out an Objective-C bridging header if you need to access Objective-C code from the same app target in your Swift file.

We need a bridging header, which Xcode automatically creates when you want to add the first Objective-C file to a Swift project. So we just add a file called “dummy”. This file I will delete later.

Yes, we want an objective C file now
Yes, we want an objective C file now

Then Xcode will ask

This is exactly what we want right now. A nice bridging header file.
This is exactly what we want right now. A nice bridging header file.

This auto-generation will also add the corresponding path to this header file into our Build Settings.

Build Settings for the Bridging-Header file
Build Settings for the Bridging-Header file

Into this header file we can then add our wanted Objective C headers like e.g.

#import "RXMLElement.h"

We can the use this library in our Swift files like e.g.

var rootXML : RXMLElement! = RXMLElement.elementFromXMLData(data) as RXMLElement

Completely remove MySQL server including all the data from Debian

I just tried to uninstall MySQL on Debian via

apt-get remove --purge mysql-server

apt-get remove --purge mysql-client

apt-get autoremove

and wondered that the directories /var/lib/mysql /etc/mysql still existed after the commands. Then I recognized, that a

apt-get remove --purge 'mysql-server.*'

is doing better and removes everything.


if you get a

/etc/init.d/mysql: WARNING: /etc/mysql/my.cnf cannot be read.

error when you try to re-install MySQL, try a

apt-get purge mysql-common

and try to re-install again.

get text between 2 lines from a file with sed

I just had the problem that I wanted to get 2000 lines of text from a big log file (> 20 million lines). It was too much to select it in my Terminal. The only thing I know was where the text of interest started and where it ended. Sed what the hero of this day and helped me with this command:

sed -n '19121287,19123287p' big_log_file.log > sliced_text.log

19121287 was the line number where it starts and 19123287 was the line where it ends.


Kill processes by their name

Sometimes you have lots of processes running on your Linux system and you want to kill them all. But you don’t want to spend too much time on killing each process by their process id. A good way to handle with this problem is to combine ps, with grep and awk:

ps -lax | grep "MY SEARCH PATTERN"| awk '{print $3}' | xargs kill -9

In this case I am getting the whole process list, then I search for processes which contain MY SEARCH PATTERN. After this I am getting the 3rd column, because there is the process ID. After that we kill ’em all!

Completely remove MySQL server and MySQL client in Debian

Sometimes it is necessary to remove MySQL completely from your Debian system. E.g. after a complete misconfiguration. I had this problem and found this commands to get rid of MySQL server and client (in this case in version 5.1). Both commands need to be executed as root:

# apt-get autoremove --purge mysql-server mysql-server-5.0

# apt-get autoremove --purge mysql-client mysql-client-5.1