Posts

how to install python library manually

  Download the package unzip it if it is zipped cd  into the directory containing setup.py If there are any installation instructions contained in documentation, read and follow the instructions OTHERWISE type in  python setup.py install

Exporting HTML Page into PDF In Django

Views.py from django.shortcuts import render from io import BytesIO from django.http import HttpResponse from django.template.loader import get_template from xhtml2pdf import pisa   from django.views import generic import pandas as pd # Create your views here. # defining the function to convert an HTML file to a PDF file def html_to_pdf ( template_src , context_dict ={}):      template = get_template(template_src)      html  = template.render(context_dict)      result = BytesIO()      pdf = pisa.pisaDocument(BytesIO(html.encode( "ISO-8859-1" )), result)       if not pdf.err:           return HttpResponse(result.getvalue(), content_type = 'application/pdf' )       return None class GeneratePdf ( generic . View ):       def get ( self , request , * args , ** kwargs ):                   ...

Renaming Y-Axis

  options : { scales : { yAxes : [{ ticks : { // Create scientific notation labels callback : function ( value, index, values ) { return value + ' %' ; } } }] } }

Refreshing the previous Page

The following lines of code will refresh your page hen you wanna go back to previous page using browser's  back arrow. < script >     window . addEventListener ( "pageshow" , function ( event ) {   var historyTraversal = event . persisted ||                          ( typeof window . performance != "undefined" &&                               window . performance . navigation . type === 2 );   if ( historyTraversal ) {     // Handle page restore.     window . location . reload ();   } });    

How to disable label on X -Axis

  options: { legend: { display: false },

Deploying a django project on Heroku

 steps to deplay a django project on heroku 1. import django_heroku (settings.py)  => ALLOWED_HOSTS = ['127.0.0.1', '.herokuapp.com'] 2. django_heroku.settings(locals()) (at the end of settings.py) open your repository with Git Bash and run the following commands 3 pip freeze 4. pip freeze > requiremets.txt 5. creating Procfile with no extension (web: gunicorn <Project Name>.wsgi 6. run the commands   $ heroku login   $ git status   $ git add -A .   $ git commit -m "Message"   $heroku config:set DEBUG_COLLECTSTATIC=1   $ heroku config:set DISABLE_COLLECTSTATIC=1   $heroku create -a <app name> ( if you wanna create new app)     heroku git:remote -a example-app r   $ git push heroku main ($ git push --force  heroku main)    summary of commands from step 6: https://devcenter.heroku.com/articles/git

Useful programs in c programming language

C Programming Language/ programs C program to shutdown a computer #include  <dos.h> main() { system("c:\\windows\\system32\\shutdown /s /t 3600");  // means that it will go off after 3600 seconds } C Program To Calculate Mean and Standard Deviation #include<math.h> #include<stdio.h> #define MAX 10 void main() { int i, n; float num[MAX], deviation, sum, sumsqr, mean, variance, stddev; sum = 0; ...