Monday, November 22, 2010

Some cool geeky gifts I see this year - About 6 (2010)

Found these while searching for gifts and thought I should document them.
On a second thought, maybe I should document for each holiday, would be fun to see these 10 years from now 8-)

Wearable camcorder & Bluetooth device
This is neat !
You can record upto 5 hours of video. Now the quality isn't that great (15 fps HVGA) but still seems to be a pretty unique concept.
The details mentions that the bluetooth functionality doesn't support BB or iPhones.. dissapointing.
But still a cool gift, I guess if you have kids and are at social events a lot.


This might not be new, but I've only come across it this year.
Seems to be a functional hoodie for anyone.


Nothing much to say on this.


Parrot AR.Drone
I saw this at brookstone the other day and it blew my mind !!!!
Now this is some serious fun with your iphone !!
  • Remote control quadricopter controlled by iPhone, iPod touch, or iPad
  • Interchangeable hulls designed for both indoor and outdoor use
  • Fly and battle with other Drone users via a Wi-Fi network
  • Front-view camera with live video feed on your iPhone/iPod touch
This is an expensive toy and from my previous experiences with RC planes, they break.
My skill in flying these are terrible hence got the warranty and was able to replace the broken parts.
The reason I'm excited is soon this will get cheaper and we could have better ones every year.


I like my Wii since its more than sitting on the couch while being entertained.
Kinect takes it a notch ahead where you don't need a remote at all.

Your hands are the controllers. Also, it works with any XBox you have ever purchased. I'm pretty sure, this is going to be the hottest toy this year.
The reason for this being on the geeky list.


Rocking Guitar T-Shirt
Not meant to replace your old Fender, but at least the volume seems to make a punch.
Fun T-shirt for a kiddo. Amazon might ship them faster.

There were a few lego ones, but then that is another blog in itself 8-)

If you have found a geeky gift this year, drop a line.

Tuesday, November 9, 2010

If twitter becomes a time sucking vampire

I think there are three stages of using twitter -
1.) "Its a waste of my time, I have better things to do."
2.) "Meh... let me see what the fuss is about."
3.) o.k. too much bird shit coming in, let me organize and cleanup

I'm in the third stage, following has helped keeping the bird shit from breaking the door and oozing on to the carpet -


Stop Talking !   Listen...
I have a lot of interesting things to say, say about every 1 or 2 hours. But not always. Twitter has this strange power where it pulls you to fill that void of 140 characters.. (or is it just me ?!). I decided on holding back on my urge to tweet something, I give it 10 seconds and see if it is still something I'd like to tweet.

Well, I overcame that urge. I learned that I should listen more, just as I would do in a room full of people. Twitter suddenly feels a lot calmer. You see a tweet coming, hold it in your hands, look at it and let it go on its own way. If twitter were seen as a tool, its use is more effective by watching the tweets, unless you have something worth sharing.

Retweet - More often
When you see people saying something worthwhile retweet it. Spread what is good. Copyblogger is currently trying to find good bloggers. I love those guys, and retweet them often.

Nip in the bud
If I see someone tweeting like a parrot saying nothing important, I unfollow them. If I have setup 15 mins/day to read tweets, and 10 mins. are wasted because you tweet 7 times about "how big a burrito you had for lunch" --
I will blow horn at your birdie.
I will kung-fu your beakie
I will glue your wingie
I will ruffle your featherie
ok ok...enough violence on that little birdie.

Don't follow the leader (only)
Well, I'm not much fan for blathering. To improve the quality of  tweets I started doing this
  1. Find best people in your field of interest  (I am still working on that)
  2. Follow who they are following
If the best in the field think these people are worth their time, they really must be. Follow them, you can always unfollow. I recently read something to this line on HN - Don't aim for what your hero has achieved, aim for what he is aiming for[tweet]

Some very smart people talk there, and I like to listen.

