-
Jquery Datatables modify fnserverData and pagination
Here is a quick snippet for custom AJAX data for Jquery datatables : 1234567891011121314151617181920212223242526272829303132 var table = $(‘#table-index’).dataTable({ "serverSide": true, "searching": false, "ordering": false, […]
-
Using format instead of %s for string replacement
Usually we use “%s” for string replacement in Python: 1"asddas %s" % (‘hello’,) There is better way to do it: 123"hello {a} {b} {c}".format(a=’error’, b=’hello’, c=’world’) "hello {0} {1} {2}".format("hello", "world", "fine") "hello {}".format("hello")
-
Example automatic python script installation in Ubuntu
Here is some good example for automatic python installation script setup : https://raw.githubusercontent.com/webnotes/erpnext/master/install_erpnext.py
-
Git problem and solution
Here are some lists that very helpful to solve git issues: http://stackoverflow.com/questions/3636914/how-can-i-see-what-i-am-about-to-push-with-git
-
Decoder jpeg not available in Ubuntu 14.04
To solve this issue : 1sudo apt-get install libjpeg-dev libfreetype6-dev zlib1g-dev libpng-dev xfonts-base xfonts-75dpi libjpeg8-dev libjpeg-turbo8-dev
-
Your branch and ‘origin/master’ have diverged, and have 1 and 1 different commit each, respectively.
I got this problem: 123456λ git status On branch master Your branch and ‘origin/master’ have diverged, and have 1 and 1 different commit each, respectively. (use "git pull" to merge the remote branch into yours) nothing to commit, working directory clean Solution 12λ git reset –hard origin/master HEAD is now at 63813ef fix localdb
-
Django 1.7 reset migration solved
Here is a quickstep to reset database migration in Django 1.7 : 12python manage.py makemigrations –empty your_app python manage.py makemigrations your_app
-
Git rollback last commit in remote
To rollback last commit : 12git reset HEAD~1 –hard git push -f
-
Git checkout track from remote branch
Let’s say somebody already push their branch in remote called “finances”. We want to fetch and working on this branch from our local. So, the solution : 12345git fetch –all Fetching origin From github.com:polatic/vasham-erp * [new branch] finance -> origin/finance Then, we checkout with tracking 123git checkout -t origin/finance Branch finance set […]
-
Accelerate django development server with django-devserver
As we know what django development server running on single thread. This is make development a bit slow. There is some alternative, by using django-devserver Here is the quickstep: 1. Install the app 1pip install git+git://github.com/nealtodd/django-devserver 2. Edit your local_settings.py 12345INSTALLED_APPS = (‘devserver’,) + INSTALLED_APPS MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + ( ‘devserver.middleware.DevServerMiddleware’, ) 3. Then […]
-
Ubuntu Check Memory Usage by Process
Here is a quick snippet for check memory usage by process : 1ps aux | sort -rn -k 5,6 | less
-
Solve Django Filter queryset result duplicates with Pagination
When we filter using multiple filter and mixed with django pagination, somehow the results are duplicates. This is incorrect. Apparently, looking at the source code https://github.com/alex/django-filter/blob/master/django_filters/filters.py#L105, I found this line: 1234q = Q() for v in value: q |= Q(**{self.name: v}) return qs.filter(q).distinct() By default, django-filter not using “AND” condition and that’s why […]
-
Setup Django and Timezone follow server datetime (Ubuntu)
Here is quickfix to setup Django working with server timezone. 1. Set Server Timezone Check by : 12date Mon Jan 5 10:54:38 WIB 2015 If this not correct or you want to change server timezone, then edit “/etc/timezone” 1Asia/Jakarta Then do : 12sudo dpkg-reconfigure –frontend noninteractive tzdata date Now you should see the updated server […]