This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 _ |