brew install docker --cask
from /Applications/Docker.app
Wait until the "Docker Dashboard starting…"-message disappears (= Setup complete)
""" | |
Single Responsibility Principle | |
“…You had one job” — Loki to Skurge in Thor: Ragnarok | |
A class should have only one job. | |
If a class has more than one responsibility, it becomes coupled. | |
A change to one responsibility results to modification of the other responsibility. | |
""" | |
class Animal: | |
def __init__(self, name: str): |
from django.test import TestCase, RequestFactory | |
from django.views.generic import TemplateView | |
from ..lib.views import YourMixin | |
class YourMixinTest(TestCase): | |
''' | |
Tests context-data in a Django Mixin like a boss | |
''' |
<!doctype html> | |
<title>Site Maintenance</title> | |
<style> | |
body { text-align: center; padding: 150px; } | |
h1 { font-size: 50px; } | |
body { font: 20px Helvetica, sans-serif; color: #333; } | |
article { display: block; text-align: left; width: 650px; margin: 0 auto; } | |
a { color: #dc8100; text-decoration: none; } | |
a:hover { color: #333; text-decoration: none; } | |
</style> |
# Microphone Realtime background noise reduction script | |
# author Luigi Maselli - https://grigio.org licence: AS-IS | |
# credits: http://askubuntu.com/questions/18958/realtime-noise-removal-with-pulseaudio | |
# run as: sudo && pulseaudio -k | |
# wget -qO - https://gist.github.com/adrianolsk/bfa32f3227dc674eff72a2008f6c0316 | sudo bash && pulseaudio -k | |
sudo cp /etc/pulse/default.pa /etc/pulse/default.pa.bak | |
sudo cat <<EOT >> /etc/pulse/default.pa | |
load-module module-echo-cancel source_name=noechosource sink_name=noechosink |
import numpy as np | |
import pylab as pl | |
import pandas as pd | |
from sklearn import svm | |
from sklearn import linear_model | |
from sklearn import tree | |
from sklearn.metrics import confusion_matrix |
# initial version: http://stackoverflow.com/a/7936523/617185 \ | |
# by Mikhail Kashkin(http://stackoverflow.com/users/85739/mikhail-kashkin) | |
def get_yt_video_id(url): | |
"""Returns Video_ID extracting from the given url of Youtube | |
Examples of URLs: | |
Valid: | |
'http://youtu.be/_lOT2p_FCvA', | |
'www.youtube.com/watch?v=_lOT2p_FCvA&feature=feedu', |
List compiled by Amit Agarwal
from re import compile | |
from django.conf import settings | |
from django.http import HttpResponseRedirect | |
from django.utils.http import is_safe_url | |
EXEMPT_URLS = [compile(settings.LOGIN_URL.lstrip('/'))] | |
if hasattr(settings, 'LOGIN_EXEMPT_URLS'): | |
EXEMPT_URLS += [compile(expr) for expr in settings.LOGIN_EXEMPT_URLS] | |
class LoginRequiredMiddleware: |
di Django, kita bisa menggunakan authentication framework
untuk membuat aksi-aksi seperti login
, logout
dan sebagainya. biasanya saat kita memanfaatkan view built-in django.contrib.auth.views.login
untuk login, kita hanya boleh login dengan username
dan password
secara default. nah bagaimana misalnya dalam suatu proyek, aplikasi yang kita buat juga bisa menggunakan username
, email
dan password
? di sini saya mau mengucapkan terimakasih kepada Antonio Mele yang mau berbagi bagaimana membuat Authentication Backend agar email
user bisa digunakan untuk login.
di sini saya punya project bernama bookmarks
dan aplikasi bernama account
. sekarang buat terlebih dahulu file auth backendnya bernama authentication.py
di dalam direktori account
lalu isikan dengan kode berikut ini:
from django.contrib.auth.models import User