Categories
personal

My ideal morning daily routine

morning tea

I’ve been very interested in how successful people (in different areas) have established morning routines. The most common claim is that it frees you from early decision fatigue and structures your day. Some of the morning routines are inspiring.

It has been a struggle for me to achieve a perfect morning routine because I have early meetings with my team in India. My biggest problem is going to bed early the night before to be able to wake up without much struggle at 6:30am the next morning.

This is how my typical uninspiring and stumbling morning routine looks like:

– 8:20 Wake up.
– 8:25 Make tea.
– 8:30 Start conference calls while sipping the tea.
– 11:00 After conference calls, take a quick shower (if this is skipped, then shower time is at 6pm).
– 11:30 Figure out the rest of the day’s activities as they come.

And here’s what my ideal morning routine should look like:

– 6:30am Wake up
– 6:35 Have a cup of tea (typically Monkey picked Oolong tea) in complete silence while I plan my day.
– 6:50 Meditate for 15-20 minutes.
– 7:15 Exercise for 30-40 minutes (elliptical machine or walking outside).
– 7:55 Shower.
– 8:15 Breakfast
– 8:30 Ready to start conference calls.

Achieving this morning routine is important for me because no matter how chaotic or busy the day can get, I’ve already had some time for myself (meditation), done at least some exercise and had the first meal of the day. This gives me a feeling of accomplishment: The day starts and I already have stuff done, even if that stuff is not exactly work related.

Do you have a morning routine? Does it helps you be more focused or productive during the day?

Here are a few videos of people I look up to with morning or daily routines.

Categories
personal

My goldfish companion

IMG_20160206_181829

Today I want to tell you about a goldfish that stayed with me for the last 3 years and recently passed away. This is meaningful to me because that fish was my companion in important stages of my life. Crazy as it might sound, here’s my goldfish story.

I’ve always had a fish tank in my house. Without one, it doesn’t feel like my home. This goldfish came to a then empty tank, along with other smaller fish after I moved to a new house in a new city. I never get too attached to fish, no one does. But this guy won me over quickly.

The fish tank was near my dining table and the goldfish kept me company during all my meals. It was always facing towards the dining table when we were sitting down. The calmness of its swim and the beauty of its long dress-like tail always provided some kind of peace of mind when you watched.

It lived a happy life for 3 years through 2 cities, until I decided to upgrade its tank to one much larger. That’s when the complication began.

I got more fish to add to the larger tank and set up everything. But something went wrong at the new tank. The water quality decreased when I added the new fish, which had bad water from the shop‘s tanks. The first days it seemed okay, but after two days he started to show signs of weakness. I spent two days taking care of it, separated to a quarantine tank with good water quality and all. Researched on possible illnesses, gave it salt baths, etc. Nothing worked.

On its final night, I was looking at it and, for the first time, I gently touched it with my hand. I slowly put my hand below so it could rest in my palm, it looked up to me and gave the last breath. It was heart breaking.

I don’t know if it was a male or female. It didn’t have a name. It was just, there…always there. Now I miss its company.

Fish pets can become more than just a fancy decoration at home. You can get attached to a fish as if it was a dog or a cat, or any other type of pet. They say that goldfish have personalities and this one became a familiar face at home.

That fish witnessed important stages of my life. It saw my bachelor life in Guadalajara. We drove together from Guadalajara to Mexico city. It was the only one who saw me getting out of my house, dressed up as a groom to get married. It was also the first one to greet us home when my girlfriend and I arrived as a married couple for the first time. It witnessed when people broke into my house and stole our things. It saw many moments of me, my home and my newly formed family.

That’s why that goldfish meant a lot to me. A silent companion in my life. It will be forever missed in this family.

IMG_20150213_113832409

Categories
personal

Resolutions for 2016

GST_0134.jpg