Group'em see'em later
Although this is something I've seen before, its just recently that I've started implementing this. Add a hashtag (#) at the end of everything you tweet, e.g. #productivity, #tips. Later if you want to find a tweet about something you tweeted 4 months back and you know it was about a neat python script, you can just search with the corresponding hashtag. Since anyone can create a hashtag, you want a unique one, so when you search for it, it doesn't show the ten thousand tweets tagged by other people. For example instead of just #tips tag it with #zzztips.

How about 15/20 mins. ?
I am a big fan of not wasting time. I've blogged earlier about this here.
Instead of randomly visiting Twitter (of course unless you have something to tweet), I've setup a time aside - 20 mins. max/day. During this 20 min., I visit twitter from my iPhone, hence if there are any good links, I save them to read later through instapaper. Install the instapaper app. so you can read later what you bookmarked. Retweet the good ones and follow someone who has been retweeted and has funny/valuable info.

Create Lists In order to read through the most important tweets I've created "lists". One of them is called the "NoShit" list. Which is a group of people who have something valuable to say (mostly) and don't spam my twitter account. Its easy to create such lists or just follow one that someone else has created.

Lessons learned
  • Read more tweets than you tweet
  • Retweet more often
  • Unfollow people who have nothing worthwhile to say
  • Follow the leaded & who he is following
  • Use hashtags
  • Cap the amount of time spent on twitter
  • Create the "noshit" list
If you have any good tips to share about twitter, please do.

Follow me on twitter @nikhilkodilkar

Monday, October 25, 2010

Lessons learnt while saving my Pet (projects) : Hint - "Fake it"





Note: This is a follow up to my previous blog


Some months back I desperately wanted start working on my pet projects and decided to make some changes on how I manage my time. I learned the following lessons -



Fake it ( It helps ! )
"Work expands so as to fill the time available for its completion."
Remember your bachelor days, when you hadn't cleaned your room in a week and you suddenly got word  that your friends/family were on way ? Now remember how you cleaned the room in 5 minutes flat 8-)

On a normal day, it would've definitely taken you more (lot more) than 5 mins. to do the exact same work. Deadlines are wonderful things 8-) Btw, this is called the Parkinson's law, you can read more here and LOT more here. I create fake deadlines for myself. And I admit I'm addicted to them.. 8-|

Here is my experiment - The drafts of all my blogs are on fake deadlines of 12 mins. I have to write 90% of my blog in the 12* mins. It gives me a rush, the brain starts spewing out words and at the end of 12 mins. I have something that could easily have taken me 30 mins. of liesurely writing. Forget the spelling, forget the markup, just write plain words. As I have described in my previous blog, I set time for some unusual things and let the mind & body figure out a way to achieve it.

*12 mins - That's what I set for my first draft blog and it worked, hence sticking to it.

Don't start on anything without setting its deadline [ tweet this ]


Baby steps are useful especially when you grow up

Divide your goal into as smaller a task as possible. Set your smallest task 1 week apart. Since I have a regular 8-6 job, the biggest free chunks of time I get, are over the weekend. Hence setting deadlines over Sunday night works best for me. My new blog, my website enhancements, gathering information on topics, etc. all have a deadline of Sunday night. Since friends/family are important, I try to spend Friday night or first half of Saturday with them & then dive into the pet project. Since I know I have limited time to party or enjoy the company of family, I make most of it. The main point being, pick a day 7 days apart, that works best for you.

I use a simple task/deadline sheet and store it as a google document -








Having written deadlines is simple & effective & a lot better than having a deadline somewhere in the maze of neurons.

Mind is like a dog, throw it a deadline and it will run behind it, else its going to sit there and lick you crazy [ tweet this ]

This is an excellent book on training your brain - What to say when you talk to yourself

There is a reason you call it "Pet Project"
You will usually have 2 or 3 projects in mind. (I suggest no more than 3).
Alternate between them. If you feel bored/burnt out with a project, stop it and jump to another one. Give into your feelings at times. You don't want your pet project to become your office project, which needs to be completed no matter what.

This has worked wonders for me for one simple reason - When I jump into the next project, I jump with a lot of energy and I get a lot of work done. Each jump is like a sprint instead of a marathon !!


Are you planted in the correct soil ?
See yourself as a plant. You need good food for your mind, conducive air with ideas to inspire you, healthy plants around you that want to grow tall with you with ambition to prosper not just survive.

If I surround myself with garbage, I'm going to produce more garbage [Don't ask me how I know that]

