Tuesday, March 12, 2019

How to make Brother HL 2040 printer working under Linux?


Go to this link -> https://www.openprinting.org/printer/Brother/Brother-HL-2040

Click on the link "directly download PPD" which is underlined in green colour
PPD for Brother-HL-2040


Now in your linux machine (Debian based)
goto printer settings -> Select the "provide PPD" option -> Browse to the downloaded PPD file and "apply"

Check with the test print.

Friday, March 1, 2019

how to do math operations inside Django template?

1. Install "django-mathfilters" package using pip
   pip install django-mathfilters

2. Open settings.py file of your Django project and add  'mathfilters' in INSTALLED_APPS section.
   After this your settings.py file's INSTALLED_APPS section will look as follows
   INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'mathfilters',
   ]

3. Now you can do the basic math operations like add, sub, mul, div etc., like as follows
    add - {{ 8|add:4 }}
    mul - {{ your_var|mul:2 }}

For more details please refer -> https://pypi.org/project/django-mathfilters/

Thursday, February 28, 2019

How to import csv data into mongodb?

How to import large amount of csv data to mongodb
mongoimport -d <dbname> -c <collection_name> --type csv --file </path/to/actual/file.csv> --headerline

<blah> - Replace with your respective values

-d <dbname> - Tells to your mongo server into which database you want to import
-c <collection_name> - Tells to your mongo server in <dbname> into which collection you want to import
--type csv - Says it is a csv file
--file <path> - Give full path to your csv file
--headerline - if given, uses the first line as field names.

Monday, November 12, 2018

How to fix "Use gi.require_version('Gtk', '3.0') before import" error

Error:

gi.require_version error









Solution:

Replace the line
"from gi.repository import Gtk"

with

"import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk "

Wednesday, July 19, 2017

How to get the serial number of your network device in linux?


1. sudo lshw -C network | grep -i serial
    lshw    - Command used to list the details of all available hardware in a system.
    -C      - Option used to specify hardware "class".
        network - We asked "lshw" to list only the network devices.

    grep    - Command used to print lines that matches the given pattern
    -i    - Option used to ignore case sensitivity
    serial    - Pattern used to fetch the lines that contains the word "serial"

Example:
$sudo lshw -C network | grep -i serial
[sudo] password for :
       serial: 78:f2:9e:f3:88:e7

   
2. /sbin/ifconfig | grep -i hwaddr or sudo ifconfig | grep -i hwaddr
    ifconfig-Command used to configure network devices.
    grep    - Command used to print lines that matches the given pattern
    -i    - Option used to ignore case sensitivity
    serial    - Pattern used to fetch the lines that contains the word "serial"


Example:
$/sbin/ifconfig | grep -i hwaddr
eth0      Link encap:Ethernet  HWaddr 78:f2:9e:f3:88:e7  


3. GUI Way
Applications -> System Tools -> Settings

                                  You will land in the following screen
Settings panel



Click on Network the following window will be open


Network settings panel


The green highlighted part is our interest.