It is that time of the year again. Time to review the year that finished and plan for the year ahead. At least this time I’m writing this in the first days of the year instead of the first months like last year. For me, 2015 was a rollercoaster. Started very steady with lots of work and projects, then changed direction completely.

Like in previous years, here’s how my main 5 points from 2015 went:

1. Health
This topic has not progressed in a year at all. This must be something to prioritize.

2. Projects
Last year I started notasbit.com as a WordPress blog to write about tech news. But then I transformed it into an automated news grabber which released me from having to write the news themselves to prepare for the radio show which I still have going on. That project is one of my favorites, as it needs very little maintenance and brings me a lot of entertainment. Is the project I’ve done that I use the most. Then I have a project with my cousin to help him in his tourism agency that has been going on for 6 months now but in very slow progress. It’s been an learning experience for me working with his team and developing it on my own. Also there’s another project I’m working on for a head hunter agency which I’m very interested in finishing for publication.

3. Photography
I had no big plans for this area of my life for 2015 other than having some lenses. Well, one of my biggest dreams of having a Nikon 70-200mm 2.8 has become a reality. I’ve been wanting that lens for a while to improve the photos I take in low light in the theaters at the ballet. Another big change happened after the robbery incident. As I mentioned in my blog post then, I took that bad situation where they stole my camera body as an opportunity to improve my gear. So I finally made the jump from a half-frame body to a full frame. Now with the Nikon D750 and the zoom lens, the quality I get in low light is something I struggled for with my previous gear. My main machine is now a Macbook Pro, so I’m now fully editing my RAW files in Lightroom. I also started to get more into video this year with several videos published in my Youtube channel.

4. Travel
We never got to go to Cuba, but we did travel to several places in the country and visit friends which was nice.
5. Writing and reading
I missed on the 6 books in the year, I only got two read. And on the writing, well, this blog was almost forgotten. Only 5 posts in all year! Then notasbit blog got changed into an automated system, so no writing there either. I think I used that time to do more projects this year instead.

To remember 2015 here are some of the images captured in the year:

Fish in bags

GST_3781.jpg

GST_3868.jpg

GST_4054.jpg

GST_4183

Sala Covarrubias

GST_4656

GST_4860

GST_4952

GST_5192

GST_5623

GST_5825

GST_5813

GST_6265

GST_6300

GST_6336

Hotel Quinta Real Villahermosa

Hand made chocolate

GST_6819

GST_6992

GST_8298

GST_0008.jpg

GST_0024.jpg

GST_0047.jpg

GST_0091.jpg

GST_0115.jpg

GST_0153.jpg

GST_0225.jpg

GST_0294.jpg

GST_0339.jpg

GST_0406.jpg

So far, this 2016 doesn’t seem to have much surprises or any ups and downs. On 2015 I’ve focused a lot on searching ways to diversify my income and came up with some plans. I think that this 2016 will be about executing those plans more thoroughly.

Health

I keep promising myself to do more about my health with the tendency of not reaching my goals. I won’t stop promising myself healthier life and even though I don’t reach my goals, attempting it never hurts. I’m curious about starting to run. I’ve heard a lot of people getting addicted to it and almost being as annoying as a cross-fit nut. I’ve never tried running as an activity and don’t know where or how to start but I’ll try it. My current body fat is 29%, worse than last year’s post. I need to lower that a lot.

Projects

This is an area where I have a lot of things going on at the same time. I’m worried that because of the high load I won’t be able to manage and complete anything. My mum suggested to have an agenda and set aside time for each project in my day. It is a good idea, since most weeks go by and because of work I forget to put some time for my projects. I want to continue and finish up all projects started last year. I don’t plan on starting new ones anytime soon but a lot of things can happen in a year.

Media