Good thing is that you can change your soil.

Here is what I did - I got interested in startups and wanted to know more about them. Wanted to know what the biggest minds in the industry were thinking/doing, how they started/failed. And its not difficult to surround yourself with them -
  1. For 45 minutes listen to a CEO speak about his experiences and his advice. These podcasts fit in my mantra of following advice of people who have actually done it. I'm forever indebted to Stanford University for this.
  2. What the best minds in the industry are viewing and watching - Google Tech Talks. And contrary to the belief at times they will have a speaker who talks about something totally non-tech. I remember one of the episode was about making Kimchi and the science behind it 8-) 
Go to the iTunes podcast directory or Youtube and you'll find podcasts on every which topic. Subscribe to them, you can listen to them anywhere & everywhere.

If you don't have friends who share the same goals & ambitions you can do this -
  1. Get them involved in what your thoughts are, and many will be interested in getting along. A lot of people want to come out of their regular lives and implement their ideas, and just need that small nudge of inspiration.
  2. Make new friends - always good.
  3. If you don't find such people, be alone and work on your pet projects, slowly you will start attracting the correct people.

In summary -
  1. Deadlines are your friends - Before you start any task, give it a deadline.
  2. Alternate between projects. If bored/burned-out, switch to another pet project. Remember there is a reason you call it "Pet Project"
  3. Listen to podcasts to virtually surround yourself with good ideas & people. Of-course real people are the first choice 8-)

If you have similar ideas/hacks you employ, let me know. I'm always ready for a new baby step !

Links to books referred in the blog
What to say when you talk to yourself

Other good books



Follow me on twitter @nikhilkodilkar

Wednesday, October 20, 2010

Best "Server Busy" message I've seen !







Trying to word my thoughts about this simple experience -

Attention to detail - They could've put a "twitter is busy" message and would've been fine, but they want to take care of every part of the user interaction. Guarding the image they have in the users mind.

Little bit of cuteness goes a long way - The unpleasantness of my experience was greatly reduced.

Impression - Seems like the group of people who created this would be a great "bunch" to work with 8-)

If you guys have come across a great "Service unavailable" picture, please let me know, would be fun to see them !
Keeps the creative juice flowing.

Monday, October 18, 2010

Why I eat alone(usually) and probably you should too

Update Here is the followup to this blog

Note : No, I'm not the geeky dude who rarely talks to people and is socially awkward 8-)

Sometime back, I had no time to work on my pet projects, blogs and readings. Or so I thought..

The myth : "I don't have enough time"
As for anything in life, there are exceptions, and I'm sure there are people who truly don't have time. e.g. Anyone who just had a baby, or is doing a Ph.D & working part time Or someone doing a startup(bootstrap), coding, raising funds and pitching over lunch meetings.

For the rest of us this does not hold true.
The myth should be transformed into this statement - "I don't have enough interest to do xyz, hence I never find time for it"

If you truly have interest and think you don't have time, read along.

Not long ago I lived this myth, till I actually read Timothy Ferris. He does startups, writes books, finds time to blog & do all kinds of interesting things. His book is life changing, and its on my reading list for the second time.

I thought you had to be a superman to find time to all these things. Turns out you can do them all  without wearing your underwear over your trousers.

Here are some changes I made to my lifestyle -

30 mins. everyday down the drain
Most people get 30 to 45 mins. for lunch. Typically you'll have a group of 4-5 people huddled around a table eating. The topics of discussion are mostly -
  • Some world event - How the middle east peace process is worthless
  • Some take over in the industry - Google just bought blindtype, did you hear about it ?
  • Something they did over the weekend or will do - "And this guy sitting across our table, farted while ordering" 8-))))

