Saturday, July 9, 2011

network monitoring tools on linux

netactview: a network activity viewer for linux

I was trying to find a linux equivalent for "diamondcs port explorer"/tcpview/cports. It was surprisingly hard to get this information: took well over an hour, but I finally got exactly what I needed: netactview

netactview dynamically updates what ports are in use by what application, just like tcpview/cports/etc

It's available here:
http://netactview.sourceforge.net/download.html



iftop: display bandwidth usage on an interface





















iftop needs libpcap and libcurses, and helps identify which connection is sucking out all your bandwidth. Quoting the home page, "Handy for answering the question "why is our ADSL link so slow?"

iftop can also show source and destination ports in each network connection (press ? for the help screen, just like you would in top).

iftop home page

Saturday, July 2, 2011

Ubuntu!!!

A person with ubuntu is open and available to others, affirming of others, does not feel threatened that others are able and good, for he or she has a proper self-assurance that comes from knowing that he or she belongs in a greater whole and is diminished when others are humiliated or diminished, when others are tortured or oppressed.

-- Archbishop Desmond Tutu, 1999

Monday, June 6, 2011

phone screen questions


Phone screen technical questions


What is the difference between client-side and server-side scripting? Under what situation will you use which type?
Give me some examples of each type of scripting technology.



Describe the company to him, what kind of work is done here – brief intro to the project/product.

Instructions


  1. Go through those questions with the candidate on the phone, and fill in the gathered answers in the space provided after each question
  2. Pick one experience on their resume and ask the candidate a question or two to verify their participation and role in that experience.

General


  1. What is the difference between a process and a thread?
    A process has its own address space; a thread is part of a process and uses the address space of its parent process.

  2. What is the difference between a heap and a stack?
    A heap is memory used to store non-local data. A stack can be used to only store local data (ie, data that can be accessed only by the function that is executing, or any function that it calls).

  3. What is an access violation?
    Illegal access to a memory location, or accessing a memory location that is not mapped.

  4. How do you determine the code location of an access violation that occurs in the field?
    Configure the process to generate an image dump file and then load this in the debugger to view the call stack.

MultiThreaded Experience


  1. What is the difference between a semaphore and a lock?
    A lock allows exactly one entity (thread, process) to access a protected resource; a semaphore allows a specific number (controlled number) of entities (processes, threads) to allow a resource.

  2. What is a deadlock?
    A situation where there are two resources protected by two locks, A and B. One process (or thread) comes along, locks A, and wants to lock B. But another process (or thread) has locked B and is waiting to lock A. Neither one can proceed and this situation is called a deadlock.

C/C++


  1. What are the two arguments to the function “main”?
    argc, and argv
    Count of arguments and an array (or vector) of string arguments.

  2. What is a C++ class?
    It is a type of data structure that allows for the code and data associated with a logical object to be abstracted or packaged together.

  3. What is a virtual function?
    A function of a class that can be overridden by derived classes.

  4. What is the difference between a private member and a protected member of a C++ class?
    Private allows access by methods of the class (or by friends of the class).  Protected allows access by derived classes as well.

  5. What is a Reference in C++?
    Like a pointer, it is the address of an object, but syntactically, it behaves like the object itself.

  6. Why are templates important to C++?
    No root base class exists for creation of generic containers as in Java or other rooted OO languages, and templates allow enforcement of type safety.

COM/COM+


  1. What are the three methods on the IUnknown interface?
    AddRef, Release, QueryInterface.

  2. How do you create a new com object?
    CoCreateInstance

  3. What are the different apartment threading models in COM?
    STA (single threaded), MTA (multi threaded), TNA (thread neutral) and Both/Any (allows STA, MTA or TNA to match creator apartment)

  4. What language is used to define COM interfaces?
    IDL.

