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 / admin.py
Last active January 29, 2017 09:48
Django Question Models System, see also: http://stackoverflow.com/q/40784376/6396981
from django.contrib import admin
from app_name.models import *
class AnswerAdmin(admin.ModelAdmin):
list_display = ['question', 'answer', 'score']
list_filter = ['question__type', 'score']
search_fields = ['question__title', 'answer', 'score']
raw_id_fields = ['question']
@agusmakmun
agusmakmun / uuidPhoneDecrypter.py
Last active September 25, 2018 00:11
UUID Phone Decrypter
import sys
import uuid
import time
import itertools
import argparse
# UUID Phone Decrypter
# Author: Summon Agus (github.com/agusmakmun)
# MIT License
@agusmakmun
agusmakmun / result-data.json
Last active January 25, 2017 03:51
Semantic UI Realtime Search: https://jsfiddle.net/agaust/5854gae9/2/ (with default button show more results) and https://jsfiddle.net/agaust/5854gae9/4/ (only show button more results if under limited items).
{
"action": {
"text": "View all 429 results",
"url": "/path/to/results"
},
"total_found": 439,
"limited_items": true,
"items": [
{
"profile_url": "/profile/amanda",

For Ubuntu

These errors indicate that there is some problem with DNS.

  • check cat /etc/resolv.conf for your DNS settings.
  • And add following name server in /etc/resolv.conf for temporary or in /etc/resolvconf/resolv.conf.d/head for permanent
nameserver 8.8.8.8
nameserver 8.8.4.4
@agusmakmun
agusmakmun / django-oder.py
Last active January 21, 2017 09:50
Django Order Ascending & Descending - Question: http://stackoverflow.com/q/41775641/6396981
def topic_threads(request, topic_slug):
"""
return all threads that contains with this topic.
:param `topic_slug` is slug from the topic.
"""
numb_pages = 10
get_page = request.GET.get('page')
template_name = 'path/to/topic_threads.html'
topic = get_object_or_404(Topic, slug=topic_slug)
threads = Thread.objects.published().filter(topic=topic)

Keybase proof

I hereby claim:

  • I am agusmakmun on github.
  • I am agusmakmun (https://keybase.io/agusmakmun) on keybase.
  • I have a public key whose fingerprint is D3DE F045 5B47 C435 B922 B02E 914B 3FA0 7E53 D974

To claim this, I am signing this object:

1. Signup at https://keybase.io

2. Installing, learn more: https://keybase.io/download Example: Ubuntu 32bit

curl -O https://prerelease.keybase.io/keybase_i386.deb
sudo dpkg -i keybase_i386.deb
sudo apt-get install -f
run_keybase
import hashlib
from django import template
try:
# Python 3
from urllib.parse import urlencode
except:
from urllib import urlencode
register = template.Library()
@agusmakmun
agusmakmun / models.py
Last active January 10, 2017 15:57
Django Forum Notifications Concept
class Notification(TimeStampedModel):
sender = models.ForeignKey(User, related_name='sender_notification')
receiver = models.ForeignKey(User, related_name='receiver_notification')
content_type = models.ForeignKey(
ContentType, related_name='notification', on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
STATUS_CHOICES = (
('mention', _('Mention')),
('reply', _('Reply Comment')),