do you postfix?

Recently I was engaged on setting up mail client on the new redhat (rhel6) server for one of my clients. The server was on its default setup of sendmail. Since it is a bit outdated, I decided to use postfix relaying on gmail SMTP.

First thing first, make sure sendmail is not running by running this command

sudo service sendmail stop

Make sure if there are any lingering processes out there by issuing proper process listing commands on your server and kill those if you have to

Then check if you have postfix installed your machine

sudo service postfix start

If you got any complaint like service not found or something along that line, just install the postfix

sudo yum install postfix

Ok now lets go to the juicy part of integrating the postfix with gmail SMTP.
Lets assume your username is gopostfixgo@gmail.com and password is #nomoresendmail

Now lets proceed to the configuration part of the postfix.
go to postfix config folder

cd /etc/postfix

Here you will see a couple of files. Our interest would be on the main.cf file
First, before you start messing with the file, create a copy of it

sudo cp mail.cp main.cp.bak

Just go to the end of file and add the following snippet in there

smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/pki/tls/certs/self.pem
relayhost = [smtp.gmail.com]:587    

That last line right there would tell the postfix it has to relay the SMTP to other server.

Now lets create the sasl_passwd file

sudo touch sasl_passwd
echo "[smtp.gmail.com]:587 gopostfixgo@gmail.com:#nomoresendmail" > sasl_passwd

The above command would add the content to the sasl_passwd file.

Then to obscure the password information you placed on in the sasl_passwd file,

sudo postmap /etc/postfix/sasl_passwd

The other point would be creating a self certificate you would be using for your secure communication. If you have a certificate you are using already, then just point it to the right place and you should be fine

cd /etc/pki/tls/certs/
make self.pem

The above command would give you interactive wizard that you will follow and create the certificate.

After this, you need to tell the postfix to pick the changes you have been ramming. For that just restart postfix

sudo service postfix restart

Then open your logger to see if there are anything that are suspicious going or if mail is not working, you can tail it as

tail /var/log/maillog

Common Errors
1. Google might be sending some kind of error saying you have to log into the web browser bla bla bla.. then do the following
Go to https://www.google.com/settings/security/lesssecureapps and login with your google account and turn it on

Working From Home? Here are some tips for ya

As it sounds nice, unless you follow some guidelines, working from home can be quite boring and unpleasing, been there :).. here are some tips I will share with you to be as effective as possible

You and Your House – Nothing Technical

#1 – Hygiene – Looks trivial ha? Working from, unfortunately, is highly associated with working in pajamas which is mostly correct. Think about it and you can’t find any other thing filthier than that, you are working with what you wore the whole night ugh.. Guess what comes along with that – you might not take shower too.
So the fix, make sure that is your priority, dart into your shower before hitting your desk. Brush your teeth, wear your deodorants.. basically do what you would have done if you were to fly to your office. This has a very refreshing effect on you especially on the morning.

#2 – Dress Nice – yeah mostly if you have done tip #1, this would come natural. Just wear something other than your pajama. Also, use this opportunity to wear what you want, shorts, flipflops, hoodies.. you are not supposed to follow dress code here – just dress nice.
This has a good effect on you especially when you want to go out – you are just ready and you won’t have excuse not to go out and get fresh air :)

#3 – Clean your Surrounding – This would apply if you are single mostly. It would come easy to toss papers and pizza boxes here and there, not to clean your kitchen and bathroom, not to fix your bed and not to let fresh air to your room. This would be a simple reason to hate your room. It is difficult to keep up with it as I have trouble to do that, but if you make it habit, then the flip side would be impossible in return.

#4 – Make sure You Are Well Fed – One thing I noticed working from home is how easy it is to miss lunch and breakfasts most of the time. I think I was OK when I was working in the office as there would be others reminding for lunch or to a short trip to the near by corner store. I don’t have to explain why you should not be hungry – you will easily be angry and angry programmer is the one you don’t want to be.
The fix – make sure you have snacks, fruits, candies, string cheese, yogurt or something that can be consumed immediately in your house, some protein bars are good too. They might not be healthy in most cases, but be selective and store them. Have your stack of water and beverages at hand as well.
But, the biggest thing would be to be able to cook. One thing, it would help you for break, and second you feel great that you are eating what prepared which is healthier and cheaper.

