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 / git-branch-gh-pages.md
Last active January 4, 2017 09:37
Simply tutorial how to work with git branch, ex: to create github page (gh-pages)
{
"ids": [
"#cfs_top_ifr",
"#cfs_top_div"
],
"keywords": [
"uzone.id",
"cfs.uzone.id",
"cloudfront.net",
"uadexchange.com",
@agusmakmun
agusmakmun / safe_exclude.py
Last active January 3, 2017 00:26
Django Custom safe excludes from dangerous XSS Injection. Answered from: http://stackoverflow.com/a/41434870/6396981
from bs4 import BeautifulSoup
from django import template
from django.utils.html import escape
register = template.Library()
INVALID_TAGS = ['script',]
def clean_html(value):
soup = BeautifulSoup(value)
for tag in soup.findAll(True):
@agusmakmun
agusmakmun / upload.sh
Last active January 2, 2017 17:54
Git upload tag, commit & upload to pypi
#!/bin/bash
# Command to upload new version release at pypi
# ./upload.sh pypi
if [ "$1" == "pypi" ]; then
python setup.py sdist upload -r pypi
fi
if [ "$1" == "git" ]; then
@agusmakmun
agusmakmun / list_emojis.js
Last active December 27, 2016 15:11
List Emoji from github emoji
var emojis = [':bowtie:', ':smile:', ':laughing:', ':blush:', ':smiley:', ':relaxed:', ':smirk:', ':heart_eyes:', ':kissing_heart:', ':kissing_closed_eyes:', ':flushed:', ':relieved:', ':satisfied:', ':grin:', ':wink:', ':stuck_out_tongue_winking_eye:', ':stuck_out_tongue_closed_eyes:', ':grinning:', ':kissing:', ':kissing_smiling_eyes:', ':stuck_out_tongue:', ':sleeping:', ':worried:', ':frowning:', ':anguished:', ':open_mouth:', ':grimacing:', ':confused:', ':hushed:', ':expressionless:', ':unamused:', ':sweat_smile:', ':sweat:', ':disappointed_relieved:', ':weary:', ':pensive:', ':disappointed:', ':confounded:', ':fearful:', ':cold_sweat:', ':persevere:', ':cry:', ':sob:', ':joy:', ':astonished:', ':scream:', ':neckbeard:', ':tired_face:', ':angry:', ':rage:', ':triumph:', ':sleepy:', ':yum:', ':mask:', ':sunglasses:', ':dizzy_face:', ':imp:', ':smiling_imp:', ':neutral_face:', ':no_mouth:', ':innocent:', ':alien:', ':yellow_heart:', ':blue_heart:', ':purple_heart:', ':heart:', ':green_heart:', ':broken_he
@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
# This method if the files has no extentions.
$ for file in *; do mv "$file" "$file.png"; done
# This method if the files has extentions before.
$ for file in *.jpg; do mv "$file" "$file.png"; done
@agusmakmun
agusmakmun / serializer.py
Last active July 22, 2024 19:25
Sample Upload image with Django Rest Framework.
from rest_framework import serializers
from evotee.models import Candidate
class CandidateSerializer(serializers.ModelSerializer):
selection = serializers.CharField(
source='selection.code',
read_only=True
)
photo = serializers.ImageField(
from django.contrib.auth import (
authenticate, get_backends, login, logout
)
#etc....
def userLogin(request):
next_page = request.GET.get('next')
if request.user.is_authenticated():
if not next_page == None:
# From: http://django-admin-honeypot.readthedocs.io/en/latest/manual/faq.html#why-is-the-ip-address-logged-as-127-0-0-1
class RemoteAddrMiddleware(object):
def process_request(self, request):
if 'HTTP_X_FORWARDED_FOR' in request.META:
ip = request.META['HTTP_X_FORWARDED_FOR'].split(',')[0].strip()
request.META['REMOTE_ADDR'] = ip