Skip to content

Instantly share code, notes, and snippets.

nix1947 / gist:56e66d1b9d9043e7366ec5f452f64baf
Created Sep 23, 2021
unique column with multiple column in mysql. (Useful for one to one relation)
View gist:56e66d1b9d9043e7366ec5f452f64baf
-- One to one relation between user_order and shipping_address table.
create table user_order ADD UNIQUE index("id", "shipping_address_id");
nix1947 / gist:dc68cd741c3bb4cb6068220bf0c61c31
Created Sep 23, 2021
Creating a foreign key table in mysql with references.
View gist:dc68cd741c3bb4cb6068220bf0c61c31
-- 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 / index.html
Created Jul 10, 2018 — forked from IanSmith89/index.html
Materialize Cheatsheet
View index.html
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Materialize It!</title>
// Google Material Icons
<link href="" rel="stylesheet">
// Google Material CSS
nix1947 /
Created Jun 8, 2018 — forked from hatarist/
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 / Basic MultiValueField MultiWidget
Created Feb 28, 2018 — forked from elena/Basic MultiValueField MultiWidget
Super Basic Django MultiValueField / MutliWidget example
View Basic MultiValueField MultiWidget
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 /
Created Feb 20, 2018 — forked from neara/
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 /
Created Jan 31, 2018 — forked from lancejpollard/
Complete List of HTML Meta Tags

Copied from

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 /
Created Oct 15, 2017 — forked from palewire/
My current default Django LOGGING configuration
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
'null': {
nix1947 / append.html
Created Jul 31, 2017
jquery multiple elements appending
View append.html
// create thumbnail tag
var li = $("<li></li>");
var h3 = $("<h3></h3>");
var p = $("<p></p>", {
text: itemTitle
View django ajax
def course_ajax_search(request):
if request.method == "POST":
search_text = request.POST.get('search_text')
# Full text search
if len(search_text) < 2:
return HttpResponse(" ")
courses = Course.objects.filter(