def safe_int(val, default=None):
    """
    Returns int() of val if val is not convertable to int use default
    instead

    :param val:
    :param default:
    """
    try:
        val = int(val)
    except (ValueError, TypeError):
        val = default
    return val
