This is just a blog to try and spread some of the knowledge that has been freely given to me by the wider community, without which I'd get absolutely nothing accomplished. I hope this benefits some of you out there.

Thursday, July 16, 2009

Programmers Take Note



I recently read a blog entry on Reddit that got me thinking. The gist of it was something like this: take notes of everything you want to know how to do because it will become your most valuable tool.

I truly believe that. They don't have to be fancy or in order, they just have to be there and searchable by using grep. A record of your experience will become invaluable and I have started making notes myself.

Here is a small bash script I wrote to help make making notes easier:

#!/bin/bash
today="note_`eval date +%Y_%m_%d`"
filename="/home/dir/notes/$today"
if [ -z "$1" ]
then
exec vi $filename
else
echo -e "\n\n" >> $filename
`cat $1 >> $filename`
exec vi $filename
fi

This will allow you to either just type "makenote" and start/add to today's note, or "makenote your_script.sh" to append the script to the bottom of your new/current note. From there you can add your comments about the script.

Put a symbolic link to this script, or simply copy it, into your path (probably /usr/bin will do)
and you can use the command makenote from anywhere and the note will go to the right place.

Here is a small example of some of the notes I've made, maybe it'll inspire some of you:

FIND FILE BY NAME

About

The `locate` command will find all files that have the name you
specify. Probably the results will be too much, so pipe it through
as many greps as you need to find what you're looking for.

Example

locate python | grep sqlite | grep transactions


MYSQL SHOW COLUMNS

Example

SHOW COLUMNS FROM mytable FROM mydb;
SHOW COLUMNS FROM mydb.mytable;


FIND ALL PORTS CURRENTLY LISTENING

Run

nestat -an|grep -i listen

Extra

Most port numbers are listed in /etc/services


The only problem with taking notes is that these days we all work on many different machines. Some are at home, others at multiple work stations. How do we keep them all in sync so we don't lose any? Good question. Maybe something with the google docs api to sync our notes across all computers, like a simple command to grab the latest in google docs and then write them back when you're done. If anyone has an idea to solve this problem please let me know!

No comments:

Post a Comment

Followers