Skip to content

Instantly share code, notes, and snippets.

View sandiprb's full-sized avatar
🏠
Working from home

Sandip B sandiprb

🏠
Working from home
View GitHub Profile
@dokterbob
dokterbob / fields.py
Created March 18, 2011 19:07
Email field with domain existence validation for Django.
import logging
logger = logging.getLogger(__name__)
# Note: we need dnspython for this to work
# Install with `pip install dnspython`
import dns.resolver, dns.exception
from django import forms
from django.utils.translation import ugettext as _
@fwielstra
fwielstra / api.js
Created June 14, 2011 14:46
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@x86ed
x86ed / blag_model.py
Created March 30, 2012 03:57
Django blog model
import urllib2
import mimetypes
from django.conf import settings
from django.db import models
from django.contrib.auth.models import User
class Category(models.Model):
name = models.CharField(max_length=32)
class Meta:
@kezabelle
kezabelle / models.py
Created April 20, 2015 08:12
Is there a better way of handling sometimes prefetched data in Django models than this?
class MyRelation(models.Model):
"""
This simple example demonstrates the fat model which needs some related data,
but obviously can't know [without introspecting as I'm doing here] whether or
not it needs to eagerly fetch the data, or whether it can just enumerate
the prefetch results.
"""
def prefetched_active_users(self):
# assumes .prefetch_related('users') has happened.
@learncodeacademy
learncodeacademy / webpack.config.js
Created January 8, 2016 03:55
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
@craigvantonder
craigvantonder / flush-dns.sh
Last active February 3, 2021 04:42
Flushing the DNS in Ubuntu 16.04
#!/bin/bash
# NB: First install nscd with sudo apt-get install nscd
# run this command to flush dns cache:
sudo /etc/init.d/dns-clean restart
# or use:
sudo /etc/init.d/networking force-reload
# Flush nscd dns cache:
sudo /etc/init.d/nscd restart
@busypeoples
busypeoples / FlowReactTutorial.js
Last active July 17, 2023 10:12
Flow Fundamentals For ReactJS Developers
//
// MIT License
//
// Copyright (c) 2018 Ali Sharif
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is