Skip to content

Instantly share code, notes, and snippets.


Mohsin aljiwala

Block or report user

Report or block aljiwala

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
aljiwala /
Created Apr 6, 2020
Google Style Python Docstrings: Example
# -*- coding: utf-8 -*-
"""Example Google style docstrings.
This module demonstrates documentation as specified by the `Google Python
Style Guide`_. Docstrings may extend over multiple lines. Sections are created
with a section header and a colon followed by a block of indented text.
Examples can be given using either the ``Example`` or ``Examples``
sections. Sections support any reStructuredText formatting, including

Keybase proof

I hereby claim:

  • I am aljiwala on github.
  • I am aljiwala ( on keybase.
  • I have a public key ASAVREBd3BSfzkZGpjGWKOxdUJWDwHPjcJkfnyQ28YpjIAo

To claim this, I am signing this object:

aljiwala /
Created Jul 26, 2018
Get meta keywords and description from website.
def get_soup(url):
# Func which should return `BeautifulSoup` object.
def get_meta_from_website(url, attrs=['description', 'keywords']):
Should return meta data from given website URL.
* Receives:
- url (string)
from re import match
from urllib.parse import urlparse
from urllib.parse import ParseResult
def get_parsed_url(url):
p = urlparse(url, 'http')
netloc = p.netloc or p.path
path = p.path if p.netloc else ''
if not netloc.startswith('www.'):
netloc = 'www.' + netloc
import requests
from time import sleep
from bs4 import BeautifulSoup
def extract_from_ed_india():
final = list()
pages = range(1, 32)
for i in pages:
aljiwala /
Created Jul 18, 2018 — forked from mderazon/
Google apps script to export to individual csv files all sheets in an open spreadsheet
* script to export data in all sheets in the current spreadsheet as individual csv files
* files will be named according to the name of the sheet
* author: Michael Derazon
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var csvMenuEntries = [{name: "export as csv files", functionName: "saveAsCSV"}];
ss.addMenu("csv", csvMenuEntries);
aljiwala /
Last active Jul 24, 2018
Divide CSV data into chunks
# Built-in imports.
from sys import argv
from os.path import join as join_path
# Third party imports.
from pandas import read_csv
def get_row_count(src_filepath):
with open(src_filepath, 'r') as f:
aljiwala /
Created Mar 14, 2018
Django Standalone Script
import sys, os, django
sys.path.append("/path/to/store") #here store is root folder(means parent).
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "store.settings")
from store_app.models import MyModel
aljiwala /
Created Nov 25, 2017
Mixin to any view or viewset to get kwargs with lowercase values. Based on a `lookup_field` attribute.
from rest_framework.generics import get_object_or_404
class CaseInsensitiveLookupMixin(object):
Apply this mixin to any view or viewset to get kwargs with lowercase
values. Based on a `lookup_field` attribute.
def get_object(self):
queryset = self.get_queryset() # Get the base queryset
aljiwala /
Created Nov 25, 2017
Compress the size of the given file with the particular `scale` until `max_size` limit is achieved.
from PIL import Image
from io import BytesIO
def compress_image(original_file, max_size, scale):
It should compress the size of the given file with the particular `scale`
until `max_size` limit is achieved.
assert(0.0 < scale < 1.0)
You can’t perform that action at this time.