This time I switched the word “photography” to “media” because I’ve been experimenting with video too. I’ve been following several vloggers and I’m very curious to explore that. Editing is not an easy task and very time consuming, but daily vlogs are the best way to practice to perfection. I won’t commit to do vlogging yet but it’s a very strong idea I’ve been thinking about for several months. In photography, I really want to make some money out of it. I’m trying stock photography websites with very little results. Paid jobs would be nice but I still lack the confidence. Maybe that’s what I should work on this year: confidence. And in that topic of confidence, I’d like to grow my Instagram account. I’m trying to post more frequently and maybe a 365 project will help grow my account faster. One post a day. Currently I have 390 followers.

Travel

Cuba is still in the plans for this year. We’ll start the savings planning early in the year so it can happen. Besides that, there’s not much planned so far for the year’s traveling. I guess less travel times means more time to focus on work and projects.

I hope 2016 will be a year of steady grow in several areas in my life, preparing for a more exciting 2017. But, many things happen in a year, who knows if this year will be as calm and steady as I see it in these early days of the year.

Categories
Events personal

Trip to Villahermosa, Tabasco

Hotel Quinta Real Villahermosa

We’re almost done with the year and I realized there’s much to post in this blog. Back in July we went to Villahermosa, Tabasco for the wedding of a friend. It was my first time there so I didn’t know what to expect. Very soon into my trip I found out that they have very interesting food and recipes. We went to a traditional Villahermosa cuisine restaurant to try it out.

GST_6406

No, this is not the traditional restaurant, that was a quick stop because we were running late.

Okay back to my story. The pejelagarto is a very popular dish around there. They prepare it in several ways: grilled, stuffed, in fillet, etc. In my case, I got to try it in empanadas. To me it tasted like crab (yes, with a B not a P).

GST_6414

GST_6421

GST_6426

After the wedding, we went to a cacao farm where they give tours to show how chocolate is made. I was expecting to see a big factory and large farming lands, but it was a lot simpler. The farming land looks like a small jungle in the middle of the town, which grew around the perimeter of the old cacao fields. The place feels like a real jungle with the humidity, the plants everywhere covering the sun and the sounds of birds and other animals. The tour guide told us they have a section where monkeys live. This was their habitat before the town came into the jungle, so they are trying to preserve them there. We couldn’t spot any of them but sometimes you could hear them in the distance.

GST_6430

Guacamayas

GST_6428

We saw several types of trees that I’ve only read about in books. The rubber tree which produces a resin that native Mexican tribes used to create shoes and the first balls to play games. A cinnamon tree, which I never stopped to think how cinnamon is obtained. The tree is small and you can peel a part of it’s trunk or branches and that’s the cinnamon sticks. Then a gum tree used by Mexicans for centuries for chewing gum before Thomas Adams created the chewing gum industry world wide.

Rubber tree | Arbol de hule

Cacao plant

We also got to try freshly done hand-made chocolate. They demonstrated the traditional process of making chocolate from the cacao seeds. I participated adding the spices and trying the resulting mix. Then they explained how that process is now translated into industrial processes and how most milk chocolate has barely any of the outstanding health benefits of the cacao (also, white chocolate is just fat, no benefits at all).

Hand made chocolate

GST_6448

It’s been a bad year for my writing but I started experimenting with video recording and editing. So I’ll be posting some of my video experiments using mainly a GoPro Hero 3+ Silver. I hope you enjoy this first one about this trip.

Categories
GNU/Linux Free Software & Open Source Programming & Web Development

My Python & Django deployment workflow and tools

Yellow python

If you’re new to Python web development with Django, there are some things that tutorials don’t teach. Deploying to a server when you finish your local development can be a frustrating task. Here is a rundown of the tools and workflow I use for deploying a Django based website.

A few days ago when I launched the new version of Notasbit.com, I ended up having a discussion with a friend about deployment methods for Ruby on Rails and Django websites. My friend is used to Rails development and deployment, something I am not familiar with since Rails 1.8 (looong time ago by now) and he insisted that Ruby Gems method is way easier while Python deployment was a hassle. Yes, for people not familiar with the right tools it can be. There are different versions of Python and library dependencies and versions that can make maintaining a Django website a nightmare.

