Skip to content

Instantly share code, notes, and snippets.

View mascot6699's full-sized avatar
:octocat:
Here to help everyone 😄

Umang Shukla mascot6699

:octocat:
Here to help everyone 😄
View GitHub Profile
from PIL import Image
import pdb
BANNER_SIZE = (650,400)
THUMBNAIL_SIZE = (106,80)
TILE_SIZE = (82,61)
GIVEN_FILE = "tile123.png"
def resize_picture(saved_name, root_image, size):
@mascot6699
mascot6699 / .gitignore
Created August 15, 2015 05:42
The standard gitignore file of django projects
*.py[cod]
# C extensions
*.so
# Packages
*.egg
*.egg-info
build
eggs
@mascot6699
mascot6699 / multihost.py
Created September 1, 2015 04:28
Django MultiHostMiddleware: A simple middleware component that lets you use a single Django instance to server multiple distinct hosts.
# File: multihost.py
import time
from django.conf import settings
from django.utils.cache import patch_vary_headers
class MultiHostMiddleware:
def process_request(self, request):
try:
import urllib
import base64
import httplib
import ast
import requests
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
def get_access_token(CONSUMER_KEY, CONSUMER_SECRET):
# calling oauth 2 access_token api
import requests
from requests.auth import HTTPBasicAuth
data = {'grant_type':'password','username':'username','password':'password'}
auth=HTTPBasicAuth('id', 'secret')
aa = requests.post('http://127.0.0.1:8000/o/token/', auth=auth, data=data)
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
@mascot6699
mascot6699 / requirements.txt
Created January 25, 2016 04:52
Initial requirements for non-real django projects (Mongodb)
git+https://github.com/django-nonrel/django.git
git+https://github.com/django-nonrel/djangotoolbox.git
git+https://github.com/django-nonrel/mongodb-engine.git
djangorestframework==2.4.0
djutil==0.2
pymongo==3.2
wheel==0.24.0
# For dumping the database
pg_dump -W -U <username> -h localhost <dbname> > <file_name>
# For loading the database
psql -W -U <username> -H <db_name> < <file_name>
# for uploading a file on server
scp -i server.pem <file_name> ubuntu@url:<file_name>
# for downloading a file
map $http_user_agent $limit_bots {
default 0;
~*(google|bing|yandex|msnbot) 1;
~*(AltaVista|Googlebot|Slurp|BlackWidow|Bot|ChinaClaw|Custo|DISCo|Download|Demon|eCatch|EirGrabber|EmailSiphon|EmailWolf|SuperHTTP|Surfbot|WebWhacker) 1;
~*(Express|WebPictures|ExtractorPro|EyeNetIE|FlashGet|GetRight|GetWeb!|Go!Zilla|Go-Ahead-Got-It|GrabNet|Grafula|HMView|Go!Zilla|Go-Ahead-Got-It) 1;
~*(rafula|HMView|HTTrack|Stripper|Sucker|Indy|InterGET|Ninja|JetCar|Spider|larbin|LeechFTP|Downloader|tool|Navroad|NearSite|NetAnts|tAkeOut|WWWOFFLE) 1;
~*(GrabNet|NetSpider|Vampire|NetZIP|Octopus|Offline|PageGrabber|Foto|pavuk|pcBrowser|RealDownload|ReGet|SiteSnagger|SmartDownload|SuperBot|WebSpider) 1;
~*(Teleport|VoidEYE|Collector|WebAuto|WebCopier|WebFetch|WebGo|WebLeacher|WebReaper|WebSauger|eXtractor|Quester|WebStripper|WebZIP|Wget|Widow|Zeus) 1;
~*(Twengabot|htmlparser|libwww|Python|perl|urllib|scan|email|PycURL|Pyth|PyQ|WebCollector|WebCopy|webcraw) 1;
}
{
"goal_setting": [
{
"items": [
{
"Person": {
"action": {},
"data": "Test Gm"
},
"50% completion": {