Article
0 comment

Dereferencing deeply nested arrays with array_reduce

Sometimes you need to grab a value from a deeply nested array and you get a path description to that value as a string. For example you get a path as

$path = “A.B.C.D.X”;

which refers to a value in an array like this:

$param[‘A’][‘B’][‘C’][‘D’][‘X’] = “Dorky”;

Now you would like to get the value “Dorky” only by using the string description in $path. You need to get every indexing step as a string value by exploding the string at the “.” characters.

$patharray = explode(”.”, $path);

Then you need to go along this path in array form and dereference the $param array down to its value. You could do so with a foreach loop on the $path array. But you can do it more elegant using array_reduce.
Normally array_reduce iterates over an array and gathers (in any sense) information to sum it up in some single value. But you can also replace this “sum variable” by something else. For example by a dereferenced value of an array … you get a clue?
And since we don’t want to pollute our namespaces with callback functions, why not use the new PHP5.3 feature of anonymous functions?
Putting it all together leads to a one liner:

$value = array_reduce(explode(’.’, $str), function($v, $w) { return $v[$w]; }, $param);

To try it out here is the complete script:

<?php
$str=“A.B.C.D.X”;
$param[‘A’][‘B’][‘C’][‘D’][‘X’]=“Dorky”;
$value=array_reduce(explode(’.’, $str), function($v, $w) { return $v[$w]; }, $param);
print_r($value);
?>

Have fun!

Article
0 comment

How to use a Cisco VPN configuration with open source vpnc

Sometimes you get to use Cisco VPN Gateway. And sometimes you don’t have an original Cisco VPN client or it just doesn’t work. This is the case with MacOS Lion 10.7. But wait, there’s rescue!

You could use the open source VPN client vpnc. In my case I used a homebrew port, which could be installed via:

brew install vpnc

To use the binary installed in /usr/local/sbin you need to add /usr/local/sbin to your path. Next you need to convert the original Cisco pcf file into a vpnc conf file with the also installed pcf2vpnc tool:

pcf2vpnc original.pcf newfile.conf

Copy that newfile.conf to /usr/local/etc/vpnc and start up your vpn connection via:

sudo vpnc newfile

You need to enter whatever password (possibly containing a RSA SecurID token) and you should be connected.

Connection could be terminated with:

sudo vpnc-disconnec

Article
0 comment

Virtual LAMP develop environment with vagrant on a Mac

Sometimes its preferable to have a controlled development environment. One way to do so is using a virtualization. One of those is Oracle’s VirtualBox. To use it seamlessly in a Mac based development setup there is a way to boot a VirtualBox headless, that means without a GUI. To make life a bit easier some really smart ruby guys have developed Vagrant, a system to build and control headless VirtualBox installations.VirtualBox also supports port forwarding (for ports >1024, we come to that later) so we’re able to access the services inside the box from the Mac outside. It also supports sharing directories, so we also can access the project files from both sides of the box.
Fortunately Vagrant provides a Ruby config file to setup both sharing and port forwaring in a totally easy way. To get started, please install VirtualBox and Vagrant as described on the respective web sites.
We now need to supply a prebuilt Debian Squeeze box. Graeme Mathieson was so kind to supply it here. We follow his instructions and install tha base debian using a

vagrant box add debian_squeeze_32 http://mathie-vagrant-boxes.s3.amazonaws.com/debian_squeeze_32.box

To start now we need a project directory. I keep all my Vagrant projects in a special directory ~/vagrant. Therein I created a project directory called debian_squeeze since I’m going to create a Debian Squeeze box. In this directory we create a Project using vagrant init debian_squeeze_32. This creates project file named Vagrantfile which is already preconfigured to use our Debian box.. Open that with the editor of your choice and add two lines of port forwarding below the one commented out as anexample:

  config.vm.forward_port “http”, 80, 8080
  config.vm.forward_port “mysql”, 3306, 3306

This will forward the MySQL standard port and the web server port 80 to external 8080. In addition I would like to share a directory, where all my web roots will reside. So please go the comment block below the forwarding examples which presents an example for a share_folder function call and enter the following line:

  config.vm.share_folder “opt-sites”, “/opt/sites”, “/opt/sites”