Java

  1. What is a Java Class?
    It is a type of data structure that allows for the code and data associated with a logical object to be abstracted or packaged together.

  2. What package do you need to import for simple TCP/IP communications?
    java.net.*

  3. What is the Java VM?
    Java programs are compiled to bytecode that is then executed by the Java Virtual Machine.

  4. How do you create a pointer in Java?
    You don’t!

  5. What is the java facility that allows you to inspect classes at runtime called?
    reflection

Networking:


  1. What is a DMZ?
    De-Militarized Zone, or the network zone between two firewalls.

  2. What is NAT?
    Network Address Translation - or a device that maps one IP address to another.

  3. Why do you need technology like NAT?
    To map internal IP addresses/Ports (which are typically in the non-routable range) to external IP addresses/Ports.

  4. What is the purpose of calling bind when listening on a TCP socket?
To specify a local end point (IP address and port) to accept connections on

IIS/ASP:

  1. How are ASP pages different from HTML?
    ASP pages contain server side scripting.

  2. What is a CSS file used for?
    CSS = cascading style sheet, used to specify formatting separately from the HTML content.

  1. How do you perform client side validation on a form element?
    Typically, associate a client side validation script with an event on the HTML element.   .NET supports some declarative client side validation.

SQL Server

  1. What is a join?
    A SQL operation that produces a single (logical) table from two or more tables, by matching one column in one table with a column in the other table.

  2. How are inner and outer joins different?
    An inner join is where the result contains rows that have a match in the column values in both tables.   An outer join allows data from one of the tables to be included even if the join column data is null.

  3. What is normalization?
    The design process that eliminates repetitive data.

  4. Assume you have a SQL table with 30 million rows and you want to fetch a few records.  How do you ensure the query returns quickly?
    Ensure that the where and order by criteria are supported with appropriate indexes.

XML / XSLT

  1. What is a DOM
    Document Object Model is a parsed, in memory XML document.

  1. What is XSLT
    Extensible Style Language Transformations.

  2. What is XSLT useful for?
    For converting XML data to any other format.

  3. What techniques are normally used to embed an arbitrary XML document inside another as a text entity?
    Normally either XML entity encoding (e.g. “&” -> “&&”) or enclosing the data in a CDATA section.



Friday, May 27, 2011

Bill Gates on What Makes a Good Software Manager

source: http://www.worklifecoach.com/bill_gates.pdf


From the New York Times: What Makes a Good Manager (10/8/97) By BILL GATES.

RECENTLY I wrote about 10 qualities of a good employee, which prompted quite a few people to ask about the attributes of a good manager.

There isn't a magic formula for good management, of course, but if you're a manager, perhaps these tips will help you be more effective:

1 Choose a field thoughtfully. Make it one you enjoy. It's hard to be productive without enthusiasm. This is true whether you're a manager or employee.

2 Hire carefully and be willing to fire. You need a strong team, because a mediocre team gives mediocre results, no matter how well managed it is. One mistake is holding on to somebody who doesn't measure up. It's easy to keep this person on the job because he's not terrible at what he does. But a good manager will replace him or move him to where he can succeed unambiguously.

3 Create a productive environment. This is a particular challenge because it requires different approaches depending on the context. Sometimes you maximise productivity by giving everybody his or her own office. Sometimes you achieve it by moving everybody into open space. Sometimes you use financial incentives to stimulate productivity. A combination of approaches is usually required. One element that almost always increases productivity is providing an information system that empowers employees. When I was building Microsoft, I set out to create an environment where software developers could thrive. I wanted a company where engineers liked to work. I wanted to create a culture that encouraged them to work together, share ideas and remain motivated. If I hadn't been a software engineer myself, there's no way I could have achieved my goal.

4 Define success. Make it clear to your employees what constitutes success and how they should measure their achievements. Goals must be realistic. Project schedules, for example, must be set by the people who do the work. People will accept a "bottoms-up" deadline they helped set, but they'll be cynical about a schedule imposed from the top that doesn't map to reality. Unachievable goals undermine an organisation. At my company, in addition to regular team meetings and one-on-one sessions between managers and employees, we use mass gatherings periodically and E-mail routinely to communicate what we expect from employees. If a reviewer or customer chooses another company's product , we analyse the situation. We say to our people, "The next time around we've got to win. What's needed?" The answers to these questions help us define success.

