How to install Python’s Virtualenv

Since I made a post about how to install pip, I will show you have to take advantage of it about using a Virtual Environment. The Virtual Environment serves for the purpose of making a project while not changing anything in your system. You can use different versions of Python or packages by using virtualenv.

To install it we will use the command:

pip install virtualenv

To make use of virtualenv:

virtualenv venv

(this last is the name of your virtual environment, you can choose any name)

To activate:

source venv/bin/activate

or

. venv/bin/activate

To deactivate:

Yes you got it!

deactivate

If you installed pip with python2 and want to create a virtual environment to work with python3 you’ll have to use the following command:

virtualenv -p python3.x

If virtualenv was installed with Python3:

virtualenv -p python2.x

And there you have it! A configured Virtual Environment.

My first programming interview

First of all I finished after work the Ruby Koans, it was an awesome experience and made me understand much more about testing. It happened so fast that I felt sad for being so short but at the same time felt an inner feeling that I have accomplished something good. Rails Tutorial is next (for a second time).

My first interview. Oh when I received a phone call from a recruiter scheduling an interview for a Python position I was in complete awe! I remembered her saying: “next Tuesday at 4:30PM”. I was like: “Yes! Sure! “The following week I studied Python as a voracious bear that hunts his prey, mastered my skills and was prepared. When I went to the subway and read the confirmation email, saw that it was changed to 4PM, and the time was 3:55PM. I rushed to call the recruiter but she didn’t answer at first, the while on the train called again and got in touch with her.
I arrived late and had to wait an excruciating 20 minutes! Finally comes the girl that was going to interview me. She asked me a few pseudo technical questions which I got right and then asked me if I had completed my college education which I said no, and then she said that I wasn’t suitable for the job because of that. No tests whatsoever, then the entire interview questions were about Ruby and soon I realized that she had 0 knowledge about programming. She didn’t know that Ruby was an Object Oriented Language and that Ruby is not Ruby on Rails the later is a framework and the former is the language.
I was really pissed off and lost an opportunity (a story for a later post). It can be seen that the interviewer haven’t read my resume and also does not have respect for other people’s time.

After all life goes on and I grew from this experience and attacked coding with more power. There will be other interviews and the job that I want will come true. With hard work, habit and will-power, great things happen.

Ruby Koans Dice Project

I finish my day with this project in the amazing Ruby Koans learning method, and had completed 216/282! Got to see the Ruby documentation and feels like I am getting more into the syntax.
Here is the code I made in the about_dice_project.rb:

# Implement a DiceSet Class here:
class DiceSet
  attr_reader :values
  def roll(num)
    @values = []
    (1..num).each { |count| @values << rand(1..6) }
  end
  @values
end

Why I hate C#

It all started when I installed Visual Studio Essentials. Had a few recommendations about learning C# and that it would get me a job easily and fast! Why not give it a shot.
While installing I worked out, went shopping and when arrived the installation was on progress! So I picked my guitar. Yes! Acoustic guitar, not guitar hero… I’m done with games since these are time wasters. Keep away from them if you want to be successful! Go outside with some friends (or alone) and play sports or any other activity you like that releases your stress.
So, after a few hours it finally installed and went to learn it, I really hated it… No visceral reaction whatsoever. It is a very high level language, looked like JAVA, a terrible clone I must say. My hard drive was full of software that I didn’t even know what it did or if was useful. Maybe it is a way or “the way” that Microsoft pushes their products on people as they do in the corporate world. “Open your mouth and take another dose of our new programs. They are buggy and expensive but we promise you that they will work because we force schools and technicians to get certificates in order to have a job and earn more. Oh is it too heavy for you computer? Here, new workstations whether laptops or desktops it will run fast, just until the new release. We are Intel partners and we need to flush out these machines before a new technology 3% faster and triple of the price appears in the market.”
Needless to say that I uninstalled  but a hot load of the software suite that was installed wasn’t removed automatically, and they are tens of them. I guess Windows 10 will be reinstalled since I do not want to remove them one by one. Terrible flaw.

By the way, this blog was created after I received advice from a gentleman named Jonh Sonmez from SimpleProgrammer.com in how to market myself. I think he is doing an amazing job by sharing his experiences and guiding young men in this masculine crisis of today.
Check his youtube channel.

Have an amazing day, afternoon, evening or night.

Install pip on Linux

I have been using Xubuntu 15.10 after passing through Debian, OpenSUSE and Fedora in the past few months. I can say that was pretty impressed by the latter and former. To this day my favorite one is Debian and the reason I installed Xubuntu on my laptop is because it saved me some time configuring it and has less bloatware than Ubuntu which sucks (not sorry).

Pip is the official Python package installer and the one that came with this distribution was quite old for what I wanted to do. Correction! This distribution didn’t have any pip installed so I tried through:

sudo apt-get install python-pip

or

sudo apt-get install python3-pip (if you use python 3.x)

To upgrade it, is through the command as shown:

sudo pip install -U pip

This way went amazingly well with Fedora 23, but not with Xubuntu.
So I went to this website, downloaded the file and ran the command:

sudo python get-pip.py

or

sudo python3 get-pip.py

If a warning message appears worry not. It is normal because when you use sudo you become root and this folder in question is your user’s folder.

And there you have it! The last stable pip release.

In the future I will write a post about using Virtual Environments and the efficacy reached with them using different python versions or even packages.

Ruby Koans Triangle

Yesterday I came to find this exercise pretty interesting, it called back the distant geometry lessons I’ve had in the past.

This was compromised of two separate test files and one which we will code the project named triangle.rb, was accomplished by first passing the test for building a triangle and last to raise the Exceptions or errors.
My answer was the following one:

def triangle(a, b, c)
  if a <= 0 || b <= 0 || c <= 0
    raise TriangleError, "Size must be over 0."
end

  if ((a+b) <= c || ((a+c) <= b) || ((b+c) <= a)
    raise TriangleError, "Illegal triangle!"
  end

# end of error raise

  if (a == b) && (b == c)
    :equilateral
  elsif (a == b) || (a == c) || (b == c)
    :isosceles
  else
    :scalene
  end
end

class TriangleError < StandardError
end

This might not be the most neat and correct Ruby syntax but I’ll get there.

Test Driven Development

In my last post I shared the difficulty of Automated Testing and skipped that exercise, then stumbled across Ruby Koans by Neo, which is a way of learning Ruby syntax through TDD. I began on Friday and continued until today, minus the weekend because it’s almost fully occupied by work. I’m half way on it and has proven me to be a very effective way of learning the language and testing as well. After finishing I will take Michael Hartl’s Rails Tutorial book.

This blog post should have been written last week, so this week I will write two, more technical maybe about Python to remember a few things and also to keep the momentum.

Object Oriented Programming was a lot abstract for me (and still is), I was accustomed with Pascal and C (which I love) but thanks to Ruby it is going away.