Here is what I use for deploying Django websites on a live server:

The tools

Git

You cannot be serious about programming in general these days if you’re not using a version control system. In Linus Torvald’s words: “if you’re not using Git, you’re an idiot”. I keep all my projects under version control, even if I’m the only developer on it, even when the code is for personal use only. It not only is a good practice to keep, but it also works as your backup. When I got robbed from my computers, I didn’t loose any project data because it was all backed up on several Git repositories at different places. For deployment tasks, you need to install Git on your server. The server you’re deploying to will serve as a backup as well.

Virtualenv

All that version and dependency hell can be isolated using Python’s Virtualenv tool. This is a tool that will create an encapsulated environment of a given python version and all the libraries you want to use in a project without messing with the system’s main versions. So this way, you can have an old Django 1.4 project running on the same server than another project running a later Django 1.8 or 1.9 version, as well as their respective dependencies.

Fabric

The only reason I still haven’t started using Python 3 on my projects is Fabric. This tool will automate all the project maintenance tasks needed, and that includes doing the deployment. It is similar to a Makefile but you write your tasks in Python code so you don’t need to learn a whole new syntax.

Now to the implementation details…

On your local development machine the project structure will look like this:

Project directory structure. The idea is to have the virtualenv outside the version controlled directory. You can also use virtualenvwrapper and have all your virtualenvs in a separate location. I like to have them contained in a same folder for now.

mainproject.com/
 |
 +-- env/ (virtualenv)
 |
 +-- django_project/
     |
     --- manage.py
     --- .git/
     --- fabfile.py
     --- deploy_tools/
     --- All other django project files & dirs

Deployment scripts

In the directory deploy_tools we’ll place the files necessary to configure apache, nginx, gunicorn, uwsgi or whatever other server configuration scripts needed for deployment.

Here’s an example of the Nginx configuration script I use:

upstream mywebsite {  #the upstream component nginx needs to connect to
    server unix:///tmp/mywebsite.sock; # for a file socket
}

server {    
    listen      80;   # the port your site will be served on
    server_name www.mywebsite.com;   # the domain name it will serve for
    charset     utf-8;

    client_max_body_size 250M;   # max upload size, adjust to taste

    location /static {
        alias /var/www/mywebsite/static; # your Django project's static files - amend as required
    }

    location / {     # Finally, send all non-media requests to the Django server.
        uwsgi_pass  mywebsite;
        uwsgi_param QUERY_STRING $query_string;
        uwsgi_param REQUEST_METHOD $request_method;
        uwsgi_param CONTENT_TYPE $content_type;
        uwsgi_param CONTENT_LENGTH $content_length;

        uwsgi_param REQUEST_URI $request_uri;
        uwsgi_param PATH_INFO $document_uri;
        uwsgi_param DOCUMENT_ROOT $document_root;
        uwsgi_param SERVER_PROTOCOL $server_protocol;
        uwsgi_param HTTPS $https if_not_empty;

        uwsgi_param REMOTE_ADDR $remote_addr;
        uwsgi_param REMOTE_PORT $remote_port;
        uwsgi_param SERVER_PORT $server_port;
        uwsgi_param SERVER_NAME $server_name;
    }
}

Settings handling

There are many ways to solve the problem about settings file management in Django applications. I like to have a general settings file and a local one for the different environments. To achieve this, add a local_settings.py file and add it to the git ignore list.

Then add the following at the end of your general settings.py file:

# Import local settings
try:
    from local_settings import *
except ImportError:
    pass

In your remote server, create a local_settings.py file and add DEBUG = False or override any other setting you need specifically for that server. You can have different settings for local, staging, testing or production or any other servers you need to have.

Fabric tasks

For example, you might need to download a copy of your production database to use for development tests. Instead of typing the same mysqldump command every time, you can automate it like this:

