Skip to content

Instantly share code, notes, and snippets.

View edison7500's full-sized avatar
:octocat:
I may be slow to respond.

err edison7500

:octocat:
I may be slow to respond.
View GitHub Profile
@edison7500
edison7500 / noprefix_i18n.py
Created September 30, 2019 03:00
django default language_code no prefix urls
import re
import logging
from django.conf import settings
from django.urls import LocaleRegexURLResolver
from django.utils.translation import get_language
logger = logging.getLogger("django")
class NoPrefixLocaleRegexURLResolver(LocaleRegexURLResolver):
@edison7500
edison7500 / bmi.py
Created September 11, 2019 07:28
python 计算 BMI
# how to calculate BMI
def BMI(height, weight):
bmi = weight/(height**2)
return bmi
# Driver code
height = 1.79832
weight = 70
# calling the BMI function
@edison7500
edison7500 / plugin.js
Created August 21, 2019 04:05
jquery.plugin.js
import $ from "jquery";
/**
* Generate a jQuery plugin
* @param pluginName [string] Plugin name
* @param className [object] Class of the plugin
* @param shortHand [bool] Generate a shorthand as $.pluginName
*
* @example
* import plugin from 'plugin';
@edison7500
edison7500 / jquery.scrollToTop.js
Last active August 21, 2019 04:05
jquery.scrollToTop.js
import $ from "jquery";
import plugin from "./plugin";
class ScrollToTop {
constructor(element, options) {
const $element = $(element);
$(window).scroll(function () {
if ($(this).scrollTop() > options.offset) {
$element.fadeIn();
@edison7500
edison7500 / model2csv.py
Last active July 16, 2019 03:13
django command model2csv
"""
Prints CSV of all fields of a model.
"""
import csv
import logging
import sys
from django.core.management.base import BaseCommand