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
#!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 / 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 / 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 / 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 / deps.pp
Created September 12, 2016 19:25 — forked from rcrowley/deps.pp
Deploying Django with Puppet
stage { "pre": before => Stage["main"] }
class python {
package {
"build-essential": ensure => latest;
"python": ensure => "2.6.6-2ubuntu1";
"python-dev": ensure => "2.6.6-2ubuntu1";
"python-setuptools": ensure => "latest";
}
exec { "easy_install pip":
path => "/usr/local/bin:/usr/bin:/bin",