This file contains 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 HttpResponse | |
# imports for reportlab | |
import time | |
from reportlab.lib import colors | |
from reportlab.lib.enums import TA_JUSTIFY | |
from reportlab.lib.pagesizes import letter | |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image,\ | |
Table, TableStyle | |
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle |
This file contains 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 pyPdf | |
>>> output = pyPdf.PdfFileWriter() | |
>>> files = ['a.pdf', 'b.pdf'] | |
>>> pdf_path = '/home/jinesh/Documents/' | |
>>> for file in files: | |
... pdf = pdf_path + file | |
... f = open(pdf, 'rb') | |
... input = pyPdf.PdfFileReader(f) |
This file contains 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://oliverdavies.co.uk/blog/2011/10/19/install-and-configure-subversion-svn-server-ubuntu | |
# http://odyniec.net/articles/ubuntu-subversion-server/ | |
$ sudo mkdir /home/svn | |
$ sudo mkdir ~/ecomexpress | |
$ sudo svnadmin create /home/svn/ecomexpress -m 'initial project structure' | |
$ cd ~/ecomexpress 1 |
This file contains 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
def get_shipments_in_range(customer, date_on): | |
q = Q() | |
q = q & Q(shipper_id = int(customer.id)) | |
dt = datetime.datetime.strftime(date_to, "%Y-%m-%d") | |
df = dt - datetime.timedelta(days=dt.day-1) | |
date_to = dt.strftime("%Y-%m-%d") | |
date_from = df.strftime("%Y-%m-%d") | |
q = q & Q(added_on__range=(date_from,date_to)) | |
shipments = Shipment.objects.filter(q) | |
return shipments |
This file contains 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
#reference: http://stackoverflow.com/a/7678125/846193 | |
import traceback | |
from multiprocessing.pool import Pool | |
import multiprocessing | |
# Shortcut to multiprocessing's logger | |
def error(msg, *args): | |
return multiprocessing.get_logger().error(msg, *args) |
This file contains 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
os.system("nohup /usr/bin/python /home/path/billing.py arg1 arg2 arg3 > /dev/null & ") |
This file contains 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
# to get the process details using pid | |
ps -p $PID -o pid,vsz=MEMORY -o user,group=GROUP -o comm,args=ARGS | |
$/proc/$PID/stat | |
# nohup - run a process even if we close the terminal. The below command will run | |
# the script(startbilling.py) with parameters ('20130601' '20130630' | |
# '/home/web/ecomm.prtouch.com/ecomexpress/static/uploads/billing/bill.xls') | |
# and write log to /home/jinesh/bill.log | |
$ nohup /usr/local/bin/python scripts/billscript/startbilling.py '20130601' '20130630' '/home/web/ecomm.prtouch.com/ecomexpress/static/uploads/billing/bill.xls' > /home/jinesh/bill.log & |
This file contains 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
data:text/html, <html contenteditable> | |
data:text/html, <html contenteditable><style>body {color: #333; width: 960px; margin: 0 auto; display: block; height: 100%; font-size: 36px; padding: 20px;}</style></html> | |
data:text/html, <html><head><link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'><style type="text/css"> html { font-family: "Open Sans" } * { -webkit-transition: all linear 1s; }</style><script>window.onload=function(){var e=false;var t=0;setInterval(function(){if(!e){t=Math.round(Math.max(0,t-Math.max(t/3,1)))}var n=(255-t*2).toString(16);document.body.style.backgroundColor="#ff"+n+""+n},1e3);var n=null;document.onkeydown=function(){t=Math.min(128,t+2);e=true;clearTimeout(n);n=setTimeout(function(){e=false},1500)}}</script></head><body contenteditable style="font-size:2rem;line-height:1.4;max-width:60rem;margin:0 auto;padding:4rem;"> |
This file contains 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 datetime | |
>>> from django.utils.timezone import utc | |
>>> date_to = datetime.datetime(2013,05,07,tzinfo=utc) | |
>>> date_from = datetime.datetime(2013,05,05, tzinfo=utc) | |
>>> q = Q() | |
>>> q = q & Q(shipper=4) | |
>>> q = q & Q(inscan_date__gte=date_from, inscan_date__lte=date_to) | |
>>> sps = Shipment.objects.filter(q) |