Skip to content

Instantly share code, notes, and snippets.

View essanpupil's full-sized avatar

Ikhsan N. Rosyidin essanpupil

View GitHub Profile
@essanpupil
essanpupil / .vimrc
Last active August 22, 2017 07:02
My personal vimrc
call plug#begin('~/.vim/plugged')
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
Plug 'tpope/vim-fugitive'
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/syntastic'
Plug 'kien/ctrlp.vim'
Plug 'bling/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'scrooloose/nerdcommenter'
Plug 'pangloss/vim-javascript'
@essanpupil
essanpupil / get_object_or_404_select_related.py
Created December 19, 2016 03:36
Combining django queryset Model.get_object_or_404 with select_related
@essanpupil
essanpupil / phantomjs_log_location.py
Last active December 5, 2016 17:26
Setup ghostdriver.log location for PhantomJS
# taken from http://blog.michaelyin.info/2015/05/18/how-to-disable-ghostdriver-log-when-using-selenium/
driver = webdriver.PhantomJS(service_log_path='/tmp/ghostdriver.log')
# taken from http://ericholscher.com/blog/2009/apr/16/testing-ajax-views-django/
response = self.client.post('/ratings/vote/', {'value': '1',}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(200, response.status_code)
@essanpupil
essanpupil / postgres
Created September 9, 2016 07:57 — forked from mmrwoods/postgres
Postgres maintenance crontab file
# dump all databases once every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz
# vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night)
45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze"
45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet"
# re-index all databases once a week
0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database {};"'
@essanpupil
essanpupil / django_test_runner_custom_arguments.py
Last active August 14, 2016 08:15
django test runner sample to add custom command line test argument
from django.test.runner import DiscoverRunner
class CustomTestRunner(DiscoverRunner):
@classmethod
def add_arguments(cls, parser):
parser.add_argument('--headless',
action='store_true', default=False, dest='headless',
help='Add this options to do headless browser testing')
#!/bin/bash
#
# Program : check_cronjob
#
PROGNAME=`basename $0`
REVISION=`echo '$Revision: 0.1 $' | sed -e 's/[^0-9.]//g'`
. /usr/lib/nagios/plugins/utils.sh
# -*- coding: utf8 -*-
from django.test import TestCase
from django.core.urlresolvers import reverse
class ProfileViewTest(TestCase):
"""Unit test for verify profile views"""
fixtures = ['users.json']