Frequently asked questions

Brazilian Jiu-Jitsu

Can I replace worn out stripes on my belt by myself?

If you have been awarded stripes and they are so worn out that they fall off the belt patch, it is ok to replace them yourself. If you want to keep the original stripes you can give them a couple of extra stitches with white yarn.

Depending on the tape you can iron them right after they were put on, this will create a better bond of the glue to the tissue.

Do you wash your belt?

Yes, you do! However, you don't want to wash it after every training as you should do with your gi. The wear and tear of your belt should come from rolling, not from washing. It is ok to wash your belt every couple of weeks.

How often do you wash your gi?

After every training. You sweat a lot, especially during sparring. Sweat contains lactic acid, urea and mineral that will remain in the gi when it dries and very quickly become smelly if not removed by washing.

While in other sports it may be acceptable to put on your clothing twice before you put it into the laundry, in combat sports which involve sparring this is a bad idea.

My gi is smelly even though I wash it after every training. What can I do?

This is a common issue for people who sweat a lot. Try washing your gi with cheap vinegar, the one they sell for cleaning. Even better is to let the gi soak in water with vinegar for some time before you wash it.

If this doesn't help you should buy a antibacterial detergent. Most of them are formulated to also remove smell from tissues.

Do not use softener as it will damage the tissue and weaken your gi!

What are the requirements to get your first stripe as a white belt in Brazilian Jiu-Jitsu?

Bjj is known for high standards as well as for its more informal rank system based on generally assumed expectations for each belt color.

So what exactly is required to get your first stripe largely depends on your school or instructor.

In general terms, a candidate for the first stripe amongst others should

  • be familiar with etiquette and standards of the dojo,
  • train regularly,
  • be familiar with all basic movements such as shrimp, roll forward/backward/sideways, sit-through, technical stand-up, etc.
  • know and be able to identify all major positions, i.e. back mount, mount, side control, closed/open guard, half guard.
  • seamlessly integrate into the flow of each class,
  • show some progress,
  • should be able to properly tie his belt (sic!),

Apart from the above there are usually some specific techniques or skills you need to show, for instance basic escapes from mount and side control.

What is the difference between gi and no-gi?

First of all the rule sets are different. The keikogi, generally called "gi" is the kimono worn during the practice of jiu-jitsu. It allows for good gripping which is why grips to the gi are an essential part of the techniques. Many techniques entirely depend on parts of the gi such as chokes, and guards. In no-gi it is not allowed to grip any part of the clothing. Because the gi absorbs most of the sweat during sparring or competion good grips can still be established on the opponent.

This is not the case in no-gi. The rash guards worn in competion very quickly become slippery which leads to a far more dynamic and faster game. Submissions and sweeps are more difficult because of the lack of gripping in no-gi.

Because of the difficulties to establish good grips on the upper limbs and torso the legs have become an important target for attacks to a point where many jiu-jitseiros that practice no-gi specialize in leg attacks. There are many leg and foot attacks in no-gi that are not legal under gi rules.

What is the most important rank in Brazilian Jiu-Jitsu?

For me the most important rank is the first stripe on your white belt. The white belt is the only belt you do not get awarded, you just go and buy one, so anybody can legitimately wear a plain white belt. When you get your first stripe it is the first time you actually get awarded a rank. Apart from the technical requirements that may be related to it (depending on your school or club) the first stripe actually means that your instructor thinks you are consistent and serious about bjj. You are now part of it.

Royal Enfield Himalayan

How big are the side panniers of the Royal Enfield Himalayan

According to product specs they have a capacity of 26 liters. Dimensions are

  • length: 47cm
  • height: 37cm
  • width: 20cm

Therefore they are not much smaller than a regular cabin suitcase.

What is the fuel tank capacity of the Himalayan?

Capacity is 15 liters. As soon as you are down to 5 liters the reserve indicator will light up and the trip counter will show you the distance you have been driving in reserve. However, at the beginning the trip odometer will reset quite a few times which is probably caused by leaning into curves or going uphill/downhill.

15 liters does not seem to be much but with a mileage of 3l/km you can safely make 300 km before hitting the next petrol station. This should be more than enough in most parts of the world. However, protection bars on either side of the fuel tank are prepared to attach jerry cans which would extend the radius to a crazy 600 kilometers before you get into reserve.

What is the real mileage of a RE Himalayan?

