Sunday, June 15, 2014

vlc no decoder module fedora 20

Sometime after updating Fedora 19 to 20 (using fedup), VLC stopped playing some h264 videos.

An error message such as this appeared:

no suitable decoder module for fourcc `h264'. VLC probably does not support this sound or video format.


No suitable decoder module:
VLC does not support the audio or video format "h264". Unfortunately there is no way for you to fix this.

It was missing lame-libs. A sudo yum install lame-libs solved my issue.

What is more important is how I solved this:

a) vlc -vvv mediafile.mp4

b) Look for yellow or red warning/error messages. A lot of information gets outputted.

eg:
0x1666118] main libvlc warning: cannot load module `/usr/lib64/vlc/plugins/demux/libavformat_plugin.so' (libmp3lame.so.0: cannot open shared object file: No such file or directory)

c) This message states that libmp3lame.so.0 does not exist.

d) sudo repoquery --whatprovides '*/libmp3lame.so.0'

returned:
lame-libs-0:3.99.5-2.fc19.i686

Friday, May 30, 2014

Failed to load libGL.so on Fedora 20 and Android emulator

I got this warning when trying to get the android emulator working on Fedora 20.

You need to install 2 packages to get this working:

sudo yum install mesa-libGL-devel mesa-libGL-devel.i686

The libGL.so message disappeared after this. Command to search for this lib on future installs.

sudo yum whatprovides */libGL.so

Thursday, May 1, 2014

How humor and software development are related.

I've been putting out a few resumes and getting back to an HR person with my status. Part of my response describes how having a funny bone has affected me as a developer.

Hi XXX,

Hope your talent search is going well for XXX. We had a short but good talk last week and went over my qualifications and past work experience. I enjoyed listening to what you and XXX were looking for in prospective employees. I did my best to be as cool as possible, but having our call dropped and me running around the all corners of my building trying to find a good connection, might have made me sound a little nervous :)

My three main takeaways from our call was that culture, personality and technology skills were equally valued by XXX.

Coming from a small town, I feel that I was able to grow up in an environment where being good to your neighbours and having great friends were an important part of life. People still left their doors unlocked and when you drive by in a car you wave your hand. I think I certainly have brought this attitude with me as a Vancouverite, and will wave to my neighbours when I bike or walk around my part of town. I stopped doing this downtown as people looked at me strange (except in downtown east side where they tried to hug me...ewww)

Having not a lot to do in a small town also made you grow your personality and one aspect is that I think I have a great sense of humour and wit. All you have are your friends and when there wasn't much to do we would sit around and make jokes. It was a game of one upmanship, when someone said something funny, you tried your best to build on it or say something even funnier. It's important to note that humour can sometimes hurt people, and being careful not to cross that line is part of the fun. I tend to respect Stephen Colbert's type of humour, and know I'll never be as good. People have told me that I'm funny, but I always tell them, "Really? I'm the least funny person among my funny group of friends".

This trait has helped me make friends and interact with people, but I think it also has helped my career. Rule of comedy - funny comes in threes. You tend to look at a situation or a phrase and think of three things that you can add to it. It really helps with improving your lateral thinking and I find that I apply this to all aspects of my every day work. During a conversation or a question, I come up a set of options, and try to mentally travel down each path and drop the ones that don't work. Then express the good ones. Keep repeating until the best solution is found. This is what developers do all day I feel that it is one of my strongest attributes that one would expect from someone who was more artsy.

...

A large part of software development is analyzing a situation and choosing an option and testing the results. Comedy is analyzing a situation, finding the absurdity and testing among your peers. Nothing is funnier than seeing your TDD tests pasts, am I right? Is it no wonder that some great comedians had STEM backgrounds?

Jimmy Fallon - CPSC (yes he dropped out for SNL)
Mike Judge - Physics
Rowan Atkinson - EEng
Ray Romano - Accounting

Wednesday, February 12, 2014

Finally a MySQL connector that works with Django and Python 3

The django community isn't the most supportive of mysql. They have valid arguments on why postgres is superior is to mysql and I don't disagree with them. Except that I have a level of comfort with MySQL that I've gotten from being paid to work with it the past six years. I'm not necessarily forgiving MySQL for its quirks, but I know I can depend on the large community and the vast resources if I ever run into problems. On the chance that one of my projects 'hockey sticks', there are experts who have gotten MySQL to scale with the traffic.

For those that are techno puritans, they sometimes forget that MariaDB is a solid open initiative that deserves support from the community as it adheres to the same open source principles as Postgres.

I've been patiently creating my app in Python 2.7 eagerly waiting for one of the MySQL connectors to work with Python 3 and Django. Finally in the past month MySQL released an official one.

I tested this connector with the Django tutorial app and got ./manage.py syncdb to create some tables for my test models. More testing will be needed to see if south and other parts of the Django ORM are working correctly.

http://dev.mysql.com/doc/connector-python/en/connector-python-django-backend.html

System:
Fedora 20
Django
Python 3.3

Step 1:
sudo yum install python-virtualenv

Step 2 - Create your python 3 environment:
virtualenv -p /usr/bin/python3 myenv

# On fedora python 3 is sym linked to python3.3

cd myenv
source bin/activate

Step 3 - Install Django and the official mysql connector:
pip install django # at the time of this writing it is 1.6.2.
pip install mysql-connector-python

# This matches the connector version from the mysql link above.
# Downloading mysql-connector-python-1.1.5.zip (337kB): 337kB downloaded

Step 4 - Configure Django settings.py to use this database connector:

