Skip to content

Instantly share code, notes, and snippets.

View Billybob's full-sized avatar

Mickael Billybob

View GitHub Profile
@mh-firouzjah
mh-firouzjah / Django-login-required-middleware.md
Last active August 10, 2025 12:44
Django Login Required Middleware

Django Login Required Middleware

if you need users to be loged in first, before visiting your website, so it's easier to use a middleware to check if they're loged in or not. inorder to have such a middleware, use the following code:

# middleware.py
import re

from django.conf import settings
from django.contrib.auth.middleware import AuthenticationMiddleware
@james2doyle
james2doyle / vue.pretty-bytes.filter.js
Last active November 28, 2021 01:07
Vue.js pretty bytes filter. This filter formats bytes into human readable formats
// usage: {{ file.size | prettyBytes }}
Vue.filter('prettyBytes', function (num) {
// jacked from: https://github.com/sindresorhus/pretty-bytes
if (typeof num !== 'number' || isNaN(num)) {
throw new TypeError('Expected a number');
}
var exponent;
var unit;
var neg = num < 0;