Mileage is around 3 liters of 95 octane per 100 kilometers. This is based on a 2.000 km trip from Guardamar del Segura (Alicante, Spain) to Wickrath (Mönchengladbach, Germany) over all sorts of terrain in meteorological conditions.

What is the top speed of the RE Himalayan?

Top speed is around 120 km/h. That being said you do not want to ride this bike at this speed for various reasons.

  • The 410LS engine with its 24.5 PS has a hard time getting up to that speed.
  • Long stroke engines do not like high revs and your motor will suffer a lot.
  • The bike will start to vibrate not only because of the single cylinder engine but also due to the PIRELLI MT 60 multi-purpose tires.

To put it in a nutshell the bike is not designed to go over 100 km/h and the ride is not comfortable. Best cruising speed is between 80 and 95 km/h which is also a good speed for long distance rides.


How can I guess the filetype whithout depending on the file extension, for instance on uploaded files?

Most file formats use a signature also called file magic or magic number which is simply a specific sequence of bytes. For instance PDF files always start with %PDF- plus version number. All you have to do is to compare the first bytes of the file with the signature.

The following script guesses a series of files (you can extend the list of signatures as you wish).

from collections import namedtuple

FileType = namedtuple('DataType', ['type', 'subtype', 'name'])

FT_BZIP2 = 2
FT_ZIP = 3
FT_RAR = 4
FT_7Z = 5
FT_TAR = 8
FT_PS = 10
FT_PDF = 11
FT_XML = 12