#4 – Exercise – Yup, it is like blinking of an eye when 10-12 hours of your day flies by before your eyes. The more you do that, the more your body would get used to it and hence less metabolism and high carbs would be your immediate friends. You definitely don’t want that.
the fix – Have smaller dumbbells at your house it could range from 6-50lb and make sure you play with them every 2 hours or so, you can set your mobile alarm or one of those gadgets which would help you remind that you should get up and do some exercise. Pushups, pullups, situps, stretches, head to knees, joggings, boxings.. there are numerous of those you can do in your house – just make sure you know your limit and you do it drop at a time. If you over do it, since you know where the bed is..

#5 – Have Natural Light – In the morning, open your blinds and let the light fill your room. It is natural and energetic than the lamp hanging on your roof. Also, let the air visit your surrounding as well.

#6 – Get Office Chair and Desk – You might be tempted to work from bed. nahh.. Avoid that for a lot of reasons. The first, you are breaking tip #1, as you might still be in your pajamas if you work from bed :), two it not healthy for your back as you might be curling yourself, third, you are way near for sleeping and productivity might not look good.
The fix – Get office chair and desk. There are a lot of Ergonomic chairs out there that are meant to be helpful for longer hours of working, the desk too..

#7 – Reminder for taking break – If you were in the office, there are quite successive breaks you would take without your conscious. A co-worker might be sharing a story what she and her husband run into when they were dining in the neighborhood, a fellow programmer requesting for review or help, breaking news on the TV, funny links being passed around on the communication tools and the like.. all those are effective ways of staying alert and taking a break. You won’t get those when you are in your own dungeons – so do that reminder on your one-of-many gadgets you sport.
But, make sure you know your limit as well, it is easy to get carried away on youtube or huffingtonpost..

#8 – Limit Your Communication – It would come handy talking to phone and responding to texts when you work from home. But somehow people would respond or call per your rate of communication. Though it is good to communicate, you should also tell yourself that you are at “work” and all the ethics and discipline would 100% apply here too. So, be cautious about it and setback.

#9 – Hangout Online With Coworkers – You work from home and so does others, they are your co-workers. So you can still hangout with them and chitchat a bit on work related or completely non-work related stuff. That would make it more natural – you are sharing thoughts or concerns and what nots with co-worker. This is even more effective way to learn about the work itself and about your virtual friends. Still business as usual, you are working with/for them and communication with them shall not and will not deter the professionalism you have.

#10 – Music – There are quite number of researches out there on how music would affect the ability of concentration while programming. For me, it is working fine, I can put on my headphone and just work fine – probably this is something I picked from my co-workers. I am just mentioning it – this is absolutely personal color choice. The good thing is working from home serves both choices equally.. if you like woking in a silent or in music, the actions to be taken are entirely in your hands.

#11 – Work outside 2 Days a Week – I have worked from Starbucks, public libraries, college libraries[this has some limitation], hotel lobbies, restaurants and literally anywhere I see that wifi logo.. but I have to admit Starbucks is the number one. It is great to work outside of your home for the sake of change. It provides the best of two worlds – you are alone and you are with peoples as well – what a goodie! Just make sure the rules of the places, some places like Panera Bread would allow you to work for 30 mins only during their busy hours, others like college libraries might not allow you to tunnel, and others have cap on bandwidth usage. Worst case, you can tether from your phone and work till you make it to your home. But, going out and working from those areas would make you feel active outgoing

#12 Have Something To Play With Yoyo is the best one in this category. Just have yoyo, some, rubik’s cube, small robots and the like that you would invest maybe 5 minutes when your brain is tied up with solving a problem and/or trying to come up with better algorithm for the problem you are facing.. again..

Next time I will share a thought on You and Tech – on how to stay sharp and upto the technology, tools to help that, news and selected articles sites..

Let me get back …

:insert not working for pasting on Vim editor

I will not explain how useful vim is, if you a developer on the *nix systems, then that is number one tool to tuck into your toolbox.

Now you want to paste huge text into vim and it looks all wacky, and the insert mode is not handling it.. here is what you would do..

Open your vim with

vi filename.ext

then do

:set paste

This will allow your vim to be in the paste mode and you can dump all you have without any problem then change the mode using esc and save it as :w

Access MySQL from Host being on Vagrant

For this all you would need is tunneling/port forwarding from vagrant to mysql.

Being on vagrant machine, figure out what the host ip is, usually netstat would tell you that.
The default being 10.0.2.2 and assuming you have 3306 port on host machine do the following

