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 / 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 / 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 / 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 / nginx.conf
Created July 17, 2016 11:54 — forked from calebwoods/nginx.conf
Sample Nginx config for deployment of Angular.js app
server { listen 80;
server_name example.com;
access_log /var/log/example.com/nginx.access.log;
error_log /var/log/example.com/nginx.error.log;
root /var/www/apps/example.com/public;
charset utf-8;
location / {
rewrite ^ https://$host$request_uri? permanent;
}

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@Chitrank-Dixit
Chitrank-Dixit / gunicorn_start.bash
Created July 31, 2016 19:03 — forked from postrational/gunicorn_start.bash
Example of how to set up Django on Nginx with Gunicorn and supervisordhttp://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
#!/bin/bash
NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@Chitrank-Dixit
Chitrank-Dixit / create_python_module
Created August 22, 2016 19:01
Python Create and Upload code to the module
The python module basic commands
to clean and remove the module
$ python setup.py sdist (this command will remove the module from your systems python)
$ python setup.py install ( this command will install the module to your system's python)
$ python setup.py register ( this command will register your module to the pypi)
$ python setup.py sdist upload ( this command will upload your newer module version)