Do you notice something in the topics above ?
  • You have little or no impact on them or from them
  • You don't want to discuss many of them, but one of your colleague does
  • They don't add anything of value to you
  • And there are a lot faster ways to keep yourself informed e.g your rss reader, etc.

I understand that once in a while one does need this. But, doing this everyday for years at a stretch didn't seem correct, I thought there was a chance to improve here. You can utilize these 30 mins. in learning something new or reading about a new topic.

Here is what I tried - I wanted to start learning a new computer language. I was bored with Java and had heard good things about Python. I subscribed to this podcast and started listening to the 5/10 min. episodes while I munched on my sandwich. Also, the list of books I wanted to read was close to two dozen, hence I started listening to their audiobook versions! There is list of good books at the bottom of this post, which I've either read or am currently reading/listening.

You would be surprised at the amount of reading you can finish if you do it for 30 mins. everyday. Once you start doing this, you will eagerly await your lunch break, since it provides food for both your body & mind.


Living consciously (Mindfully) - My experiment
Now now ! You going all philosophical on me mate !!

Not yet 8-) I'm not Thich Nhat Hanh.

I'm referring to the part where we get lost thinking about one thing, while doing something totally different. Or try to do multiple things at a time. No matter how much you believe, Humans cannot multitask.
We have a limited quota of attention, and as soon as we divide it our performance takes a severe beating.

Here is an experiment I did -
I bought a simple kitchen timer, the simplest kind and tried to time my getting-ready routine in the morning. Surprised I was. My maximum time went shaving, taking a shower, and getting ready after that. It took me exactly the same time to get ready after shower as it took to shower ! I timed and consciously concentrated on showering, cutting my time to a precise 7 mins from 12.

I would've dismissed the above experiment as time paranoia, about a year back. But that's not the point, its an experiment in concentrating on the task at hand and not letting your mind wander. 7 mins. of focusing might sound small, but it isn't. I learnt that within a month I was focusing better, concentrating longer and fighting distractions more effectively in general.


I once read that you don't make something out of your life working 8-5, its what you do after 5, that determines it. [ tweet this sentence ]


Your work life is not coffee break time
If you have an 8-5 job, do your job in that time. Don't take more than 15 mins. per day to do the following during office hours-
  • Coffee breaks
  • Chat breaks
  • Smoking breaks

In my 10 years of experience, I've seen my fair share of people who take these breaks a lot more than 15 mins. Plus they take them about 3 to 4 times in a day. Of course, no 2 days are equal, and you'll need more breaks on some days. But seems setting a limit is something one can do. If you take a break, because you are "Bored" at your job, it probably means L
  • that you need to take some extra initiative, or
  • take on more responsibility, or
  • develop new tools or ways to be more productive
  • And if none of the above work, maybe you need a more challenging job - your skills are way over what your job is asking you to do.

The benefits - You will finish your work on time, get home and can start working on your pet projects.

The above points have changed my 8-6 & after 6 life. I am finally working on my pet project, writing blogs and completing tasks faster.

I will soon follow up with another blog with more of this.
Here is the followup to this blog.

Lessons :
  1. Don't waste your lunch time
  2. Live consciously - Don't multitask - only one task at hand.
  3. At work - minimize distractions


If you have similar hacks, please do let me know, I'm always in a mood to learn.



As promised here are some good books to read -
22 immutable laws of marketing - I'm currently reading this, and its a mere 132 pages of condensed awesomeness
4 Hour work week
Six pillars of self esteem
The invisible Gorilla
Atlas Shrugged
The fountain head
Freakonomics
Outliers
Economics in one lesson
Mindless Eating: Why we eat more than we think


Update Here is the followup to this blog






BTW, I customized this blogger theme.
If you like it, I'll share the template.

Thursday, May 20, 2010

Lessons I learnt when my laptop was stolen

