Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

agusmakmun

🏠
Working from home
View GitHub Profile
@agusmakmun
agusmakmun / 1.srp.py
Created December 22, 2022 14:36 — forked from dmmeteo/1.srp.py
SOLID Principles explained in Python with examples.
View 1.srp.py
"""
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):
View django-models-choices.py
import operator
from collections import OrderedDict
from django.utils.translation import gettext_lazy as _
class EnumMetaClass(type):
def __init__(cls, name, bases, classdict):
def _human_enum_values(enum):
return cls.__choices__[enum]
@agusmakmun
agusmakmun / mac-cheat-sheet.md
Last active October 21, 2021 04:14
Mac Cheat Sheet
View mac-cheat-sheet.md
  1. Minimize app in dock: Opt + Click the icon app (https://apple.stackexchange.com/a/38201)
  2. Screenshot: ⌘ cmd + Shift + 3/4
  3. Record Screen: ⌘ cmd + Shift + 5 - https://support.apple.com/en-us/HT208721
  4. Set primary display: https://www.addictivetips.com/mac-os/set-the-primary-display-on-macos/
  5. GIF Screen Recorder: ???
  6. Set default editor to nano: https://unix.stackexchange.com/a/501863
  7. Resize window: https://www.theverge.com/2020/3/6/21168153/macos-catalina-windows-size-rearrange-how-to
  8. See all opened windows: System Preferences > Mission Control > Keyboard & Mouse Shortcuts => Mission Control : Left Option - https://support.apple.com/guide/mac-help/open-windows-spaces-mission-control-mh35798/mac
  9. make auto-hide/show for the dock faster - https://apple.stackexchange.com/a/46222 defaults write com.apple.dock autohide-time-modifier -float 0.5;killall Dock
@agusmakmun
agusmakmun / django-modify-admin-login-form.md
Last active September 29, 2021 08:37
Modify the default Django admin login form without modifying the entire models to new AdminSite
View django-modify-admin-login-form.md

For example we want to modify the default login form with only add new reCAPTCHA feature. Ya, because previously I have an issue about brute forcing password to this page. So, we should add it reCAPTCHA to fix the fuln issue.

Option 1

We can just overwrite the default admin site from django.

  1. myapp/forms.py
@agusmakmun
agusmakmun / 1.permissions-haulier.json
Last active November 5, 2020 07:57
can be partial & FE doesn't need to send the "description" field because it read-only fields. Note: this valid format focused on "generalPermissions".
View 1.permissions-haulier.json
{
"dashboard": {
"generalPermissions": []
},
"scheduler": {
"generalPermissions": [
{
"code": "scheduler.add_plantrip",
"description": "Can add plan trip"
},
@agusmakmun
agusmakmun / 1.interview-voice.md
Last active November 1, 2020 23:32
Interview
View 1.interview-voice.md
  1. Introduction about yourself.

Let me introduce my self, My name is Agus Makmun, and I was 26 years old. I come from South Sumatera, indonesia. And I was bachelor's degree in computer science at university muhammadiyah of surakarta.

I have exposure working every aspect of the software development with Python, Django, Rest API, Web Development, AWS (Lightsail, S3, EC2, RDS), Digital Ocean, Python Anywhere, other VPS Deployment, Microservices & Legal Scraping.

@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)
View test_views.py
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 / notif-me.md
Created March 12, 2020 04:52
How to make a notification when terminal process is complete
View notif-me.md

I have started a long process through a terminal. Is it possible to make the Ubuntu terminal make a sound once the process is complete? This way, I don’t need to keep checking, but will instead be notified through a sound or another notification.

You can use this some alternatives;

$ your-bash-command && aplay /path/to/sound.wav  # can also with *.ogg file.
View Lamidi Store.md

Toko Sembako LAMIDI, menyediakan:

Produk

Kebutuhan Pokok Herbal Lainnya
Beras Air Zam-zam Aneka Sabun & Samphoo
Gas LPG Kopi Radix Aneka Jajan
Bensin/Pertalite Odol Radix Aneka Minuman
Dedak Minyak Zaitun Aneka Bumbu dapur
@agusmakmun
agusmakmun / gist:6bef2e4b4d86141b7bb248c01fa94604
Created July 24, 2019 13:58 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
View gist:6bef2e4b4d86141b7bb248c01fa94604
<!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>