Friday, November 12, 2010

Matlab's keyboard command in python

A nice function to mimic matlab's keyboard command in python.

import code
import sys
def keyboard(banner=None):
    ''' Function that mimics the matlab keyboard command '''
    # use exception trick to pick up the current frame
    try:
        raise None
    except:
        frame = sys.exc_info()[2].tb_frame.f_back
    print "# Use quit() to exit :) Happy debugging!"
    # evaluate commands in current namespace
    namespace = frame.f_globals.copy()
    namespace.update(frame.f_locals)
    try:
        code.interact(banner=banner, local=namespace)
    except SystemExit:
        return 

Friday, September 17, 2010

LaTeX Todo's

A very interesting package todonotes, allows keeping track on unfinished items in a LaTeX manuscript by posting colorful notes on the margin and a table of changes to be made. Available at
http://www.ctan.org/tex-archive/macros/latex/contrib/todonotes/

Monday, March 22, 2010

Matlab-Java Integration, Working note.

Since Matlab runs on a JVM, it can easily integrate JAVA classes. Here is a quick view, mostly taken from the Matlab documentation.
 
[mFns, mexFns, javaClasses] = inmem; %Check which classes in memory

% classpath 
which classpath.txt
edit classpath.txt 

% imports
import java.lang.String
L = import % return import list 

% creating objects
strObj = javaObject('java.lang.String', 'Hello World')
frame = java.awt.Frame('Frame A') 
setSize(frame, 800, 400)
newFrameRef = frame

% concatenating object using cat or [] 
myObjs = [strObj; frame] 

% save trial.mat myObjs 
% load trial.mat 

% getting class attributes
names = fieldnames(strObj, '-full') % second argument optional 

% accessing object data
frameDim = getSize(frame) 
h = frameDim.height 

w = java.awt.Frame.WIDTH % static data, say, counters

% test class name
if (isjava(obj))
    name = isa(obj, 'class_name')
end

% invoking methods
% obj.method(args) OR method(obj, args) 
getTitle(frame) 
javaMethod('startsWith' , gAddress, str) % longer method names
java.lang.Double.isNaN(2.2) % static methods
javaMethod('isNaN' , 'java.lang.Double', 2.2) % static javaMethod 

methodsview java.awt.Frame % class name 

javaArray('java.lang.Double', 4, 5) 

Saturday, February 13, 2010

try out buzz - blogspot integration

Trying to incorporate this in google buzz

ComputerScience@Mattel


Mattel Inc, makers of Barbie Dolls are releasing a new Barbie, who is a computer engineer (Related IEEE Spectrum Article).

The release is scheduled for tomorrow coinciding with Computer Engineers Week starting tomorrow. One might wonder with the choice of the organizers starting the week to coincide with Valentine's Day :)

This is especially relevant considering the fact that the number of women in CS is decreasing; and the special incentives both by the Industry and Academia to promote women in the field, e.g., Anita Borg awards, IBM's EXITE, etc.

Personally, I wish luck to the efforts :)

Thursday, January 7, 2010

The road ahead.

The article, The Best and Worst Jobs, puts actuaries as the best job on a number of categories, followed by software engineers and computer systems analysts.

Interestingly, one thing they all have in common is that they empower others to do their jobs "better" or "efficiently". Put in simple terms, the end result of their effort does not result in any physical goods/labor, etc. Yet, the number of software professionals is growing every year.


One interesting analogy may be made to the machine operators in the 40s. They were necessary to operate the complex machines that resulted in the mass-production. However, they were eventually replaced with the advent of automation. The same pattern, though yet in its infancy, can be observed in terms of automated IDE's, code helpers, etc.

Further, while leaders like of the business such as Google, Microsoft, tend to constantly innovate, will the market for software code allow for multiple mediocres providers to survive. In fact, we already see that 1 in 10 software startups eventually fail. Now, one may speculate that while radios have since been absorbed into cell phones, and hence there is and will be a constant need to VLSI engineers, one should also note that even in that domain - most of the processes have become automated.

Ultimately, major progress in a field occurs while trying to solve problems imposed due to real world limitations. Computer science relies on other fields of science to provide it with problems which it tries to model in some fashion. This is also partly true of mathematics. Therefore, there will always be a need for great mathematicians.
However, how many mediocre mathematicians can be found except in educational institutions :) When we factor in the fact that usually, only those who are interested in mathematics tend to become mathematicians, and that number is considerably lower - one might begin to see an uncomfortable truth.

The average software engineer of the future whose predecessors wrote mediocre code for automating a mundane process will find himself out of a job in a market filled with many competitors and shrinking opportunities. We will probably see this trend over the next two decades.