Before we go ahead, lets go over a "What if" condition -
"Right now, some stranger has access to your personal laptop and they are going over everything you have on the hard drive".

Enough to send chills through my spine, how about you ?

Replace laptop with "Backup storage" or "Desktop" to get the desired effect 8-)

Recently my house was broken into, and along with other valuables, they took my beloved Thinkpad (Yes, I love those plain black no-nonsense machines).

It had a lot of personal & important information..

Its been almost a month, and it still drives me crazy.

o.k. enough of rambling, let me get you to the meat of the story -

Lessons
As most of you, my laptop didn't have any encryption.
The only safety it had was my password and luckily fingerprint scanner. This is one reason I liked thinkpads.
You can have a pretty long & complicated password, but at the same time have fingerprint authentication. Hence when you want to login to your computer, you just swipe your finger and you are in.
For anyone who wants to breakin to the computer they have an uphill battle.

Coming back to encryption, I should have had atleast a very rudimentary encryption enabled, so that even if someone gets in, they have to have basic skills to get to your data.

There are a number of ideas which you can employ, and I want to get this out, so all my friends can implement them -

1.) Hide your personal folders
I know, this sounds extremely lame, especially for all who have grown with computers.
But you will be surprised how many people don't know how to "unhide" a folder.
I'm talking about PCs here.
Here is another reason - Someone who is into breaking in hopefully isn't as skilled as the above.

This is the minimum ! I'm kicking myself for not doing even this.

2.) Truecrypt
Did you know that there is a free encryption program available on the internet, which you can use to encrypt a part or whole of your harddrive or your backup USB drive ?

Well neither did I.

I started looking into it after the breakin and discovered Truecrypt
You can learn more by clicking on the link above.
Go over this step-by-step process to create a secure directory on your harddrive which is encrypted and private only to you.

For geeks like me who want to get into the details of everything, there is this nice comparison of features.

If you are going to buy a new laptop, you have two more options - Hardware encryption & Bitlocker.
Bitlocker only comes with Windows 7 ultimate.
Hardware encryption as shown below.

3.) Use an encrypted harddrive
There is a saying - "Once your tongue is burnt my hot milk, you will make sure that butter milk is cold". (Sorry for the ghastly translation, but I guess you get it - butter milk is never served hot).

Hence, I wasn't satisfied with software encryption, and wanted to get something -
a.) more robust
b.) more unobstrusive
c.) Better performance (There is nothing called "too fast" 8-) )

God answered - Hardware encryption 8-)

Since I was buying a new laptop, I wanted to see if there are laptops which inherently provide hardware encryption, something built into the system.
The answer is SED - Self encrypting drives, a.k.a (Toshiba HDD) FED : Full Encrypted Disks (Seagate).

In FED's the encryption key exists with the harddrive controller itself and is not exposed to your computer/OS or even you. The key is stored by the controller on the harddrive at a secret location.
Also encryption cannot be disabled on them.
The next logical question that comes to mind is - How in the world do I access my own files if I don't have the encryption key ?!!
Valid question, the crux is, you have to enable a hardrive password.
This password is in the BIOS.

FEDs solved an important concern of mine - A lot of HDD have passwords so you can't boot from them. However, stick the HDD as a secondary on a separate computer, and boom, you have access to all its data.

In the case of FED, if you stick the drive as secondary, all you see is 256 AES encrypted data you cannot read 8-) And if you stick it as primary, you need a harddrive password.

Now, with a thinkpad even before you get to the OS, you have swipe your finger and then enter the HDD password.

This is good enough for the average, non-CIA, non-FBI, non-SPY kind of people, just like you and me.

4.) Which laptops have FEDs ?
I was trying to find laptops with FEDs and again thinkpad came to the rescue.
& Surprise - Although I loved the HP laptops, none of them came with FEDs !!!
Dell has an Inspiron with encryption drives, but thinkpad has a lot more value/money. Plus there is thinkvantage 8-) Someday I'll blog about why my logical brain pushes me to thinkpads.

