I am mikek's Blog

The personal blog of Mike Karthauser, who you may know from Brightstorm Limited or the internet.

Restarting virtual box from commandline on OSX

$ sudo /Library/StartupItems/VirtualBox/VirtualBox restart

Filed under: code snippets

Deploying Magento

This is a guide to help you update your URL after you move your site from one environment to another. For example if you have your website on your localhost and now you want to publish it. You will need to change your URL to reflect this.

Find Rows to update
select * from core_config_data where path = 'web/unsecure/base_url';

Next you will need this one:
select * from core_config_data where path = ‘web/secure/base_url’;

You may need this:
select * from core_config_data where path = ‘admin/url/custom’;

* remember you might have to put in your table prefix if you are using one

If you have multiple store BE CAREFUL and note the config_id numbers for each row, that is how we will ensure that we can the results we want!

Each query will return something like this

‘261’, ‘default’, ‘0’, ‘web/unsecure/base_url’, ‘http://your.dev-domain.com/’

You need to note the first column which is your config_id, each id is unique and we can use that to update just the row we want to update. This will ensure you don’t update a wrong row or more rows than you wanted.

read the guide

Filed under: code snippets,

Changing the path to site root in cpanel

For changing the main/primary domain, you will need to have root SSH access and be able to locate and edit the following file (replacing your user & domain info):

cd /var/cpanel/userdata/USERNAME/DOMAIN.COM

1. Once you have opened the file, look for the following line:

documentroot: /home/USERNAME/public_html

2. Modify the location according to your needs. Save it and exit.

3. Rebuild the Apache conf and restart Apache:

service httpd restart


Filed under: code snippets, development

Raspberry Pi + Wii

I recently came across this post showing the capabilities of the Gertboard. What I didn’t realise up to this point was how straight forward it was to connect up Nintendo Wii remote controls to the Raspberry Pi and use it to control programs (and activate the GPIO).

The Wii remote despite its infrared sender is actually a Bluetooth device and can be connected to the Pi via any generic (cheap) USB Bluetooth dongle and a library that turns the signals into something Python can get involved with.

Here’s a Brian Hensleys blog which explains the process of how he did it.

Filed under: code snippets, raspberry pi

Python and Minecraft Pi edition

A blog dedicated to Minecraft on the Raspberry Pi.


Along with the blog, the nice guys at MCPIPY have provided all their code in a git repo which makes it massively easy to get the scripts onto the Pi.

You can access the git repo here

Filed under: code snippets, raspberry pi

Scripted building in Minecraft Pi edition

Following on from our success at getting hold of Minecraft Pi edition running https://iammikek.wordpress.com/2013/02/03/minecraft-pi-edition/, it was time to explore programming Pi edition directly.

We started by getting the demo minecraft API program from stuffaboutcode.

Having run through the demo we had a bit of fun changing the parameters of various commands to understand more about how things worked, settling on the ‘diamond tower’ as the best to modify.

We started with building towers, then walls and then big blocks (20x20x20) made from various materials such as diamond, glass, water and lava.

Flowing water


Flowing lava


I’m not that familiar with python scripting so will need to dip into the docs a bit before further modification.

Here’s what’s been written so far (modified from stuffoncodes example)

#Raspberry Pi, Minecraft API - the basics
#Tower mod

#import the minecraft.py module from the minecraft directory
import minecraft.minecraft as minecraft
#import minecraft block module
import minecraft.block as block
#import time, so delays can be used
import time

if __name__ == "__main__":

#Gives us plenty of time to switch between terminal and Minecraft Pi edition

#Connect to minecraft by creating the minecraft object
# - minecraft needs to be running and in a game
mc = minecraft.Minecraft.create()

#Find out your players position
playerPos = mc.player.getPos()

#Using your players position
# - the players position is an x,y,z coordinate of floats (e.g. 23.59,12.00,-45.32)
# - in order to use the players position in other commands we need integers (e.g. 23,12,-45)
# - so round the players position
# - the Vec3 object is part of the minecraft class library
playerPos = minecraft.Vec3(int(playerPos.x), int(playerPos.y), int(playerPos.z))

mc.postToChat("Create blocks - making a crazy tower for ern")

# - loop 10 times
for zpos in range(0,10):
# builds along the z axis
for xpos in range(0,10):
#sets y axis to ground level (0)
# makes towers
for up in range(0, 10):
mc.setBlock(playerPos.x + xpos, playerPos.y + up, playerPos.z + zpos, block.LAVA_FLOWING)

A few times we ran this script, we ended up stuck inside the cubes and had to exit the game. I would imagine placing this many blocks at once might make the app a bit fragile.

Sadly this week it seems an upgrade on the iOS Minecraft Pocket edition means that we can’t access each others networked games. Hopefully we’ll get that functionality back when another version of Pi edition is released.

Am thinking now of ways we can add some sensors via GPIO and see how we can program a bit of outside world interaction with the game – maybe getting the dog involved to be a bit of chaos.. Watch this space.

Filed under: code snippets, raspberry pi

How to manage processes from the Linux terminal

The Linux terminal has a number of useful commands that can display running processes, kill them, and change their priority level. This post from How To Geek lists the classic, traditional commands, as well as some more useful, modern ones.


Filed under: code snippets


A few links relating to hook form alter
In Drupal 7. Used to modify form output .


Filed under: code snippets, development

How to change the default crontab editor

env EDITOR=nano crontab -e

Thanks to http://www.linuxquestions.org/questions/red-hat-31/how-to-change-the-default-crontab-editor-395750/ for the tip

Filed under: code snippets, development

Dealing with wildcards in croogo

i’ve been looking into wildcards for visibility paths primarity so I can add a block into my news/view page without specifying all my news articles.

inside blocks function within croogo component, there is a query which checks the url:

'Block.visibility_paths LIKE' => '%"' . $this->controller->params['url']['url'] . '"%',

obviously, adding news/* wont match so no block in this instance.

The solution I settled on was to modify the conditions and add another check:

I replaced:

'conditions' => array(
'Block.status' => 1,
'Block.region_id' => $regionId,
'AND' => array(
'OR' => array(
'Block.visibility_roles' => '',
'Block.visibility_roles LIKE' => '%"' . $this->roleId . '"%',
'OR' => array(
'Block.visibility_paths' => '',
'Block.visibility_paths LIKE' => '%"' . $this->controller->params['url']['url'] . '"%',
//'Block.visibility_paths LIKE' => '%"' . 'controller:' . $this->params['controller'] . '"%',
//'Block.visibility_paths LIKE' => '%"' . 'controller:' . $this->params['controller'] . '/' . 'action:' . $this->params['action'] . '"%',


'conditions' => array(
'Block.status' => 1,
'Block.region_id' => $regionId,
'AND' => array(
'OR' => array(
'Block.visibility_roles' => '',
'Block.visibility_roles LIKE' => '%"' . $this->roleId . '"%',
'OR' => array(
array('Block.visibility_paths LIKE' => '%"' . $this->controller->params['url']['url'] . '"%'),
'Block.visibility_paths LIKE' => '%"' .
'controller:' . $this->controller->params['controller'] . '/' .
'action:' . $this->controller->params['action'] . '/'.
'type:' . $this->controller->params['named']['type'] .

This then allows the addition of the following in visibility paths


to get our result.

Filed under: code snippets, development, ,

what's hot

Flickr Photos

Tree graffiti

Tree graffiti

Tree graffiti

More Photos

Sponsor Mike run the Bath Half marathon

mikek on twitter