Skip to content

Instantly share code, notes, and snippets.

View AnjaneyuluBatta505's full-sized avatar

Anjaneyulu Batta AnjaneyuluBatta505

View GitHub Profile
@AnjaneyuluBatta505
AnjaneyuluBatta505 / Python3, Pip3, Virtualenv and Virtualenvwrapper Setup
Created July 26, 2018 07:09 — forked from IamAdiSri/Python3, Pip3, Virtualenv and Virtualenvwrapper Setup
Setting up and using Python3, Pip3, Virtualenv (for Python3) and Virtualenvwrapper (for Python3)
First install pip for Python2. Download the get-pip.py file from https://bootstrap.pypa.io/get-pip.py
$ cd <download location>
$ sudo -H python ./get-pip.py
Installing pip also installs Python3
To run Python3
$ python3
Install pip3 by just executing the same file as in the step above, but this time using Python3
$ sudo -H python3 ./get-pip.py
@AnjaneyuluBatta505
AnjaneyuluBatta505 / upgrade-postgres-9.5-to-9.6.md
Created July 6, 2018 14:08 — forked from delameko/upgrade-postgres-9.5-to-9.6.md
Upgrading PostgreSQL from 9.5 to 9.6 on Ubuntu 16.04

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.6 main --stop
sudo pg_upgradecluster 9.5 main
sudo pg_dropcluster 9.5 main
@AnjaneyuluBatta505
AnjaneyuluBatta505 / baseline.txt
Created April 28, 2018 04:37 — forked from acdha/baseline.txt
Benchmark of several Python Excel writing modules
Versions:
python : 2.7.1
openpyxl : 2.2.5
pyexcelerate: 0.6.6
xlsxwriter : 0.7.3
xlwt : 1.0.0
Dimensions:
Rows = 10000
@AnjaneyuluBatta505
AnjaneyuluBatta505 / get_oauth2_token.py
Created April 27, 2018 11:29 — forked from clarketm/get_oauth2_token.py
How to get Google OAuth 2.0 access token in console using the Python API
#!/usr/bin/env python
'''
This script will attempt to open your webbrowser,
perform OAuth 2.0 authentication and print your access token.
To install dependencies from PyPI:
$ pip install oauth2client
Then run this script:
@AnjaneyuluBatta505
AnjaneyuluBatta505 / workon.sh
Created April 23, 2018 06:15
workon is a bash completion function
workon is a function
workon ()
{
typeset -a in_args;
typeset -a out_args;
in_args=("$@");
if [ -n "$ZSH_VERSION" ]; then
i=1;
tst="-le";
else
@AnjaneyuluBatta505
AnjaneyuluBatta505 / create_pdf_using_pdfkit_and_wkhtml.py
Created February 18, 2018 10:56
html to pdf using pdfkit and wkhtmltopdf
import pdfkit
from django.http import HttpResponse
from django.template import loader
def create_pdf(request):
"""
url: https://learnbatta.com/blog/django-html-to-pdf-using-pdfkit-and-wkhtmltopdf-5/
"""
html = loader.render_to_string('invoice.html', {})
output= pdfkit.from_string(html, output_path=False)
@AnjaneyuluBatta505
AnjaneyuluBatta505 / property.py
Created January 26, 2018 12:55
suage of python property
class Person(object):
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
@property
def full_name(self):
return self.first_name + ' ' + self.last_name
@full_name.setter
def full_name(self, value):
first_name, last_name = value.split(' ')
@AnjaneyuluBatta505
AnjaneyuluBatta505 / python_mgetattr.py
Created January 25, 2018 12:48
deep attribute lookup
def mgetattr(obj, lookup):
# deep attribute lookup
for attr in lookup.split('.'):
obj = getattr(obj, attr)
return obj
@AnjaneyuluBatta505
AnjaneyuluBatta505 / blogpost_ld+json.js
Created January 5, 2018 07:02
schema for blogpost in json ld
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BlogPosting",
"mainEntityOfPage":{
"@type":"WebPage",
"@id":"http://applefostering.co.uk/skills-foster/"
},
"headline": "The Skills to Foster",
"image": {
@AnjaneyuluBatta505
AnjaneyuluBatta505 / python_iterator.py
Created December 17, 2017 10:44
Custom python iterator
class Fibonacci:
def __init__(self, limit):
self.limit = limit
self.counter = 0
self.fib_data = []
def __iter__(self):
return self
def next(self):