Another option is to buy an FED from Seagate and put it into your laptop. Here is the issue with that or what I've learnt from the Seagate forum. If you buy and configure an FED by yourself, the harddrive is married to your motherboard. In the sense, you cannot take that drive and stick in another laptop. With a thinkpad you can do it.

5.) Lets catch a thief
Think like a thief to catch a thief. If that is difficult 8-) just buy Lojack.
Lojack is a software which can help you track a lost/stolen computer.
Does my new laptop have Lojack ? Ya betcha 8-)

So my friends, if you have your faithful laptop with you, atleast get truecrypt on it and Lojack it 8-)

Follow me on twitter @nikhilkodilkar

Tuesday, April 27, 2010

Solaris, AIX : Braindump ~ tips/tricks

Note: These are braindumps !
While learning any topic I make notes, at first they are very basic and progressively they get advanced.
Don't expect super wisdom ("Gyan") out of these.
As I said just braindumps 8-)
If you have some tips you'd like to share, post in comments and I'll include them here for everybodys benefit.
System Administration
Solaris - Get a core dump of a process gcore, more details here.
AIX - Get a core dump of a process gencore, more details here.
AIX - netstat - excellent IBM documentation here.
AIX - Instead of" ps -ef" I use "ps uaxwwww" to see all the processes running on the server. This is great for finding child processes in hung state.
Solaris - use the bsd ps - /usr/ucb/ps -auxwwww to see all the processes running on the server
Solaris - Set environment variables for all users - /etc/profile
Bash and ksh reads /etc/profile first of all if invoked as a login shell, tcsh and csh reads /etc/.cshrc and /etc/.login .

See the man page of respective shell.

However, these files are only read once, when you login to a system, so if you modify either of them you have to re-login or start a new shell on the system as they are not read dynamically. However you can force a re-read of the files, in bash this would be done with a dot:
.
/etc/profile

and in csh/tcsh by the 'source' command:
source /etc/.cshrc

Solaris - Space taken by various directories under current one : du -skh *


jQuery : braindump ~ tips/tricks

Note: These are braindumps !

While learning any topic I make notes, at first they are very basic and progressively they get advanced.

Don't expect super wisdom ("Gyan") out of these.
As I said just braindumps 8-)

If you have some tips you'd like to share, post in comments and I'll include them here for everybodys benefit.

jQuery

Enable/Disable a checkbox

var t = "#show_1234" + crFarmID;

$(t).attr("disabled", false); // Enable the show/hide button again

$(t).attr("disabled", true); // Disable the show/hide button again

Check/Uncheck checkboxes

t = "#myCheckBoxID";

$(t).attr('checked', false); // uncheck the "edit" checkbox

Change Background color of a DIV

showDiv = "#IDOfDIVToChangeColor"; // Color the showhide DIV again

$(showDiv).css('background-color', crColor);

Click an Element

var t = "#IWantToClickThisDIVID";

$(t).trigger("click");

Floating message box

Great one from Roshan - http://roshanbh.com.np/2008/07/top-floating-message-box-using-jquery.html

After the message is shown, I actually blink it to grab a bit of the users attention, by doing so -

$("#message_box").fadeOut(450).fadeIn(350);

450 & 350 time gaps make it subtle.

Change transparency of a DIV

$("#MY_DIV_ID").css({ "opacity" : 0.95 });

Change HREF in an anchor

$("#MY_DIV_ID").attr("href", "www.google.com/");


Select all DIVs with an ID like x. The below example, selects all DIVs with name lineItem, e.g. lineItem-1, lineItem-2, etc.
$('div[id*=lineItem]').css('border','3px dotted green');

dJango : Braindump ~ tips/tricks

Note: These are braindumps !

While learning any topic I make notes, at first they are very basic and progressively they get advanced.

Don't expect super wisdom ("Gyan") out of these.
As I said just braindumps 8-)

If you have some tips you'd like to share, post in comments and I'll include them here for everybodys benefit.

