Skip to content

Instantly share code, notes, and snippets.

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

agusmakmun

🏠
Working from home
View GitHub Profile
@agusmakmun
agusmakmun / a_Docker setup.md
Created March 20, 2024 16:35 — forked from Swiss-Mac-User/a_Docker setup.md
Installing SonarQube on Docker and SonarScanner using Homebrew on macOS

Docker setup

Install the Docker UI application for macOS

brew install docker --cask

Open the Docker.app

from /Applications/Docker.app

Go to the Docker Dashboard

Wait until the "Docker Dashboard starting…"-message disappears (= Setup complete)

@agusmakmun
agusmakmun / 1.srp.py
Created December 22, 2022 14:36 — forked from dmmeteo/1.srp.py
SOLID Principles explained in Python with examples.
"""
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):
@agusmakmun
agusmakmun / test_views.py
Created May 8, 2020 06:57 — forked from dnmellen/test_views.py
How to create a unittest for a "View" Mixin (Django Testing)
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
'''
@agusmakmun
agusmakmun / gist:6bef2e4b4d86141b7bb248c01fa94604
Created July 24, 2019 13:58 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!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
@agusmakmun
agusmakmun / svmflag.py
Created November 23, 2017 04:36 — forked from glamp/svmflag.py
Plotting SVM predictions using matplotlib and sklearn
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
@agusmakmun
agusmakmun / get_yt_video_id.py
Last active November 19, 2017 22:47 — forked from kmonsoor/get_yt_video_id.py
Extract Video-ID from a Youtube url
# 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',
@agusmakmun
agusmakmun / google-chrome-extensions.md
Created December 25, 2016 11:31 — forked from labnol/google-chrome-extensions.md
Google Chrome Extensions

Best Google Chrome Extensions

List compiled by Amit Agarwal

  1. Vimium — Power users can browse the web using keyboard shortcuts. No mouse required.
  2. Buffer — Share links to multiple social websites with a go.
  3. PushBullet — Send web links, text notes and even push files from computer to your phone.
  4. Clip Better — Don't send raw links over email, send previews that suggest what a link is all about.
  5. Streamus — A YouTube music play for Chrome that also includes a radio.
  6. Mighty Text — Send and receive SMS text messages from your desktop
@agusmakmun
agusmakmun / LoginRequiredMiddleware.py
Created October 20, 2016 04:09 — forked from r0yfire/LoginRequiredMiddleware.py
Django Login Required Middleware
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:
@agusmakmun
agusmakmun / auth_backend.md
Created October 11, 2016 12:08 — forked from solanoize/auth_backend.md
Menambahkan Authentication Backend di Django agar user bisa login dari emailnya

Pendahuluan

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.

Solusi

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