Buy Young – Spurring the Young Entrepreneurs

I’m proud to be a part of the team that worked on launching the Buy Young campaign spurring young Americans to take up more initiative, become more entrepreneurial and play a part in steering America in the right direction.

IVR Tech has made some news and also got a mention on the White House blog. We even got a letter from the White House congratulating our efforts and all this has only spurred us to do bigger and better things!

White House Letter - Buy Young Initiative

White House Letter - Buy Young Initiative

How to fetch records between specific times but relative dates?

Recently I had to write a report for a client that goes out everyday. The query was required to contain results between 09 30 AM yesterday and 09 30 AM today. I’m no great shakes in SQL and so I set about to use Google to find my answer.

Believe it or not, I had some hard time finding pages that gave me this information. A lot of potential sites came up and I poured through a lot of information and finally came across what I wanted. I’m posting it here again so the next time you need something like this, you can stumble upon this more easily.

SELECT * FROM table_in_question
WHERE date_in_question >= TIMESTAMP(DATE_ADD(CURRENT_DATE(), INTERVAL -1 DAY), ’093000′)
AND date_in_question < TIMESTAMP(CURDATE(),'093000');

The query is pretty simple and self explanatory so I will give you a very short explanation. The TIMESTAMP function of MySQL with two arguments will return an object after concatenating the date and time part from the arguments. This object’s data type is datetime which is what most people use to store times in the database. From here on it is the usual comparison in the where clause. To break it down further:

TIMESTAMP(DATE_ADD(CURRENT_DATE(), INTERVAL -1 DAY), ’093000′) today will return 2011-03-18 09:30:00.000

and

TIMESTAMP(DATE_ADD(CURRENT_DATE(), INTERVAL -1 DAY), ’093000′) tomorrow will return 2011-03-19 09:30:00.000

When you write a query like this, you let the database do some heavy lifting very easily as compared to writing that code yourself in the business and just passing it as arguments to the query.

Happy St. Patrick’s day & cheers! :-)

Tidbit #2 – Infographics

Very very interesting read. An article how about how people these days use information and graphics together to display information to the user which stands by itself.

Infographics

Some of the things I see these days makes me wonder, how did they do it and will I ever catch up!!!!! Happy reading folks.

Peace.

Tidbit #1 – Scales of the universe

Gives you a perspective…. I’ll leave it at that and let you find your perspective.

Scales of the universe

Default Port Numbers for Port Forwarding in SSH

If you tunnel into your servers using SSH and are in need of setting port forwarding to your servers, you will need the default port numbers on which the servers are listening.

I have compiled a list of services and their default port numbers for quick reference. Unless your administrator has changed the ports, you could use the same.

MySQL - 3306
RDP - 3389
SVN - 3690
SQL Server - 1433

I will add more to the list (yeah, I know, big list :-) ) as and when I can.

And if you are looking for decent programs that will help you create SSH tunnels and setup server side port forwarding, I can recommend a couple. For windows you could try Bitvise Tunnelier. For Ubuntu give gSTM a shot. You can install gSTM from within Synaptic.

Phone Number Formatting – OpenOffice.org Calc – Macro

I usually run into situations at work where I need to clean a CSV file having phone numbers. Doing a quick Google search does not help because most people out there want the exact opposite.

Let me give you an example.


What most people want:

Input:
1234567890
Output:
123-456-7890 (or) (123) 456 780 (or) 123 456 7890

What I people want:

Input:
123-456-7890 (or) (123) 456 780 (or) 123 456 7890 (or) 123*456*789

Output:
1234567890

Doing a slow and careful Google search led me to this beautiful piece of code. Just select the region which you want cleaned and run the following macro. It will save you a lot of time. Also feel free to modify it to your needs.

Sub replace 

  oCurrentSelection = ThisComponent.CurrentSelection
  xReplaceDesc = oCurrentSelection.createReplaceDescriptor() 

  xReplaceDesc.SearchRegularExpression = TRUE
  xReplaceDesc.SearchString = "[- *.]"
  xReplaceDesc.ReplaceString = "" 

  oCurrentSelection.replaceAll( xReplaceDesc ) 

End Sub

Have fun!

Success: “Relative to What?”

I read this article recently written by a very good friend of mine. The message conveyed was food for thought and the language was exquisite.

Success: “Relative to What?”

It is an interesting read and I thought of sharing it here so when you guys find some time, do read it.

MySQL Workbench – Error Code: 1175

Have you ever encountered the following error when using MySQL Workbench to perform an UPDATE or DELETE without the PRIMARY KEY or INDEX like most of us do?

Error Code: 1175
You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

If you do, the fix is pretty simple:

  1. Select Edit->Preferences
  2. Navigate to SQL Editor Tab
  3. Uncheck this option: “Forbid UPDATE and DELETE statements without a WHERE clause (safe updates)”

While the text states that this will only prevent statements from running without a WHERE clause (which is a good thing), it will also prevent statements which do not use the PRIMARY KEY or INDEX in the WHERE clause.

PS: Now that you have unchecked it, make sure you are SUPER careful when running queries! :-D

Pretty Printing (Formatting) XML using Java

As a part of the project I was working on, I had to deal with XML request and response documents. The DOM documents were big and very cluttered. It was a not a sight that will please the eyes.

I did some quick googling and combined various posts from various places to create this method that will do some neat printing of XML when you are in a bind and neatly formatted XML. Feel free to tweak and use as you see fit.

/**
 * Sends the XML document to any stream. To print on console pass System.Out as the argument for OutputStream
 * @param xmlDocument
 * @param stream
 * @throws Exception
 */
public void printXMLToStream (Document xmlDocument, OutputStream stream) throws Exception {
	try {
		Transformer transformer = TransformerFactory.newInstance().newTransformer();
		transformer.setOutputProperty("omit-xml-declaration","yes");
		transformer.setOutputProperty(OutputKeys.METHOD, "xml");
		transformer.setOutputProperty(OutputKeys.INDENT, "yes");
		transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "3");
		transformer.transform(new DOMSource(xmlDocument), new StreamResult(stream));
	}
	catch (Exception e) {
		throw new Exception("Error occured in printXMLToStream()\n" + e);
	}
}

TortoiseSVN equivalent on Ubuntu? Get RabbitVCS!

Have you guys been wondering about moving to Ubuntu and have been held back because of a good GUI based shell extension like TortoiseSVN.

Well you don’t have to anymore. I was just doing some googling to figure out an Ubuntu equivalent of TortoiseSVN and I stumbled upon RabbitVCS.

I’m going to be using it over time and will let you folks know how this works out for me. Please feel free to give it a shot and let me know if this was a useful tool.

Here are the installation instructions for Karmic and Lucid. For other versions/distros please visit their site.

sudo add-apt-repository ppa:rabbitvcs/ppa
sudo apt-get update
sudo apt-get install rabbitvcs-cli rabbitvcs-gedit rabbitvcs-core rabbitvcs-nautilus rabbitvcs-thunar

Here are a few screenshots:

Nautilus Integration
Nautilus Integration

Commit Dialog
Commit Dialog

Show Log
Show Log