dJango


Altering tables in dJango

Everything changes (eventually). Once you code is stable, there comes a point when you need to add a feature which requires change in DB. For dJango/MySQL this is the process you should follow. Link - http://www.djangobook.com/en/1.0/chapter05/


Sending emails

http://docs.djangoproject.com/en/1.1/topics/email/


Selecting only a few columns

Many times you don't need to select all the columns/fields, in that case use the defer keyword -

Entry.objects.defer("lede", "body")

Which will select everything but "lede" & "body".



Per/Shell Scripting : Braindump ~ tips/tricks

Note: These are braindumps !

While learning any topic I make notes, at first they are very basic and progressively they get advanced.

Don't expect super wisdom ("Gyan") out of these.
As I said just braindumps 8-)

If you have some tips you'd like to share, post in comments and I'll include them here for everybody's benefit.


Perl/Shell Scripting

Get yesterdays date via perl

ret=`perl -e '$d = time(); $d-=86400; @f = localtime($d); printf "%04d%02d%02d\n", $f[5]+1900, $f[4]+1, $f[3];'`

echo "Date from perl is : $ret"

Simple String concatenation example in perl -

String concatenation in ksh

m1='xx'

m2='YY'

combined="$m1$m2"

length of string

length($line)

Good link for perl - Clear & concise perl

Get todays date & current time
$time_v = time;
($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isd) = localtime($time_v);
($day, $month, $year) = (localtime)[3,4,5];