ssh username@10.0.2.2 -L 3306:127.0.0.1:3306 -N

The above would forward the 3306 [ the one on the left ] to the hosts port. Mind you, you have to use 127.0.0.1 to access your vagrant machine in place of localhost which might not work.

how to get into programming part 2

Part 1 was on generic stuff that I have little idea on. But on programming and being a programmer, I can say a bit as I am living as a programmer.

Getting into programming
Lets start from simple questions first:
What do I need to be a programmer
A college diploma or degree would be good to be a programmer – but IT IS NOT MANDATORY. I have worked with great great programmers who have just a high school diploma, who have totally unrelated degree and who were working stuffs that in no way related to computers for that matter.
****But, if you have the chance to go to school and learn about programming/computers – it would make life easier and it would definitely create a difference. By yourself, you need a lot of experience to understand the basic things, with class it is so easy. By yourself you be a bad programmer for a while before you know it is bad, with class you will be guided with the best practices and become a good computer citizen right away – so if there is a chance of going to school never turn it down..

So what do you need?
A computer, a good book/website about programming and passion to program.

Where shall I begin?
In programming itself, there other branches as well: you can work on desktop applications, mobile applications and web applications.
I would advise to concentrate on web and mobile applications these days.

I will greatly discuss the web part.
The first thing on my list of advice is do something and see something..
The webpage you are interacting today for different kinds of tasks, be it facebook, google, yahoo, you online banking and the like – they are all web applications. Your goal would be to be one of those peoples who created such a good applications that make our life easier from day today.
Speaking of web applications, there are different kinds of tools that would allow us to create the websites: here are the major ones
1. The basic HTML part we discussed on the designer section of part 1
2. Good understanding of server-client architecture. All we need to know is a major part of this only
3. Fair Database knowledge – don’t worry, you will learn it as requirement when you get started to work on your web stuff
4. At least one web programming language. The HTML we discussed is only for look and data bridge part – there is another main part behind every website.
For example, when you log into facebook, facebook would know you right? it will pull if there are any new messages you have, who liked you? who has friend requested you and the like. All this has to be done somewhere. Based on your username, facebook gurus should provide you with messages that are sent to you only without sharing to the others… and even more tasks. I was talking about this task.
The above task is generally known as back-end development. It could be done using different programming languages – notable ones are PHP, Ruby, ASP.Net, Java and more and more.
So, you need to know at least one of these languages to work as a back-end developer. It looks a lot right? Again it is NOT

umm.. which one shall I study/read first
Here is the fun part. We are going to do it step by step. There are a lot of things we have to know,but we dont have to know all of them before we need them right?
Here is what we do in the order of importance..

1. Lets create simple website..
Oops.. I don’t know anything.. how could create that?
That is what we are going to do. At this level we will see how simple it is to create a very simple one
Open any text editor like notepad, How to open notepad and insert

<html>
<head>
<title>my first webpage</title>
</head>
<body>
Here is my first webpage
</body>
</html>

Then save it as my_first_web.html
After this doubleclick on it and you will see your very first webpage.
Then go back to HTML Introduction and invest a good amount of time by changing font, color, bar and the like until you can do it without further reference..the site has online editor also so you can test it online.

Afte that I would say invest a little bit of time on any programming language before you dive into the web programming.
C++ is a good candidate for it..
Intro to programming Actually, check this guy’s videos they are a good start points..

The following links are also helpful ones
http://cplus.about.com/od/introductiontoprogramming/a/career.htm
http://lifehacker.com/5401954/programmer-101-teach-yourself-how-to-code

I will try to write on Web programming next time – especially on PHP
Please post your questions/comments and I will try to answer accordingly.

How to get into programming part 1

I have been asked a lot of times, especially from fellow Ethiopians, on how to get into programming as a career or stream of life style..
But this note is not only for those who are asking that, it is for:
– those peoples with a lot of potential into programming and not just do it only because they don’t have enough information where to begin
– Friends, and relatives whom I see are in some other work stream but I think they are a good candidates for programming and make a decent living out of it..

First thing first, lets start from addressing common questions:
How could I get into computer profession?
It is a broad question and I will try to dissect into the following parts