This means: name this share “opt-sites” and link the internal /opt/sites to the Mac directory /opt/sites. Note that both directives are simple ruby function calles and in both the first parameter is a custom string to identify the share / forwarding internally. And please replace my /opt/sites with the paths you like.
Close the editor and fire up your installation with vagrant up. Log into your box with vagrant ssh You will be logged in as user vagrant who is allowed to administer the system with sudo. Now we can install all the needed PHP5 and MySQL packages. The Debian packaging system will ensure that the services will also be started up so we are ready to proceed.
Log out from the system with CRTL-d and test the web server installation and forwarding by pointing your browser to http://127.0.0.1:8080 You s.hould see the default Apache web page. Now if you’re like me you would like to get rid of that 8080 port. On a mac you can do so by reconfiguring the ipfw firewall with an additional local transparent proxy rule. Luckily a user over at ServerVault called Sammy has done this for a slightly different port setup. Since I don’t like to set up the rule on the command line I installed WaterRoof, a GUI for ipfw. Start WaterRoof and add a rule containing

fwd 127.0.0.1,8080 tcp from 127.0.0.1 to 127.0.0.1 dst-port 80

My rule has the rule no. 1000. This is only for the sequence of execution. With that in effect, you now can access your debian web server with http://127.0.0.1 And y.ou can install some MySQL client tool and access the MySQL server on localhost:3306.
One last note of cation: please don’t use vagrant destroy on your project since that deletes any Debian package installed into your Squeeze box and lets you start with a brand new naked box. Hope you enjoyed and happy hacking.

[Update]
To use the port forwarding on the command line, please use:

sudo /sbin/ipfw -q add fwd 127.0.0.1,8080 tcp from 127.0.0.1 to 127.0.0.1 dst-port 80

 

Article
0 comment

From Knowledge to Competence Management – Part I

Introduction

This will be the start of a series of articles dealing with the transition of knowledge management to competence networking. I published this first part some time ago on another blog of mine and have revised it for republication here. Planned topics are the nature of knowledge, classical knowledge management, the idea of competence management, social capital, open innovation and which current developments in technology are able to support the realization of a competence network site.

The nature of knowledge

Most of the following ideas can be found in Managing Flow: A Process Theory of the Knowledge-Based Firm by I. Nonaka et al. We will use it only as a short introduction to advance quickly to the more practical topics.

First we have to make a distinction between knowledge and information. The german translation “Wissen” mixes the meaning of the two terms a bit so I would like to explain the probably obvious: information are facts, which can be collected, written down and transmitted. Knowledge can be divided in explicit knowledge which can be written down and transmitted and implicit or tacid knowledge, which can be described as “knowing how to do something”. Tacid knowledge is not readily transferable from one person to another.

Explicit knowledge seems to be strongly related to information but knowledge is subjective while information is not. Knowledge is an attribute acquired by a human being and therefore according to cognitive science filtered by personal views and experiences. A different person could come to different results when put into the same situation.

This leads directly to the next feature: knowledge is process-related which means that it is acquired in a process of interaction between one or more human beings and its or their environment. Different processes of acquisition may result in different outcome.

The process of knowledge acquisition normally ends with the subject identifying an acceptable outcome. What one views as acceptable has to obey our rules of aesthetics. So acceptable knowledge normally means aesthetic knowledge.

Knowledge is an extensive value which means its value (for a company) depends on the number of people possessing the knowledge while its exact value is uncertain since its subjective.

Its non-physical since it’s not used up when consumed. That also means that its transfer or publication can not be undone – just like information. This aspect will be of some importance when talking about open innovation later on.

Conclusion

All this means that knowledge can only be acquired in practice. Its created in the process of human beings interacting with each other and their environment. It’s not static, it’s completely dynamic. Storing it is like cutting a twig from a tree.

The next posting will deal with classical knowledge management and the relation of firms to knowledge, also known as the the knowledge-based view of the firm. Stay curious and leave a comment!

Article
0 comment

Any sufficiently advanced technology is indistinguishable from magic

I just wanted to share some words about the technology used in building this site. After playing around with many different CMS and blog engines I decided to use ExpressionEngine (EE). This has several reasons:

  • Its built using PHP which allows me to put my hands as deep into the code as I want or need to accomplish a given goal.
  • I used EE to build several customer web sites, so there is a significant amount of knowledge about solving complex problems with EE.
  • EE is one of the most versatile blog engines I know since it allows you to create as many blog or channel streams as you like and use as many of them in one page template as needed.
  • EE in version 2 is completely rebuilt using the CodeIgniter framework. This leads to clean compact code and lots of possibilities to extend its functionality.
  • Its well documented. the learning curve is steep (you can do lots of new things in a short amount of time).

I also have a nearly complete blog engine written in Django in my “cool projects drawer” but you know fast such projects advance …