5 To be a good manager, you have to like people and be good at communicating. This is hard to fake. If you don't enjoy interacting with people, it'll be hard to manage them well. You must have a wide range of personal contacts within your organisation. You need relationships - not necessarily personal friendships - with a fair number of people, including your own employees. You must encourage these people to tell you what's going on and give you feedback about what people are thinking about the company and your role in it;

6 Develop your people to do their jobs better than you can. Transfer your skills to them. This is an exciting goal, but it can be threatening to a manager who worries that he's training his replacement. If you're concerned, ask your boss: "If I develop somebody who can do my job super well, does the company have some other challenge for me or not?" Many smart managers like to see their employees increase their responsibilities because it frees the managers to tackle new or undone tasks. There's no shortage of jobs for good managers. The world has an infinite amount of work to be done.

7 Build morale. Make it clear there's plenty of goodwill to go around and that it's not just you or some hotshot manager who's going to look good if things go well. Give people a sense of the importance of what they're working on - its importance to the company, its importance to customers.

8 Take on projects yourself. You need to do more than communicate. The last thing people want is a boss who just doles out stuff. From time to time, prove you can be hands-on by taking on one of the less attractive tasks and using it as an example of how your employees should meet challenges.

9 Don't make the same decision twice. Spend the time and thought to make a solid decision the first time so that you don't revisit the issue unnecessarily. If you're too willing to reopen issues, it interferes not only with your execution but also with your motivation to make a decision in the first place. People hate indecisive leadership; However, that doesn't mean you have to decide everything the moment it comes to your attention. Nor that you can't ever reconsider a decision.

10 Let people know whom to please. Maybe it's you, maybe it's your boss, and maybe it's somebody who works for you. You're in trouble and risking paralysis in your organisation when employees start saying to themselves: "Am I supposed to be making this person happy or this other person happy? They seem to have different priorities.

"I don't pretend that these are the only 10 approaches a manager should keep in mind. There are lots of others. Just a month ago I encouraged leaders to demand bad news before good news from their employees. But these 10 ideas may help you manage well, and I hope they do."

-- Bill Gates

Thursday, January 6, 2011

Friday, December 31, 2010

groovy: get your classpath right!

Here’s some basic, basic groovy code with a simple SQL query to retrieve some data from an oracle DB:
import groovy.sql.Sql
def sql = Sql.newInstance("jdbc:oracle:thin:@hostname:1521:testdb", "user", "pass", "oracle.jdbc.driver.OracleDriver")

def query = "select * from tablename where name='Beta 1'"

row = sql.firstRow(query)

println row

However, despite various attempts, I couldn’t even establish a DB connection because of this annoyingly persistent exception:
Caught: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
        at sql1.run(sql1.groovy:13)

So of course, I immediately googled the rather-descriptive error message, and quickly learnt that Groovy didn't know where to find the oracle jdbc driver. With a few more searches, I discovered that the missing driver was located inside a jar that was called something like “ojdbc14.jar” or something.

I found where the jar was on my file system:
”C:\Users\ambars\.m2\repository\com\oracle\ojdbc14\10.2.0.1.0” contained ojdbc14-10.2.0.1.0.jar that seemed like a good candidate for the jar containing the required oracle jdbc driver. Seemed like I’m making progress, good.

Now how could I tell Groovy/Java to search this path? I figured that I had to include the jar’s file-system path into my Java CLASSPATH, so that groovy would know where to find missing classes.

Okay, so I added “C:\Users\ambars\.m2\repository\com\oracle\ojdbc14\10.2.0.1.0” to my CLASSPATH environment variable, but that didn’t seem to work.

