Autonomy Artificial Intelligence - Blog

Thursday, April 16, 2009

SVN to GIT Migration

I have so many projects that need migration from subversion over to git that I got sick of doing it manually each time (after the second time actually).

So, I've written a little howto, along with a script that does all the work for you, the syntax is simply...

  s2g -s svn-co-uri -g local-git-repo-dir

The details are on the Autonomy Docson website.

For Trac users, there's also a section in there which shows you how you can point your existing Trac project from subversion to git.

If there's any missing information, let me know and I'll update the document.

Variable-Variables in Bash

Know the boring details already and just want the answer?

    EVAL=$(eval echo -n \$${VAR})

Otherwise read on...

This took me longer than it normally does to look something up in the man page, so I may as well share it in case others have the same need in writing a shell script...

Variable-variables, for those that don't know, are variables that you'd like resolved not once, but twice.  For example...

  foo=bar
  bar=zap

The first resolution of foo (i.e. $foo), would give the value bar.  The second resolution of foo (i.e $$foo) would give the first resolution of bar (i.e. $bar), which is zap.  While this double-dollar syntax is exactly how you'd do this in a language like PHP, it's a little more annoying in Bash.

Here's an example where I need to check for a to see if all elements in a list have been set...

EXIT=0
for VAR in GIT_BASE SVN_BASE; do
  EVAL=$(eval echo -n \$${VAR}) #. Double-resolve
  if [ -z "${EVAL}" ]; then     #. $VAR not set?
    EXIT=$((${EXIT} + 1))       #. Increment EXIT
  fi
done
exit ${EXIT}

So if GIT_BASE and SVN_BASE are both set, EXIT will hold a value of 0, if none are set, it will hold 0, and so on.

Tuesday, April 14, 2009

The Recommended Unix/Linux Filesystem Layout (FSH) for Enterprise (Third-Party) Packages

More often than not, a Unix/Linux system administrators are required to install 3rd party enterprise vendor software, and most of those times, they often have to go to the toilet and throw up.  Most of the time, the enterprise world puts in a seriously low dose of effort in writing the installer, and then the systems administrator has to watch it basically take a good dump all over their hard work, and contaminate their once-clean servers.

This document is a proposal for system administrators who are cautious, and care about standards and good practice.

It is a recommended filesystem hierarchy standard based on that created by the FHS Group, and open (and welcoming) to public scrutiny - as that but the most important ingredient in writing quality - be it software, standards or protocols.
 

Wednesday, April 9, 2008

Python Yield (Generator) Statement in a Nutshell

This will be the shortest bit of information you're likely to find, but it's great as a refresher.  If you are not familiar with Python generators and iterators you should read something comprehensive.  A great document I recommend is by Norman Matlof, that can be found here.

def myIterFunction():
  i = 2;
  while True:
    i *= i
    yield i

myIterFn = myIterFunction()
for i in range(0, 16):
  print myIterFn.next()

What happens here is that we first create our iterator, myIterFn, and then we iterate through it by calling the special iterator function called next().  Each time, we do it's like we awaken the myIterFunction from where we last left it (at the point where yield returned control back to the calling function).  Each subsequent call will awaken the function and run until it next encounters the yield operator.

The other advantage is that with this code, you could generate infinitely long sequences.

As a side-note, I should add that the simple example above can be done without using a generator, for example...

i = 2
def myIterFunction():
  global i
  i *= i
  return i

...but as you can see, you either have to use a global variable, or write a class to accommodate this.

Now, can anyone point out how this can be done in Objective-C, please post =).

Tuesday, April 8, 2008

OMS (Oracle Management Server) & RAC (Real Application Cluster)

Reconfiguring an existing OMS (front-end), Grid Control, to talk to RAC is simple.

Aim
  • To reconfigure OMS to point to you new RAC setup.

Assumptions
  • I will refer to all paths via the ORACLE_HOME variable, which as far as this task is concerned is not even required. As an example, in my setup it is set to  /u01/app/oracle/product/10.2.0/oms10g.
  • That the database migration is already complete.

Files
  • ${ORACLE_HOME}/bin/emctl
  • ${ORACLE_HOME}/sysman/config/emoms.properties
  • ${ORACLE_HOME}/network/admin/tnsnames.ora

Tasks
  1. Add a new TNS entry to your tnsnames.ora, give the alias a name of your choice, let's say EMREP.
  2. Start editing emoms.properties and make the following changes adapter according to your environment.
  3. Comment out oracle.sysman.eml.mntr.emdRepServer=oms.mycompany.com.
  4. Add oracle.sysman.eml.mntr.emdRepRAC=TRUE.
  5. Add oracle.sysman.eml.mntr.emdRepConnectDescriptor=EMREP.
  6. Save and quit.
  7. Restart OMS (emctl stop|start|status oms etc.)

All Blogged Up.

I've set up my first (ever) blog; pity I'm always short of words. Time to go to bed.