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 / 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
#!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 / 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
@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 / 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 / app.py
Created September 20, 2013 04:15 — forked from scturtle/app.py
from flask import Flask, request, session, redirect, url_for
import urllib
import requests
app = Flask(__name__)
app.secret_key = 'iwonttellyou'
redirect_uri = 'http://localhost:5000/callback'
client_id = '' # get from https://code.google.com/apis/console
client_secret = ''
@Chitrank-Dixit
Chitrank-Dixit / custom_panel.css
Created November 4, 2013 15:58
Customized Panels that we used in Eventus trending_event.html and profile.html
.well-inverse {
min-height: 20px;
padding: 19px;
margin-bottom: 20px;
background-color: #ffffff;
border: 1px solid #e3e3e3;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
/* -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.05);
@Chitrank-Dixit
Chitrank-Dixit / getJson.js
Last active December 27, 2015 20:29
get JSON data from any url in knockoutjs
// write this snippet inside the Knockout viewModel
// getting all the comments from the server
$.getJSON("comments.php", function(commentModels) {
var t = $.map(commentModels.comments, function(item) {
return new Comment(item);
});
self.comments(t);
});
@Chitrank-Dixit
Chitrank-Dixit / sendJson.js
Created November 9, 2013 11:35
Send the Form Data as JSON in Knockoutjs
// write this under Knockout viewModel
// This is an example to send all the users comments to the server
// Basic Example we can fit it for other purposes as well
self.save = function() {
return $.ajax({
url: "comments.php",
contentType: 'application/json',
type: 'POST',
data: JSON.stringify({
@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: