Skip to content

Instantly share code, notes, and snippets.

View Chitrank-Dixit's full-sized avatar
🎯
Focusing

Chitrank Dixit Chitrank-Dixit

🎯
Focusing
View GitHub Profile
@Chitrank-Dixit
Chitrank-Dixit / base.html
Created June 30, 2016 15:42 — forked from techietek/base.html
django-grappelli import_export buttons not being styled
{% extends "admin/base_site.html" %}
{% load i18n admin_static admin_modify %}
{% load admin_urls %}
{% load url from future %}
{% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %}
{% if not is_popup %}
{% block breadcrumbs %}
<ul>
<li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></li>
@Chitrank-Dixit
Chitrank-Dixit / Django EC2 Ubuntu
Created March 17, 2016 18:36 — forked from eezis/Django EC2 Ubuntu
Django on Amazon EC2 using Ubuntu
ALSO SEE THIS: http://eddychan.com/post/18484749431/minimum-viable-ops-deploying-your-first-django-app-to
AND THIS: http://bitnami.com/stack/django
These are my notes on how to quickly setup a python, virtualenv (use virtualenv-burrito FTW), and django.
Setup an EC-2 instance:
=======================
Use the quick launch wizard:
@Chitrank-Dixit
Chitrank-Dixit / latex_cleaner.py
Created September 8, 2015 06:28
clean latex file remove all formatting and just keep the mathematical equations formatting active.
def get_all_data(datasource):
#print "In get_all_data"
#datasource = datasource.replace('\n','')
start = datasource.find('\\textb')
#import pdb; pdb.set_trace()
#print start
if start == -1:
return None,0
st_data = datasource.find('f', start)
@Chitrank-Dixit
Chitrank-Dixit / libsass-install.bash
Last active August 29, 2015 14:26 — forked from edouard-lopez/libsass-install.bash
Installing/Compiling libsass and sassc on Ubuntu 14.04+/Linux Mint 17+ (needed by node-sass)
# Based on https://github.com/sass/libsass/wiki/Building-with-autotools
# Install dependencies
apt-get install automake libtool
# Fetch sources
git clone https://github.com/sass/libsass.git
git clone https://github.com/sass/sassc.git libsass/sassc
# Create configure script
@Chitrank-Dixit
Chitrank-Dixit / search_keyword.py
Created July 8, 2015 06:34
The following program searches for the occurrence of a keyword from a supplied page
# This is the script download a page from the server and then search from it the required keyword
import urllib2
def get_all_occurences(page):
length = len(keyword)
start_link = page.find(keyword)
if start_link == -1:
return None, 0
end_quote = start_link + length
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask.ext.httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
@Chitrank-Dixit
Chitrank-Dixit / web_crawler.py
Last active November 27, 2016 09:46
simple web crawler to crawl through pages using urllib2 python module
# Write a web crawler
'''
A crawler is a program that starts with a url on the web (ex: http://python.org), fetches the web-page corresponding to that url, and parses all the links on that page into a repository of links. Next, it fetches the contents of any of the url from the repository just created, parses the links from this new content into the repository and continues this process for all links in the repository until stopped or after a given number of links are fetched.
'''
# urllib2 for downloading web pages
import urllib2
# get_next_target() takes a page and checks for the positions of the links it finds from '<a href='
@Chitrank-Dixit
Chitrank-Dixit / extract_mail.py
Created February 2, 2014 21:21
Extract Email from the pages , text files etc using Python re module (Regular Expressions)
# this is the correct program
import re
import urllib2
# get_next_target() takes a page and checks for the positions of the links
def get_next_target(page):
match=re.findall(r'[\w.-]+@[\w.-]+',page)
if match:
return match
@Chitrank-Dixit
Chitrank-Dixit / lexical_analyser.py
Last active October 7, 2022 16:40
The following Python Program takes the C program and Perform Lexical analysis over a simple C program (Very Buggy Program need to fix more instances)
# The Following Program would work as Lexical Analyser
#
# Write a C/C++ program which reads a program written
# in any programming language (say C/C++/Java) and then perform
# lexical analysis. The output of program should contain the
# tokens i.e. classification as identifier, special symbol, delimiter,
# operator, keyword or string. It should also display the number of
# identifiers, special symbol, delimiter, operator, keyword, strings
# and statements
@Chitrank-Dixit
Chitrank-Dixit / edit_date.py
Created December 29, 2013 04:42
Converting a Date from dd/mm/yyyy format to yyyy/mm/dd format in python a simple script The date are in the file 'testdate.txt' in dd/mm/yyyy format and after conversion look at convDate list
# from dd/mm/yyyy to yyyy/mm/dd format of dates
f = open('testdate.txt')
i = f.read()
print i
date = i.split("\n")
print date
convDate = []
for adate in date:
if '/' in adate: