This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# It ignore whole certain directory | |
env/ | |
instance/* | |
# It ignore all files in certain directory but not given directory | |
!instance/.gitkeep | |
!migrations/__init__.py | |
# It ignore all files which has certain extension | |
*.pyc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpResponseRedirect | |
def authors_only(function): | |
def wrap(request, *args, **kwargs): | |
profile = request.user.get_profile() | |
if profile.usertype == 'Author': | |
return function(request, *args, **kwargs) | |
else: | |
return HttpResponseRedirect('/') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.validator.addMethod("emailFormat", | |
function (value, element) { | |
// return !/[0-9]*/.test(value); | |
return this.optional(element) || /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/.test(value); | |
}, | |
//'Please enter a valid email address.' | |
"Please enter a valid email" | |
); | |
$.validator.addMethod("blankSpace", | |
function (value, element) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Git clone from specific branch | |
git clone -b my-branch [email protected]:user/myproject.git | |
# Before pushed code need to run given command.. | |
git stash clear; git stash; git pull; git stash apply; | |
git commit files | |
git add . | |
git commit -m "udpate" | |
git push |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
======= Interviews ========== | |
# Duration July - August 2021 | |
## Django: | |
* Flow of Django | |
* Django Middlewares | |
* Django request/response cycle | |
* API security(auth based token and others) | |
* Avoid deadloak in django ( F() ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# search with and/or condition | |
df4 = df3.query('(From=="AHH" & To=="BBH") | (From=="BBH" & To=="AHH")') | |
OR | |
data.loc[(data["Gender"]=="Female") & (data["Education"]=="Not Graduate") & (data["Loan_Status"]=="Y"), ["Gender","Education","Loan_Status"]] | |
# Rows to columns | |
df = df.stack().reset_index().rename(columns={'level_0':'From','level_1':'To', 0:'Hours'}) | |
# Join two df like sql join | |
df1 = df1.merge(record_df, on='location_code', how='outer', suffixes=('_x', '_y')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
import pandas as pd | |
import pymongo | |
def import_content(filepath): | |
mng_client = pymongo.MongoClient('localhost', 27017) | |
mng_db = mng_client['route_planning'] | |
collection_name = 'lat_long' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For Dump and Restore : | |
mongodump --db=<old_db_name> --collection=<collection_name> --out=data/ | |
mongorestore --db=<new_db_name> --collection=<collection_name> data/<db_name>/<collection_name>.bson | |
Loop on mongodb query: | |
db.users.find().forEach( function(myDoc) { print( "user: " + myDoc.name ); } ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Python script for batch geocoding of addresses using the Google Geocoding API. | |
This script allows for massive lists of addresses to be geocoded for free by pausing when the | |
geocoder hits the free rate limit set by Google (2500 per day). If you have an API key for paid | |
geocoding from Google, set it in the API key section. | |
Addresses for geocoding can be specified in a list of strings "addresses". In this script, addresses | |
come from a csv file with a column "Address". Adjust the code to your own requirements as needed. | |
After every 500 successul geocode operations, a temporary file with results is recorded in case of | |
script failure / loss of connection later. | |
Addresses and data are held in memory, so this script may need to be adjusted to process files line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Tuesday 23-July-2019 | |
@author: Vikas shrivastava | |
For more info go to official documentation of folium https://python-visualization.github.io/folium/modules.html | |
""" |
OlderNewer