Check if the line is not a comment & is not 0 length
if( (!($line =~ m/^#/)) && (length($line) > 10) )

Split line with delimeter ":"
@cArr = split(/:/, $line);

Passing variables between shell scripts (ksh) & Perl

# typeset -x MY_VARIABLE="SomeValue"

# perl -e 'print $ENV{"MY_VARIABLE"}'

As seen here - http://www.unix.com/shell-programming-scripting/44882-passing-value-shell-perl.html

More info. about typeset - http://www.docs.hp.com/en/B2355-90046/ch23s06.html

perl date time object info.

http://datetime.perl.org/index.cgi?FAQBasicUsage

SED - sed one liners that'll save your life 8-) - Link

Mysql Braindump = Tips & Tricks !

Note: These are braindumps !
While learning any topic I make notes, at first they are very basic and progressively they get advanced.
Don't expect super wisdom ("Gyan") out of these.
As I said just braindumps 8-)

If you have some tips you'd like to share, post in comments and I'll include them here for everybodys benefit.




MySQL
See all tables - "show tables;"
Configuring mysql for the first time after installation - The documentation from mysql is pretty good. I've just followed them, and have shown what the output of those commands are, just to satiate any paranoid developers like me 9-)

Remove unique constraint on MySql Table
This post describes how to do it, copied from there -
alter table TABLE_NAME drop index COLUMN_NAME;

Backup your MySQL database
mysqldump -u root -p DatabaseName > backuped_up_DB_DATE.sql
This will prompt you for your password.
The above is for the complete backup, including recreate statements & data.
Other variations are in the link.
Convert string to Date select column_name
from table
where date_column > str_to_date('31-jan-2010', "%d-%b-%Y")
and date_column< str_to_date('10-feb-2010', "%d-%b-%Y"); Drivers/connectors for Mysql for various platforms

Execute queries via mysql command prompt -
mysql db_name < text_file


Running mysql on Solaris for the first time
All commands are from the mysql installation directory.
default for Solaris is /opt/mysql
1.) Run the mysql_install_db command to create the basic grant tables
./mysql_install_db --user=mysql --basedir=/opt/mysql/mysql --datadir=/opt//mysql/datadir --log-error=/opt//mysql/logs/mysql_install_db_log_file.txt
Output
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/mysql/mysql/bin/mysqladmin -u root password 'new-password'
/opt/mysql/mysql/bin/mysqladmin -u root -h password 'new-password'
Alternatively you can run:
/opt/mysql/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt/mysql/mysql ; /opt/mysql/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/mysql/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /opt/mysql/mysql/scripts/mysqlbug script!
The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/
2.) Start the mysql database now
mysqld_safe --user=mysql --basedir=/opt/mysql/mysql --datadir=/opt//mysql/datadir --log-error=/opt//mysql/logs/mysql_error_file.txt
Output on screen
100209 14:31:21 mysqld_safe Logging to '/opt//mysql/logs/mysql_error_file.txt'.
100209 14:31:21 mysqld_safe Starting mysqld daemon with databases from /opt//mysql/datadir
Output in the log file (log-error)
100209 14:31:21 mysqld_safe Starting mysqld daemon with databases from /opt//mysql/datadir
100209 14:31:21 [Note] Plugin 'FEDERATED' is disabled.
100209 14:31:21 InnoDB: Started; log sequence number 0 44233
100209 14:31:21 [Note] Event Scheduler: Loaded 0 events
100209 14:31:21 [Note] /opt/mysql/mysql/bin/mysqld: ready for connections.
Version: '5.1.42' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server (GPL)
3.) Shut it down from another prompt now
Shutdowm mysql deamon
mysqladmin -u root shutdown
Output in the log file (log-error)
100209 14:35:23 [Note] /opt/mysql/mysql/bin/mysqld: Normal shutdown
100209 14:35:23 [Note] Event Scheduler: Purging the queue. 0 events
100209 14:35:23 InnoDB: Starting shutdown...
100209 14:35:24 InnoDB: Shutdown completed; log sequence number 0 44233
100209 14:35:24 [Note] /opt/mysql/mysql/bin/mysqld: Shutdown complete
100209 14:35:24 mysqld_safe mysqld from pid file /opt//mysql/datadir/.pid ended
4.) Start again, this time with nohup so it can run in the background.
This is the actual command to start MySQL deamon
nohup mysqld_safe --user=mysql --basedir=/opt/mysql/mysql --datadir=/opt//mysql/datadir --log-error=/opt//mysql/logs/mysql_error_file.txt &
Output in the log file (log-error)
100209 14:38:00 mysqld_safe Starting mysqld daemon with databases from /opt//mysql/datadir
100209 14:38:00 [Note] Plugin 'FEDERATED' is disabled.
100209 14:38:00 InnoDB: Started; log sequence number 0 44233
100209 14:38:00 [Note] Event Scheduler: Loaded 0 events
100209 14:38:00 [Note] /opt/mysql/mysql/bin/mysqld: ready for connections.
Version: '5.1.42' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server (GPL)
5.) Change the password of the mysql root user
/opt/mysql/mysql/bin/mysqladmin -u root password ''
6.) Secure the mysql database, by running this command and remove/disble all unsecure options
/opt/mysql/mysql/bin/mysql_secure_installation
The questions asked are -
Change the root password? [Y/n]
Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n] Y <-- Select yes for this whether this is dev OR production
Remove test database and access to it? [Y/n]
Output you will see on the screen towards the end when everything needs to be saved
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
7.) Convert timezone in SQL query
Use this function, where "last_update_date" is the column name.
Below the timezone is being converted from UTC to EST.
convert_tz(last_update_date, '+00:00','-05:00')

8.) Sysdate equivalent in MySQL

Want to get records 5 days back ?
In oracle that sysdate-5 or sysdate-10 came so handy.
In MySQL, you can do date arithmetic by functions DATE_ADD & DATE_SUB.
Yes, as you would've guessed, DATE_SUB would subtract a certain amount.
Here is an example :

SELECT DATE_SUB(NOW(), INTERVAL 5 day);


The DATE_SUB takes the time you want to act on (NOW() gives the current date/time) and INTERVAL 5 day is giving the amount of time it wants to subtract from it.


http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add

9.) Auto increment your integer column
When you want one of the columns to auto increment :

ALTER TABLE your_table

MODIFY some_column INT NOT NULL AUTO_INCREMENT;