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 / 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 / Basic MultiValueField MultiWidget
Created February 28, 2018 10:52 — forked from elena/Basic MultiValueField MultiWidget
Super Basic Django MultiValueField / MutliWidget example
"""
An example of minimum requirements to make MultiValueField-MultiWidget for Django forms.
"""
import pickle
from django.http import HttpResponse
from django import forms
from django.template import Context, Template
from django.views.decorators.csrf import csrf_exempt
@nix1947
nix1947 / gist:56e66d1b9d9043e7366ec5f452f64baf
Created September 23, 2021 01:51
unique column with multiple column in mysql. (Useful for one to one relation)
-- One to one relation between user_order and shipping_address table.
create table user_order ADD UNIQUE index("id", "shipping_address_id");
@nix1947
nix1947 / gist:dc68cd741c3bb4cb6068220bf0c61c31
Created September 23, 2021 01:49
Creating a foreign key table in mysql with references.
-- Creating a table with foreign key references.
create table user_order(
id int not null PRIMARY key AUTO_INCREMENT,
user_id int not null,
shipping_address_id int not null,
order_date timestamp DEFAULT CURRENT_TIMESTAMP,
total_quantity int not null,
total_price int not null,
FOREIGN KEY (user_id) REFERENCES user(id),
FOREIGN KEY (shipping_address_id) REFERENCES shipping_address(id)
@nix1947
nix1947 / index.html
Created July 10, 2018 02:43 — forked from IanSmith89/index.html
Materialize Cheatsheet
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Materialize It!</title>
// Google Material Icons
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
// Google Material CSS
@nix1947
nix1947 / ipv6gen.py
Created June 8, 2018 01:15 — forked from hatarist/ipv6gen.py
I'm a lazy ass who didn't think it's worth to bother with the standard ipaddress library
import random
import sys
from netaddr import IPNetwork, IPAddress
def generate_random_ipv6(subnet):
network = IPNetwork(subnet)
return str(IPAddress(random.randrange(network.first, network.last)))
@nix1947
nix1947 / forms.py
Created February 20, 2018 07:23 — forked from neara/forms.py
Django Class Based Views and Inline Formset Example
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from models import Sponsor, Sponsorship
class SponsorForm(ModelForm):
class Meta:
model = Sponsor
@nix1947
nix1947 / meta-tags.md
Created January 31, 2018 07:47 — forked from lancejpollard/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@nix1947
nix1947 / settings.py
Created October 15, 2017 07:08 — forked from palewire/settings.py
My current default Django LOGGING configuration
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
},
'null': {
'level':'DEBUG',