1. Computer Technician
Are you interested in getting dirty hands with fixing computers, mobile devices, network configurations, fixing broken hardwares and the like? if so you can be on this area and be professional
What you need – usually you are required to have certificate in electronics and/or maintenance stuff along with a bit of experience.
MarketIn demand
2. Network Administarator
Large enterprises with so many, not limited to, computers and users that needs management require Network administrators.
Largely, this is a task where you would configure servers that run different kind of services like web or file, management of user access and resource access, management of computer’s resources that task out the above and related services, making sure server softwares are upto-date are among the tasks you will be working on
What you need You need certification for this one. The common one is cisco certification. There are tones and tones of books and training material that would help you get up and ready for the exam.. you can take a look at http://www.cisco.com/web/learning/certifications/index.html
MarketIn demand
3. Database Administrator (DBA)
Every interaction with have Facebook, the emails records we have on gmail, or any other interaction that needs to remember our data needs a database. A database is a huge part of computer related profession. The data that is stored could be in millions, each data would interact with another data, it will be backedup incase something wrong happens, it needs to be consistent and available, it should be upto-date, it shall handle insertion editing and deletion of data nicely .. you got the idea – for this there are well trained peoples who would make sure the data that we care for is properly handled. You can be one of those peoples
What you needThere are several brands of database management systems. The notables are oracle, MSSQL Server, MySQL and Postgres. You need a certification in at least one of these big database providers. Once you got the idea of one jumping to the other should be easy. And the good thing is when you are preparing for the certification you would know most of the basic stuff you would need for future profession
MarketIn demand

4. Designer (Front end developer) These days all you would see is a websites and mobile application. And apart from doing what they do, they have to be attractive and simple, easy to use, faster, forgiving on error and much more. This is usually the task of the designer.
Designer are usually artful peoples. If you are that kind of person, then design might be yours. Probably, you have come across the site or app that you tot you could have done the layout better or something..
What you needMost of the designers that I know are self-taught ones. Pretty much all you need an introductory lesson into HTML, CSS and Javascript. You need to have a good image processing software like adobe photoshop or something that can process images nicely. For that matter, there are well talented peoples that can make a good image from simple image processing softwares like MS-Paint.
Another thing would be to look as many website and apps as possible. This will give you a best approach to have your own signature that singles you out. Like a writer reads more before s/he writes kinda thing :)
The other good thing is, you can start to design just today. You have already what it needs to be the designer. A simple notepad and a web browser. There is a good step by step guide on HTML Introduction. Once you are done with it, you will be a good designer or front end developer

5. Developer/Programmer

Points on Oracle MySQL Associate Certification Exam

Certification is one way to keep on top of your expertise. It would help you to communicate easily, meet expectations. When you take certification, it is entirely for your own. No one, specially these days, will take certifications for granted. Still you will go thru a number of interviews and code challenges to show who you are. But, when there are times that all of us are the same colored potato, certification will rescue us by making us a bit bolder than the others.
Also, take the challenge. If you are working on some technology and you think you are expert on it, proof it thru certification.

I took the exam yesterday and it was cool. It was not that difficult to tell the truth. Here are some of my points that would help you if you are thinking to take that exam.

1. Are you a developer who is working on mysql as a backend and have done a number of selects, joins, where statements, group by and havings? How about querty statements like create table, alter table, add index and show databases/table..? If the answer for this questions is ‘Yes’ – congrats my friend, almost you have answered a bit more than half the questions on the exam already.
The exam’s most portion is on DML and DDL. If you have a good hands on those query types all you have to do is to get the grip on the principles behind those. Actually this will help you in general not for the exam only
Like, what are basic blocks of select statements, when do you use indexes, group bys and havings, how are the results of the query be affected? When to use Order by and limit. Practice with a number of queries with real tables..

2. Get this book – MySQL-5-0-Certification-Study-Guide. You will need only this book indeed. Read the part for the developer PartI and read on views, import and export and you will be pretty much set.
Guess what, this book is the same book you will need when you take the MySQL Developer exam I and II, which I am planning to take in the coming couple of weeks.

3. Do the exercises from the book’s CD. it has a concise exercises for each chapter and they are the best. Make sure you cover those before jumping to the exam.

4. Give it at least two weeks. It might depend on how you are prepared, but the more prepared the more walk in the park it would be.

5. Apply the general test rules :) – take a good rest before you sit for the exam, eat appropriately [dont be hungry and don’t be too loaded as well], make sure you visit the bathroom first 😉

*For me applying all those points appropriately, I was able to finish the exam way ahead of the allotted time, and score 94% – which shows those guidelines are good to follow.