Skip to main content

Posts

Showing posts from 2017

Steps to Install Redis server

Few steps necessary to build and install Redis on a server. There are no pre-built packages available for you to apt-get install it. So you have to grab the source, compile and install the generated binaries. Fortunately it all goes pretty smooth. $ wget http://download.redis.io/releases/redis-4.0.2.tar.gz $ tar xzf redis-4.0.2.tar.gz $ cd redis-4.0.2 $ make $ make test # install compiled binaries to /ur/lib/bin $ sudo make install # setup redis-server as daemon $ cd utils $ sudo ./install_server.sh # setup redis-server to autostart $ sudo update-rc.d redis_6379 defaults That ought to do it!

Volvo Door Mirror Mismatched Folding

One of the problems that I encountered with the S80 is that when I unlocked the car and pressed the button to unfold the door mirrors, they would be out of sync with each other. That is one would open and at the same time the other would close. You can open the closed mirror manually, but when you press the button to fold then mirrors, one would close and the the other would remain open. After some research online, I figured out the problem -- the mirror's folded/open position is stored in memory and the car uses this position to instruct the mirror motors on what action to perform (fold/unfold) when you press the button to unfold the mirrors again. Now if you're in a hurry and happen to switch off the vehicle before the mirror folding operation could be completed, storing of the mirror position in memory cannot be completed accurately. The solution to the problem turns out to be very simple. Turn off the car. Locate the fuse box in the passenger compartment. Locate fus...

How to Integrate Sphinx with a Django Project for Automatic Documentation Generation

A few points on integrating Sphinx with a Django redistributable project for generating documentation embedded in the source files. Project directory structure should look like this: django-redistributable/ demo/ demo/ settings.py urls.py wsgi.py templates/ manage.py docs/ conf.py index.rst Makefile make.bat redistributable/ models.py views.py templates/ static/ tests/ setup.py MANIFEST.in README.rst LICENSE requirements.txt Install sphinx and sphinx-autobuild using pip. Run sphinx-quickstart from the docs folder. Provide default answers for all prompts. Edit docs/conf.py such that the redistributable package and the demo project's apps are importable from the docs folder. At the top of the conf.py file: import os import sys import django sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) sys.path.append(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'demo')) Set...

Volvo Engine Service Required Message

This is a message that my Volvo (S80 2004 2.0T) started showing yesterday. The message was accompanied with a yellow/orange warning light, (image on the right) in the car dash. This freaked me out when it first appeared as I was worried that the car could shutdown anytime while on the move. But apparently the color of the light, yellow, is an indicator that the issue is not major and therefore such a shutdown is not an immediate possibility. On the other hand, if the color of the indicator is red, then it is indeed cause for concern and the best option is to stop the car and seek professional help immediately. In the past whenever I had issues with my car, my first reaction is to reach out to my mechanic for help. But with the Volvo, what I have learned is that with the amount of electronics and computer control that is embedded into it, it's best to first to research online, narrow down the possible causes to a select few and then approach the mechanic appraising him of y...

Volvo Service Reminder Message

This is a message that appears on my Volvo S80 after driving for a period of time. Interestingly, this message appears even though I have not driven the car for the recommended service interval - 7500 miles, or about 12000km. Did some research and it turns out that this message is displayed as a function of hours the engine has been running, duration since last service and distance covered.  Essentially, this light will come on at 7,500 mile (12,000 km) intervals, after 750 hours of driving or after 12 months, whichever occurs first, to remind the driver that the service interval has been exceeded. The light will stay on for 2 minutes after start until reset. Here's how to reset this message without using a professional interface equipment: Put the key in and turn it to ignition position I Press and hold in the reset button for the trip odometer Turn the key to ignition position II. Note! Turn the key to position II within 2 seconds. Hold the reset button for the trip ...

Django template tag to retrieve template filename

One useful Django template tag is to retrieve the template filename from inside the template. Unfortunately, Django built in tags do not provide one for this. However, you can write a simple tag to accomplish this. Here's are two tags, that return either the base filename or the full filename. from django import template register = template.Library() @register.simple_tag(takes_context=True) def basefilename(context): '''Returns filename minus the extension''' return context.template_name.split('.')[0] @register.simple_tag(takes_context=True) def fullfilename(context): '''Returns full filename with the extension''' return context.template_name To be complete, tthere should be another tag that returns the filename with its entire path. But I haven't figured out how to do this -- at least from within the confines of the template tag framework.