Still no good :-(

Hmmm, “groovy –h” indicates that I can specify a classpath on the command line with the –cp or –classpath parameters. So let’s try that:
$ groovy -classpath C:\Users\ambars\.m2\repository\com\oracle\ojdbc14\10.2.0.1.0  sql1.groovy
Caught: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at sql1.run(sql1.groovy:2)

Dammit work already! :P

I realized that I must be missing something very basic. It had to be a total n00b Java/Groovy problem. C’mon it can’t really be so hard to specify a path can it?!?

So I started googling about setting the java CLASSPATH correctly and then I stumbled on why it wasn’t’ working for me:


JARs on the classpath
Java compiler and run-time can search for classes not only in separate files, but also in `JAR' archives. A JAR file can maintain its own directory structure, and Java follows exactly the same rules as for searching in ordinary directories. Specifically, `directory name = package name'. Because a JAR is itself a directory, to include a JAR file in the class search path, the path must reference the JAR itself, not the directory that contains the JAR. This is a very common error.

Suppose I have a JAR jarclasses.jar in directory /jarclasses. The Java compiler look for classes in this jar, we need to specify:

javac -classpath /jarclasses/jarclasses.jar
and not merely the directory jarclasses.

Thank you, http://www.roseindia.net/java/java-classpath.shtml, for saving me from a lot of frustration!
Voila! Finally it works!
$ groovy -classpath C:\Users\ambars\.m2\repository\com\oracle\ojdbc14\10.2.0.1.0\ojdbc14-10.2.0.1.0.jar sql1.groovy
[NAME:Summary, PATH:Snapshot, MAPPINGKEY:26, VERSION:v9]

It’s even easier with the CLASSPATH environment variable set correctly like this:
CLASSPATH=C:\Users\ambars\.m2\repository\com\oracle\ojdbc14\10.2.0.1.0\ojdbc14-10.2.0.1.0.jar;

Now I don’t even have to type the –classpath parameter out on the command line each time:
$ set | findstr CLASSPATH
CLASSPATH=C:\Users\ambars\.m2\repository\com\oracle\ojdbc14\10.2.0.1.0\ojdbc14-10.2.0.1.0.jar;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;.

$ groovy sql1.groovy
[NAME:Summary, PATH:Snapshot, MAPPINGKEY:26, VERSION:v9]

Tuesday, December 28, 2010

windows: setting environment variables from the command line

The standard route is rather slow and painful, even on Win7:
“MyComputer | Properties | Advanced System Settings | Environment Variables”… that’s a lot of clicks just to get to the point where you can add/edit an environment variable.

Thankfully, there’s a much easier alternative via the command line.

But first, did you know where the environment variables are stored on the file system? Until now I thought they were in some system config file, but it turns out they're actually stored in the registry itself (which technically is a system config file).
  • The logged-in user’s env variables go here:
    HKEY_CURRENT_USER\Environment
  • The machine-wide env variables go here:
    HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
The setx utility lets you change env variables for either the user or machine. The good old set command let’s you add/edit env variables too, but there are a few major differences from setx:
  • setx will permanently change the value of an env variable. The changes made by set last only for the current session.
  • Changes made by setx are not immediately visible – that is, they are not available to the current session. However, set’s changes are immediately visible.
  • You can’t delete env variables with setx, like you can with set. For example:
    set someVar=
    will delete the environment variable ‘someVar’ for the current session, but you can’t do something like this with setx.

    Instead, you have to use the “reg” utility to delete environment variables (that may or may not have been created with setx):
    REG delete HKCU\Environment /V someVar
Okay, so do you create a permanent environment variable via setx? It’s pretty straightforward:
  • To set an env variable for the current user:
    SETX <Variable> <Value>
  • To set an env variable for the machine (i.e. globally):
    SETX <Variable> <Value> -m
Example:
setx  CLASSPATH  C:\Users\ambars\.m2\repository\com\oracle\ojdbc14\10.2.0.1.0\ojdbc14-10.2.0.1.0.jar;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;.

source: http://ss64.com/nt/setx.html