Author: yodi

  • Install Zurmo CRM in Ubuntu 16.04 Xenial Xerus

    Here are step to install Zurmo CRM into Ubuntu 16.04 Xenial Xerus. Since Ubuntu 16.04 doesn’t have php5, we would like to install PHP5 1234sudo apt-get install software-properties-common sudo apt-get purge `dpkg -l | grep php| awk ‘{print $2}’ |tr "\n" " "` sudo add-apt-repository ppa:ondrej/php sudo apt-get update 1. Install php5.6 1sudo apt-get install […]

  • Setup Django + WordPress Ubuntu 16.04 Xenial Xerus

    Here is guide to setup Ubuntu 16.04 Xenial Xerus for Django and WordPress Development. First, we need to install dependencies software. 1. Install dependencies software Python, NGINX, PosgreSQL, MySQL and PHP5 1sudo apt-get install libpq-dev python-dev python-software-properties postgresql postgresql-contrib nginx git zip unzip build-essential python nmap libxslt1-dev python-pip imagemagick uwsgi uwsgi-plugin-python nmap mysql-server phpmyadmin libffi-dev […]

  • Cut and Paste in Mac OS X EL Capitan

    Here is easy way to cut and paste in Mac OS X EL Capitan: 1. Copy files by “Command + C” 2. Paste with Cut “Command + Option V” Easy right? 🙂

  • Setup New Server Ubuntu 14.10 with Django, Python and PHP

    Here is quickstep to configure a new server in Softlayer for Django and PHP development environtment. 12sudo apt-get update && sudo apt-get upgrade sudo apt-get install libpq-dev python-dev python-software-properties postgresql postgresql-contrib nginx git zip unzip build-essential python nmap libxslt1-dev python-pip imagemagick uwsgi uwsgi-plugin-python nmap mysql-server phpmyadmin libffi-dev libmysqlclient-dev libmysqlclient-dev libmysqlclient18 For Django sites-enables/ : 12345678910111213141516171819202122232425262728293031323334353637server […]

  • Open Permission access custom for Django Rest Framework

    When we need to open access for API Django-restframework, we can do it by extending the permission class. Here is some example: 123456789101112131415161718192021class PublicUserPermissions(permissions.BasePermission):     """     Granting public access permissions     """     def has_object_permission(self, request, view, obj):         # Allow get requests for all     […]

  • Kode UBER Gratis Jakarta, Indonesia

    Berikut kode gratis Uber di Jakarta Indonesia 1YODIA3UE

  • Setup SSL Certification RapidSSL on EC2

    Here are quickstep to generate SSL Certification 12openssl genrsa -out www.domain.com.key 2048 openssl req -new -key www.domain.com.key -out www.domain.com.csr 123456789101112Country Name (2 letter code) [AU]:ID State or Province Name (full name) [Some-State]:Jakarta Locality Name (eg, city) []:Jakarta Organization Name (eg, company) [Internet Widgits Pty Ltd]:PT POLATIC INFORMATIKA INDONESIA Organizational Unit Name (eg, section) []:IT Common […]

  • Running Play Framework as services in Production Ubuntu

    Here are steps to deploy Play Framework to Ubuntu as services : 1. Stage 1activator stage 2. Setup services in /etc/init.d/your-play 12345678910111213141516171819202122232425262728293031323334#!/bin/sh ### BEGIN INIT INFO # Provides:          mdm # Required-Start:    $local_fs $remote_fs $network $syslog # Required-Stop:     $local_fs $remote_fs $network $syslog # Default-Start:     2 3 4 […]

  • Solve integrity error duplicate key in Django PostgreSQL

    This error caused by we’re using database from copy / clone database. The sequences will be mixed-up. To solved this, just follow this way : 12python manage.py sqlsequencereset <app-name> > app.sql psql -U username -d database -a -f < app.sql Then your problem shall gone!

  • Tutorial Implementation Google Cloud Messaging (GCM) with Django

    Setup GCM for Android Client and Django in Server require efforts to know how it’s works. Here are simple steps to setup the newest GCM (Google Cloud Messaging) in Android. To understand about GCM, the flow is : 1. Create a Google APIs GCM project, which generates SENDER_ID and API_KEY for server implementation. 2. An […]

  • LAMPP Ubuntu in Softlayer

    Quick guide for setup LAMPP server in Ubuntu : 12sudo apt-get update && sudo apt-get upgrade -y sudo apt-get install nginx php5-fpm php5-mysql mysql-server php5-mysql php5-dev php-pear php5 nmap vim

  • How to enable WSGIPassAuthorization in NGINX + DJango

    Just in case we need to enable “WSGIPassAuthorization” in NGINX, we can put this in nginx hosts 12345proxy_pass_request_headers on; proxy_no_cache $cookie_nocache  $arg_nocache$arg_comment; proxy_no_cache $http_pragma     $http_authorization; proxy_cache_bypass $cookie_nocache $arg_nocache $arg_comment; proxy_cache_bypass $http_pragma $http_authorization;

  • ERP Development Design

    Here are the list we need consider when develop ERP. More in technical view. 1. Never trust Front-end validation We must separate between front-end validation and backend validation. Always check validation on backend to make sure the data is valid and correct. To avoid any data updates in the middle of process. 2. Audit-trail Audit-trail […]

  • Upload PostgreSQL not working, change the encoding may help

    When we upload and restore the backup into new postgresql server, sometimes we facing problem because encoding. To solve this, we can use UTF-8 : 1update pg_database set encoding = pg_char_to_encoding(‘UTF8’) where datname = ‘your-database’;

  • Uwsgi on ubuntu 14.04 not working solution

    In Ubuntu 14.04, uwsgi that installed via apt-get will not working. To make it working, please use this steps: 12sudo apt-get remove –purge uwsgi uwsgi-plugin-python sudo apt-get install uwsgi uwsgi-plugin-python Then follow this steps: 1234sudo pip install uwsgi cd /usr/bin sudo mv uwsgi uwsgi-old sudo ln -s /usr/local/bin/uwsgi uwsgi If still failed, follow this : […]

  • Setup Ubuntu Server in Softlayer for Django

    Here are a quick step to setup Ubuntu server in Softlayer for Django 1. Install depedencies 1234apt-get install python-software-properties software-properties-common add-apt-repository ppa:webupd8team/java apt-get update sudo apt-get install oracle-java7-installer 2. Install UWSGI, Python, PostgreSQL and other modules 1sudo apt-get install libpq-dev python-dev python-software-properties postgresql postgresql-contrib nginx git zip unzip build-essential python nmap libxslt1-dev python-pip imagemagick uwsgi […]

  • Becareful using int() or Decimal() for validation storing in Charfield Django

    So, we have CharField() as model field in Django. Then we want to validate input into number only. Usually, we using obj.is_digit() to validate. Common mistake happen when we using int() to convert string input. 12value = "0123123123" int(value) Will return 1"123123123" So becareful when using int() or Decimal() for converting value with leading zero

  • Update parent after children new windows closed

    Here is a snippet to update parent after new window getting closed : 12345678910111213141516171819// Start trigger pop-up new window var createUrl = $(this).data(‘url’) + selectedUUID; newwindow = window.open(createUrl, ‘Some Page, ‘scrollbars=yes,resizable=yes,height=600,width=’+screen.width/2); // Set focus on windows if (window.focus) {     newwindow.focus(); } // Update parent once children window already closed // Reload jqgrid table […]

  • JqGrid inline editing integration with DJango send csrf token

    Here is a quick snippet to send csrf_token in POST data from inline edit JqGrid to Django: 12345678910111213141516var tableGrid = $(selector).jqGrid({    ….    onSelectRow: function(id){          if(id && id!==lastSel){             $(selector).restoreRow(lastSel);             lastSel=id;          }       […]

  • Example Jquery Plugin to filtering input value real-time with Regex validation

    We try to add real-time input validation for dynamic element with some regex. Let say, user allowed only to type “numeric” and disallow any others alphabet and symbols. Then, we can write a small plugin, at this example, i use https://github.com/akzhan/jquery-keyfilter for Regex validation. Then, we just need to write this simple and easy plugin […]

  • Handle error form.save() with model validation

    Here is a quick snippet to avoid form.save() error because model validation : 12345678# handle form save with model validationerror # http://stackoverflow.com/questions/8771029/django-raise-a-validation-error-in-a-models-save-method try:     form.save() except ValidationError, e:     form._errors = {}     for _, v in e.message_dict.items():         form._errors.setdefault(NON_FIELD_ERRORS, []).extend(v)

  • Inline edit jqgrid with select2

    Here is a quick snippet for inline edit JqGrid with Select2 First, we need to bind colModel with select2 in dataInit : 1234567891011121314var colModel = [      // always put uuid and id      {name:’id’, hidden: true},      {name:’uuid’, hidden: true},      {name:’youroption’, label:’yourlabel’,editable: true,       edittype: "select", editrules: […]

  • Jqgrid for Dummies

    Here is a quick snippet of how to using JqGrid for dummies, like get data, delete data, access data or data manipulation. Setup JQGrid: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970$(document).ready(function() {     // Enable tooltips $("body").tooltip({     selector : ‘[data-toggle="tooltip"]’ }); $(".chosen").chosen(); var permission = $(‘.permission’); // Define ID for table var selector = "#table-index"; var pager = […]

  • JqGrid save inline editing callback

    Here is a quick snippet for callback when saving inline editing in JqGrid: 123456789101112// http://stackoverflow.com/questions/13303698/total-of-amount-in-jqgrid ondblClickRow: function (rowid, name, val, iRow, iCol) {     $(selector).jqGrid("editRow", rowid, {         keys: true,         aftersavefunc: function (rowid) {             var $grid = $(selector);       […]

  • JqGrid delete multiple select rows

    There is an issue if we delete rows using : 12345678910// Get all selected row var rows = $(selector).jqGrid("getGridParam", "selarrrow"); console.log(rows); // Iterate and delete for (var i in rows) {       console.log(i);       console.log(rows[i]);       $(selector).jqGrid(‘delRowData’, rows[i]); } Only a few records will deleted. The solution : 12345678910111213/** […]

  • Save django model with dictionaries

    Beware when queryset filter update() because it will pass model validation. Here is some example save model with dictionaries : 12345678910for k, v in account.items():     setattr(instance, k, v) try:     instance.save() except Exception, e:     raise ValidationError(e) else:     updated += 1     # print account

  • Convert boolean True and False field value in Django Rest Framework

    Here is a quick snippet to convert boolean True / False in DRF Serializer: 123456is_finish = serializers.SerializerMethodField() def get_is_finish(self, obj):     if obj.is_finish:         return "Selesai"     return "Progress"

  • Modify object data by write Custom Renderer in Django Rest Framework

    When we need to modify object or results from DRF / Django Rest Framework, all we need just write a custom JSON Renderer like below : 1234567891011121314class JGridJSONRenderer(renderers.JSONRenderer):     def render(self, data, accepted_media_type=None, renderer_context=None):         new_rows = []         # Name the object list         […]

  • Python remove dictionary key if value is empty

    Here is a quick snippet if we want to remove dictionary key if value is empty: 1new_dict = {k: v for k, v in _data.items() if v if v is not ”}

  • Solve issue Fullcalendar count two day as one day

    This is not bug. When we try to add day in March with start 10-03-2015T10:00:00 and end 11-03-2015T02:00:00, then it will showing one day instead of two day. To solve this issue, we need to put nextDayThreshold: 1nextDayThreshold: "00:00" To make the next day threshold every 00:00