Skip to content

Instantly share code, notes, and snippets.

View AnjaneyuluBatta505's full-sized avatar

Anjaneyulu Batta AnjaneyuluBatta505

View GitHub Profile
@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 / 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 / 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 / supervisor.conf
Created July 26, 2018 11:55 — forked from hezhao/myapp.conf
Example supervisor config file /etc/supervisor/conf.d/myapp.conf
[program:myapp]
autostart = true
autorestart = true
command = python /home/pi/myapp.py
environment=SECRET_ID="secret_id",SECRET_KEY="secret_key_avoiding_%_chars"
stdout_logfile = /home/pi/stdout.log
stderr_logfile = /home/pi/stderr.log
startretries = 3
user = pi
@AnjaneyuluBatta505
AnjaneyuluBatta505 / login_required.py
Created September 4, 2018 11:06 — forked from robgolding/login_required.py
Django Class-Based View Mixins: Part 1
class LoginRequiredMixin(object):
"""
View mixin which requires that the user is authenticated.
"""
@method_decorator(login_required)
def dispatch(self, request, *args, **kwargs):
return super(LoginRequiredMixin, self).dispatch(
self, request, *args, **kwargs)
@AnjaneyuluBatta505
AnjaneyuluBatta505 / is_valid_lookup_field_for_model.py
Created November 8, 2018 07:08
django: check if given lookup string is valid for given model
from django.db.models.constants import LOOKUP_SEP
from django.core.exceptions import FieldDoesNotExist
# django: check if given lookup string is valid for given model
def is_valid_lookup_field(model, lookup):
# will return first non relational field's verbose_name in lookup
for part in lookup.split(LOOKUP_SEP):
print(part)
try:
@AnjaneyuluBatta505
AnjaneyuluBatta505 / array_of_arrays.sql
Created November 16, 2018 12:53
merge array of arrays in postgresql with array_agg
--select ARRAY(select distinct unnest(array_agg(category.arr)))
select ARRAY(select distinct unnest(array[array[1,2,3], array[4,2,8]]))
@AnjaneyuluBatta505
AnjaneyuluBatta505 / wkhtmltopdf.sh
Created December 6, 2018 13:40 — forked from faniska/wkhtmltopdf.sh
Install wkhtmltopdf with patched QT on Ubuntu Linux
# Uncomment the next line if you have installed wkhtmltopdf
# sudo apt remove wkhtmltopdf
cd ~
# Select an appropriate link for your system (32 or 64 bit) from the page https://wkhtmltopdf.org/downloads.html and past to the next line
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvf wkhtmltox*.tar.xz
sudo mv wkhtmltox/bin/wkhtmlto* /usr/bin
sudo apt-get install -y openssl build-essential libssl-dev libxrender-dev git-core libx11-dev libxext-dev libfontconfig1-dev libfreetype6-dev fontconfig
@AnjaneyuluBatta505
AnjaneyuluBatta505 / create_normal.html
Created January 4, 2019 09:12 — forked from taranjeet/create_normal.html
Django Library: Normal form js code
<!-- create_normal.html :: part 4 -->
<script type='text/javascript'>
function updateElementIndex(el, prefix, ndx) {
var id_regex = new RegExp('(' + prefix + '-\\d+)');
var replacement = prefix + '-' + ndx;
if ($(el).attr("for")) $(el).attr("for", $(el).attr("for").replace(id_regex, replacement));
if (el.id) el.id = el.id.replace(id_regex, replacement);
if (el.name) el.name = el.name.replace(id_regex, replacement);
}
@AnjaneyuluBatta505
AnjaneyuluBatta505 / tmux.md
Created January 26, 2019 09:23 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a