Skip to content

Instantly share code, notes, and snippets.

View nix1947's full-sized avatar
:octocat:
Pro

Manoj Gautam nix1947

:octocat:
Pro
View GitHub Profile
@nix1947
nix1947 / dynamic rows loading
Created February 11, 2017 03:45
dynamically populating rows and columns of bootstrap in django template
<div class="container">
{% for project in projects %}
{% if forloop.counter0|divisibleby:3 %} <div class="row text-center"> {% endif %}
<div class="col-md-4" onclick="window.location.href='{% url 'club:robotics_detail' project.id %}'" style="cursor: pointer">
<div class="card">
<img src="http://placehold.it/300X150" alt="">
<div class="card-content">
<br>
<h4>Project {{ forloop.counter }}</h4>
<hr>
@nix1947
nix1947 / card.html
Created February 11, 2017 02:59
bootstra3 simple cards
<style>
/* card css */
.card{
background-color: red;
margin: 0;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
border-radius: 5px; /* 5px rounded corners */
}
@nix1947
nix1947 / example.conf
Created February 7, 2017 10:03
nginx configuration for django
upstream example {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
server unix:/webapps/example.com/gunicorn.sock fail_timeout=0;
}
server{
listen 80;
@nix1947
nix1947 / supervisor.conf
Created February 7, 2017 09:59
supervisor configuration for django
[program:example]
command=/webapps/example.com/gunicorn_start.sh
user=webapps
stdout_logfile=/webapps/example.com/logs/gunicorn_supervisor.log
redirect_stderr=true
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8
@nix1947
nix1947 / gunicorn_start.sh
Created February 7, 2017 09:57
gunicorn_start.sh
#!/bin/bash
# Purpose: Gunicorn starter
# Author: manojit.gautam@gmail.com
# Name of an application
NAME="Your projectname"
# project directory
PROJECTDIR=/webapps/example.com
# django project virutalenv directory
VENVDIR=/webapps/example.com/venv
# Project source directory
@nix1947
nix1947 / gist:5478a5e321f093fb52f7c59f7228f014
Created February 5, 2017 09:21
Enable media display in django in development server
1. Enable the media context processor, from settings.py file
django.template.context_processors.media
2. Set MEDIA_URL and MEDIA_ROOT in settings.py file
MEDIA_URL = '/media'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
3. Serve the media from development server in url.py file
# Serving media files during development
@nix1947
nix1947 / pre-push
Created February 3, 2017 09:59
prevent accidental push to master branch while using git
#!/bin/bash
# save this script to .git/hooks/pre-push
# Change the permission as chmod +x .git/hooks/pre-push
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
read -p "You're about to push master, is that what you intended? [y|n] " -n 1 -r < /dev/tty
@nix1947
nix1947 / es6.js
Last active December 20, 2016 18:15
Es6 cheatsheet
// Defining new function in Es6
// App is the
const App = () => {
return "Hello world";
}
// new keyword
const = "Title" // Can only assigned once.
// Exporting the module
@nix1947
nix1947 / faicon-circle.css
Last active December 18, 2016 07:35
font-awesome-circle-icon
.fa-icon{
background-color: #2D3033;
color: silver;
padding: 10px;
border-radius: 50%;
text-align: center;
vert-align: middle;
width: 30px;
height: 30px;
@nix1947
nix1947 / banner.scss
Last active December 12, 2016 12:36
Create black transparent overlay over background image in banner
.jumbotron{
//background-image: url("http://www168.lunapic.com/editor/images/slide21.jpg");
background-image: url('/static/images/banner.jpg');
background-size: cover;
box-shadow: inset 0 0 0 1000px rgba(0,0,0,.5);
background-position: center;
}
// some helper classes for bootstrap3