signatures = {b"\x53\x51\x4c\x69\x74\x65\x20\x66\x6f\x72\x6d\x61\x74\x20\x33\x00": FileType(FT_SQLITE3, None, "sqlite3"),
             b"\x42\x5A\x68": FileType(FT_BZIP2, None, "bzip2"),
             b"\x50\x4B\x03\x04": FileType(FT_ZIP, None, "zip"),
             b"\x50\x4B\x05\x06": FileType(FT_ZIP, "Empty", "zip (empty)"),
             b"\x50\x4B\x07\x08": FileType(FT_ZIP, "MultiVolume", "zip (multi-volume)"),
             b"\x52\x61\x72\x21\x1A\x07\x00": FileType(FT_RAR, "Version 1.5+", "rar (1.5 +)"),
             b"\x52\x61\x72\x21\x1A\x07\x01\x00": FileType(FT_RAR, "Version 5.0+", "rar (5.0 +)"),
             b"\x37\x7A\xBC\xAF\x27\x1C": FileType(FT_7Z, None, "7z"),
             b"\x1F\x8B": FileType(FT_GZIP, None, "gzip"),
             b"LOSRATES": FileType(FT_RATECACHE, None, "ratecache binary"),
             b"\x75\x73\x74\x61\72": FileType(FT_TAR, None, "tar"),
             b"\x23\x21": FileType(FT_SCRIPT, None, "script"),
             b"%!PS": FileType(FT_PS, None, "PostScript"),
             b"%PDF-": FileType(FT_PDF, None, "Pdf"),
             b"<?xml": FileType(FT_XML, None, "XML")

def guess_type(s):
    """Guess the file type based on the magic bytes"""
    for magicbytes, filetype in signatures.items():
        if magicbytes == s[:len(magicbytes)]:
            return filetype
    return FileType(FT_UNKNOWN, None, "unknown")

How can I load test my web server application?

If you are familiar with python you should try locust. Instead of firing up an overbloated Java application you basically design your load test as a python script. You will get through the tutorial and api specs much quicker than going through the manual of most other tools. What you do is you basically "programm users" that interacts with your web site.

I would like to show a progress bar in my command line application.

In order to show a progressbar you will need to know from the beginning or at an early stage the amount of data you will process. If you iterate over a list this is trivial. The downside is that you usuallly want to use a progress bar when you need to process a lot of data and this is exactly when you want to use a generator function instead of a list for iteration. Anyway, let's see, how you can implement a progress bar class first:

import sys

class Progressbar(object):
    def __init__(self, maxval, width=50, show_percent=True, barchar='»'):
        self.maxval = maxval
        self.width = width
        self._value = 0
        self.barchar = barchar
        self.show_percent = show_percent

    def __del__(self):

    def value(self):
        return self._value

    def value(self,value):
        self._value = value

    def percent(self):
        return '{0:5.2f}'.format(self._value/self.maxval*100)

    def paint(self):
            progress = int(self._value/self.maxval*self.width)
        except ZeroDivisionError:
            bar = self.barchar * progress
            filler = ' ' * (self.width - progress)
            if self.show_percent is True:
                output = '\r[{0}{1}] {2}% '.format(bar,filler,self.percent)
                output = '\r[{0}{1}] '.format(bar,filler)

    def inc(self):
        self._value += 1

If you do not know the number of items you are going to process you should still give the user some visual feedback:

class BusyWheel(object):
    def __init__(self, msg = 'items processed'):
        self.step = 0
        self.count = 0
        self.spokes = ['-','\\','|','/']
        self.msg = msg

    def __del__(self):

    def inc(self):
        self.count += 1
        if self.step == 3:
            self.step = 0
            self.step += 1

    def paint(self):
        sys.stdout.write('\r{0} {1:5d} {2}'.format(
            self.spokes[self.step], self.count, self.msg))

Is there a simple http server I can use for development?

If you have the python interpreter installed you can start a simple http file server with python -m http.server. Use python -m http.server --help to see options such as binding to a different address or port.

What does the `if __name__ == '__main__':` do ?

This checks if the module has been invoked as a script, so the code within the if clause will only be executed if the script was called on the command line.

In case the module was imported the code in the if clause will not be executed. This little trick makes it possible to use a module both as a standalone script and an importable module.

¿How do I process a bunch of xml files in a folder?

Code sample:

import glob
import logging
import xml.etree.ElementTree as ET
from pathlib import Path

path = Path('/path/to/xml/files')

def process_files(path):
    ns = {"edf":"",
          "atmt": ""}
    for p in glob.glob(str(path / 'hotels' / 'hotelonly' / '*.xml')):
            tree = ET.parse(p)
        except ET.ParseError:
            logging.error("An error has occured while parsing %s", p)
            root = tree.getroot()
            basic_data_node = root.find("edf:BasicData", ns)
            except AttributeError:
                logging.error("Missing 'Code' attribute in %s", p)

if __name__ == '__main__':

¿How do you alternate True and False?

Code sample:

class Alternator(object):
    def __init__(self, startswith=True):
        self._value = int(not startswith)

    def value(self):
        self._value = 1 - self._value
        return bool(self._value)

if __name__ == '__main__':
    a = Alternator()
    for i in range(0,10):


How can I return documents such as zip or pdf as file downloads in Django?

All libraries that operate on file objects such as zipfile or reportlab will also work work with file-like objects. If you dynamically generate such an object you create a buffer instance and then use django's FileResponse to return a file-like object.

import io
from django.http import FileResponse
from reportlab.pdfgen import canvas

def my_view(request):
    buffer = io.BytesIO()
    c =  canvas.Canvas(buffer)
    c.drawString(100, 100, "Hello world.")
    return FileResponse(buffer, as_attachment=True, filename='hello.pdf')

For more details see the official django documentation

How do I automatically set the creation date in a model field?

Set the auto_now_add parameter to True. In this case the field value is only set when the record ist created and does not get changed on updates. If you want to keep track of when the record has last been updated you must use auto_now.

created = models.DateField(auto_now_add=True)
last_modified = models.DateField(auto_now=True)

How do I output a formatted date in a Django template?

Use the "date" filter:

<p class="tag is-info">Published: {{article.created|date:"d/m/Y"}}</p>

I get a "TemplateNotFound" error. I have checked folder structure and path to template in and everything looks fine!

You probably have just created a new app within your project but forgot to register the app in Add your app to INSTALLED_APPS like so:



How can I use a string template for string formatting?

Use fmt.Sprintf.

func TimeToStr(t time.Time) string {
    return fmt.Sprintf("%d/%02d/%02d", t.Year(), t.Month(), t.Day())

How do I get the size of an open file?

statInfo, err := f.Stat()
if err != nil {
        return 0, err
fileSize := statInfo.Size()

Size() returns an int64, you need to cast other values you want to operate on to int64:

blockCapacity := statInfo.Size()/int64(len(byteStr))

When do you use pointers in Go?

In Go function parameters are passed as values, i.e the function receives a copy of the variable whose scope is limited to the function. This means that any modification made to the variable does not have any effect on the variable you pass to the function call. If you want to use a function to change the value of a variable you can do this by passing a pointer of the variable to the function.