def backup_db():
    """
    Gets a database dump from remote server
    """
    production1()
    date = time.strftime('%Y-%m-%d-%H%M%S')
    dbname = 'MY-DATABASE-NAME'
    path = os.path.join(os.path.dirname(__file__), 'db_backups')
    fname = "{dbname}_backup_{date}.sql.gz".format(date=date,dbname=dbname)

    run("mysqldump -u {dbuser} -p'{password}' --add-drop-table -B {database} | gzip -9 > {filename}".format(
        database=dbname,
        dbuser='MY-DB-USER',
        password='MY-SERVER-PASSWORD',
        filename=os.path.join('/tmp', fname))
    )
    get(remote_path=os.path.join('/tmp', fname),
        local_path=os.path.join(path, fname))
    run("rm {filename}".format(filename=os.path.join('/tmp', fname)))

Likewise, you can create a deploy command to get everything in the server. Here’s a fabfile.py example:

from fabric.api import *
from fabric.colors import green, red
import os
import sys
import time
from fabric.contrib import django
import datetime

sys.path.append(os.path.join(os.path.dirname(__file__),
                             'mysite'))

django.settings_module('mysite.settings')
from django.conf import settings

# Hosts
production = '[email protected]'

# Branch to pull from
env.branch = 'master'

@production
def deploy():
    """Uploads files and runs deployment actions to a given server"""
    # path to the directory on the server where your vhost is set up
    path = "/var/www/mysite"
    # name of the application process
    process = "uwsgi"

    print green("Beginning Deploy:")
    with cd(path):
        run("pwd")
        print green("Pulling master from Git server...")
        run("git pull origin %s" % env.branch)
        # use server's virtualenv for commands
        with prefix("source %s/env/bin/activate" % path):
            print green("Installing requirements...")
            run("pip install -r requirements.txt")
            print green("Collecting static files...")
            run("python mysite/manage.py collectstatic --noinput")
            print green("Migrating the database...")
            run("python mysite/manage.py migrate")
        print green("Restart the uwsgi process")
        sudo("service %s restart" % process)
    print green("DONE!")

With these tools, all you need to do when deploying new code to the server is to run one fabric command:

fab deploy

And you’re done.

Most of these ideas I took them from the book Test-Driven Development with Django. You can read it online for free to check out more details or parts I didn’t use in this example.

This is not a perfect solution to every case, but I hope this gives you some ideas for the workflow that fits your case. Share in the comments your deployment workflow or any suggestions to improve this one.

Categories
GNU/Linux Free Software & Open Source News

Launching Notasbit, a website for tech news in Spanish

notasbit_preview
For the past year I’ve been on a radio show on Tuesdays talking about the tech news of the week. I started by hunting down the most important stories, writing my script in Spanish and then broadcasting it.

One day I thought it would be a good idea to put my scripts as posts in a tech news blog. I started the blog and it was a place for people listening to the news and wanted to know more or check out the photos or videos about them with links to the original sources.

But later with work loads I could barely have time to hunt for the news, so the blog languished. I couldn’t do all that extra work besides my main day job.

So as an engineer, I decided to automate things. Notasbit.com is no longer a news blog. It is now an automated tech news website. Notasbit is the point of reference for the most interesting tech news in Spanish. The site links to the latest posts from many Spanish language tech and science news websites and sorts the most important ones at the top of the list. It differentiates itself from a simple RSS feed reader with this algorithm, so you don’t have to dig into your several feeds to find the best articles. You can also see a list of all news gathered sorted by the time they were published.

I’ll be adding more enhancements and features that will help improve the selection of the best news. Many experts say that the projects consumed by their makers are the best ones, since you have to “eat your own dog food”. I’ll see if that happens in my case.

I really hope people enjoy Notasbit.com. For me, it will ease my task of hunting down news for the radio show and will also serve as the point of reference for people who listen to me and want to know more.

Let me know if you like the site or if you have any suggestions in the comments below.