DATABASES = {
    'default': {
        'NAME': 'mydatabase',
        'ENGINE': 'mysql.connector.django',
        'USER': 'myuser',
        'PASSWORD': 'secretpassword',
        'OPTIONS': {
          'autocommit': True,
        },
    }
}


Step 5:
Create your models and run ./manage syncdb

Update: Feb 12, 2014
http://dev.mysql.com/doc/relnotes/connector-python/en/news-1-1-5.html

Changes in MySQL Connector/Python 1.1.5 (2014-01-31)
Functionality Added or Changed
- Connector/Python is now compatible with Django 1.6. (Bug #17857712)

You can find the Fedora 20 rpm from here as 1.1.5 is being tested:
https://dl.fedoraproject.org/pub/fedora/linux/updates/testing/20/x86_64/mysql-connector-python3-1.1.5-1.fc20.noarch.rpm 

I tested with Django 1.6.x

Tuesday, July 23, 2013

Can't watch mpeg-4 aac h.264 video in Linux Firefox

Updated for Fedora 19 - July 2013

Every new Fedora install, I forget how to watch apple trailers in my browser. I get the mpeg-4 aac and h.264 decoder missing message.

This can be solved in three steps:

1) Add the rpmfusion repository.

su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/releases/19/Everything/x86_64/os/rpmfusion-free-release-19-1.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/releases/19/Everything/x86_64/os/rpmfusion-nonfree-release-19-1.noarch.rpm'

2) Install vlc

sudo yum install vlc

3) Lastly this one extra command allowed the movie to play

sudo yum install gstreamer1-libav

Wednesday, July 10, 2013

Fedora 19 and Gnome 3.8 - Get back your terminal background transparency

Gnome Terminal in 3.8 had the transparency option dropped/removed not because it wasn't a useful feature, but because implementation between new and old code was difficult.

Anyways with Fedora 19 and Gnome 3.8, there is a way to get back this feature. I ended up using the window manager cinnamon as it has advanced features of gnome, yet includes lots of the intuitive right click menu options you expect on any desktop.

Step 1:
sudo yum install devilspie

Step 2:
mkdir ~/.devilspie

Step 3:
// Add any file in this dir ending in .ds and devilspie will process it.

vim ~/.devilspie/terminal-opacity.ds

Step 4:
// In this file add this line of code
// Terminal is what fedora uses as the name of these terminals.

(if
  (matches (window_name) "Terminal")
  (opacity 85)
)

Step 5:
// Add in .bash_profile the following line. It will
devilspie -a &

Step 6: Logout and log back in.

Any new terminal console windows will now be transparent - including the menu bars.

Sunday, June 2, 2013

Django change the trailing slash url convention to no trailing slash

URL Specs and search engines state that urls with and without trailing can affect your SEO rankings (and a user's ability to type in a link).

eg. example.com/page and example.com/page/

This affects some web frameworks, such as Django, as the regular expression for routing these URLs will be defined for only one of these cases. By convention Django will add a trailing slash, if a non trailing slash url is typed into the browser.

I prefer to not have a trailing slash as it is one less character to type in. I should note that some sites, like stackoverflow.com or twitter.com does not give a crap either way.

We can add this feature to Django by creating a custom middleware class that intercepts the request.path and rewrites it to the non trailing slash url.

What is middleware?

Middleware is a framework of hooks into Django’s request/response processing. It’s a light, low-level “plugin” system for globally altering Django’s input or output.

Or in layman's terms, it processes values/urls before it is sent to Django's views. You can find Django's middleware that redirects to the trailing slash url in:

django/middleware/common.py

Which was added to your project in
settings.py

MIDDLEWARE_CLASSES = (     'django.middleware.common.CommonMiddleware',


How to get Django to redirect trailing slashes to the non trailing slash url if it exists.

Step 1:

Add this line in settings.py

APPEND_SLASH = False

Step 2:

Create these paths and files

./common/
./common/__init__.py
./common/redirect.py

Step 3: Add the class to the MIDDLEWARE definition

MIDDLEWARE_CLASSES = (
    'common.redirect.RedirectTrailingSlashMiddleware',
    'django.middleware.common.CommonMiddleware',

# It must be the first class as we want to catch it before django does.

Step 4: Add this code to redirect.py

For /admin urls, I have kept the trailing slash as I don't want to break Django's admin methods

from django.conf import settings
from django.core import urlresolvers
from django import http

'''
Based on django/middleware/common.py

Django convention is to add trailing slashes to most urls
This method does the opposite and redirects trailing slashes to the
no trailing slash url if it exists
'''
class RedirectTrailingSlashMiddleware(object):

    def process_request(self, request):
        if settings.APPEND_SLASH:
           return 
        
        if '/admin' in request.path:
            settings.APPEND_SLASH = True         
            return

        new_url = old_url = request.path

        if (old_url.endswith('/')):
            urlconf = getattr(request, 'urlconf', None)
            if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
                urlresolvers.is_valid_path(request.path_info[:-1], urlconf)):
                new_url = new_url[:-1]
                if settings.DEBUG and request.method == 'POST':
                    raise RuntimeError((""
                    "You called this URL via POST, but the URL ends "
                    "in a slash and you have APPEND_SLASH set. Django can't "
                    "redirect to the non-slash URL while maintaining POST data. "
                    "Change your form to point to %s (note no trailing "
                    "slash), or set APPEND_SLASH=True in your Django "
                    "settings.") % (new_url))

        if new_url == old_url:
            # No redirects required.
            return

        return http.HttpResponsePermanentRedirect(new_url)