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
#Access Request Object Inside the Models and Signals | |
#Create a middleware.py inside any app for example :- blog | |
#middleware.py | |
import threading | |
class RequestMiddleware(object): | |
thread_local = threading.local() |
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
#Create a aws account | |
#CREATE I AM ROLE | |
1. Create the IAM role | |
2. Open the IAM from the your aws dashboard | |
3. Click on the roles | |
4. Click on create new role | |
5. Enter the Role Name CodeDeployInstanceRole | |
6. Attach Following Policies | |
a. AmazonEC2RoleforAWSCodeDeploy |
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
#Install Wand and Imagemagic Lib on Your System | |
#Pass the resolution paramenter in the Image Init Method | |
from wand.image import Image | |
with Image(filename='file.pdf', resolution=200) as image: | |
image.compression_quality = 99 | |
image.save(filename='file.jpg') |
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
"use strict"; | |
var gulp = require('gulp'); | |
var autoprefixer = require('gulp-autoprefixer'); | |
var browserSync = require('browser-sync'); | |
var concat = require('gulp-concat'); | |
var connect = require('gulp-connect'); | |
var imagemin = require('gulp-imagemin'); | |
var newer = require('gulp-newer'); | |
var notify = require('gulp-notify'); |
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
http://sacharya.com/crawling-anonymously-with-tor-in-python/ |
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
{ | |
"response": { | |
"status": "ok", | |
"userTier": "developer", | |
"total": 60576, | |
"startIndex": 1, | |
"pageSize": 8, | |
"currentPage": 1, | |
"pages": 7572, | |
"orderBy": "relevance", |
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
{ | |
u'title': { | |
u'title': u'SPORT NEWS IN BRIEF' | |
}, | |
u'modelVersion': u'1', | |
u'apiUrl': u'http://api.ft.com/content/items/v1/b0cb0082-97aa-11db-a680-0000779e2340', | |
u'location': { | |
u'uri': u'http://www.ft.com/cms/b0cb0082-97aa-11db-a680-0000779e2340.html' | |
}, | |
u'id': u'b0cb0082-97aa-11db-a680-0000779e2340', |
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
{ | |
u'bids': [ | |
[ | |
u'3272.07', | |
u'0.10051789', | |
1 | |
], | |
[ | |
u'3270.8', | |
u'3.55364293', |
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.db.models import F, Func, Value | |
from myapp.models import MyModel | |
# Annotation | |
MyModel.objects.filter(description__icontains='\r\n').annotate( | |
fixed_description=Func( | |
F('description'), | |
Value('\r\n'), Value('\n'), | |
function='replace', | |
) |
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
#!/usr/bin/env bash | |
# install docker | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update | |
sudo apt-get install -y docker-ce | |
sudo usermod -aG docker ${USER} | |
su - ${USER} | |
id -nG | |
echo "Now Enter you password" |
OlderNewer